diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2013-09-29 04:51:06 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2013-10-03 16:28:31 -0400 |
commit | 0acc2b321342aa813fa9fc485afb09fbc811f594 (patch) | |
tree | 7c7ba32188f4b48f88feca5ca9c8fc834129a64e /drivers/i2c/i2c-core.c | |
parent | 40df24997f947ab5b745d570d56a003705868dcc (diff) |
i2c: Remove redundant 'driver' field from the i2c_client struct
The 'driver' field of the i2c_client struct is redundant. The same data can be
accessed through to_i2c_driver(client->dev.driver). The generated code for both
approaches in more or less the same.
E.g. on ARM the expression client->driver->command(...) generates
...
ldr r3, [r0, #28]
ldr r3, [r3, #32]
blx r3
...
and the expression to_i2c_driver(client->dev.driver)->command(...) generates
...
ldr r3, [r0, #160]
ldr r3, [r3, #-4]
blx r3
...
Other architectures will generate similar code.
All users of the 'driver' field outside of the I2C core have already been
converted. So this only leaves the core itself. This patch converts the
remaining few users in the I2C core and then removes the 'driver' field from the
i2c_client struct.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 29d3f045a2bf..430c001b3f1e 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -248,17 +248,16 @@ static int i2c_device_probe(struct device *dev) | |||
248 | driver = to_i2c_driver(dev->driver); | 248 | driver = to_i2c_driver(dev->driver); |
249 | if (!driver->probe || !driver->id_table) | 249 | if (!driver->probe || !driver->id_table) |
250 | return -ENODEV; | 250 | return -ENODEV; |
251 | client->driver = driver; | 251 | |
252 | if (!device_can_wakeup(&client->dev)) | 252 | if (!device_can_wakeup(&client->dev)) |
253 | device_init_wakeup(&client->dev, | 253 | device_init_wakeup(&client->dev, |
254 | client->flags & I2C_CLIENT_WAKE); | 254 | client->flags & I2C_CLIENT_WAKE); |
255 | dev_dbg(dev, "probe\n"); | 255 | dev_dbg(dev, "probe\n"); |
256 | 256 | ||
257 | status = driver->probe(client, i2c_match_id(driver->id_table, client)); | 257 | status = driver->probe(client, i2c_match_id(driver->id_table, client)); |
258 | if (status) { | 258 | if (status) |
259 | client->driver = NULL; | ||
260 | i2c_set_clientdata(client, NULL); | 259 | i2c_set_clientdata(client, NULL); |
261 | } | 260 | |
262 | return status; | 261 | return status; |
263 | } | 262 | } |
264 | 263 | ||
@@ -279,10 +278,9 @@ static int i2c_device_remove(struct device *dev) | |||
279 | dev->driver = NULL; | 278 | dev->driver = NULL; |
280 | status = 0; | 279 | status = 0; |
281 | } | 280 | } |
282 | if (status == 0) { | 281 | if (status == 0) |
283 | client->driver = NULL; | ||
284 | i2c_set_clientdata(client, NULL); | 282 | i2c_set_clientdata(client, NULL); |
285 | } | 283 | |
286 | return status; | 284 | return status; |
287 | } | 285 | } |
288 | 286 | ||
@@ -1606,9 +1604,14 @@ static int i2c_cmd(struct device *dev, void *_arg) | |||
1606 | { | 1604 | { |
1607 | struct i2c_client *client = i2c_verify_client(dev); | 1605 | struct i2c_client *client = i2c_verify_client(dev); |
1608 | struct i2c_cmd_arg *arg = _arg; | 1606 | struct i2c_cmd_arg *arg = _arg; |
1607 | struct i2c_driver *driver; | ||
1608 | |||
1609 | if (!client || !client->dev.driver) | ||
1610 | return 0; | ||
1609 | 1611 | ||
1610 | if (client && client->driver && client->driver->command) | 1612 | driver = to_i2c_driver(client->dev.driver); |
1611 | client->driver->command(client, arg->cmd, arg->arg); | 1613 | if (driver->command) |
1614 | driver->command(client, arg->cmd, arg->arg); | ||
1612 | return 0; | 1615 | return 0; |
1613 | } | 1616 | } |
1614 | 1617 | ||