summaryrefslogtreecommitdiff
path: root/drivers/i2c/i2c-core.c
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2007-05-01 23:26:28 +0200
committerJean Delvare <khali@hyperion.delvare>2007-05-01 23:26:28 +0200
commit16ffadfc680bd0683dc88573c1d72cbf1e27030e (patch)
tree4cf309680cc92b7906f0e069b12a6fdf09b9c408 /drivers/i2c/i2c-core.c
parent2096b956d24c4b5950b808fc23b218425d79ebb1 (diff)
i2c: Class attribute cleanup
This patch is a minor cleanup/code shrink, using class infrastructure in i2c-core to manage the i2c_adapter attribute. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r--drivers/i2c/i2c-core.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 7bfd67f4143d..1e3e1a5b4d86 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -107,28 +107,32 @@ struct bus_type i2c_bus_type = {
/* ------------------------------------------------------------------------- */
+/* I2C bus adapters -- one roots each I2C or SMBUS segment */
+
void i2c_adapter_dev_release(struct device *dev)
{
struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
complete(&adap->dev_released);
}
-/* ------------------------------------------------------------------------- */
+static ssize_t
+show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf)
+{
+ struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
+ return sprintf(buf, "%s\n", adap->name);
+}
-/* I2C bus adapters -- one roots each I2C or SMBUS segment */
+static struct device_attribute i2c_adapter_attrs[] = {
+ __ATTR(name, S_IRUGO, show_adapter_name, NULL),
+ { },
+};
struct class i2c_adapter_class = {
.owner = THIS_MODULE,
.name = "i2c-adapter",
+ .dev_attrs = i2c_adapter_attrs,
};
-static ssize_t show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf)
-{
- struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
- return sprintf(buf, "%s\n", adap->name);
-}
-static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
-
static void i2c_client_release(struct device *dev)
{
@@ -201,9 +205,6 @@ int i2c_add_adapter(struct i2c_adapter *adap)
res = device_register(&adap->dev);
if (res)
goto out_list;
- res = device_create_file(&adap->dev, &dev_attr_name);
- if (res)
- goto out_unregister;
dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name);
@@ -219,10 +220,6 @@ out_unlock:
mutex_unlock(&core_lists);
return res;
-out_unregister:
- init_completion(&adap->dev_released); /* Needed? */
- device_unregister(&adap->dev);
- wait_for_completion(&adap->dev_released);
out_list:
list_del(&adap->list);
idr_remove(&i2c_adapter_idr, adap->nr);
@@ -278,7 +275,6 @@ int i2c_del_adapter(struct i2c_adapter *adap)
/* clean up the sysfs representation */
init_completion(&adap->dev_released);
- device_remove_file(&adap->dev, &dev_attr_name);
device_unregister(&adap->dev);
list_del(&adap->list);