Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: Proposal for new frontend architecture



Heres the patch as discussed - using I2C_AF_NOPROBE though.

Michael, it'll conflict with your class patch as it changes the same lines. Do 
you like it? Maybe we should submit it at the same time as the class patch?
--- linux-2.6.9-rc1/include/linux/i2c.h	2004-08-29 17:31:47.000000000 +0100
+++ linux-2.6.9-rc1.adqpatch/include/linux/i2c.h	2004-09-15 23:15:51.262979256 +0100
@@ -230,6 +230,12 @@
 	unsigned int class;
 	struct i2c_algorithm *algo;/* the algorithm to access the bus	*/
 	void *algo_data;
+	unsigned int flags;
+
+	/* a ioctl like command that can be used to perform specific functions
+	 * with the adapter.
+	 */
+	int (*command)(struct i2c_client *client,unsigned int cmd, void *arg);
 
 	/* --- administration stuff. */
 	int (*client_register)(struct i2c_client *);
@@ -295,6 +301,9 @@
 #define I2C_CLASS_SOUND		(1<<6)	/* sound devices */
 #define I2C_CLASS_ALL		(UINT_MAX) /* all of the above */
 
+/*flags for the adapter struct: */
+#define I2C_AF_NOPROBE   0x01			/* do not auto-probe devices on i2c bus */
+
 /* i2c_client_address_data is the struct for holding default client
  * addresses for a driver and for the parameters supplied on the
  * command line
@@ -327,6 +336,7 @@
  */
 extern int i2c_add_adapter(struct i2c_adapter *);
 extern int i2c_del_adapter(struct i2c_adapter *);
+extern int i2c_adapter_probe_drivers(struct i2c_adapter*);
 
 extern int i2c_add_driver(struct i2c_driver *);
 extern int i2c_del_driver(struct i2c_driver *);
--- linux-2.6.9-rc1/drivers/i2c/i2c-core.c	2004-08-29 17:31:47.000000000 +0100
+++ linux-2.6.9-rc1.adqpatch/drivers/i2c/i2c-core.c	2004-09-15 23:10:49.104914264 +0100
@@ -159,6 +159,30 @@
 	class_device_register(&adap->class_dev);
 
 	/* inform drivers of new adapters */
+	if (!(adap->flags & I2C_AF_NOPROBE)) {
+		list_for_each(item,&drivers) {
+			driver = list_entry(item, struct i2c_driver, list);
+			if (driver->flags & I2C_DF_NOTIFY)
+				/* We ignore the return code; if it fails, too bad */
+				driver->attach_adapter(adap);
+		}
+	}
+
+	dev_dbg(&adap->dev, "registered as adapter #%d\n", adap->nr);
+
+out_unlock:
+	up(&core_lists);
+	return res;
+}
+
+
+int i2c_adapter_probe_drivers(struct i2c_adapter* adap)
+{
+	struct list_head   *item;
+	struct i2c_driver  *driver;
+
+	down(&core_lists);
+
 	list_for_each(item,&drivers) {
 		driver = list_entry(item, struct i2c_driver, list);
 		if (driver->flags & I2C_DF_NOTIFY)
@@ -166,11 +190,8 @@
 			driver->attach_adapter(adap);
 	}
 
-	dev_dbg(&adap->dev, "registered as adapter #%d\n", adap->nr);
-
-out_unlock:
 	up(&core_lists);
-	return res;
+   	return 0;
 }
 
 
@@ -266,7 +287,9 @@
 	if (driver->flags & I2C_DF_NOTIFY) {
 		list_for_each(item,&adapters) {
 			adapter = list_entry(item, struct i2c_adapter, list);
-			driver->attach_adapter(adapter);
+			if (!(adapter->flags & I2C_AF_NOPROBE)) {
+				driver->attach_adapter(adapter);
+			}
 		}
 	}
 
@@ -1284,6 +1307,7 @@
 EXPORT_SYMBOL(i2c_release_client);
 EXPORT_SYMBOL(i2c_clients_command);
 EXPORT_SYMBOL(i2c_check_addr);
+EXPORT_SYMBOL(i2c_adapter_probe_drivers);
 
 EXPORT_SYMBOL(i2c_master_send);
 EXPORT_SYMBOL(i2c_master_recv);

Home | Main Index | Thread Index