Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 36091
b: refs/heads/master
c: defcb46
h: refs/heads/master
i:
  36089: 91c7be9
  36087: 791e568
v: v3
  • Loading branch information
Jean Delvare authored and Greg Kroah-Hartman committed Sep 26, 2006
1 parent eb698cd commit f268e4d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 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: b119c6c952a086f74202ccda4b7ed72161bb6522
refs/heads/master: defcb46ed4666095677c8f52904b9e328587a20d
14 changes: 11 additions & 3 deletions trunk/drivers/i2c/i2c-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ static struct class *i2c_dev_class;
static int i2cdev_attach_adapter(struct i2c_adapter *adap)
{
struct i2c_dev *i2c_dev;
int res;

i2c_dev = get_free_i2c_dev(adap);
if (IS_ERR(i2c_dev))
Expand All @@ -419,14 +420,20 @@ static int i2cdev_attach_adapter(struct i2c_adapter *adap)
MKDEV(I2C_MAJOR, adap->nr),
&adap->dev, "i2c-%d",
adap->nr);
if (!i2c_dev->class_dev)
if (!i2c_dev->class_dev) {
res = -ENODEV;
goto error;
class_device_create_file(i2c_dev->class_dev, &class_device_attr_name);
}
res = class_device_create_file(i2c_dev->class_dev, &class_device_attr_name);
if (res)
goto error_destroy;
return 0;
error_destroy:
class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
error:
return_i2c_dev(i2c_dev);
kfree(i2c_dev);
return -ENODEV;
return res;
}

static int i2cdev_detach_adapter(struct i2c_adapter *adap)
Expand All @@ -437,6 +444,7 @@ static int i2cdev_detach_adapter(struct i2c_adapter *adap)
if (!i2c_dev)
return -ENODEV;

class_device_remove_file(i2c_dev->class_dev, &class_device_attr_name);
return_i2c_dev(i2c_dev);
class_device_destroy(i2c_dev_class, MKDEV(I2C_MAJOR, adap->nr));
kfree(i2c_dev);
Expand Down

0 comments on commit f268e4d

Please sign in to comment.