i2c: Match dummy devices by type
Subsystems (3)
PATCH 1/1 i2c: Match dummy devices by type
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.
---
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(-)
drivers/i2c/i2c-core.c +9 -6
@@ -327,6 +327,12 @@ void i2c_unregister_device(struct i2c_clEXPORT_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);
include/linux/i2c.h +1 -1
@@ -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 *);
drivers/rtc/rtc-s35390a.c +1 -1
@@ -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);
Signature · 6 lines
Jean Delvare _______________________________________________ i2c mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/i2c
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 1 line · Jean Delvare
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.
Quoted 1 line
+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
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
A message that is not in the archive (sent off-list or not yet received): 200805050833.55242.david-b-yBeKhBN/[email protected]
Quoted 5 lines · David Brownell
Quoted 1 line · Jean Delvare
little reason to use these i2c clients to log messages.
I'd assume the opposite, actually. Any
i2c_clientshould 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 :)
Quoted 5 lines
Quoted 1 line
+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.
Signature · 6 lines
Jean Delvare _______________________________________________ i2c mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/i2c
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 8 lines · Jean Delvare
Quoted 5 lines · David Brownell
Quoted 1 line · Jean Delvare
little reason to use these i2c clients to log messages.
I'd assume the opposite, actually. Any
i2c_clientshould be sensible to use for message logging.I'd expect drivers to use the main
i2c_clientfor 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
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
Quoted 12 lines · Jean Delvare
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 <[email protected]>---
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,
Signature · 6 lines
Byron Bradley _______________________________________________ i2c mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/i2c