Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 32641
b: refs/heads/master
c: 635adb6
h: refs/heads/master
i:
  32639: 465da75
v: v3
  • Loading branch information
Jim Cromie authored and Linus Torvalds committed Jul 15, 2006
1 parent c3c1750 commit 3bf40ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 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: ae2d1f2f5b59d00b39283c52dc4ee675397bbacd
refs/heads/master: 635adb6cd25c8f816c9017a0a0349cd389eafcd3
28 changes: 8 additions & 20 deletions trunk/drivers/char/scx200_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ static int scx200_gpio_release(struct inode *inode, struct file *file)
return 0;
}


static const struct file_operations scx200_gpio_fops = {
.owner = THIS_MODULE,
.write = nsc_gpio_write,
Expand All @@ -72,11 +71,11 @@ static const struct file_operations scx200_gpio_fops = {
.release = scx200_gpio_release,
};

struct cdev *scx200_devices;
struct cdev scx200_gpio_cdev; /* use 1 cdev for all pins */

static int __init scx200_gpio_init(void)
{
int rc, i;
int rc;
dev_t devid;

if (!scx200_gpio_present()) {
Expand Down Expand Up @@ -107,25 +106,12 @@ static int __init scx200_gpio_init(void)
dev_err(&pdev->dev, "SCx200 chrdev_region err: %d\n", rc);
goto undo_platform_device_add;
}
scx200_devices = kzalloc(MAX_PINS * sizeof(struct cdev), GFP_KERNEL);
if (!scx200_devices) {
rc = -ENOMEM;
goto undo_chrdev_region;
}
for (i = 0; i < MAX_PINS; i++) {
struct cdev *cdev = &scx200_devices[i];
cdev_init(cdev, &scx200_gpio_fops);
cdev->owner = THIS_MODULE;
rc = cdev_add(cdev, MKDEV(major, i), 1);
/* tolerate 'minor' errors */
if (rc)
dev_err(&pdev->dev, "Error %d on minor %d", rc, i);
}

cdev_init(&scx200_gpio_cdev, &scx200_gpio_fops);
cdev_add(&scx200_gpio_cdev, devid, MAX_PINS);

return 0; /* succeed */

undo_chrdev_region:
unregister_chrdev_region(devid, MAX_PINS);
undo_platform_device_add:
platform_device_del(pdev);
undo_malloc:
Expand All @@ -136,7 +122,9 @@ static int __init scx200_gpio_init(void)

static void __exit scx200_gpio_cleanup(void)
{
kfree(scx200_devices);
cdev_del(&scx200_gpio_cdev);
/* cdev_put(&scx200_gpio_cdev); */

unregister_chrdev_region(MKDEV(major, 0), MAX_PINS);
platform_device_unregister(pdev);
}
Expand Down

0 comments on commit 3bf40ad

Please sign in to comment.