From: John Muir <john@jmuir.com>
To: Jean Delvare <jdelvare@suse.com>,
Guenter Roeck <linux@roeck-us.net>,
Jonathan Corbet <corbet@lwn.net>,
Mark Rutland <mark.rutland@arm.com>,
Rob Herring <robh+dt@kernel.org>,
linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org,
linux-doc@vger.kernel.org
Cc: John Muir <muirj@google.com>, John Muir <john@jmuir.com>
Subject: [PATCH 2/3] hwmon: tmp108: Use devm variants of registration interfaces.
Date: Sat, 26 Nov 2016 21:15:36 -0800 [thread overview]
Message-ID: <1480223737-82080-3-git-send-email-john@jmuir.com> (raw)
In-Reply-To: <1480223737-82080-2-git-send-email-john@jmuir.com>
From: John Muir <muirj@google.com>
Use the devm hwmon and thermal zone registration functions to
clean up the code and remove the need for an i2c_driver.remove
callback.
Signed-off-by: John Muir <john@jmuir.com>
---
drivers/hwmon/tmp108.c | 28 ++++++++--------------------
1 file changed, 8 insertions(+), 20 deletions(-)
diff --git a/drivers/hwmon/tmp108.c b/drivers/hwmon/tmp108.c
index da64517..b13d652 100644
--- a/drivers/hwmon/tmp108.c
+++ b/drivers/hwmon/tmp108.c
@@ -83,8 +83,6 @@
struct tmp108 {
struct regmap *regmap;
- struct device *hwmon_dev;
- struct thermal_zone_device *tz;
u16 config;
unsigned long ready_time;
};
@@ -245,6 +243,7 @@ static int tmp108_probe(struct i2c_client *client,
{
struct device *dev = &client->dev;
struct device *hwmon_dev;
+ struct thermal_zone_device *tz;
struct tmp108 *tmp108;
unsigned int regval;
int err;
@@ -353,18 +352,18 @@ static int tmp108_probe(struct i2c_client *client,
if (err)
return err;
- hwmon_dev = hwmon_device_register_with_groups(dev, client->name,
- tmp108, tmp108_groups);
+ hwmon_dev = devm_hwmon_device_register_with_groups(dev, client->name,
+ tmp108,
+ tmp108_groups);
if (IS_ERR(hwmon_dev)) {
dev_dbg(dev, "unable to register hwmon device\n");
return PTR_ERR(hwmon_dev);
}
- tmp108->hwmon_dev = hwmon_dev;
- tmp108->tz = thermal_zone_of_sensor_register(hwmon_dev, 0, hwmon_dev,
- &tmp108_of_thermal_ops);
- if (IS_ERR(tmp108->tz))
- return PTR_ERR(tmp108->tz);
+ tz = devm_thermal_zone_of_sensor_register(hwmon_dev, 0, hwmon_dev,
+ &tmp108_of_thermal_ops);
+ if (IS_ERR(tz))
+ return PTR_ERR(tz);
dev_info(dev, "%s, alert: active %s, hyst: %uC, conv: %ucHz\n",
(tmp108->config & TMP108_CONF_TM) != 0 ?
@@ -374,16 +373,6 @@ static int tmp108_probe(struct i2c_client *client,
return 0;
}
-static int tmp108_remove(struct i2c_client *client)
-{
- struct tmp108 *tmp108 = i2c_get_clientdata(client);
-
- thermal_zone_of_sensor_unregister(tmp108->hwmon_dev, tmp108->tz);
- hwmon_device_unregister(tmp108->hwmon_dev);
-
- return 0;
-}
-
#ifdef CONFIG_PM_SLEEP
static int tmp108_suspend(struct device *dev)
{
@@ -418,7 +407,6 @@ static struct i2c_driver tmp108_driver = {
.driver.name = DRIVER_NAME,
.driver.pm = &tmp108_dev_pm_ops,
.probe = tmp108_probe,
- .remove = tmp108_remove,
.id_table = tmp108_id,
};
--
2.8.0.rc3.226.g39d4020
next prev parent reply other threads:[~2016-11-27 5:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-27 5:15 [PATCH 1/3] hwmon: Add Texas Instruments TMP108 temperature sensor driver John Muir
2016-11-27 5:15 ` John Muir [this message]
2016-11-27 12:21 ` [PATCH 2/3] hwmon: tmp108: Use devm variants of registration interfaces Guenter Roeck
2016-11-27 5:15 ` [PATCH 3/3] hwmon: tmp108: Update driver to use hwmon_chip_info John Muir
2016-11-27 23:00 ` Guenter Roeck
2016-11-28 2:10 ` John Muir
2016-11-28 3:25 ` Guenter Roeck
2016-11-27 12:19 ` [PATCH 1/3] hwmon: Add Texas Instruments TMP108 temperature sensor driver Guenter Roeck
2016-11-28 19:40 ` John Muir
2016-11-28 19:58 ` Guenter Roeck
2016-11-28 21:25 ` John Muir
2016-11-28 22:19 ` Guenter Roeck
2016-11-28 23:10 ` John Muir
2016-11-28 23:33 ` 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=1480223737-82080-3-git-send-email-john@jmuir.com \
--to=john@jmuir.com \
--cc=corbet@lwn.net \
--cc=jdelvare@suse.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=mark.rutland@arm.com \
--cc=muirj@google.com \
--cc=robh+dt@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