[PATCH][2.6] Add command function to struct i2c_adapter

From: Michael Hunold
Date: Mon Sep 20 2004 - 12:22:21 EST


Hi there,

the attached patch adds a command function to struct i2c_adapter, similar to the command function that is already there for struct i2c_client.

The reason behind this is as follows:
In the DVB subsystem, the tuners are accessed via normal kernel i2c drivers. One big problem is, that tuners can be wired very differently depending on the surrounding hardware. Currently, we need to keep specific settings which are unique to a hardware design in the independent i2c tuner driver. This is both very ugly and makes it impossible to support DVB drivers which are not in the official Linux kernel tree, but could otherwise use in-kernel frontend driver.

If the struct i2c_adapter has a command function, it would be possible to get additional informations from the adapter in the i2c client's attach_adapter() function *before* probing the device and guessing things like i2c addresses or other hardware settings.

This patch is non-intrusive. It doesn't affect any current drivers, but only future developments.

Are there any objections against this patch?

Regards
Michael.
diff -ura linux-2.6.9-rc2-mm1/include/linux/i2c.h b/include/linux/i2c.h
--- linux-2.6.9-rc2-mm1/include/linux/i2c.h 2004-09-20 12:38:24.000000000 +0200
+++ b/include/linux/i2c.h 2004-09-20 18:53:32.000000000 +0200
@@ -231,6 +231,11 @@
struct i2c_algorithm *algo;/* the algorithm to access the bus */
void *algo_data;

+ /* a ioctl like command that can be used to perform specific functions
+ * with the adapter.
+ */
+ int (*command)(struct i2c_adapter *adapter, unsigned int cmd, void *arg);
+
/* --- administration stuff. */
int (*client_register)(struct i2c_client *);
int (*client_unregister)(struct i2c_client *);