]> git.sur5r.net Git - groeck-nct6775/commitdiff
Clean up probe function: Use devm_request_region
authorGuenter Roeck <linux@roeck-us.net>
Thu, 10 May 2012 13:24:25 +0000 (06:24 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Thu, 10 May 2012 13:24:59 +0000 (06:24 -0700)
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
nct6775.c

index 8420326e7f422e314e056339461a3b97e9116c86..f32346d36bf62f09578a8056dc5fc89a8b8b8c73 100644 (file)
--- a/nct6775.c
+++ b/nct6775.c
@@ -3089,20 +3089,14 @@ static int __devinit nct6775_probe(struct platform_device *pdev)
        int num_reg_temp;
 
        res = platform_get_resource(pdev, IORESOURCE_IO, 0);
-       if (!request_region(res->start, IOREGION_LENGTH, DRVNAME)) {
-               err = -EBUSY;
-               dev_err(dev, "Failed to request region 0x%lx-0x%lx\n",
-                       (unsigned long)res->start,
-                       (unsigned long)res->start + IOREGION_LENGTH - 1);
-               goto exit;
-       }
+       if (!devm_request_region(&pdev->dev, res->start, IOREGION_LENGTH,
+                                DRVNAME))
+               return -EBUSY;
 
        data = devm_kzalloc(&pdev->dev, sizeof(struct nct6775_data),
                            GFP_KERNEL);
-       if (!data) {
-               err = -ENOMEM;
-               goto exit_release;
-       }
+       if (!data)
+               return -ENOMEM;
 
        data->kind = sio_data->kind;
        data->addr = res->start;
@@ -3294,8 +3288,7 @@ static int __devinit nct6775_probe(struct platform_device *pdev)
 
                break;
        default:
-               err = -ENODEV;
-               goto exit_release;
+               return -ENODEV;
        }
        data->have_in = (1 << data->in_num) - 1;
        data->have_temp = 0;
@@ -3487,9 +3480,6 @@ static int __devinit nct6775_probe(struct platform_device *pdev)
         */
        superio_select(sio_data->sioreg, NCT6775_LD_VID);
        data->vid = superio_inb(sio_data->sioreg, 0xe3);
-       err = device_create_file(dev, &dev_attr_cpu0_vid);
-       if (err)
-               goto exit_release;
 
        if (fan_debounce) {
                u8 tmp;
@@ -3514,6 +3504,10 @@ static int __devinit nct6775_probe(struct platform_device *pdev)
 
        superio_exit(sio_data->sioreg);
 
+       err = device_create_file(dev, &dev_attr_cpu0_vid);
+       if (err)
+               return err;
+
        nct6775_check_fan_inputs(sio_data, data);
 
        /* Read fan clock dividers immediately */
@@ -3662,9 +3656,6 @@ static int __devinit nct6775_probe(struct platform_device *pdev)
 
 exit_remove:
        nct6775_device_remove_files(dev);
-exit_release:
-       release_region(res->start, IOREGION_LENGTH);
-exit:
        return err;
 }
 
@@ -3674,7 +3665,6 @@ static int __devexit nct6775_remove(struct platform_device *pdev)
 
        hwmon_device_unregister(data->hwmon_dev);
        nct6775_device_remove_files(&pdev->dev);
-       release_region(data->addr, IOREGION_LENGTH);
 
        return 0;
 }