[PATCH 15/36] I2C: convert i2c-dev to use struct device instead of struct class_device
- From: Greg KH <greg@xxxxxxxxx>
- Date: Fri, 1 Dec 2006 15:21:45 -0800
From: Greg Kroah-Hartman <gregkh@xxxxxxx>
As class_device is going away eventually...
Cc: Jean Delvare <khali@xxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>
---
drivers/i2c/i2c-dev.c | 26 +++++++++++++-------------
1 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 3f86903..94a4e9a 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -42,7 +42,7 @@ static struct i2c_driver i2cdev_driver;
struct i2c_dev {
struct list_head list;
struct i2c_adapter *adap;
- struct class_device *class_dev;
+ struct device *dev;
};
#define I2C_MINORS 256
@@ -92,15 +92,16 @@ static void return_i2c_dev(struct i2c_de
spin_unlock(&i2c_dev_list_lock);
}
-static ssize_t show_adapter_name(struct class_device *class_dev, char *buf)
+static ssize_t show_adapter_name(struct device *dev,
+ struct device_attribute *attr, char *buf)
{
- struct i2c_dev *i2c_dev = i2c_dev_get_by_minor(MINOR(class_dev->devt));
+ struct i2c_dev *i2c_dev = i2c_dev_get_by_minor(MINOR(dev->devt));
if (!i2c_dev)
return -ENODEV;
return sprintf(buf, "%s\n", i2c_dev->adap->name);
}
-static CLASS_DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
+static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
static ssize_t i2cdev_read (struct file *file, char __user *buf, size_t count,
loff_t *offset)
@@ -413,15 +414,14 @@ static int i2cdev_attach_adapter(struct
return PTR_ERR(i2c_dev);
/* register this i2c device with the driver core */
- i2c_dev->class_dev = class_device_create(i2c_dev_class, NULL,
- MKDEV(I2C_MAJOR, adap->nr),
- &adap->dev, "i2c-%d",
- adap->nr);
- if (!i2c_dev->class_dev) {
+ i2c_dev->dev = device_create(i2c_dev_class, &adap->dev,
+ MKDEV(I2C_MAJOR, adap->nr),
+ "i2c-%d", adap->nr);
+ if (!i2c_dev->dev) {
res = -ENODEV;
goto error;
}
- res = class_device_create_file(i2c_dev->class_dev, &class_device_attr_name);
+ res = device_create_file(i2c_dev->dev, &dev_attr_name);
if (res)
goto error_destroy;
@@ -429,7 +429,7 @@ static int i2cdev_attach_adapter(struct
adap->name, adap->nr);
return 0;
error_destroy:
- class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
+ device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
error:
return_i2c_dev(i2c_dev);
kfree(i2c_dev);
@@ -444,9 +444,9 @@ static int i2cdev_detach_adapter(struct
if (!i2c_dev) /* attach_adapter must have failed */
return 0;
- class_device_remove_file(i2c_dev->class_dev, &class_device_attr_name);
+ device_remove_file(i2c_dev->dev, &dev_attr_name);
return_i2c_dev(i2c_dev);
- class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
+ device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
kfree(i2c_dev);
pr_debug("i2c-dev: adapter [%s] unregistered\n", adap->name);
--
1.4.4.1
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- References:
- [GIT PATCH] Driver core patches for 2.6.19
- From: Greg KH
- [PATCH 1/36] Driver core: add notification of bus events
- From: Greg KH
- [PATCH 2/36] Driver core: fix "driver" symlink timing
- From: Greg KH
- [PATCH 3/36] Driver Core: Move virtual_device_parent() to core.c
- From: Greg KH
- [PATCH 4/36] CONFIG_SYSFS_DEPRECATED
- From: Greg KH
- [PATCH 5/36] Driver core: make old versions of udev work properly
- From: Greg KH
- [PATCH 6/36] CONFIG_SYSFS_DEPRECATED - bus symlinks
- From: Greg KH
- [PATCH 7/36] CONFIG_SYSFS_DEPRECATED - device symlinks
- From: Greg KH
- [PATCH 8/36] CONFIG_SYSFS_DEPRECATED - PHYSDEV* uevent variables
- From: Greg KH
- [PATCH 9/36] CONFIG_SYSFS_DEPRECATED - class symlinks
- From: Greg KH
- [PATCH 10/36] Driver core: convert vt code to use struct device
- From: Greg KH
- [PATCH 11/36] Driver core: convert vc code to use struct device
- From: Greg KH
- [PATCH 12/36] Driver core: change misc class_devices to be real devices
- From: Greg KH
- [PATCH 13/36] Driver core: convert tty core to use struct device
- From: Greg KH
- [PATCH 14/36] Driver core: convert raw device code to use struct device
- From: Greg KH
- [GIT PATCH] Driver core patches for 2.6.19
- Prev by Date: [PATCH 19/36] Driver core: convert ppdev code to use struct device
- Next by Date: Re: [OHCI] BIOS handoff failed (BIOS bug?)
- Previous by thread: [PATCH 14/36] Driver core: convert raw device code to use struct device
- Next by thread: [PATCH 16/36] Driver core: convert msr code to use struct device
- Index(es):
Relevant Pages
|