[[email protected]: Linux kernel / i2c_adapter structure]
----- Forwarded message from Godwin Stewart <[email protected]> -----
From: Godwin Stewart <[email protected]>
To: Frodo Looijaard <[email protected]>
Subject: Linux kernel / i2c_adapter structure
Organization: Nope, none here, it's a mess ;o)
X-Face: #T;eJks=B[71qrwpl6BW8xI&hP8S*4Kd%e?8o"rL02ZYf"rWa41l83a)L,*;S).Ukq$U%
II{-z#5%i&X8"%{$)ZWmE7WBDF)?wK1^7]u9T;@jqdZo?IT!d-L`!@&vW)F_1
X-Curious: You couldn't resist looking at these headers, could you!
X-MS_SUCKS: But we knew that :)
X-Operating-System: Slackware 9.0 (2.4.20)
X-Spam-Status: No, hits=0.0 required=5.0 tests= version=2.20 X-Spam-Level:
Hi there,
I noticed a change in the definition of the i2c_adapter structure in $SRC/include/linux/i2c.h between the 2.4.x and 2.6.0 kernels. More precisely, the following members are no longer present:
/* --- These may be NULL, but should increase the module use count */
void (*inc_use)(struct i2c_adapter *);
void (*dec_use)(struct i2c_adapter *);
void *data; /* private data for the adapter */
/* some data fields that are used by all types */
/* these data fields are readonly to the public */
/* and can be set via the i2c_ioctl call */The problem is that the em8300 drivers for DXR3/Hollywood+ MPEG2 decoder boards (see http://dxr3.sourceforge.net) use these members in their source.
My question is therefore, with what has their functionality been replaced?
For example :
static int em8300_i2c_reg(struct i2c_client *client)
{
struct em8300_s *em = client->adapter->data;
switch (client->driver->id) {
case I2C_DRIVERID_ADV717X:
if (!strncmp(client->name, "ADV7175", 7)) {
em->encoder_type = ENCODER_ADV7175;
}
if (!strncmp(client->name, "ADV7170", 7)) {
em->encoder_type = ENCODER_ADV7170;
}
em->encoder = client;
break;
case I2C_DRIVERID_BT865:
em->encoder_type = ENCODER_BT865;
em->encoder = client;
break;
default:
printk(KERN_ERR "em8300_i2c: unknown client id\n");
return -ENODEV;
}
return 0;
}In the above code, client->adapter is a struct i2c_adapter*, and the data field is definitely used in order to identify the encoder chip used on the board. I therefore need some way of working around the problem in order to have a go at patching the em8300 drivers.
Many thanks in advance, and Season's Greetings if we don't "speak" until after the festivities.
Signature · 15 lines
G. Stewart -- [email protected] -- [email protected] Registered Linux user #284683 (Slackware 9.0) --------------------------------------------------------------- "I once had a rose named after me and I was very flattered. But I was not pleased to read the description in the catalogue: No good in a bed, but fine up against a wall." -- Eleanor Roosevelt ----- End forwarded message ----- -- Frodo Looijaard <[email protected]> PGP key and more: http://huizen.dds.nl/~frodol Defenestration n. (formal or joc.): The act of removing Windows from your computer in disgust, usually followed by the installation of Linux or some other Unix-like operating system.
Quoted 30 lines
----- Forwarded message from Godwin Stewart <[email protected]> -----
From: Godwin Stewart <[email protected]>
To: Frodo Looijaard <[email protected]>
Subject: Linux kernel /i2c_adapterstructure
Organization: Nope, none here, it's a mess ;o)
X-Face: #T;eJks=B[71qrwpl6BW8xI&hP8S*4Kd%e?8o"rL02ZYf"rWa41l83a)L,*;S).Ukq$U%
II{-z#5%i&X8"%{$)ZWmE7WBDF)?wK1^7]u9T;@jqdZo?IT!d-L`!@&vW)F_1
X-Curious: You couldn't resist looking at these headers, could you!
X-MS_SUCKS: But we knew that :)
X-Operating-System: Slackware 9.0 (2.4.20)
X-Spam-Status: No, hits=0.0 required=5.0 tests= version=2.20 X-Spam-Level:Hi there,
I noticed a change in the definition of the
i2c_adapterstructure in$SRC/include/linux/i2c.hbetween the 2.4.x and 2.6.0 kernels. More precisely, the following members are no longer present:/* --- These may be NULL, but should increase the module use count */
void (*inc_use)(struct i2c_adapter *); void (*dec_use)(struct i2c_adapter *); void *data; /* private data for the adapter */ /* some data fields that are used by all types */ /* these data fields are readonly to the public */ /* and can be set via the i2c_ioctl call */
Quoted 4 lines
The problem is that the em8300 drivers for DXR3/Hollywood+ MPEG2 decoder boards (see http://dxr3.sourceforge.net) use these members in their source.
My question is therefore, with what has their functionality been replaced?
Use the i2c_get_adapdata() and i2c_set_adapdata() functions to get and set a private data pointer. See the adapter drivers for examples of how to use this properly.
Hope this helps,
greg k-h
Quoted 7 lines · Ky?sti M?lkki
Quoted 4 lines · Greg KH
Use the
i2c_get_adapdata()andi2c_set_adapdata()functions to get and set a private data pointer. See the adapter drivers for examples of how to use this properly.Hmm... it goes to adapter.dev.driver_data.
Yes, is there a problem with that? a i2c_adapter contains a struct device, and the driver core provides a private pointer, driver_data, which can be used by the high level driver.
Quoted 2 lines
Currently in 2.6 adapter is bound with a "dummy" driver that never references dev.driver_data.
Even if it did have a "real" driver, it would not reference this field.
Quoted 5 lines
While it does work it is not very clean as
for ani2c_adapterdevice, the device driver is the algorithm. Therefore,driver_datashould point a structure specific to this algorithm. IMO, one should move*algo_dataand not *data to dev.driver_data using the functions you mention above, right?
No. Perhaps the field, "driver_data" is a bit confusing. Perhaps it should be called "device_data", or "private".
thanks,
greg k-h
Quoted 4 lines · Greg KH
Use the
i2c_get_adapdata()andi2c_set_adapdata()functions to get and set a private data pointer. See the adapter drivers for examples of how to use this properly.
Hmm... it goes to adapter.dev.driver_data.
Currently in 2.6 adapter is bound with a "dummy" driver that never references dev.driver_data. While it does work it is not very clean as for an i2c_adapter device, the device driver is the algorithm. Therefore, driver_data should point a structure specific to this algorithm. IMO, one should move *algo_data and not *data to dev.driver_data using the functions you mention above, right? Maybe have i2c_set/get_algodata with current _adapdata function and consider if we need a _adapdata variant at all.
Often, in place of i2c_get_adapdata, one could use either container_of() or reference into the algorithm structure which also has a void pointer for the use of the adapter code.
Some two weeks ago I posted about simplifying i2c-core and I have it compiling and running now. Will post it with comments some day RSN.
Signature · 1 line
Ky?sti M?lkki <[email protected]>