Linux I2C development
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Linux I2C <i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org>
Cc: David Brownell <david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
Subject: [PATCH] i2c: Match dummy devices by type
Date: Mon, 5 May 2008 11:28:58 +0200	[thread overview]
Message-ID: <20080505112858.5101c99a@hyperion.delvare> (raw)

As the old driver_name/type matching scheme is going away soon, change
the dummy device mechanism to use the new matching scheme.

This has the downside that dummy i2c clients can no longer choose
their name, they'll all appear as "dummy" in sysfs and in log
messages. I don't think it is a problem in practice though, as there
is little reason to use these i2c clients to log messages.

Signed-off-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
---
Byron, could you possibly test this patch? It goes on top of 2.6.26-rc1.

 drivers/i2c/i2c-core.c    |   15 +++++++++------
 drivers/rtc/rtc-s35390a.c |    2 +-
 include/linux/i2c.h       |    2 +-
 3 files changed, 11 insertions(+), 8 deletions(-)

--- linux-2.6.26-rc0.orig/drivers/i2c/i2c-core.c	2008-05-03 15:49:09.000000000 +0200
+++ linux-2.6.26-rc0/drivers/i2c/i2c-core.c	2008-05-03 15:49:18.000000000 +0200
@@ -327,6 +327,12 @@ void i2c_unregister_device(struct i2c_cl
 EXPORT_SYMBOL_GPL(i2c_unregister_device);
 
 
+static const struct i2c_device_id dummy_id[] = {
+	{ "dummy", 0 },
+	{ },
+};
+MODULE_DEVICE_TABLE(i2c, dummy_id);
+
 static int dummy_probe(struct i2c_client *client,
 		       const struct i2c_device_id *id)
 {
@@ -342,13 +348,13 @@ static struct i2c_driver dummy_driver = 
 	.driver.name	= "dummy",
 	.probe		= dummy_probe,
 	.remove		= dummy_remove,
+	.id_table	= dummy_id,
 };
 
 /**
  * i2c_new_dummy - return a new i2c device bound to a dummy driver
  * @adapter: the adapter managing the device
  * @address: seven bit address to be used
- * @type: optional label used for i2c_client.name
  * Context: can sleep
  *
  * This returns an I2C client bound to the "dummy" driver, intended for use
@@ -364,15 +370,12 @@ static struct i2c_driver dummy_driver = 
  * i2c_unregister_device(); or NULL to indicate an error.
  */
 struct i2c_client *
-i2c_new_dummy(struct i2c_adapter *adapter, u16 address, const char *type)
+i2c_new_dummy(struct i2c_adapter *adapter, u16 address)
 {
 	struct i2c_board_info info = {
-		.driver_name	= "dummy",
-		.addr		= address,
+		I2C_BOARD_INFO("dummy", address),
 	};
 
-	if (type)
-		strlcpy(info.type, type, sizeof info.type);
 	return i2c_new_device(adapter, &info);
 }
 EXPORT_SYMBOL_GPL(i2c_new_dummy);
--- linux-2.6.26-rc0.orig/include/linux/i2c.h	2008-05-03 15:49:09.000000000 +0200
+++ linux-2.6.26-rc0/include/linux/i2c.h	2008-05-03 15:49:18.000000000 +0200
@@ -262,7 +262,7 @@ i2c_new_probed_device(struct i2c_adapter
  * client handles for the extra addresses.
  */
 extern struct i2c_client *
-i2c_new_dummy(struct i2c_adapter *adap, u16 address, const char *type);
+i2c_new_dummy(struct i2c_adapter *adap, u16 address);
 
 extern void i2c_unregister_device(struct i2c_client *);
 
--- linux-2.6.26-rc0.orig/drivers/rtc/rtc-s35390a.c	2008-05-03 15:49:09.000000000 +0200
+++ linux-2.6.26-rc0/drivers/rtc/rtc-s35390a.c	2008-05-03 15:49:18.000000000 +0200
@@ -227,7 +227,7 @@ static int s35390a_probe(struct i2c_clie
 	/* This chip uses multiple addresses, use dummy devices for them */
 	for (i = 1; i < 8; ++i) {
 		s35390a->client[i] = i2c_new_dummy(client->adapter,
-					client->addr + i, "rtc-s35390a");
+					client->addr + i);
 		if (!s35390a->client[i]) {
 			dev_err(&client->dev, "Address %02x unavailable\n",
 						client->addr + i);


-- 
Jean Delvare

_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c

             reply	other threads:[~2008-05-05  9:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-05  9:28 Jean Delvare [this message]
     [not found] ` <20080505112858.5101c99a-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-05-05 15:33   ` [PATCH] i2c: Match dummy devices by type David Brownell
     [not found]     ` <200805050833.55242.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
2008-05-05 16:43       ` Jean Delvare
     [not found]         ` <20080505184319.462b0ce6-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-05-05 17:06           ` David Brownell
2008-05-05 17:31   ` Byron Bradley

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=20080505112858.5101c99a@hyperion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org \
    --cc=i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox