aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/pc8736x_gpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/pc8736x_gpio.c')
-rw-r--r--drivers/char/pc8736x_gpio.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c
index bfc45e0cc602..11bd78c80628 100644
--- a/drivers/char/pc8736x_gpio.c
+++ b/drivers/char/pc8736x_gpio.c
@@ -259,7 +259,8 @@ static struct cdev pc8736x_gpio_cdev;
259 259
260static int __init pc8736x_gpio_init(void) 260static int __init pc8736x_gpio_init(void)
261{ 261{
262 int rc = 0; 262 int rc;
263 dev_t devid;
263 264
264 pdev = platform_device_alloc(DEVNAME, 0); 265 pdev = platform_device_alloc(DEVNAME, 0);
265 if (!pdev) 266 if (!pdev)
@@ -307,7 +308,14 @@ static int __init pc8736x_gpio_init(void)
307 } 308 }
308 dev_info(&pdev->dev, "GPIO ioport %x reserved\n", pc8736x_gpio_base); 309 dev_info(&pdev->dev, "GPIO ioport %x reserved\n", pc8736x_gpio_base);
309 310
310 rc = register_chrdev(major, DEVNAME, &pc8736x_gpio_fops); 311 if (major) {
312 devid = MKDEV(major, 0);
313 rc = register_chrdev_region(devid, PC8736X_GPIO_CT, DEVNAME);
314 } else {
315 rc = alloc_chrdev_region(&devid, 0, PC8736X_GPIO_CT, DEVNAME);
316 major = MAJOR(devid);
317 }
318
311 if (rc < 0) { 319 if (rc < 0) {
312 dev_err(&pdev->dev, "register-chrdev failed: %d\n", rc); 320 dev_err(&pdev->dev, "register-chrdev failed: %d\n", rc);
313 goto undo_request_region; 321 goto undo_request_region;
@@ -318,6 +326,11 @@ static int __init pc8736x_gpio_init(void)
318 } 326 }
319 327
320 pc8736x_init_shadow(); 328 pc8736x_init_shadow();
329
330 /* ignore minor errs, and succeed */
331 cdev_init(&pc8736x_gpio_cdev, &pc8736x_gpio_fops);
332 cdev_add(&pc8736x_gpio_cdev, devid, PC8736X_GPIO_CT);
333
321 return 0; 334 return 0;
322 335
323undo_request_region: 336undo_request_region: