Commit 60b129d7 authored by Jean Delvare's avatar Jean Delvare Committed by Jean Delvare

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.
Signed-off-by: default avatarJean Delvare <khali@linux-fr.org>
parent b11a9d83
...@@ -327,6 +327,11 @@ void i2c_unregister_device(struct i2c_client *client) ...@@ -327,6 +327,11 @@ void i2c_unregister_device(struct i2c_client *client)
EXPORT_SYMBOL_GPL(i2c_unregister_device); EXPORT_SYMBOL_GPL(i2c_unregister_device);
static const struct i2c_device_id dummy_id[] = {
{ "dummy", 0 },
{ },
};
static int dummy_probe(struct i2c_client *client, static int dummy_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
...@@ -342,13 +347,13 @@ static struct i2c_driver dummy_driver = { ...@@ -342,13 +347,13 @@ static struct i2c_driver dummy_driver = {
.driver.name = "dummy", .driver.name = "dummy",
.probe = dummy_probe, .probe = dummy_probe,
.remove = dummy_remove, .remove = dummy_remove,
.id_table = dummy_id,
}; };
/** /**
* i2c_new_dummy - return a new i2c device bound to a dummy driver * i2c_new_dummy - return a new i2c device bound to a dummy driver
* @adapter: the adapter managing the device * @adapter: the adapter managing the device
* @address: seven bit address to be used * @address: seven bit address to be used
* @type: optional label used for i2c_client.name
* Context: can sleep * Context: can sleep
* *
* This returns an I2C client bound to the "dummy" driver, intended for use * This returns an I2C client bound to the "dummy" driver, intended for use
...@@ -364,15 +369,12 @@ static struct i2c_driver dummy_driver = { ...@@ -364,15 +369,12 @@ static struct i2c_driver dummy_driver = {
* i2c_unregister_device(); or NULL to indicate an error. * i2c_unregister_device(); or NULL to indicate an error.
*/ */
struct i2c_client * 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 = { struct i2c_board_info info = {
.driver_name = "dummy", I2C_BOARD_INFO("dummy", address),
.addr = address,
}; };
if (type)
strlcpy(info.type, type, sizeof info.type);
return i2c_new_device(adapter, &info); return i2c_new_device(adapter, &info);
} }
EXPORT_SYMBOL_GPL(i2c_new_dummy); EXPORT_SYMBOL_GPL(i2c_new_dummy);
......
...@@ -227,7 +227,7 @@ static int s35390a_probe(struct i2c_client *client, ...@@ -227,7 +227,7 @@ static int s35390a_probe(struct i2c_client *client,
/* This chip uses multiple addresses, use dummy devices for them */ /* This chip uses multiple addresses, use dummy devices for them */
for (i = 1; i < 8; ++i) { for (i = 1; i < 8; ++i) {
s35390a->client[i] = i2c_new_dummy(client->adapter, s35390a->client[i] = i2c_new_dummy(client->adapter,
client->addr + i, "rtc-s35390a"); client->addr + i);
if (!s35390a->client[i]) { if (!s35390a->client[i]) {
dev_err(&client->dev, "Address %02x unavailable\n", dev_err(&client->dev, "Address %02x unavailable\n",
client->addr + i); client->addr + i);
......
...@@ -262,7 +262,7 @@ i2c_new_probed_device(struct i2c_adapter *adap, ...@@ -262,7 +262,7 @@ i2c_new_probed_device(struct i2c_adapter *adap,
* client handles for the extra addresses. * client handles for the extra addresses.
*/ */
extern struct i2c_client * 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 *); extern void i2c_unregister_device(struct i2c_client *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment