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

[PATCH] i2c: add i2c_adapter class support

parent d498eb57
......@@ -62,6 +62,10 @@ static struct device_driver i2c_generic_driver = {
.remove = i2c_device_remove,
};
static struct class i2c_adapter_class = {
.name = "i2c-adapter"
};
/* ---------------------------------------------------
* registering functions
......@@ -97,6 +101,13 @@ int i2c_add_adapter(struct i2c_adapter *adap)
adap->dev.driver = &i2c_generic_driver;
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 */
list_for_each(item,&drivers) {
driver = list_entry(item, struct i2c_driver, list);
......@@ -150,6 +161,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
}
/* clean up the sysfs representation */
class_device_unregister(&adap->class_dev);
device_unregister(&adap->dev);
list_del(&adap->list);
......@@ -443,14 +455,19 @@ struct bus_type i2c_bus_type = {
.match = i2c_device_match,
};
static int __init i2c_init(void)
{
return bus_register(&i2c_bus_type);
int retval;
retval = bus_register(&i2c_bus_type);
if (retval)
return retval;
return class_register(&i2c_adapter_class);
}
static void __exit i2c_exit(void)
{
class_unregister(&i2c_adapter_class);
bus_unregister(&i2c_bus_type);
}
......@@ -475,7 +492,7 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg msgs[],int num)
return ret;
} else {
dev_err(&adap->dev, "I2C level transfers not supported\n");
DEB2(dev_dbg(&adap->dev, "I2C level transfers not supported\n"));
return -ENOSYS;
}
}
......
......@@ -240,7 +240,8 @@ struct i2c_adapter {
int timeout;
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
/* No need to set this when you initialize the adapter */
......
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