From patchwork Thu Apr 18 19:58:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10907935 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8A0E5161F for ; Thu, 18 Apr 2019 19:59:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EA5028C0B for ; Thu, 18 Apr 2019 19:59:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6070728C0E; Thu, 18 Apr 2019 19:59:31 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0ED6828C0B for ; Thu, 18 Apr 2019 19:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=kUQND+0ejCKgAJAOShuYjBUq9te8IDo/wFc+jUQ3OCw=; b=SgRn8fU5p+rno2Q+qovt1dRhDJ LWY3FZYj8Ow7notZHly+JVngMvYgecG76kroLg4Pw4jnn+8Wc+qRRdhUeVxL10prUFyzl1Z93BeeG vlLp7orlmbYShYK0jz7pAKzFPsZgyuxvVyo770RQL8F7e2HcXaiix05c7Y1GhnQw4RdJ8BxnPHDTz 1yvi6Ut0sV/lHO16wtL9DCsSHbj8L53foRjpU19Zoh+huFJ7ETLGaBgwNtBrbAFL+S/5ST1bC5SJ9 ZtilMAllxOfyEqN6bijY7ibxbm1nLzF519vK6Z7mgGtZ97uSQj35ourxYK8i36rjGSr7j75/Nfmmw XntRUgIg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hHDBr-0003lA-SD; Thu, 18 Apr 2019 19:59:23 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hHDB0-0002el-Az for linux-arm-kernel@lists.infradead.org; Thu, 18 Apr 2019 19:58:34 +0000 Received: by mail-pg1-x541.google.com with SMTP id g8so1674475pgf.2 for ; Thu, 18 Apr 2019 12:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=iWQMJ2qTXasITQgDK7vc9YMGIL8w6QMaEOeMp9MVgzI=; b=ptnitUg6IR26fWprpiE9SfWzcu4vKN3PFmzfsz+4CDYEGeIqed3/8Lo9tQysZUG4Lv SGLNuz5reGyNFVfirM8CCbcaXLvTAcwDEgUNrIdldCkCvUMcqtz+SUzeeYsxEbAhrhe8 OZV4IdpJ/JrDKgyaiDznPuk+NqeEQ+jdLfRbHLUzkg+Mi1UVxsBjWuVyNwUATQGgOyAi Ur8Ltu5Z/kfZiNlkj5lQHDvgInKi5nOQho3eNt1oc8wHMjoaJVJpgrlgv/bsrCPNbZ2p uBvINGwHLyrn0+sEuBYiyqP1Yz3q4x1JO738O87cTk3RZL6XE3D7tVRwHfsrL5pwO/Mq XG7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=iWQMJ2qTXasITQgDK7vc9YMGIL8w6QMaEOeMp9MVgzI=; b=Li8g5KYQ2jBVXzN72lMa6n3IfU0NpCXWaWtHaxnYViy0lEUF7xjqvww1EN5HrdPw+V VNod3sjIeAFOrg6rwdNHKUUX3+GC+aqvWhgCSDPKO6kyCKVlYUsqe0fH+yf7SPxyWdHV JyNgeyf5XSnHtegESnBbTKiAme9klpsMfgejR281TGCLO/xUIHvEeAiJDE/rzLPcg+z0 ay642rSljECRlS2rD1mlR7eQHmBAScWfYG2c7n59Bakv0d+zwLlmwlgAq++bXnXl5B8M qShHZQ+IJxdhhdZH1GMG5g1O6N4euC0RE5hh6gd+G9rMfseHN++3LZi46zsb9m5ynUZl MobA== X-Gm-Message-State: APjAAAWyk4cU2vigojeiThf1saKMQG2DYeojeWXJvEgnhQf8W2QKQuip KxbLpCyhbu/ErNsW1YbRaA02A1EtA4U= X-Google-Smtp-Source: APXvYqwapDl66OdPq4SqQZL/qnGUXMG1TzJPI+cBC4ddbm9BEsja+OuErjgE2UHtPRBNttg6+aDKSg== X-Received: by 2002:a63:fa46:: with SMTP id g6mr89147313pgk.382.1555617509572; Thu, 18 Apr 2019 12:58:29 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id n21sm10519669pfb.42.2019.04.18.12.58.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Apr 2019 12:58:29 -0700 (PDT) From: Guenter Roeck To: linux-hwmon@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, linux-pm@vger.kernel.org Subject: [PATCH 4/6] hwmon: (mlxreg-fan) Use devm_thermal_of_cooling_device_register Date: Thu, 18 Apr 2019 12:58:18 -0700 Message-Id: <1555617500-10862-5-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555617500-10862-1-git-send-email-linux@roeck-us.net> References: <1555617500-10862-1-git-send-email-linux@roeck-us.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190418_125830_652358_358AF2D6 X-CRM114-Status: GOOD ( 13.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jean Delvare , Tomer Maimon , Nancy Yuen , Andrew Jeffery , Patrick Venture , Bartlomiej Zolnierkiewicz , Kamil Debski , Tali Perry , Eduardo Valentin , Avi Fishman , Joel Stanley , Daniel Lezcano , Zhang Rui , Guenter Roeck , Benjamin Fair MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Call devm_thermal_of_cooling_device_register() to register the cooling device. Also introduce struct device *dev = &pdev->dev; to make the code easier to read. Signed-off-by: Guenter Roeck --- drivers/hwmon/mlxreg-fan.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/drivers/hwmon/mlxreg-fan.c b/drivers/hwmon/mlxreg-fan.c index db8c6de0b6a0..a14347ea0d77 100644 --- a/drivers/hwmon/mlxreg-fan.c +++ b/drivers/hwmon/mlxreg-fan.c @@ -420,42 +420,42 @@ static int mlxreg_fan_config(struct mlxreg_fan *fan, static int mlxreg_fan_probe(struct platform_device *pdev) { struct mlxreg_core_platform_data *pdata; + struct device *dev = &pdev->dev; struct mlxreg_fan *fan; struct device *hwm; int err; - pdata = dev_get_platdata(&pdev->dev); + pdata = dev_get_platdata(dev); if (!pdata) { - dev_err(&pdev->dev, "Failed to get platform data.\n"); + dev_err(dev, "Failed to get platform data.\n"); return -EINVAL; } - fan = devm_kzalloc(&pdev->dev, sizeof(*fan), GFP_KERNEL); + fan = devm_kzalloc(dev, sizeof(*fan), GFP_KERNEL); if (!fan) return -ENOMEM; - fan->dev = &pdev->dev; + fan->dev = dev; fan->regmap = pdata->regmap; - platform_set_drvdata(pdev, fan); err = mlxreg_fan_config(fan, pdata); if (err) return err; - hwm = devm_hwmon_device_register_with_info(&pdev->dev, "mlxreg_fan", + hwm = devm_hwmon_device_register_with_info(dev, "mlxreg_fan", fan, &mlxreg_fan_hwmon_chip_info, NULL); if (IS_ERR(hwm)) { - dev_err(&pdev->dev, "Failed to register hwmon device\n"); + dev_err(dev, "Failed to register hwmon device\n"); return PTR_ERR(hwm); } if (IS_REACHABLE(CONFIG_THERMAL)) { - fan->cdev = thermal_cooling_device_register("mlxreg_fan", fan, - &mlxreg_fan_cooling_ops); + fan->cdev = devm_thermal_of_cooling_device_register(dev, + NULL, "mlxreg_fan", fan, &mlxreg_fan_cooling_ops); if (IS_ERR(fan->cdev)) { - dev_err(&pdev->dev, "Failed to register cooling device\n"); + dev_err(dev, "Failed to register cooling device\n"); return PTR_ERR(fan->cdev); } } @@ -463,22 +463,11 @@ static int mlxreg_fan_probe(struct platform_device *pdev) return 0; } -static int mlxreg_fan_remove(struct platform_device *pdev) -{ - struct mlxreg_fan *fan = platform_get_drvdata(pdev); - - if (IS_REACHABLE(CONFIG_THERMAL)) - thermal_cooling_device_unregister(fan->cdev); - - return 0; -} - static struct platform_driver mlxreg_fan_driver = { .driver = { .name = "mlxreg-fan", }, .probe = mlxreg_fan_probe, - .remove = mlxreg_fan_remove, }; module_platform_driver(mlxreg_fan_driver);