All of lore.kernel.org
 help / color / mirror / Atom feed
From: dtor_core@ameritech.net (Dmitry Torokhov)
To: sensors@Stimpy.netroedge.com
Cc: LKML <linux-kernel@vger.kernel.org>, Greg KH <gregkh@suse.de>,
	Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Subject: [RFC/PATCH 20/22] W1: add w1_device_id/MODULE_DEVICE_TABLE for
Date: Thu, 19 May 2005 06:25:53 +0000	[thread overview]
Message-ID: <200504210227.36554.dtor_core@ameritech.net> (raw)
In-Reply-To: <200504210207.02421.dtor_core@ameritech.net>

W1: support for automatic family drivers loading via hotplug:
    - allow family drivers support list of families;
    - export supported families through MODULE_DEVICE_TABLE.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/w1/w1.c                 |    6 ++++--
 drivers/w1/w1.h                 |    3 ++-
 drivers/w1/w1_sernum.c          |    9 ++++++++-
 drivers/w1/w1_thermal.c         |    9 ++++++++-
 include/linux/mod_devicetable.h |    4 ++++
 scripts/mod/file2alias.c        |   16 ++++++++++++++++
 6 files changed, 42 insertions(+), 5 deletions(-)

Index: dtor/drivers/w1/w1.c
=================================--- dtor.orig/drivers/w1/w1.c
+++ dtor/drivers/w1/w1.c
@@ -58,9 +58,11 @@ static int w1_bus_match(struct device *d
 	 */
 	struct w1_slave *slave = to_w1_slave(dev);
 	struct w1_family *family = to_w1_family(drv);
+	struct w1_device_id *id;
 
-	if (slave->reg_num.family = family->fid)
-		return 1;
+	for (id = family->id_table; id->family; id++)
+		if (slave->reg_num.family = id->family)
+			return 1;
 
 	return 0;
 }
Index: dtor/drivers/w1/w1.h
=================================--- dtor.orig/drivers/w1/w1.h
+++ dtor/drivers/w1/w1.h
@@ -41,6 +41,7 @@ struct w1_reg_num
 
 #include <linux/completion.h>
 #include <linux/device.h>
+#include <linux/mod_devicetable.h>
 
 #include <asm/semaphore.h>
 
