Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 363903
b: refs/heads/master
c: 7638ffc
h: refs/heads/master
i:
  363901: ca4cd11
  363899: a97475a
  363895: 07ce250
  363887: 7a5c0df
  363871: 9f2722c
  363839: 93d3589
  363775: 369bfe9
v: v3
  • Loading branch information
Ian Abbott authored and Greg Kroah-Hartman committed Apr 5, 2013
1 parent 8fbe1e6 commit 49deb8c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 24 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: 70f30c3771f1e7c55d381954d84beff9c257a2b6
refs/heads/master: 7638ffcb50903d9ddbf605c7e9578d72658a960a
34 changes: 18 additions & 16 deletions trunk/drivers/staging/comedi/comedi_fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -2274,22 +2274,24 @@ static void comedi_device_cleanup(struct comedi_device *dev)
mutex_destroy(&dev->mutex);
}

int comedi_alloc_board_minor(struct device *hardware_device)
struct comedi_device *comedi_alloc_board_minor(struct device *hardware_device)
{
struct comedi_file_info *info;
struct comedi_device *dev;
struct device *csdev;
unsigned i;

info = kzalloc(sizeof(*info), GFP_KERNEL);
if (info == NULL)
return -ENOMEM;
info->device = kzalloc(sizeof(struct comedi_device), GFP_KERNEL);
if (info->device == NULL) {
return ERR_PTR(-ENOMEM);
dev = kzalloc(sizeof(struct comedi_device), GFP_KERNEL);
if (dev == NULL) {
kfree(info);
return -ENOMEM;
return ERR_PTR(-ENOMEM);
}
info->device = dev;
info->hardware_device = hardware_device;
comedi_device_init(info->device);
comedi_device_init(dev);
spin_lock(&comedi_file_info_table_lock);
for (i = 0; i < COMEDI_NUM_BOARD_MINORS; ++i) {
if (comedi_file_info_table[i] == NULL) {
Expand All @@ -2299,20 +2301,20 @@ int comedi_alloc_board_minor(struct device *hardware_device)
}
spin_unlock(&comedi_file_info_table_lock);
if (i == COMEDI_NUM_BOARD_MINORS) {
comedi_device_cleanup(info->device);
kfree(info->device);
comedi_device_cleanup(dev);
kfree(dev);
kfree(info);
pr_err("comedi: error: ran out of minor numbers for board device files.\n");
return -EBUSY;
return ERR_PTR(-EBUSY);
}
info->device->minor = i;
dev->minor = i;
csdev = device_create(comedi_class, hardware_device,
MKDEV(COMEDI_MAJOR, i), NULL, "comedi%i", i);
if (!IS_ERR(csdev))
info->device->class_dev = csdev;
dev->class_dev = csdev;
dev_set_drvdata(csdev, info);

return i;
return dev;
}

static struct comedi_file_info *comedi_clear_minor(unsigned minor)
Expand Down Expand Up @@ -2475,14 +2477,14 @@ static int __init comedi_init(void)

/* create devices files for legacy/manual use */
for (i = 0; i < comedi_num_legacy_minors; i++) {
int minor;
minor = comedi_alloc_board_minor(NULL);
if (minor < 0) {
struct comedi_device *dev;
dev = comedi_alloc_board_minor(NULL);
if (IS_ERR(dev)) {
comedi_cleanup_board_minors();
cdev_del(&comedi_cdev);
unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
COMEDI_NUM_MINORS);
return minor;
return PTR_ERR(dev);
}
}

Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/staging/comedi/comedi_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
int do_rangeinfo_ioctl(struct comedi_device *dev,
struct comedi_rangeinfo __user *arg);
int comedi_alloc_board_minor(struct device *hardware_device);
struct comedi_device *comedi_alloc_board_minor(struct device *hardware_device);
void comedi_release_hardware_device(struct device *hardware_device);
int comedi_alloc_subdevice_minor(struct comedi_subdevice *s);
void comedi_free_subdevice_minor(struct comedi_subdevice *s);
Expand Down
9 changes: 3 additions & 6 deletions trunk/drivers/staging/comedi/drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,6 @@ int comedi_device_attach(struct comedi_device *dev, struct comedi_devconfig *it)
int comedi_auto_config(struct device *hardware_device,
struct comedi_driver *driver, unsigned long context)
{
int minor;
struct comedi_device *comedi_dev;
int ret;

Expand All @@ -427,11 +426,9 @@ int comedi_auto_config(struct device *hardware_device,
return -EINVAL;
}

minor = comedi_alloc_board_minor(hardware_device);
if (minor < 0)
return minor;

comedi_dev = comedi_dev_from_minor(minor);
comedi_dev = comedi_alloc_board_minor(hardware_device);
if (IS_ERR(comedi_dev))
return PTR_ERR(comedi_dev);

mutex_lock(&comedi_dev->mutex);
if (comedi_dev->attached)
Expand Down

0 comments on commit 49deb8c

Please sign in to comment.