From e43d5fefa7fe4e5d0999033753c15e1f30e06ff6 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Sat, 2 Jun 2012 12:04:06 -0700 Subject: hwmon: (smsc47b397) Convert to use devm_ functions Convert to use devm_ functions to reduce code size and simplify the code. Cc: Mark M. Hoffman Signed-off-by: Guenter Roeck Acked-by: Jean Delvare --- drivers/hwmon/smsc47b397.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'drivers/hwmon') diff --git a/drivers/hwmon/smsc47b397.c b/drivers/hwmon/smsc47b397.c index c5f6be478ba..65b07de11a0 100644 --- a/drivers/hwmon/smsc47b397.c +++ b/drivers/hwmon/smsc47b397.c @@ -231,13 +231,9 @@ static const struct attribute_group smsc47b397_group = { static int __devexit smsc47b397_remove(struct platform_device *pdev) { struct smsc47b397_data *data = platform_get_drvdata(pdev); - struct resource *res; hwmon_device_unregister(data->hwmon_dev); sysfs_remove_group(&pdev->dev.kobj, &smsc47b397_group); - res = platform_get_resource(pdev, IORESOURCE_IO, 0); - release_region(res->start, SMSC_EXTENT); - kfree(data); return 0; } @@ -261,19 +257,17 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev) int err = 0; res = platform_get_resource(pdev, IORESOURCE_IO, 0); - if (!request_region(res->start, SMSC_EXTENT, - smsc47b397_driver.driver.name)) { + if (!devm_request_region(dev, res->start, SMSC_EXTENT, + smsc47b397_driver.driver.name)) { dev_err(dev, "Region 0x%lx-0x%lx already in use!\n", (unsigned long)res->start, (unsigned long)res->start + SMSC_EXTENT - 1); return -EBUSY; } - data = kzalloc(sizeof(struct smsc47b397_data), GFP_KERNEL); - if (!data) { - err = -ENOMEM; - goto error_release; - } + data = devm_kzalloc(dev, sizeof(struct smsc47b397_data), GFP_KERNEL); + if (!data) + return -ENOMEM; data->addr = res->start; data->name = "smsc47b397"; @@ -283,7 +277,7 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev) err = sysfs_create_group(&dev->kobj, &smsc47b397_group); if (err) - goto error_free; + return err; data->hwmon_dev = hwmon_device_register(dev); if (IS_ERR(data->hwmon_dev)) { @@ -295,10 +289,6 @@ static int __devinit smsc47b397_probe(struct platform_device *pdev) error_remove: sysfs_remove_group(&dev->kobj, &smsc47b397_group); -error_free: - kfree(data); -error_release: - release_region(res->start, SMSC_EXTENT); return err; } -- cgit v1.2.3-18-g5258