Skip to content

Commit 03c835f

Browse files
Uwe Kleine-Königwsakernel
Uwe Kleine-König
authored andcommitted
i2c: Switch .probe() to not take an id parameter
Commit b8a1a4c ("i2c: Provide a temporary .probe_new() call-back type") introduced a new probe callback to convert i2c init routines to not take an i2c_device_id parameter. Now that all in-tree drivers are converted to the temporary .probe_new() callback, .probe() can be modified to match the desired prototype. Now that .probe() and .probe_new() have the same semantic, they can be defined as members of an anonymous union to save some memory and simplify the core code a bit. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent 7eafbd4 commit 03c835f

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

drivers/i2c/i2c-core-base.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -561,15 +561,8 @@ static int i2c_device_probe(struct device *dev)
561561
goto err_detach_pm_domain;
562562
}
563563

564-
/*
565-
* When there are no more users of probe(),
566-
* rename probe_new to probe.
567-
*/
568-
if (driver->probe_new)
569-
status = driver->probe_new(client);
570-
else if (driver->probe)
571-
status = driver->probe(client,
572-
i2c_match_id(driver->id_table, client));
564+
if (driver->probe)
565+
status = driver->probe(client);
573566
else
574567
status = -EINVAL;
575568

include/linux/i2c.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ enum i2c_driver_flags {
236236
/**
237237
* struct i2c_driver - represent an I2C device driver
238238
* @class: What kind of i2c device we instantiate (for detect)
239-
* @probe: Callback for device binding - soon to be deprecated
240-
* @probe_new: New callback for device binding
239+
* @probe: Callback for device binding
240+
* @probe_new: Transitional callback for device binding - do not use
241241
* @remove: Callback for device unbinding
242242
* @shutdown: Callback for device shutdown
243243
* @alert: Alert callback, for example for the SMBus alert protocol
@@ -272,14 +272,18 @@ enum i2c_driver_flags {
272272
struct i2c_driver {
273273
unsigned int class;
274274

275+
union {
275276
/* Standard driver model interfaces */
276-
int (*probe)(struct i2c_client *client, const struct i2c_device_id *id);
277+
int (*probe)(struct i2c_client *client);
278+
/*
279+
* Legacy callback that was part of a conversion of .probe().
280+
* Today it has the same semantic as .probe(). Don't use for new
281+
* code.
282+
*/
283+
int (*probe_new)(struct i2c_client *client);
284+
};
277285
void (*remove)(struct i2c_client *client);
278286

279-
/* New driver model interface to aid the seamless removal of the
280-
* current probe()'s, more commonly unused than used second parameter.
281-
*/
282-
int (*probe_new)(struct i2c_client *client);
283287

284288
/* driver model interfaces that don't relate to enumeration */
285289
void (*shutdown)(struct i2c_client *client);

0 commit comments

Comments
 (0)