Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 41183
b: refs/heads/master
c: ac11d06
h: refs/heads/master
i:
  41181: 28db955
  41179: 2b4bb3c
  41175: 497b80c
  41167: 3e3e589
  41151: 7f45c39
v: v3
  • Loading branch information
Greg Kroah-Hartman committed Dec 1, 2006
1 parent 07ea5e3 commit 804ae7d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 38ca6c34d385f143027ff40dd271c61adcc9b23c
refs/heads/master: ac11d0601bbe73c92e31b393eeb1225593788d4c
26 changes: 13 additions & 13 deletions trunk/drivers/i2c/i2c-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -92,15 +92,16 @@ static void return_i2c_dev(struct i2c_dev *i2c_dev)
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)
Expand Down Expand Up @@ -413,23 +414,22 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
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;

pr_debug("i2c-dev: adapter [%s] registered as minor %d\n",
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);
Expand All @@ -444,9 +444,9 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap)
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);
Expand Down

0 comments on commit 804ae7d

Please sign in to comment.