Linux I2C development
 help / color / mirror / Atom feed
* [PATCH] i2c: Match dummy devices by type
@ 2008-05-05  9:28 Jean Delvare
       [not found] ` <20080505112858.5101c99a-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Jean Delvare @ 2008-05-05  9:28 UTC (permalink / raw)
  To: Linux I2C; +Cc: David Brownell

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

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

* Re: [PATCH] i2c: Match dummy devices by type
       [not found] ` <20080505112858.5101c99a-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
@ 2008-05-05 15:33   ` David Brownell
       [not found]     ` <200805050833.55242.david-b-yBeKhBN/0LDR7s880joybQ@public.gmane.org>
  2008-05-05 17:31   ` Byron Bradley
  1 sibling, 1 reply; 5+ messages in thread
From: David Brownell @ 2008-05-05 15:33 UTC (permalink / raw)
  To: Jean Delvare; +Cc: Linux I2C

On Monday 05 May 2008, Jean Delvare wrote:
> little reason to use these i2c clients to log messages.

I'd assume the opposite, actually.  Any i2c_client should
be sensible to use for message logging.


> +MODULE_DEVICE_TABLE(i2c, dummy_id);

Strike that.  There's no reason to export this, is there?
The only dummy devices are the ones drivers which tell th
core about.  We wouldn't *want* to try hotplugging them.


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

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

* Re: [PATCH] i2c: Match dummy devices by type
       [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>
  0 siblings, 1 reply; 5+ messages in thread
From: Jean Delvare @ 2008-05-05 16:43 UTC (permalink / raw)
  To: David Brownell; +Cc: Linux I2C

On Mon, 5 May 2008 08:33:54 -0700, David Brownell wrote:
> On Monday 05 May 2008, Jean Delvare wrote:
> > little reason to use these i2c clients to log messages.
> 
> I'd assume the opposite, actually.  Any i2c_client should
> be sensible to use for message logging.

I'd expect drivers to use the main i2c_client for that. i2c-core may
still use the dummy clients for debug messages, but it probably doesn't
matter. And nothing will break, the logs with just have "dummy" as the
client name.

At the moment, I can't foresee any problem important enough to require
improving the situation - especially since I have no clear idea what I
would do anyway. But if you can think of potential problems and you can
propose a solution, I'm listening of course :)

> > +MODULE_DEVICE_TABLE(i2c, dummy_id);
> 
> Strike that.  There's no reason to export this, is there?
> The only dummy devices are the ones drivers which tell th
> core about.  We wouldn't *want* to try hotplugging them.

Totally correct, thanks for pointing this out. I thought I had already
removed it, but obviously not. Fixed.

-- 
Jean Delvare

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

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

* Re: [PATCH] i2c: Match dummy devices by type
       [not found]         ` <20080505184319.462b0ce6-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
@ 2008-05-05 17:06           ` David Brownell
  0 siblings, 0 replies; 5+ messages in thread
From: David Brownell @ 2008-05-05 17:06 UTC (permalink / raw)
  To: Jean Delvare; +Cc: Linux I2C

On Monday 05 May 2008, Jean Delvare wrote:
> On Mon, 5 May 2008 08:33:54 -0700, David Brownell wrote:
> > On Monday 05 May 2008, Jean Delvare wrote:
> > > little reason to use these i2c clients to log messages.
> > 
> > I'd assume the opposite, actually.  Any i2c_client should
> > be sensible to use for message logging.
> 
> I'd expect drivers to use the main i2c_client for that.

That is, you're expecting drivers to invest *extra* work to
keep track of such stuff  ...

Probably not a big deal, since the messages will at least
be labeled according to the device address.  And not many
drivers need such stuff.  But I still think it's better
not to expect "busy work" like that.

- Dave


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

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

* Re: [PATCH] i2c: Match dummy devices by type
       [not found] ` <20080505112858.5101c99a-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
  2008-05-05 15:33   ` David Brownell
@ 2008-05-05 17:31   ` Byron Bradley
  1 sibling, 0 replies; 5+ messages in thread
From: Byron Bradley @ 2008-05-05 17:31 UTC (permalink / raw)
  To: Jean Delvare; +Cc: David Brownell, Linux I2C

On Mon, 5 May 2008, Jean Delvare wrote:

> 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.
> 

Tested and working, it registers the s35390a and the seven dummy devices:

i2c-core: driver [rtc-s35390a] registered
i2c /dev entries driver
i2c-core: driver [dev_driver] registered
i2c-adapter i2c-0: adapter [mv64xxx_i2c adapter] registered
i2c 0-0030: uevent
rtc-s35390a 0-0030: probe
i2c 0-0031: uevent
i2c-adapter i2c-0: client [dummy] registered with bus id 0-0031
i2c 0-0032: uevent
dummy 0-0032: probe
i2c-adapter i2c-0: client [dummy] registered with bus id 0-0032
i2c 0-0033: uevent
dummy 0-0033: probe
i2c-adapter i2c-0: client [dummy] registered with bus id 0-0033
i2c 0-0034: uevent
dummy 0-0034: probe
i2c-adapter i2c-0: client [dummy] registered with bus id 0-0034
i2c 0-0035: uevent
dummy 0-0035: probe
i2c-adapter i2c-0: client [dummy] registered with bus id 0-0035
i2c 0-0036: uevent
dummy 0-0036: probe
i2c-adapter i2c-0: client [dummy] registered with bus id 0-0036
i2c 0-0037: uevent
dummy 0-0037: probe
i2c-adapter i2c-0: client [dummy] registered with bus id 0-0037
i2c-adapter i2c-0: master_xfer[0] R, addr=0x30, len=1
i2c-adapter i2c-0: master_xfer[0] R, addr=0x31, len=1
i2c-adapter i2c-0: master_xfer[0] R, addr=0x30, len=1
i2c-adapter i2c-0: master_xfer[0] R, addr=0x32, len=7
rtc-s35390a 0-0030: rtc core: registered rtc-s35390a as rtc0
i2c-adapter i2c-0: master_xfer[0] R, addr=0x31, len=1
i2c-adapter i2c-0: master_xfer[0] W, addr=0x31, len=1
i2c-adapter i2c-0: master_xfer[0] W, addr=0x34, len=1
i2c-adapter i2c-0: client [s35390a] registered with bus id 0-0030

Cheers,

-- 
Byron Bradley

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

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

end of thread, other threads:[~2008-05-05 17:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-05  9:28 [PATCH] i2c: Match dummy devices by type Jean Delvare
     [not found] ` <20080505112858.5101c99a-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2008-05-05 15:33   ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox