From patchwork Sun Nov 27 05:15:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Muir X-Patchwork-Id: 9448685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A316C6071A for ; Sun, 27 Nov 2016 05:16:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A60A203C0 for ; Sun, 27 Nov 2016 05:16:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C62326220; Sun, 27 Nov 2016 05:16:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 060BA203C0 for ; Sun, 27 Nov 2016 05:16:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752167AbcK0FQe (ORCPT ); Sun, 27 Nov 2016 00:16:34 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:33207 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751546AbcK0FQW (ORCPT ); Sun, 27 Nov 2016 00:16:22 -0500 Received: by mail-pg0-f65.google.com with SMTP id 3so9568471pgd.0 for ; Sat, 26 Nov 2016 21:16:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jmuir.com; s=jmuirsoft; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=n4b7qNCtZ2WWUvWARW/a21aB9cmtPbOH8O8QU9vKZN0=; b=HA0W4DQ6F5NFCTiqC8doChRY6ctIsQMITLSub5v90EHF7z4Rl64DMjRVgMqx/3U/oV bN1KV73c+dz+F8ucub6ztgBy0UoMVy/P+vGWRLgRZe4529Wfz+vL3l3PmS0vNfTP4Ncr do3hhiJrKOSToyhMm3brRS9FoR/FLBOifafFo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=n4b7qNCtZ2WWUvWARW/a21aB9cmtPbOH8O8QU9vKZN0=; b=gfz9wKymOTTL4vqcKTTL1ajAYydaj9qh6dufn/Ja/jmDnnXabWXE6t3Nq6flIBN+Bo R4ymJh1H/2MkF0yS0MM/gWEhRbaxInJarBdzbyYAFhHMyUgS3jejU4hrTEraAxzC503+ unRTJDIzmOHPff5LnTS7L3w68uTSBS3IIsnXXS96ya+gO9F7+b1fsnqoOKmdrI0LTzih +MQzErJjl21OUEUjoJac075rF8jQaps1REV8lEFXuVKD56ZLkmUaB66VgC9RWWSQVFRG 28G+qQ2D1hdfQk51H4eF7DpaojtI5uPpIo2jvPejlC3/eAJY5nZ+oCit1AaxV/1pwhC2 LcZg== X-Gm-Message-State: AKaTC03xnK3YqnDAGsnSmK4SkqCF8Ry8aHzDu+egREcYJNcTvt/Ln/GVtWW8TgX1Ze266g== X-Received: by 10.84.194.37 with SMTP id g34mr35215135pld.36.1480223782164; Sat, 26 Nov 2016 21:16:22 -0800 (PST) Received: from muirj.mtv.corp.google.com ([100.96.154.70]) by smtp.gmail.com with ESMTPSA id q12sm77938345pfj.18.2016.11.26.21.16.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 26 Nov 2016 21:16:21 -0800 (PST) From: John Muir To: Jean Delvare , Guenter Roeck , Jonathan Corbet , Mark Rutland , Rob Herring , linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org Cc: John Muir , John Muir Subject: [PATCH 2/3] hwmon: tmp108: Use devm variants of registration interfaces. Date: Sat, 26 Nov 2016 21:15:36 -0800 Message-Id: <1480223737-82080-3-git-send-email-john@jmuir.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1480223737-82080-2-git-send-email-john@jmuir.com> References: <1480223737-82080-2-git-send-email-john@jmuir.com> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: John Muir 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 --- 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, };