LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* chris: struct device - replace bus_id with dev_name(), dev_set_name()
@ 2008-11-07  0:38 Kay Sievers
  2008-11-07 12:01 ` Jesper Nilsson
  0 siblings, 1 reply; 4+ messages in thread
From: Kay Sievers @ 2008-11-07  0:38 UTC (permalink / raw)
  To: Jesper Nilsson; +Cc: Greg KH, linux-kernel

(I did not compile or test it, please let me know, or help fixing
 it, if something is wrong with the conversion)

This patch is part of a larger patch series which will remove
the "char bus_id[20]" name string from struct device. The device
name is managed in the kobject anyway, and without any size
limitation, and just needlessly copied into "struct device".

To set and read the device name dev_name(dev) and dev_set_name(dev)
must be used. If your code uses static kobjects, which it shouldn't
do, "const char *init_name" can be used to statically provide the
name the registered device should have. At registration time, the
init_name field is cleared, to enforce the use of dev_name(dev) to
access the device name at a later time.

We need to get rid of all occurrences of bus_id in the entire tree
to be able to enable the new interface. Please apply this patch,
and possibly convert any remaining remaining occurrences of bus_id.

We want to submit a patch to -next, which will remove bus_id from
"struct device", to find the remaining pieces to convert, and finally
switch over to the new api, which will remove the 20 bytes array
and does no longer have a size limitation.

Thanks,
Kay


From: Kay Sievers <kay.sievers@vrfy.org>
Subject: chris: struct device - replace bus_id with dev_name(), dev_set_name()

Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
---
 arch/cris/arch-v32/drivers/iop_fw_load.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/arch/cris/arch-v32/drivers/iop_fw_load.c
+++ b/arch/cris/arch-v32/drivers/iop_fw_load.c
@@ -24,12 +24,12 @@
 #error "Please contact <greg@kroah.com> for details on how to fix it properly."
 
 static struct device iop_spu_device[2] = {
-	{ .bus_id =     "iop-spu0", },
-	{ .bus_id =     "iop-spu1", },
+	{ .init_name =     "iop-spu0", },
+	{ .init_name =     "iop-spu1", },
 };
 
 static struct device iop_mpu_device = {
-	.bus_id =       "iop-mpu",
+	.init_name =       "iop-mpu",
 };
 
 static int wait_mpu_idle(void)



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: chris: struct device - replace bus_id with dev_name(), dev_set_name()
  2008-11-07  0:38 chris: struct device - replace bus_id with dev_name(), dev_set_name() Kay Sievers
@ 2008-11-07 12:01 ` Jesper Nilsson
  2008-11-17 22:53   ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Jesper Nilsson @ 2008-11-07 12:01 UTC (permalink / raw)
  To: Kay Sievers; +Cc: Greg KH, linux-kernel

On Fri, Nov 07, 2008 at 01:38:40AM +0100, Kay Sievers wrote:
> This patch is part of a larger patch series which will remove
> the "char bus_id[20]" name string from struct device. The device
> name is managed in the kobject anyway, and without any size
> limitation, and just needlessly copied into "struct device".

Thanks, but I think that since this driver has been broken a long time
it is high time to fix it, and I think the fix removes the need for your patch.

Greg, could you please look this patch over?


[CRISv32] Fix IOP fw-loader to use platform_device.

Change IOP fw-loader to use platform_device instead of
raw device, which should be more correct usage.

Signed-off-by: Stefan Andersson <stefan.andersson@axis.com>
Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>

---

 iop_fw_load.c |   69 ++++++++++++++++++++++++----------------------------------
 1 file changed, 29 insertions(+), 40 deletions(-)

diff --git a/arch/cris/arch-v32/drivers/iop_fw_load.c b/arch/cris/arch-v32/drivers/iop_fw_load.c
index 3b3857e..7376012 100644
--- a/arch/cris/arch-v32/drivers/iop_fw_load.c
+++ b/arch/cris/arch-v32/drivers/iop_fw_load.c
@@ -1,13 +1,14 @@
 /*
  * Firmware loader for ETRAX FS IO-Processor
  *
- * Copyright (C) 2004  Axis Communications AB
+ * Copyright (C) 2004-2008  Axis Communications AB
  */
 
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/device.h>
+#include <linux/platform_device.h>
 #include <linux/firmware.h>
 
 #include <hwregs/reg_rdwr.h>
@@ -20,16 +21,17 @@
 
 #define IOP_TIMEOUT 100
 
