diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-24 13:29:18 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-24 13:29:18 -0700 |
commit | 0cd5ff591ab6473355d5a6a47f7694def28e451d (patch) | |
tree | aed0ea4fbb724f13208ed76d438518ffc9130a17 /drivers/hwmon/smsc47m1.c | |
parent | 3539fc544f39017cf3403b9319fb4d74b5116135 (diff) | |
parent | e30bca12573fbf54e2470723aadc047549d147ce (diff) |
Merge tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon updates from Guenter Roeck:
"New drivers for DA9052/53 PMIC as well as HIH-6130/HIH-6131 humidity
and temperature sensors.
Convert drivers to use devm_ functions and to use dev_pm_ops. Address
a couple of Coverity errors/warnings as well as compile warnings.
Some functional improvements in applesmc driver."
* tag 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (72 commits)
hwmon: (applesmc) Ignore some temperature registers
hwmon: (applesmc) Allow negative temperature values
hwmon: (s3c-hwmon) Use devm_kzalloc instead of kzalloc
hwmon: (w83781d) Fix compile warning
hwmon: (applesmc) Shorten minimum wait time
hwmon: (exynos4_tmu) Use struct dev_pm_ops for power management
hwmon: (gpio-fan) Use struct dev_pm_ops for power management
hwmon: (abituguru3) Use struct dev_pm_ops for power management
hwmon: (abituguru) Use struct dev_pm_ops for power management
hwmon: (acpi_power_meter) Fix unintentional integer overflow
hwmon: (acpi_power_meter) Cleanup and optimizations
hwmon: Honeywell Humidicon HIH-6130/HIH-6131 humidity and temperature sensor driver
hwmon: (applesmc) Skip sensor mapping
hwmon: (ntc_thermistor) Ensure that data->name string is terminated
hwmon: (w83l785ts) Convert to use devm_ functions
hwmon: (w83l785ts) Simplify code and improve readability
hwmon: (smsc47m192) Convert to use devm_ functions
hwmon: (smsc47m1) Convert to use devm_ functions
hwmon: (smsc47b397) Convert to use devm_ functions
hwmon: (k8temp) Convert to use devm_ functions
...
Diffstat (limited to 'drivers/hwmon/smsc47m1.c')
-rw-r--r-- | drivers/hwmon/smsc47m1.c | 45 |
1 files changed, 11 insertions, 34 deletions
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index b5aa38dd7ab9..dba0c567e7a1 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c @@ -584,18 +584,17 @@ static void smsc47m1_restore(const struct smsc47m1_sio_data *sio_data) #define CHECK 1 #define REQUEST 2 -#define RELEASE 3 /* * This function can be used to: * - test for resource conflicts with ACPI * - request the resources - * - release the resources * We only allocate the I/O ports we really need, to minimize the risk of * conflicts with ACPI or with other drivers. */ -static int smsc47m1_handle_resources(unsigned short address, enum chips type, - int action, struct device *dev) +static int __init smsc47m1_handle_resources(unsigned short address, + enum chips type, int action, + struct device *dev) { static const u8 ports_m1[] = { /* register, region length */ @@ -642,21 +641,13 @@ static int smsc47m1_handle_resources(unsigned short address, enum chips type, break; case REQUEST: /* Request the resources */ - if (!request_region(start, len, DRVNAME)) { - dev_err(dev, "Region 0x%hx-0x%hx already in " - "use!\n", start, start + len); - - /* Undo all requests */ - for (i -= 2; i >= 0; i -= 2) - release_region(address + ports[i], - ports[i + 1]); + if (!devm_request_region(dev, start, len, DRVNAME)) { + dev_err(dev, + "Region 0x%hx-0x%hx already in use!\n", + start, start + len); return -EBUSY; } break; - case RELEASE: - /* Release the resources */ - release_region(start, len); - break; } } @@ -694,11 +685,9 @@ static int __init smsc47m1_probe(struct platform_device *pdev) if (err < 0) return err; - data = kzalloc(sizeof(struct smsc47m1_data), GFP_KERNEL); - if (!data) { - err = -ENOMEM; - goto error_release; - } + data = devm_kzalloc(dev, sizeof(struct smsc47m1_data), GFP_KERNEL); + if (!data) + return -ENOMEM; data->addr = res->start; data->type = sio_data->type; @@ -733,8 +722,7 @@ static int __init smsc47m1_probe(struct platform_device *pdev) } if (!(fan1 || fan2 || fan3 || pwm1 || pwm2 || pwm3)) { dev_warn(dev, "Device not configured, will not use\n"); - err = -ENODEV; - goto error_free; + return -ENODEV; } /* @@ -810,27 +798,16 @@ static int __init smsc47m1_probe(struct platform_device *pdev) error_remove_files: smsc47m1_remove_files(dev); -error_free: - platform_set_drvdata(pdev, NULL); - kfree(data); -error_release: - smsc47m1_handle_resources(res->start, sio_data->type, RELEASE, dev); return err; } static int __exit smsc47m1_remove(struct platform_device *pdev) { struct smsc47m1_data *data = platform_get_drvdata(pdev); - struct resource *res; hwmon_device_unregister(data->hwmon_dev); smsc47m1_remove_files(&pdev->dev); - res = platform_get_resource(pdev, IORESOURCE_IO, 0); - smsc47m1_handle_resources(res->start, data->type, RELEASE, &pdev->dev); - platform_set_drvdata(pdev, NULL); - kfree(data); - return 0; } |