Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 268394
b: refs/heads/master
c: a9e39f9
h: refs/heads/master
v: v3
  • Loading branch information
Jonathan Cameron authored and Greg Kroah-Hartman committed Sep 16, 2011
1 parent 4ceabd6 commit 8d87ee8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 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: cedd1a16bbe00456fb9abda237e9b1c2bc763edd
refs/heads/master: a9e39f9e80ac24367e375c8ea110dfaec837b020
25 changes: 13 additions & 12 deletions trunk/drivers/staging/iio/industrialio-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,15 @@ struct iio_dev *iio_allocate_device(int sizeof_priv)
device_initialize(&dev->dev);
dev_set_drvdata(&dev->dev, (void *)dev);
mutex_init(&dev->mlock);

dev->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL);
if (dev->id < 0) {
/* cannot use a dev_err as the name isn't available */
printk(KERN_ERR "Failed to get id\n");
kfree(dev);
return NULL;
}
dev_set_name(&dev->dev, "iio:device%d", dev->id);
}

return dev;
Expand All @@ -1041,8 +1050,10 @@ EXPORT_SYMBOL(iio_allocate_device);

void iio_free_device(struct iio_dev *dev)
{
if (dev)
if (dev) {
ida_simple_remove(&iio_ida, dev->id);
kfree(dev);
}
}
EXPORT_SYMBOL(iio_free_device);

Expand Down Expand Up @@ -1100,22 +1111,14 @@ int iio_device_register(struct iio_dev *dev_info)
{
int ret;

dev_info->id = ida_simple_get(&iio_ida, 0, 0, GFP_KERNEL);
if (dev_info->id < 0) {
ret = dev_info->id;
dev_err(&dev_info->dev, "Failed to get id\n");
goto error_ret;
}
dev_set_name(&dev_info->dev, "iio:device%d", dev_info->id);

/* configure elements for the chrdev */
dev_info->dev.devt = MKDEV(MAJOR(iio_devt), dev_info->id);

ret = iio_device_register_sysfs(dev_info);
if (ret) {
dev_err(dev_info->dev.parent,
"Failed to register sysfs interfaces\n");
goto error_free_ida;
goto error_ret;
}
ret = iio_device_register_eventset(dev_info);
if (ret) {
Expand All @@ -1142,8 +1145,6 @@ int iio_device_register(struct iio_dev *dev_info)
iio_device_unregister_eventset(dev_info);
error_free_sysfs:
iio_device_unregister_sysfs(dev_info);
error_free_ida:
ida_simple_remove(&iio_ida, dev_info->id);
error_ret:
return ret;
}
Expand Down

0 comments on commit 8d87ee8

Please sign in to comment.