-#error "This driver is broken with regard to its driver core usage."
-#error "Please contact <greg@kroah.com> for details on how to fix it properly."
+int iop_fw_load_spu(const unsigned char *fw_name, unsigned int spu_inst);
+int iop_fw_load_mpu(unsigned char *fw_name);
+int iop_start_mpu(unsigned int start_addr);
 
-static struct device iop_spu_device[2] = {
-	{ .bus_id =     "iop-spu0", },
-	{ .bus_id =     "iop-spu1", },
+static struct platform_device iop_spu_device[2] = {
+	{ .name =     "iop-spu0", },
+	{ .name =     "iop-spu1", },
 };
 
-static struct device iop_mpu_device = {
-	.bus_id =       "iop-mpu",
+static struct platform_device iop_mpu_device = {
+	.name =       "iop-mpu",
 };
 
 static int wait_mpu_idle(void)
@@ -61,7 +63,7 @@ int iop_fw_load_spu(const unsigned char *fw_name, unsigned int spu_inst)
 		.fsm =            regk_iop_spu_no,
 	};
 	reg_iop_sw_cpu_r_mc_stat mc_stat;
-        const struct firmware *fw_entry;
+	const struct firmware *fw_entry;
 	u32 *data;
 	unsigned int timeout;
 	int retval, i;
@@ -72,9 +74,8 @@ int iop_fw_load_spu(const unsigned char *fw_name, unsigned int spu_inst)
 	/* get firmware */
 	retval = request_firmware(&fw_entry,
 				  fw_name,
-				  &iop_spu_device[spu_inst]);
-	if (retval != 0)
-	{
+				  &iop_spu_device[spu_inst].dev);
+	if (retval != 0) {
 		printk(KERN_ERR
 		       "iop_load_spu: Failed to load firmware \"%s\"\n",
 		       fw_name);
@@ -121,29 +122,29 @@ int iop_fw_load_spu(const unsigned char *fw_name, unsigned int spu_inst)
 	/* release ownership of memory controller */
 	(void) REG_RD(iop_sw_cpu, regi_iop_sw_cpu, rs_mc_data);
 
- out:
+out:
 	release_firmware(fw_entry);
 	return retval;
 }
+EXPORT_SYMBOL(iop_fw_load_spu);
 
 int iop_fw_load_mpu(unsigned char *fw_name)
 {
 	const unsigned int start_addr = 0;
 	reg_iop_mpu_rw_ctrl mpu_ctrl;
-        const struct firmware *fw_entry;
+	const struct firmware *fw_entry;
 	u32 *data;
 	int retval, i;
 
 	/* get firmware */
-	retval = request_firmware(&fw_entry, fw_name, &iop_mpu_device);
-	if (retval != 0)
-	{
+	retval = request_firmware(&fw_entry, fw_name, &iop_mpu_device.dev);
+	if (retval != 0) {
 		printk(KERN_ERR
 		       "iop_load_spu: Failed to load firmware \"%s\"\n",
 		       fw_name);
 		return retval;
 	}
-	data = (u32 *) fw_entry->data;
+	data = (u32 *)fw_entry->data;
 
 	/* disable MPU */
 	mpu_ctrl.en = regk_iop_mpu_no;
@@ -161,10 +162,11 @@ int iop_fw_load_mpu(unsigned char *fw_name)
 		data++;
 	}
 
- out:
+out:
 	release_firmware(fw_entry);
 	return retval;
 }
+EXPORT_SYMBOL(iop_fw_load_mpu);
 
 int iop_start_mpu(unsigned int start_addr)
 {
@@ -189,34 +191,24 @@ int iop_start_mpu(unsigned int start_addr)
 		goto out;
 	/* enable MPU */
 	REG_WR(iop_mpu, regi_iop_mpu, rw_ctrl, mpu_ctrl);
- out:
+out:
 	return retval;
 }
+EXPORT_SYMBOL(iop_start_mpu);
 
 static int __init iop_fw_load_init(void)
 {
-#if 0
-	/*
-	 * static struct devices can not be added directly to sysfs by ignoring
-	 * the driver model infrastructure.  To fix this properly, please use
-	 * the platform_bus to register these devices to be able to properly
-	 * use the firmware infrastructure.
-	 */
-	device_initialize(&iop_spu_device[0]);
-	kobject_set_name(&iop_spu_device[0].kobj, "iop-spu0");
-	kobject_add(&iop_spu_device[0].kobj);
-	device_initialize(&iop_spu_device[1]);
-	kobject_set_name(&iop_spu_device[1].kobj, "iop-spu1");
-	kobject_add(&iop_spu_device[1].kobj);
-	device_initialize(&iop_mpu_device);
-	kobject_set_name(&iop_mpu_device.kobj, "iop-mpu");
-	kobject_add(&iop_mpu_device.kobj);
-#endif
+	platform_device_register(&iop_mpu_device);
+	platform_device_register(&iop_spu_device[0]);
+	platform_device_register(&iop_spu_device[1]);
 	return 0;
 }
 
 static void __exit iop_fw_load_exit(void)
 {
+	platform_device_unregister(&iop_mpu_device);
+	platform_device_unregister(&iop_spu_device[0]);
+	platform_device_unregister(&iop_spu_device[1]);
 }
 
 module_init(iop_fw_load_init);
@@ -225,6 +217,3 @@ module_exit(iop_fw_load_exit);
 MODULE_DESCRIPTION("ETRAX FS IO-Processor Firmware Loader");
 MODULE_LICENSE("GPL");
 
-EXPORT_SYMBOL(iop_fw_load_spu);
-EXPORT_SYMBOL(iop_fw_load_mpu);
-EXPORT_SYMBOL(iop_start_mpu);


/^JN - Jesper Nilsson
-- 
               Jesper Nilsson -- jesper.nilsson@axis.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: chris: struct device - replace bus_id with dev_name(), dev_set_name()
  2008-11-07 12:01 ` Jesper Nilsson
@ 2008-11-17 22:53   ` Greg KH
  2008-11-18  8:14     ` Jesper Nilsson
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2008-11-17 22:53 UTC (permalink / raw)
  To: Jesper Nilsson; +Cc: Kay Sievers, linux-kernel

On Fri, Nov 07, 2008 at 01:01:36PM +0100, Jesper Nilsson wrote:
> On Fri, Nov 07, 2008 at 01:38:40AM +0100, Kay Sievers wrote:
> > This patch is part of a larger patch series which will remove
> > the "char bus_id[20]" name string from struct device. The device
> > name is managed in the kobject anyway, and without any size
> > limitation, and just needlessly copied into "struct device".
> 
> Thanks, but I think that since this driver has been broken a long time
> it is high time to fix it, and I think the fix removes the need for your patch.
> 
> Greg, could you please look this patch over?
> 
> 
> [CRISv32] Fix IOP fw-loader to use platform_device.
> 
> Change IOP fw-loader to use platform_device instead of
> raw device, which should be more correct usage.
> 
> Signed-off-by: Stefan Andersson <stefan.andersson@axis.com>
> Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>

Looks sane to me.  Want me to take it through my tree, or will you be
submitting it?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: chris: struct device - replace bus_id with dev_name(), dev_set_name()
  2008-11-17 22:53   ` Greg KH
@ 2008-11-18  8:14     ` Jesper Nilsson
  0 siblings, 0 replies; 4+ messages in thread
From: Jesper Nilsson @ 2008-11-18  8:14 UTC (permalink / raw)
  To: Greg KH; +Cc: Kay Sievers, linux-kernel

On Mon, Nov 17, 2008 at 11:53:59PM +0100, Greg KH wrote:
> On Fri, Nov 07, 2008 at 01:01:36PM +0100, Jesper Nilsson wrote:
> > On Fri, Nov 07, 2008 at 01:38:40AM +0100, Kay Sievers wrote:
> > > This patch is part of a larger patch series which will remove
> > > the "char bus_id[20]" name string from struct device. The device
> > > name is managed in the kobject anyway, and without any size
> > > limitation, and just needlessly copied into "struct device".
> > 
> > Thanks, but I think that since this driver has been broken a long time
> > it is high time to fix it, and I think the fix removes the need for your patch.
> > 
> > Greg, could you please look this patch over?
> > 
> > 
> > [CRISv32] Fix IOP fw-loader to use platform_device.
> > 
> > Change IOP fw-loader to use platform_device instead of
> > raw device, which should be more correct usage.
> > 
> > Signed-off-by: Stefan Andersson <stefan.andersson@axis.com>
> > Signed-off-by: Jesper Nilsson <jesper.nilsson@axis.com>
> 
> Looks sane to me.  Want me to take it through my tree, or will you be
> submitting it?

Thanks, good to hear, I'll take it into the CRIS-tree.

> thanks,
> 
> greg k-h

/^JN - Jesper Nilsson
-- 
               Jesper Nilsson -- jesper.nilsson@axis.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-11-18  8:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-07  0:38 chris: struct device - replace bus_id with dev_name(), dev_set_name() Kay Sievers
2008-11-07 12:01 ` Jesper Nilsson
2008-11-17 22:53   ` Greg KH
2008-11-18  8:14     ` Jesper Nilsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).