lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 7 Nov 2008 13:01:36 +0100
From:	Jesper Nilsson <Jesper.Nilsson@...s.com>
To:	Kay Sievers <kay.sievers@...y.org>
Cc:	Greg KH <greg@...ah.com>,
	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: chris: struct device - replace bus_id with dev_name(),
	dev_set_name()

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@...s.com>
Signed-off-by: Jesper Nilsson <jesper.nilsson@...s.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@...ah.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@...s.com
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