@@ -118,7 +119,7 @@ void w1_remove_master_device(struct w1_m
 
 struct w1_family {
 	struct device_driver	driver;
-	u8			fid;
+	struct w1_device_id	*id_table;
 	const char		*name;
 
 	int (*join)(struct w1_slave *);
Index: dtor/drivers/w1/w1_thermal.c
=================================--- dtor.orig/drivers/w1/w1_thermal.c
+++ dtor/drivers/w1/w1_thermal.c
@@ -50,11 +50,18 @@ static void w1_thermal_leave(struct w1_s
 	device_remove_file(&slave->dev, &w1_thermal_temperature_attr);
 }
 
+static struct w1_device_id w1_thermal_ids[] = {
+	{ .family = W1_FAMILY_THERMAL, },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(w1, w1_thermal_ids);
+
 static struct w1_family w1_thermal_family = {
 	.driver		= {
 		.name	= "thermal",
 	},
-	.fid		= W1_FAMILY_THERMAL,
+	.id_table	= w1_thermal_ids,
 	.name		= "Digital Thermometer Driver",
 	.join		= w1_thermal_join,
 	.leave		= w1_thermal_leave,
Index: dtor/drivers/w1/w1_sernum.c
=================================--- dtor.orig/drivers/w1/w1_sernum.c
+++ dtor/drivers/w1/w1_sernum.c
@@ -40,11 +40,18 @@ MODULE_DESCRIPTION("1-Wire Silicon Seria
  * by W1 core.
  */
 
+static struct w1_device_id w1_serial_num_ids[] = {
+	{ .family = W1_FAMILY_SERIAL_NUM, },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(w1, w1_serial_num_ids);
+
 static struct w1_family w1_serial_num_family = {
 	.driver		= {
 		.name	= "sernum",
 	},
-	.fid		= W1_FAMILY_SERIAL_NUM,
+	.id_table	= w1_serial_num_ids,
 	.name		= "Serial Number Driver",
 };
 
Index: dtor/scripts/mod/file2alias.c
=================================--- dtor.orig/scripts/mod/file2alias.c
+++ dtor/scripts/mod/file2alias.c
@@ -25,6 +25,7 @@ typedef Elf64_Addr	kernel_ulong_t;
 #include <stdint.h>
 #endif
 
+typedef uint64_t	__u64;
 typedef uint32_t	__u32;
 typedef uint16_t	__u16;
 typedef unsigned char	__u8;
@@ -199,6 +200,18 @@ static int do_serio_entry(const char *fi
 	return 1;
 }
 
+/* Looks like: "w1:fidNsnN" */
+static int do_w1_entry(const char *filename,
+		       struct w1_device_id *id, char *alias)
+{
+	id->family = TO_NATIVE(id->family);
+	id->serial = TO_NATIVE(id->serial);
+
+	sprintf(alias, "w1:fid%02Xsn%024llX", id->family, id->serial);
+
+	return 1;
+}
+
 /* looks like: "pnp:dD" */
 static int do_pnp_entry(const char *filename,
 			struct pnp_device_id *id, char *alias)
@@ -291,6 +304,9 @@ void handle_moddevtable(struct module *m
 	else if (sym_is(symname, "__mod_serio_device_table"))
 		do_table(symval, sym->st_size, sizeof(struct serio_device_id),
 			 do_serio_entry, mod);
+	else if (sym_is(symname, "__mod_w1_device_table"))
+		do_table(symval, sym->st_size, sizeof(struct w1_device_id),
+			 do_w1_entry, mod);
 	else if (sym_is(symname, "__mod_pnp_device_table"))
 		do_table(symval, sym->st_size, sizeof(struct pnp_device_id),
 			 do_pnp_entry, mod);
Index: dtor/include/linux/mod_devicetable.h
=================================--- dtor.orig/include/linux/mod_devicetable.h
+++ dtor/include/linux/mod_devicetable.h
@@ -174,5 +174,9 @@ struct serio_device_id {
 	__u8 proto;
 };
 
+struct w1_device_id {
+	__u8	family;
+	__u64	serial;
+};
 
 #endif /* LINUX_MOD_DEVICETABLE_H */

WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Torokhov <dtor_core@ameritech.net>
To: sensors@Stimpy.netroedge.com
Cc: LKML <linux-kernel@vger.kernel.org>, Greg KH <gregkh@suse.de>,
	Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Subject: [RFC/PATCH 20/22] W1: add w1_device_id/MODULE_DEVICE_TABLE for automatic driver loading
Date: Thu, 21 Apr 2005 02:27:36 -0500	[thread overview]
Message-ID: <200504210227.36554.dtor_core@ameritech.net> (raw)
In-Reply-To: <200504210207.02421.dtor_core@ameritech.net>

W1: support for automatic family drivers loading via hotplug:
    - allow family drivers support list of families;
    - export supported families through MODULE_DEVICE_TABLE.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/w1/w1.c                 |    6 ++++--
 drivers/w1/w1.h                 |    3 ++-
 drivers/w1/w1_sernum.c          |    9 ++++++++-
 drivers/w1/w1_thermal.c         |    9 ++++++++-
 include/linux/mod_devicetable.h |    4 ++++
 scripts/mod/file2alias.c        |   16 ++++++++++++++++
 6 files changed, 42 insertions(+), 5 deletions(-)

Index: dtor/drivers/w1/w1.c
===================================================================
--- dtor.orig/drivers/w1/w1.c
+++ dtor/drivers/w1/w1.c
@@ -58,9 +58,11 @@ static int w1_bus_match(struct device *d
 	 */
 	struct w1_slave *slave = to_w1_slave(dev);
 	struct w1_family *family = to_w1_family(drv);
+	struct w1_device_id *id;
 
-	if (slave->reg_num.family == family->fid)
-		return 1;
+	for (id = family->id_table; id->family; id++)
+		if (slave->reg_num.family == id->family)
+			return 1;
 
 	return 0;
 }
Index: dtor/drivers/w1/w1.h
===================================================================
--- dtor.orig/drivers/w1/w1.h
+++ dtor/drivers/w1/w1.h
@@ -41,6 +41,7 @@ struct w1_reg_num
 
 #include <linux/completion.h>
 #include <linux/device.h>
+#include <linux/mod_devicetable.h>
 
 #include <asm/semaphore.h>
 
@@ -118,7 +119,7 @@ void w1_remove_master_device(struct w1_m
 
 struct w1_family {
 	struct device_driver	driver;
-	u8			fid;
+	struct w1_device_id	*id_table;
 	const char		*name;
 
 	int (*join)(struct w1_slave *);
Index: dtor/drivers/w1/w1_thermal.c
===================================================================
--- dtor.orig/drivers/w1/w1_thermal.c
+++ dtor/drivers/w1/w1_thermal.c
@@ -50,11 +50,18 @@ static void w1_thermal_leave(struct w1_s
 	device_remove_file(&slave->dev, &w1_thermal_temperature_attr);
 }
 
+static struct w1_device_id w1_thermal_ids[] = {
+	{ .family = W1_FAMILY_THERMAL, },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(w1, w1_thermal_ids);
+
 static struct w1_family w1_thermal_family = {
 	.driver		= {
 		.name	= "thermal",
 	},
-	.fid		= W1_FAMILY_THERMAL,
+	.id_table	= w1_thermal_ids,
 	.name		= "Digital Thermometer Driver",
 	.join		= w1_thermal_join,
 	.leave		= w1_thermal_leave,
Index: dtor/drivers/w1/w1_sernum.c
===================================================================
--- dtor.orig/drivers/w1/w1_sernum.c
+++ dtor/drivers/w1/w1_sernum.c
@@ -40,11 +40,18 @@ MODULE_DESCRIPTION("1-Wire Silicon Seria
  * by W1 core.
  */
 
+static struct w1_device_id w1_serial_num_ids[] = {
+	{ .family = W1_FAMILY_SERIAL_NUM, },
+	{ }
+};
+
+MODULE_DEVICE_TABLE(w1, w1_serial_num_ids);
+
 static struct w1_family w1_serial_num_family = {
 	.driver		= {
 		.name	= "sernum",
 	},
-	.fid		= W1_FAMILY_SERIAL_NUM,
+	.id_table	= w1_serial_num_ids,
 	.name		= "Serial Number Driver",
 };
 
Index: dtor/scripts/mod/file2alias.c
===================================================================
--- dtor.orig/scripts/mod/file2alias.c
+++ dtor/scripts/mod/file2alias.c
@@ -25,6 +25,7 @@ typedef Elf64_Addr	kernel_ulong_t;
 #include <stdint.h>
 #endif
 
+typedef uint64_t	__u64;
 typedef uint32_t	__u32;
 typedef uint16_t	__u16;
 typedef unsigned char	__u8;
@@ -199,6 +200,18 @@ static int do_serio_entry(const char *fi
 	return 1;
 }
 
+/* Looks like: "w1:fidNsnN" */
+static int do_w1_entry(const char *filename,
+		       struct w1_device_id *id, char *alias)
+{
+	id->family = TO_NATIVE(id->family);
+	id->serial = TO_NATIVE(id->serial);
+
+	sprintf(alias, "w1:fid%02Xsn%024llX", id->family, id->serial);
+
+	return 1;
+}
+
 /* looks like: "pnp:dD" */
 static int do_pnp_entry(const char *filename,
 			struct pnp_device_id *id, char *alias)
@@ -291,6 +304,9 @@ void handle_moddevtable(struct module *m
 	else if (sym_is(symname, "__mod_serio_device_table"))
 		do_table(symval, sym->st_size, sizeof(struct serio_device_id),
 			 do_serio_entry, mod);
+	else if (sym_is(symname, "__mod_w1_device_table"))
+		do_table(symval, sym->st_size, sizeof(struct w1_device_id),
+			 do_w1_entry, mod);
 	else if (sym_is(symname, "__mod_pnp_device_table"))
 		do_table(symval, sym->st_size, sizeof(struct pnp_device_id),
 			 do_pnp_entry, mod);
Index: dtor/include/linux/mod_devicetable.h
===================================================================
--- dtor.orig/include/linux/mod_devicetable.h
+++ dtor/include/linux/mod_devicetable.h
@@ -174,5 +174,9 @@ struct serio_device_id {
 	__u8 proto;
 };
 
+struct w1_device_id {
+	__u8	family;
+	__u64	serial;
+};
 
 #endif /* LINUX_MOD_DEVICETABLE_H */

  parent reply	other threads:[~2005-05-19  6:25 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-21  7:07 [RFC/PATCH 0/22] W1: sysfs, lifetime and other fixes Dmitry Torokhov
2005-05-19  6:25 ` Dmitry Torokhov
2005-04-21  7:08 ` [RFC/PATCH 1/22] W1: whitespace fixes Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:08 ` [RFC/PATCH 2/22] W1: formatting fixes Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:09 ` [RFC/PATCH 3/22] W1: use attribute group for master's attributes Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:10 ` [RFC/PATCH 4/22] W1: use attribute group for slave's attributes Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:11 ` [RFC/PATCH 5/22] W1: list handling cleanup Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:13 ` [RFC/PATCH 6/22] W1: drop owner field from master and slave structures Dmitry Torokhov
2005-05-19  6:25   ` [RFC/PATCH 6/22] W1: drop owner field from master and slave Dmitry Torokhov
2005-04-21  7:13 ` [RFC/PATCH 7/22] W1: bus operations cleanup Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:15 ` [RFC/PATCH 8/22] W1: merge master code into one file Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:16 ` [RFC/PATCH 9/22] W1: drop custom hotplug over netlink notification Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:17 ` [RFC/PATCH 10/22] W1: drop main control thread Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:18 ` [RFC/PATCH 11/22] W1: move w1_search to the rest of IO code Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:19 ` [RFC/PATCH 12/22] W1: drop unneeded master attributes Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:20 ` [RFC/PATCH 13/22] W1: cleanup master attributes handling Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:21 ` [RFC/PATCH 14/22] W1: rename timeout to scan_interval Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:22 ` [RFC/PATCH 15/22] W1: add slave_ttl master attribute Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:23 ` [RFC/PATCH 16/22] W1: cleanup masters refcounting & more Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:23 ` [RFC/PATCH 17/22] W1: cleanup slave " Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:25 ` [RFC/PATCH 18/22] W1: cleanup family implementation Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:26 ` [RFC/PATCH 19/22] W1: convert families to be proper sysfs rivers Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:27 ` Dmitry Torokhov [this message]
2005-05-19  6:25   ` [RFC/PATCH 20/22] W1: add w1_device_id/MODULE_DEVICE_TABLE for Dmitry Torokhov
2005-04-21  7:36 ` [RFC/PATCH 21/22] W1: implement standard hotplug handler Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21  7:38 ` [RFC/PATCH 22/22] W1: expose module parameters in sysfs Dmitry Torokhov
2005-05-19  6:25   ` Dmitry Torokhov
2005-04-21 13:18 ` [RFC/PATCH 0/22] W1: sysfs, lifetime and other fixes Evgeniy Polyakov
2005-05-19  6:25   ` Evgeniy Polyakov
2005-04-21 14:31   ` Dmitry Torokhov
2005-05-19  6:25     ` Dmitry Torokhov
2005-04-25  9:08     ` Evgeniy Polyakov
2005-05-19  6:25       ` Evgeniy Polyakov
2005-04-25 16:32       ` Dmitry Torokhov
2005-05-19  6:25         ` Dmitry Torokhov
2005-04-25 19:26         ` Evgeniy Polyakov
2005-05-19  6:25           ` Evgeniy Polyakov
2005-04-25 21:32           ` Dmitry Torokhov
2005-05-19  6:25             ` Dmitry Torokhov
2005-04-26  7:19             ` Evgeniy Polyakov
2005-05-19  6:25               ` Evgeniy Polyakov
2005-04-25 20:15         ` Evgeniy Polyakov
2005-05-19  6:25           ` Evgeniy Polyakov
2005-04-25 20:22           ` Dmitry Torokhov
2005-05-19  6:25             ` Dmitry Torokhov
2005-04-26  6:43             ` Evgeniy Polyakov
2005-05-19  6:25               ` Evgeniy Polyakov
2005-04-26  6:50               ` Dmitry Torokhov
2005-05-19  6:25                 ` Dmitry Torokhov
2005-04-26  7:06                 ` Evgeniy Polyakov
2005-05-19  6:25                   ` Evgeniy Polyakov
2005-04-26  7:16                   ` Dmitry Torokhov
2005-05-19  6:25                     ` Dmitry Torokhov
2005-04-26  7:35                     ` Evgeniy Polyakov
2005-05-19  6:25                       ` Evgeniy Polyakov
2005-04-26  7:00               ` Greg KH
2005-05-19  6:25                 ` Greg KH
2005-04-26  7:17                 ` Evgeniy Polyakov
2005-05-19  6:25                   ` Evgeniy Polyakov
2005-04-26  6:58         ` Greg KH
2005-05-19  6:25           ` Greg KH
2005-04-21 16:09   ` Dmitry Torokhov
2005-05-19  6:25     ` Dmitry Torokhov
2005-04-25  9:11     ` Evgeniy Polyakov
2005-05-19  6:25       ` Evgeniy Polyakov
2005-04-25 16:36       ` Dmitry Torokhov
2005-05-19  6:25         ` Dmitry Torokhov
2005-04-25 19:32         ` Evgeniy Polyakov
2005-05-19  6:25           ` Evgeniy Polyakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200504210227.36554.dtor_core@ameritech.net \
    --to=dtor_core@ameritech.net \
    --cc=gregkh@suse.de \
    --cc=johnpol@2ka.mipt.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sensors@Stimpy.netroedge.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.