mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
i2c: i2c stack can probe()
One of a series of I2C infrastructure updates to support enumeration using the standard Linux driver model. This patch updates probe() and associated hotplug/coldplug support, but not remove(). Nothing yet _uses_ it to create I2C devices, so those hotplug/coldplug mechanisms will be the only externally visible change. This patch will be an overall NOP since the I2C stack doesn't yet create clients/devices except as part of binding them to legacy drivers. Some code is moved earlier in the source code, helping group more of the per-device infrastructure in one place and simplifying handling per-device attributes. Terminology being adopted: "legacy drivers" create devices (i2c_client) themselves, while "new style" ones follow the driver model (the i2c_client is handed to the probe routine). It's an either/or thing; the two models don't mix, and drivers that try mixing them won't even be registered. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Jean Delvare <khali@linux-fr.org>
This commit is contained in:
parent
5cedb05db3
commit
7b4fbc50fa
2 changed files with 110 additions and 44 deletions
|
@ -113,7 +113,7 @@ struct i2c_driver {
|
|||
* can be used by the driver to test if the bus meets its conditions
|
||||
* & seek for the presence of the chip(s) it supports. If found, it
|
||||
* registers the client(s) that are on the bus to the i2c admin. via
|
||||
* i2c_attach_client.
|
||||
* i2c_attach_client. (LEGACY I2C DRIVERS ONLY)
|
||||
*/
|
||||
int (*attach_adapter)(struct i2c_adapter *);
|
||||
int (*detach_adapter)(struct i2c_adapter *);
|
||||
|
@ -121,10 +121,16 @@ struct i2c_driver {
|
|||
/* tells the driver that a client is about to be deleted & gives it
|
||||
* the chance to remove its private data. Also, if the client struct
|
||||
* has been dynamically allocated by the driver in the function above,
|
||||
* it must be freed here.
|
||||
* it must be freed here. (LEGACY I2C DRIVERS ONLY)
|
||||
*/
|
||||
int (*detach_client)(struct i2c_client *);
|
||||
|
||||
/* Standard driver model interfaces, for "new style" i2c drivers.
|
||||
* With the driver model, device enumeration is NEVER done by drivers;
|
||||
* it's done by infrastructure. (NEW STYLE DRIVERS ONLY)
|
||||
*/
|
||||
int (*probe)(struct i2c_client *);
|
||||
|
||||
/* driver model interfaces that don't relate to enumeration */
|
||||
void (*shutdown)(struct i2c_client *);
|
||||
int (*suspend)(struct i2c_client *, pm_message_t mesg);
|
||||
|
@ -148,6 +154,8 @@ struct i2c_driver {
|
|||
* @name: Indicates the type of the device, usually a chip name that's
|
||||
* generic enough to hide second-sourcing and compatible revisions.
|
||||
* @dev: Driver model device node for the slave.
|
||||
* @driver_name: Identifies new-style driver used with this device; also
|
||||
* used as the module name for hotplug/coldplug modprobe support.
|
||||
*
|
||||
* An i2c_client identifies a single device (i.e. chip) connected to an
|
||||
* i2c bus. The behaviour is defined by the routines of the driver.
|
||||
|
@ -163,6 +171,7 @@ struct i2c_client {
|
|||
int usage_count; /* How many accesses currently */
|
||||
/* to the client */
|
||||
struct device dev; /* the device structure */
|
||||
char driver_name[KOBJ_NAME_LEN];
|
||||
struct list_head list;
|
||||
struct completion released;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue