[PATCH 3/3] w1: stop using struct device template for master devices

Danilo Krummrich <[email protected]>
Newsgroups dev.linux.lists.driver-core,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
w1_alloc_dev() uses memcpy() with a static struct device template
(w1_master_device) to initialize new master devices.

Replace the memcpy() with a w1_master_dev_init() helper that sets only
bus, type, and release.

Signed-off-by: Danilo Krummrich <[email protected]>
---
Compile-tested only, no hardware available.
---
 drivers/w1/w1.c          | 15 +++++++--------
 drivers/w1/w1_int.c      |  7 +++----
 drivers/w1/w1_internal.h |  2 +-
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c
index b40f2d9fd29d..d71e2a1568bd 100644
--- a/drivers/w1/w1.c
+++ b/drivers/w1/w1.c
@@ -193,19 +193,18 @@ struct device_driver w1_master_driver = {
 	.bus = &w1_bus_type,
 };
 
-struct device w1_master_device = {
-	.parent = NULL,
-	.bus = &w1_bus_type,
-	.type = &w1_master_device_type,
-	.init_name = "w1 bus master",
-	.release = &w1_master_release
-};
-
 static struct device_driver w1_slave_driver = {
 	.name = "w1_slave_driver",
 	.bus = &w1_bus_type,
 };
 
+void w1_master_dev_init(struct device *dev)
+{
+	dev->bus = &w1_bus_type;
+	dev->type = &w1_master_device_type;
+	dev->release = &w1_master_release;
+}
+
 #if 0
 struct device w1_slave_device = {
 	.parent = NULL,
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
index 19a0ea28e9f3..a59ca19471e0 100644
--- a/drivers/w1/w1_int.c
+++ b/drivers/w1/w1_int.c
@@ -22,8 +22,7 @@ static int w1_enable_pullup = 1;
 module_param_named(enable_pullup, w1_enable_pullup, int, 0);
 
 static struct w1_master *w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
-				       struct device_driver *driver,
-				       struct device *device)
+				       struct device_driver *driver)
 {
 	struct w1_master *dev;
 	int err;
@@ -57,7 +56,7 @@ static struct w1_master *w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
 	mutex_init(&dev->bus_mutex);
 	mutex_init(&dev->list_mutex);
 
-	memcpy(&dev->dev, device, sizeof(struct device));
+	w1_master_dev_init(&dev->dev);
 	dev_set_name(&dev->dev, "w1_bus_master%u", dev->id);
 	snprintf(dev->name, sizeof(dev->name), "w1_bus_master%u", dev->id);
 	dev->dev.init_name = dev->name;
@@ -116,7 +115,7 @@ int w1_add_master_device(struct w1_bus_master *master)
 	} while (found);
 
 	dev = w1_alloc_dev(id, w1_max_slave_count, w1_max_slave_ttl,
-		&w1_master_driver, &w1_master_device);
+		&w1_master_driver);
 	if (!dev) {
 		mutex_unlock(&w1_mlock);
 		return -ENOMEM;
diff --git a/drivers/w1/w1_internal.h b/drivers/w1/w1_internal.h
index cb5a74e9939a..ffe7c7e8c4ca 100644
--- a/drivers/w1/w1_internal.h
+++ b/drivers/w1/w1_internal.h
@@ -65,7 +65,7 @@ void __w1_family_get(struct w1_family *f);
 struct w1_family *w1_family_registered(u8 fid);
 
 extern struct device_driver w1_master_driver;
-extern struct device w1_master_device;
+void w1_master_dev_init(struct device *dev);
 extern int w1_max_slave_count;
 extern int w1_max_slave_ttl;
 extern struct list_head w1_masters;
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.