public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Matthew Garrett <matthew.garrett@nebula.com>
Cc: Corentin Chary <corentin.chary@gmail.com>,
	Cezary Jackiewicz <cezary.jackiewicz@gmail.com>,
	acpi4asus-user@lists.sourceforge.net,
	platform-driver-x86@vger.kernel.org, lm-sensors@lm-sensors.org,
	linux-kernel@vger.kernel.org, Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 3/5] compal-laptop: Use devm_kzalloc to allocate local data structure
Date: Sat, 23 Nov 2013 11:03:19 -0800	[thread overview]
Message-ID: <1385233401-21517-4-git-send-email-linux@roeck-us.net> (raw)
In-Reply-To: <1385233401-21517-1-git-send-email-linux@roeck-us.net>

Reduce code size and simplify error path.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/platform/x86/compal-laptop.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/x86/compal-laptop.c b/drivers/platform/x86/compal-laptop.c
index 8b119a7..9deb035 100644
--- a/drivers/platform/x86/compal-laptop.c
+++ b/drivers/platform/x86/compal-laptop.c
@@ -1026,24 +1026,21 @@ static int compal_probe(struct platform_device *pdev)
 		return 0;
 
 	/* Fan control */
-	data = kzalloc(sizeof(struct compal_data), GFP_KERNEL);
+	data = devm_kzalloc(&pdev->dev, sizeof(struct compal_data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
 	initialize_fan_control_data(data);
 
 	err = sysfs_create_group(&pdev->dev.kobj, &compal_attribute_group);
-	if (err) {
-		kfree(data);
+	if (err)
 		return err;
-	}
 
 	data->hwmon_dev = hwmon_device_register(&pdev->dev);
 	if (IS_ERR(data->hwmon_dev)) {
 		err = PTR_ERR(data->hwmon_dev);
 		sysfs_remove_group(&pdev->dev.kobj,
 				&compal_attribute_group);
-		kfree(data);
 		return err;
 	}
 
@@ -1083,8 +1080,6 @@ static int compal_remove(struct platform_device *pdev)
 	hwmon_device_unregister(data->hwmon_dev);
 	power_supply_unregister(&data->psy);
 
-	kfree(data);
-
 	sysfs_remove_group(&pdev->dev.kobj, &compal_attribute_group);
 
 	return 0;
-- 
1.7.9.7


  parent reply	other threads:[~2013-11-23 19:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-23 19:03 [PATCH 0/5] hwmon updates for x86 platform drivers Guenter Roeck
2013-11-23 19:03 ` [PATCH 1/5] asus-wmi: Convert to use devm_hwmon_device_register_with_groups Guenter Roeck
2013-11-23 19:03 ` [PATCH 2/5] compal-laptop: Replace SENSOR_DEVICE_ATTR with DEVICE_ATTR Guenter Roeck
2013-11-23 19:03 ` Guenter Roeck [this message]
2013-11-23 19:03 ` [PATCH 4/5] compal-laptop: Use devm_hwmon_device_register_with_groups Guenter Roeck
2013-11-23 19:03 ` [PATCH 5/5] eeepc-laptop: Convert to use devm_hwmon_device_register_with_groups Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1385233401-21517-4-git-send-email-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=acpi4asus-user@lists.sourceforge.net \
    --cc=cezary.jackiewicz@gmail.com \
    --cc=corentin.chary@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lm-sensors@lm-sensors.org \
    --cc=matthew.garrett@nebula.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox