aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-06-02 12:58:03 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-09-24 00:08:30 -0400
commit805fd8c5b8868036e1e1298fcccf7499f6d6ede2 (patch)
tree1debc5c95fe4a6ac38511acd6fe588bed73ee885 /drivers
parent64adf39837c7cf744161b18598577cbe2467a01d (diff)
hwmon: (dme1737) Convert to use devm_ functions
Convert to use devm_ functions to reduce code size and simplify the code. Cc: Juerg Haefliger <juergh@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hwmon/dme1737.c45
1 files changed, 13 insertions, 32 deletions
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c
index e7c6a19f3b25..fe0eeec0b750 100644
--- a/drivers/hwmon/dme1737.c
+++ b/drivers/hwmon/dme1737.c
@@ -2475,11 +2475,9 @@ static int dme1737_i2c_probe(struct i2c_client *client,
2475 struct device *dev = &client->dev; 2475 struct device *dev = &client->dev;
2476 int err; 2476 int err;
2477 2477
2478 data = kzalloc(sizeof(struct dme1737_data), GFP_KERNEL); 2478 data = devm_kzalloc(dev, sizeof(struct dme1737_data), GFP_KERNEL);
2479 if (!data) { 2479 if (!data)
2480 err = -ENOMEM; 2480 return -ENOMEM;
2481 goto exit;
2482 }
2483 2481
2484 i2c_set_clientdata(client, data); 2482 i2c_set_clientdata(client, data);
2485 data->type = id->driver_data; 2483 data->type = id->driver_data;
@@ -2491,14 +2489,14 @@ static int dme1737_i2c_probe(struct i2c_client *client,
2491 err = dme1737_init_device(dev); 2489 err = dme1737_init_device(dev);
2492 if (err) { 2490 if (err) {
2493 dev_err(dev, "Failed to initialize device.\n"); 2491 dev_err(dev, "Failed to initialize device.\n");
2494 goto exit_kfree; 2492 return err;
2495 } 2493 }
2496 2494
2497 /* Create sysfs files */ 2495 /* Create sysfs files */
2498 err = dme1737_create_files(dev); 2496 err = dme1737_create_files(dev);
2499 if (err) { 2497 if (err) {
2500 dev_err(dev, "Failed to create sysfs files.\n"); 2498 dev_err(dev, "Failed to create sysfs files.\n");
2501 goto exit_kfree; 2499 return err;
2502 } 2500 }
2503 2501
2504 /* Register device */ 2502 /* Register device */
@@ -2513,9 +2511,6 @@ static int dme1737_i2c_probe(struct i2c_client *client,
2513 2511
2514exit_remove: 2512exit_remove:
2515 dme1737_remove_files(dev); 2513 dme1737_remove_files(dev);
2516exit_kfree:
2517 kfree(data);
2518exit:
2519 return err; 2514 return err;
2520} 2515}
2521 2516
@@ -2526,7 +2521,6 @@ static int dme1737_i2c_remove(struct i2c_client *client)
2526 hwmon_device_unregister(data->hwmon_dev); 2521 hwmon_device_unregister(data->hwmon_dev);
2527 dme1737_remove_files(&client->dev); 2522 dme1737_remove_files(&client->dev);
2528 2523
2529 kfree(data);
2530 return 0; 2524 return 0;
2531} 2525}
2532 2526
@@ -2645,19 +2639,16 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev)
2645 int err; 2639 int err;
2646 2640
2647 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 2641 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
2648 if (!request_region(res->start, DME1737_EXTENT, "dme1737")) { 2642 if (!devm_request_region(dev, res->start, DME1737_EXTENT, "dme1737")) {
2649 dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n", 2643 dev_err(dev, "Failed to request region 0x%04x-0x%04x.\n",
2650 (unsigned short)res->start, 2644 (unsigned short)res->start,
2651 (unsigned short)res->start + DME1737_EXTENT - 1); 2645 (unsigned short)res->start + DME1737_EXTENT - 1);
2652 err = -EBUSY; 2646 return -EBUSY;
2653 goto exit;
2654 } 2647 }
2655 2648
2656 data = kzalloc(sizeof(struct dme1737_data), GFP_KERNEL); 2649 data = devm_kzalloc(dev, sizeof(struct dme1737_data), GFP_KERNEL);
2657 if (!data) { 2650 if (!data)
2658 err = -ENOMEM; 2651 return -ENOMEM;
2659 goto exit_release_region;
2660 }
2661 2652
2662 data->addr = res->start; 2653 data->addr = res->start;
2663 platform_set_drvdata(pdev, data); 2654 platform_set_drvdata(pdev, data);
@@ -2683,8 +2674,7 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev)
2683 (device == SCH5127_DEVICE)) { 2674 (device == SCH5127_DEVICE)) {
2684 data->type = sch5127; 2675 data->type = sch5127;
2685 } else { 2676 } else {
2686 err = -ENODEV; 2677 return -ENODEV;
2687 goto exit_kfree;
2688 } 2678 }
2689 } 2679 }
2690 2680
@@ -2703,14 +2693,14 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev)
2703 err = dme1737_init_device(dev); 2693 err = dme1737_init_device(dev);
2704 if (err) { 2694 if (err) {
2705 dev_err(dev, "Failed to initialize device.\n"); 2695 dev_err(dev, "Failed to initialize device.\n");
2706 goto exit_kfree; 2696 return err;
2707 } 2697 }
2708 2698
2709 /* Create sysfs files */ 2699 /* Create sysfs files */
2710 err = dme1737_create_files(dev); 2700 err = dme1737_create_files(dev);
2711 if (err) { 2701 if (err) {
2712 dev_err(dev, "Failed to create sysfs files.\n"); 2702 dev_err(dev, "Failed to create sysfs files.\n");
2713 goto exit_kfree; 2703 return err;
2714 } 2704 }
2715 2705
2716 /* Register device */ 2706 /* Register device */
@@ -2725,12 +2715,6 @@ static int __devinit dme1737_isa_probe(struct platform_device *pdev)
2725 2715
2726exit_remove_files: 2716exit_remove_files:
2727 dme1737_remove_files(dev); 2717 dme1737_remove_files(dev);
2728exit_kfree:
2729 platform_set_drvdata(pdev, NULL);
2730 kfree(data);
2731exit_release_region:
2732 release_region(res->start, DME1737_EXTENT);
2733exit:
2734 return err; 2718 return err;
2735} 2719}
2736 2720
@@ -2740,9 +2724,6 @@ static int __devexit dme1737_isa_remove(struct platform_device *pdev)
2740 2724
2741 hwmon_device_unregister(data->hwmon_dev); 2725 hwmon_device_unregister(data->hwmon_dev);
2742 dme1737_remove_files(&pdev->dev); 2726 dme1737_remove_files(&pdev->dev);
2743 release_region(data->addr, DME1737_EXTENT);
2744 platform_set_drvdata(pdev, NULL);
2745 kfree(data);
2746 2727
2747 return 0; 2728 return 0;
2748} 2729}