Commit fb1a2653 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge kroah.com:/home/greg/linux/BK/bleed-2.5

into kroah.com:/home/greg/linux/BK/i2c-2.5
parents 55f3c6b7 392e687b
This diff is collapsed.
...@@ -55,13 +55,17 @@ int i2c_device_remove(struct device *dev) ...@@ -55,13 +55,17 @@ int i2c_device_remove(struct device *dev)
return 0; return 0;
} }
static struct device_driver i2c_generic_driver = { static struct device_driver i2c_adapter_driver = {
.name = "i2c", .name = "i2c_adapter",
.bus = &i2c_bus_type, .bus = &i2c_bus_type,
.probe = i2c_device_probe, .probe = i2c_device_probe,
.remove = i2c_device_remove, .remove = i2c_device_remove,
}; };
static struct class i2c_adapter_class = {
.name = "i2c-adapter"
};
/* --------------------------------------------------- /* ---------------------------------------------------
* registering functions * registering functions
...@@ -94,9 +98,16 @@ int i2c_add_adapter(struct i2c_adapter *adap) ...@@ -94,9 +98,16 @@ int i2c_add_adapter(struct i2c_adapter *adap)
if (adap->dev.parent == NULL) if (adap->dev.parent == NULL)
adap->dev.parent = &legacy_bus; adap->dev.parent = &legacy_bus;
sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); sprintf(adap->dev.bus_id, "i2c-%d", adap->nr);
adap->dev.driver = &i2c_generic_driver; adap->dev.driver = &i2c_adapter_driver;
device_register(&adap->dev); device_register(&adap->dev);
/* Add this adapter to the i2c_adapter class */
memset(&adap->class_dev, 0x00, sizeof(struct class_device));
adap->class_dev.dev = &adap->dev;
adap->class_dev.class = &i2c_adapter_class;
strncpy(adap->class_dev.class_id, adap->dev.bus_id, BUS_ID_SIZE);
class_device_register(&adap->class_dev);
/* inform drivers of new adapters */ /* inform drivers of new adapters */
list_for_each(item,&drivers) { list_for_each(item,&drivers) {
driver = list_entry(item, struct i2c_driver, list); driver = list_entry(item, struct i2c_driver, list);
...@@ -150,6 +161,7 @@ int i2c_del_adapter(struct i2c_adapter *adap) ...@@ -150,6 +161,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
} }
/* clean up the sysfs representation */ /* clean up the sysfs representation */
class_device_unregister(&adap->class_dev);
device_unregister(&adap->dev); device_unregister(&adap->dev);
list_del(&adap->list); list_del(&adap->list);
...@@ -443,14 +455,23 @@ struct bus_type i2c_bus_type = { ...@@ -443,14 +455,23 @@ struct bus_type i2c_bus_type = {
.match = i2c_device_match, .match = i2c_device_match,
}; };
static int __init i2c_init(void) static int __init i2c_init(void)
{ {
return bus_register(&i2c_bus_type); int retval;
retval = bus_register(&i2c_bus_type);
if (retval)
return retval;
retval = driver_register(&i2c_adapter_driver);
if (retval)
return retval;
return class_register(&i2c_adapter_class);
} }
static void __exit i2c_exit(void) static void __exit i2c_exit(void)
{ {
class_unregister(&i2c_adapter_class);
driver_unregister(&i2c_adapter_driver);
bus_unregister(&i2c_bus_type); bus_unregister(&i2c_bus_type);
} }
...@@ -475,7 +496,7 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg msgs[],int num) ...@@ -475,7 +496,7 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg msgs[],int num)
return ret; return ret;
} else { } else {
dev_err(&adap->dev, "I2C level transfers not supported\n"); DEB2(dev_dbg(&adap->dev, "I2C level transfers not supported\n"));
return -ENOSYS; return -ENOSYS;
} }
} }
......
...@@ -240,7 +240,8 @@ struct i2c_adapter { ...@@ -240,7 +240,8 @@ struct i2c_adapter {
int timeout; int timeout;
int retries; int retries;
struct device dev; /* the adapter device */ struct device dev; /* the adapter device */
struct class_device class_dev; /* the class device */
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
/* No need to set this when you initialize the adapter */ /* No need to set this when you initialize the adapter */
...@@ -280,10 +281,12 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data) ...@@ -280,10 +281,12 @@ static inline void i2c_set_adapdata (struct i2c_adapter *dev, void *data)
/* Must equal I2C_M_TEN below */ /* Must equal I2C_M_TEN below */
/* i2c adapter classes (bitmask) */ /* i2c adapter classes (bitmask) */
#define I2C_ADAP_CLASS_SMBUS (1<<0) /* lm_sensors, ... */ #define I2C_ADAP_CLASS_SMBUS (1<<0) /* lm_sensors, ... */
#define I2C_ADAP_CLASS_TV_ANALOG (1<<1) /* bttv + friends */ #define I2C_ADAP_CLASS_TV_ANALOG (1<<1) /* bttv + friends */
#define I2C_ADAP_CLASS_TV_DIGINAL (1<<2) /* dbv cards */ #define I2C_ADAP_CLASS_TV_DIGITAL (1<<2) /* dbv cards */
#define I2C_ADAP_CLASS_DDC (1<<3) /* i2c-matroxfb ? */ #define I2C_ADAP_CLASS_DDC (1<<3) /* i2c-matroxfb ? */
#define I2C_ADAP_CLASS_CAM_ANALOG (1<<4) /* camera with analog CCD */
#define I2C_ADAP_CLASS_CAM_DIGITAL (1<<5) /* most webcams */
/* i2c_client_address_data is the struct for holding default client /* i2c_client_address_data is the struct for holding default client
* addresses for a driver and for the parameters supplied on the * addresses for a driver and for the parameters supplied on the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment