From: Guenter Roeck Date: Thu, 10 May 2012 13:24:25 +0000 (-0700) Subject: Clean up probe function: Use devm_request_region X-Git-Tag: nct6775-v0.9~17 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2e3aa9314eb94b4762134c281d3c6d70e4a7a21c;p=groeck-nct6775 Clean up probe function: Use devm_request_region Signed-off-by: Guenter Roeck --- diff --git a/nct6775.c b/nct6775.c index 8420326..f32346d 100644 --- 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; }