From patchwork Sat May 8 13:14:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12246061 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65BC0C433B4 for ; Sat, 8 May 2021 13:15:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BBEC613EE for ; Sat, 8 May 2021 13:15:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230508AbhEHNQd (ORCPT ); Sat, 8 May 2021 09:16:33 -0400 Received: from mout.gmx.net ([212.227.15.15]:48607 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230438AbhEHNQc (ORCPT ); Sat, 8 May 2021 09:16:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1620479715; bh=nJPCrfzp9weQNf8S+cmL0fOeRc8N+G79gA6rNCRyytw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=O3wCXYKwzNsRS2atk+WF1XkHjyeRzyJ6ejrJVCz9yVK+cu+zl2frWn0ReLtGg86+b 3l3Awf2MOPMvikYXwqHCs8Fpsx+KxnXTgMJZpveTbxpmX/wxSLfe5GkL5rKmnWaQkL 0XHXLwcqJ1pygK6szJw4UBSMv72DaRadzQlyJQaw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.fritz.box ([84.154.223.76]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MxDkw-1lLVVK33SS-00xbMR; Sat, 08 May 2021 15:15:14 +0200 From: W_Armin@gmx.de To: hdegoede@redhat.com Cc: linux-hwmon@vger.kernel.org, linux@roeck-us.net, jdelvare@suse.com Subject: [PATCH v2 1/4] hwmon: (sch56xx) Use devres functions for watchdog Date: Sat, 8 May 2021 15:14:54 +0200 Message-Id: <20210508131457.12780-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210508131457.12780-1-W_Armin@gmx.de> References: <20210508131457.12780-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:C/TOmwHG6Tox6yVnyXkLz+4qWNAX9bnt/uvS9YoxLm1MKr1OKjQ p/njc669YXMThDrMFsjf+FMCWu3z1EfwDt5/eCM53O2SsAmz8lAfCft8jzpUaG/YrzQO5Gv cUDbmmRPfVCL2aBntheL06RGhX+oz5pz714dPUEe8jurPysngeXOQM7HyGVmg2Qpx3iEiHf vCwYq/xf6uR7/v7Yt5AwQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:wxXzi9XXq3Q=:kNq9rlAGbEEQJvQRqN/ci4 rwbEb93c9D4b+w/cw4GlSA4Da6VWNej5KoHXSJPnlqq9tF3Izol2Uxisxojru6d9f4QoiuNsf /o4cRnKcZsfWRB/7ojFuZ25GwP2x3APCl4MlBOAmg9oOtYX8rASqVdlV2B0NDOy4OVoUehJmC 4lnQ6swaAItFwotJRuKzVXaZHF0H0Qk+2OZFLFA2w40FRLUvH6rjr7iLJMtiML1kWDoFb348X XHMiq9nJB5cE+vTJuQC19OLJ7NPhi3k+RacIyyh9VJJ3uAyNyn5vjU6XT1MJyT26tuBQ8pF9o XU2N3NNyKiiw2Fct6CF1+Zg07HMeJ7SsVYf/ONJ/dl6wwVk1G8RdTpjD4e98lplx5J6rYmQIQ BYGYf23pdRnh5t9gxfC3vTHrcQcofrSy+27n8xPd6Hq8oQG8sjk1jZEv/i++8Nt6qZaHJu2it f9WLnGkHVJfbFdh1rGwNPguYPUzTTQoE1MQ4IQxQzVRpeReVl5fR0/T6jjzO0gto2UUqJ2ssT yvIdRnHReY7kOWRFZ/7vxx9qJKw0Y/IndyVAYSWGLja2VVkcrKLWH/0G0o4jBkwqo1n7IGbVI Nw++gbD7Raqe6hwzt6KHtbheHEt55AgUiPuEpdTs3tCunUZmzr2CXRh+28t9yRbMIBtPoKYHk edDVKgeivnm32KEXVzmhNlR3/bmQLvquevVt4qXKLAc+ZxsN08AwDgdby4C5rGTrlbxPOFYrQ 3h7+tpM6W/WKgZsSzQryn2dTLqol3OyqJr92kVfhWdfULo553SmuR9HxcAkTLFjbaGAyRFoUw DNeirXytBuFuaFUxcohl+9M+ogt2R53D4d8daZ1LqG3BzHntgP2Qt006b3JTmSz5AXljGv5bZ N8coZrXEF4e9GCk2fWlaoB996mHmKLRtKFtm5zTFHh0Ju5Zpvun6/w4k7nD6cL0jbXqyxqyUD 7e01kcw73ak8Hilz/Hbxus2Qo0wwcM2OrECbQGEB9w4kDf37UmjRQtPGaNReKmMO38bwvzfmC 0ywapim6iDD4FWpVXsUk62X5HZJr9aFSqRc6rS1Kl0l10Dkvv/SLpFyhmehKK+7hcwmYkAgfn 2xkQByOUEBhDyq63bTNHZ7VxNxmzPVe9/epBWNgG91D0VNGPe2W42AwK1Z75RGcdGQzCwViIQ cp+YEs15OQDWXpTLtMPtkVAcGgJMNjjwY7TopV6QyFsiZoby/b1BxBVGWtVBz6pbSBmmY= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf Use devm_kzalloc()/devm_watchdog_register() for watchdog registration since it allows us to remove the sch56xx_watchdog_data struct from the drivers own data structs. Remove sch56xx_watchdog_unregister since devres takes care of that now. Signed-off-by: Armin Wolf --- drivers/hwmon/sch5627.c | 18 +++--------------- drivers/hwmon/sch5636.c | 9 ++------- drivers/hwmon/sch56xx-common.c | 28 ++++++++++------------------ drivers/hwmon/sch56xx-common.h | 4 ++-- 4 files changed, 17 insertions(+), 42 deletions(-) -- 2.20.1 diff --git a/drivers/hwmon/sch5627.c b/drivers/hwmon/sch5627.c index 4324a5dbc968..8f1b569c69e7 100644 --- a/drivers/hwmon/sch5627.c +++ b/drivers/hwmon/sch5627.c @@ -64,7 +64,6 @@ static const char * const SCH5627_IN_LABELS[SCH5627_NO_IN] = { struct sch5627_data { unsigned short addr; - struct sch56xx_watchdog_data *watchdog; u8 control; u8 temp_max[SCH5627_NO_TEMPS]; u8 temp_crit[SCH5627_NO_TEMPS]; @@ -357,16 +356,6 @@ static const struct hwmon_chip_info sch5627_chip_info = { .info = sch5627_info, }; -static int sch5627_remove(struct platform_device *pdev) -{ - struct sch5627_data *data = platform_get_drvdata(pdev); - - if (data->watchdog) - sch56xx_watchdog_unregister(data->watchdog); - - return 0; -} - static int sch5627_probe(struct platform_device *pdev) { struct sch5627_data *data; @@ -460,9 +449,9 @@ static int sch5627_probe(struct platform_device *pdev) return PTR_ERR(hwmon_dev); /* Note failing to register the watchdog is not a fatal error */ - data->watchdog = sch56xx_watchdog_register(&pdev->dev, data->addr, - (build_code << 24) | (build_id << 8) | hwmon_rev, - &data->update_lock, 1); + sch56xx_watchdog_register(&pdev->dev, data->addr, + (build_code << 24) | (build_id << 8) | hwmon_rev, + &data->update_lock, 1); return 0; } @@ -472,7 +461,6 @@ static struct platform_driver sch5627_driver = { .name = DRVNAME, }, .probe = sch5627_probe, - .remove = sch5627_remove, }; module_platform_driver(sch5627_driver); diff --git a/drivers/hwmon/sch5636.c b/drivers/hwmon/sch5636.c index 5683a38740f6..a5cd4de36575 100644 --- a/drivers/hwmon/sch5636.c +++ b/drivers/hwmon/sch5636.c @@ -54,7 +54,6 @@ static const u16 SCH5636_REG_FAN_VAL[SCH5636_NO_FANS] = { struct sch5636_data { unsigned short addr; struct device *hwmon_dev; - struct sch56xx_watchdog_data *watchdog; struct mutex update_lock; char valid; /* !=0 if following fields are valid */ @@ -372,9 +371,6 @@ static int sch5636_remove(struct platform_device *pdev) struct sch5636_data *data = platform_get_drvdata(pdev); int i; - if (data->watchdog) - sch56xx_watchdog_unregister(data->watchdog); - if (data->hwmon_dev) hwmon_device_unregister(data->hwmon_dev); @@ -495,9 +491,8 @@ static int sch5636_probe(struct platform_device *pdev) } /* Note failing to register the watchdog is not a fatal error */ - data->watchdog = sch56xx_watchdog_register(&pdev->dev, data->addr, - (revision[0] << 8) | revision[1], - &data->update_lock, 0); + sch56xx_watchdog_register(&pdev->dev, data->addr, (revision[0] << 8) | revision[1], + &data->update_lock, 0); return 0; diff --git a/drivers/hwmon/sch56xx-common.c b/drivers/hwmon/sch56xx-common.c index 6c84780e358e..2db3456ba6f1 100644 --- a/drivers/hwmon/sch56xx-common.c +++ b/drivers/hwmon/sch56xx-common.c @@ -378,8 +378,8 @@ static const struct watchdog_ops watchdog_ops = { .set_timeout = watchdog_set_timeout, }; -struct sch56xx_watchdog_data *sch56xx_watchdog_register(struct device *parent, - u16 addr, u32 revision, struct mutex *io_lock, int check_enabled) +void sch56xx_watchdog_register(struct device *parent, u16 addr, u32 revision, + struct mutex *io_lock, int check_enabled) { struct sch56xx_watchdog_data *data; int err, control, output_enable; @@ -393,17 +393,17 @@ struct sch56xx_watchdog_data *sch56xx_watchdog_register(struct device *parent, mutex_unlock(io_lock); if (control < 0) - return NULL; + return; if (output_enable < 0) - return NULL; + return; if (check_enabled && !(output_enable & SCH56XX_WDOG_OUTPUT_ENABLE)) { pr_warn("Watchdog not enabled by BIOS, not registering\n"); - return NULL; + return; } - data = kzalloc(sizeof(struct sch56xx_watchdog_data), GFP_KERNEL); + data = devm_kzalloc(parent, sizeof(struct sch56xx_watchdog_data), GFP_KERNEL); if (!data) - return NULL; + return; data->addr = addr; data->io_lock = io_lock; @@ -438,24 +438,16 @@ struct sch56xx_watchdog_data *sch56xx_watchdog_register(struct device *parent, data->watchdog_output_enable = output_enable; watchdog_set_drvdata(&data->wddev, data); - err = watchdog_register_device(&data->wddev); + err = devm_watchdog_register_device(parent, &data->wddev); if (err) { pr_err("Registering watchdog chardev: %d\n", err); - kfree(data); - return NULL; + devm_kfree(parent, data); } - return data; + return; } EXPORT_SYMBOL(sch56xx_watchdog_register); -void sch56xx_watchdog_unregister(struct sch56xx_watchdog_data *data) -{ - watchdog_unregister_device(&data->wddev); - kfree(data); -} -EXPORT_SYMBOL(sch56xx_watchdog_unregister); - /* * platform dev find, add and remove functions */ diff --git a/drivers/hwmon/sch56xx-common.h b/drivers/hwmon/sch56xx-common.h index 75eb73617cf2..e907d9da0dd5 100644 --- a/drivers/hwmon/sch56xx-common.h +++ b/drivers/hwmon/sch56xx-common.h @@ -14,6 +14,6 @@ int sch56xx_read_virtual_reg16(u16 addr, u16 reg); int sch56xx_read_virtual_reg12(u16 addr, u16 msb_reg, u16 lsn_reg, int high_nibble); -struct sch56xx_watchdog_data *sch56xx_watchdog_register(struct device *parent, - u16 addr, u32 revision, struct mutex *io_lock, int check_enabled); +void sch56xx_watchdog_register(struct device *parent, u16 addr, u32 revision, + struct mutex *io_lock, int check_enabled); void sch56xx_watchdog_unregister(struct sch56xx_watchdog_data *data); From patchwork Sat May 8 13:14:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12246063 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E832EC433B4 for ; Sat, 8 May 2021 13:15:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C156E6140F for ; Sat, 8 May 2021 13:15:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230486AbhEHNQj (ORCPT ); Sat, 8 May 2021 09:16:39 -0400 Received: from mout.gmx.net ([212.227.15.19]:41491 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230438AbhEHNQh (ORCPT ); Sat, 8 May 2021 09:16:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1620479719; bh=c47mtKcTTDyETKykmcb/ghEg6LlaFnC4rQfErD3WyMU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=O/07a7HxH5UuWioppg4pS5CCNj0l2H+YQ7czZCs47B8F+1saD16epi9XfWb5rMmdH 59y/9uA/ySgZh/jF2Mlj6tw4GvAMGvKpzurUKdg8tzs1Ks6q+RUc2/gsm1VCtG7P8Y DwpEB7PsnvB2CsIfCWh02kS5mqrjmqd9eTDjPbnk= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.fritz.box ([84.154.223.76]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mw9UE-1lMatW37qe-00s4YF; Sat, 08 May 2021 15:15:18 +0200 From: W_Armin@gmx.de To: hdegoede@redhat.com Cc: linux-hwmon@vger.kernel.org, linux@roeck-us.net, jdelvare@suse.com Subject: [PATCH v2 2/4] hwmon: (sch56xx-common) Use strscpy Date: Sat, 8 May 2021 15:14:55 +0200 Message-Id: <20210508131457.12780-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210508131457.12780-1-W_Armin@gmx.de> References: <20210508131457.12780-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:1e2PHgUiNO4gc+EL7YXk9fZs2RdCDXFXfdWrTcUpv3Ug7H8xBLc lgRNFpdGUJ1vhs8e0otZkxUCgp3NxRYBwtqzmcpKXgCFE1sRfWKq17cBNeDvPYCmHBsPPFE jdoPvry7Hp/+qHAmFdXddCpd3QtmkNsC9Q+dOx4PweMH9f8eBRV3asyLg+wUIAobiLz8Aw9 +sY0mlLfcBMdclxdVv1Mw== X-UI-Out-Filterresults: notjunk:1;V03:K0:zv1kg+b3jQA=:/azFgoL3IVqhpP8EdNp2O5 TmfWvEeQl2dgn2sfrP49aCiYz6wkyzvZntod4YvovlnbwnFB/2tzh+baFGgQi85Dikmp+SPkt C1QsN1+wIPgRIx0fY9p58pGtPrOT4bLFqWhKk0itJ03iM3TM/LtyoEATvE+Zcsvby+y4cUN2r 7h5gVxsGKMFyf6H0OVdEZJUR4VQzIXTxppTcRvhx36nZDOTC7UOFiR7bUoI9BAXIb8AR0ZC6y N+v7zI/LlhWP1eWX/JpTa/ACXj4mPbFF8EqTjD5vJniASrrg+HHMTwM8Oqb1D+kpWt0MKt5yz LyHZFobrreVEe7JyN6cl7Cl2koijZhMAnURbfa3ZdTkVBfCS7iYEFXUzMW78pCGUR2sUWoUS6 4VVgtzr3ZjUnBJsv5Mx0dVY1O6dXub9DGB2b9bnV6cF2pyMaqGufyuUfuJfUEiw6l6bfVygG/ Tk1fYLq5xMVBKRQvqyFSMmdLIhZSjJTjORxx2wbEenBr9iw9Szin9YHn/rFYmHtbX7KRl07sk rFtsXLSYd8yNrJIt3IH7+AH+QTXHMV9QSLT5oQtvzp2lNUyflSQ85L0MQFfVNzX71cKOn+Kqt uV56qDUpjLufgK1P5dwgtXWft83ETwfcW5DVjf7nFWHut02drOFFiVuRxnqzNendoSpelzK04 JIMJJehF8bmcy8D1NXISEAqOqFJpb1OLVJqsI8FL9GK6qPN89VxarDcSmwdwla6vNPNscwhZ2 PTtv0wDJfIGWjiosuNaFpeJkauz6wuyiCs9cSzGue9fkcqAWSjKYVYTG2+QCcAKLUfvm3PLkc /BFkhhU5ptDeJEI92hy1G0AdqpDHLiNc5DpKY4QefNn3v0yt266Wh/LOofJNUbcS3mm4N8O82 B3lZ84rpkg0yOjLhpeZLIcP6Rceg5yOKDKVcuDrjRugSctvkzqEdyIgYEiQnvJbEC0gkObj2G F4U13aiKRskD3ppG4JS8V6ZMLcLLyUFnKRTMIMsHOc0mzO4kgCgJ/hJfK0wlBh25DgzoS3GX8 xrWLOiPdvB2kgBYGFsV6IEaHXI84SAX/CMgEhs9E3MXKcpm0FGmoGRMfc3sj8AZVRjmN5uIzP yqXR/QWVLdu/WLCLhiQahinKk94UXzJM1/TjGE8uY4vhB4DccS2uxHq5ARhzu/eDjWPvj5XjI SvZodpxDpUGghRNyX+BonoJmABLCgQwFc3q0QUdSMXB/q3W2yHoo64NHZvFzLzubht6NI= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf strlcpy is considered deprecated. Replace it with strscpy. Signed-off-by: Armin Wolf --- drivers/hwmon/sch56xx-common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.20.1 diff --git a/drivers/hwmon/sch56xx-common.c b/drivers/hwmon/sch56xx-common.c index 2db3456ba6f1..0b3250fc57b8 100644 --- a/drivers/hwmon/sch56xx-common.c +++ b/drivers/hwmon/sch56xx-common.c @@ -408,8 +408,7 @@ void sch56xx_watchdog_register(struct device *parent, u16 addr, u32 revision, data->addr = addr; data->io_lock = io_lock; - strlcpy(data->wdinfo.identity, "sch56xx watchdog", - sizeof(data->wdinfo.identity)); + strscpy(data->wdinfo.identity, "sch56xx watchdog", sizeof(data->wdinfo.identity)); data->wdinfo.firmware_version = revision; data->wdinfo.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT; if (!nowayout) From patchwork Sat May 8 13:14:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12246065 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2168AC433ED for ; Sat, 8 May 2021 13:15:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE313613EE for ; Sat, 8 May 2021 13:15:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230438AbhEHNQj (ORCPT ); Sat, 8 May 2021 09:16:39 -0400 Received: from mout.gmx.net ([212.227.15.19]:47067 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230473AbhEHNQi (ORCPT ); Sat, 8 May 2021 09:16:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1620479720; bh=kiPO4E25fg0A7YfrgUl5L7sc1tJhBRaKwNGg+wK0k2g=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=g2wwEzJtiwVF1sVtt37Tt7X1UnCAkENMRusjdfCmgc1K1AKoDsJCJ/Uc0ApOZoR8C YS0DbACeMbg49trwnct1XnwSRbI0ElA6a1fyhT7laEsWz6uS9cBbxTyj0n1clApG9O yLDdF7ev6mOTtWytprQiGv4HWtxATPo4Pt1idTNY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.fritz.box ([84.154.223.76]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MDysg-1ln61k1Mv6-009xwf; Sat, 08 May 2021 15:15:20 +0200 From: W_Armin@gmx.de To: hdegoede@redhat.com Cc: linux-hwmon@vger.kernel.org, linux@roeck-us.net, jdelvare@suse.com Subject: [PATCH v2 3/4] hwmon: (sch56xx-common) Use helper function Date: Sat, 8 May 2021 15:14:56 +0200 Message-Id: <20210508131457.12780-4-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210508131457.12780-1-W_Armin@gmx.de> References: <20210508131457.12780-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:qad4vzhfeK8fg3ZQzFX0T37/u0zr2Zqb0HaFqpEuPaMjEg7pBKI VGDe38OfnHY6E1MkhQgCL0cbpy9zMBSHt3FGAGKdL3vgepvjeoh6J4w9sRFaGIfIhUcooye SrOC7+BJKaTjr71eM3sj77gPxCbrN3C+upxEoAgHIQIBwkyd9PmjZxcYkh0Nkk3iFHh1V4T qwpP3Ng/ZwmluAbNGlrog== X-UI-Out-Filterresults: notjunk:1;V03:K0:UQZuk7bG4Aw=:BJ+ACVsnZxYHGoZDwEJIcv t9ye04bAjOAzlkiWPZYMkuvm57VijhUCKhNO0wiPJFyNHEo1wRNo9O0NfolDr0Wbog2SPQfL2 v9xVl4XglwFTA9ZH/1qs7GWRBcacho0CapG39qmPQ9lAIrahIfy+9bLd+1pAiMA1u/nid2rmO X5DENbBg30uLiP/gzNS3Q0XVkAJw9KKM/v5oRutZ/vtUZaFZSq2PA+TZVC4nwqWqmiJAyNtY/ UWp7vOG1hQydmoEQkb7BYfJc6fniplwJcwWo2AdeSSQVVgPcbtGvEn/gVZYqkcqujXXefoxlQ 28SYk5oWpAYMGO5Kyryk+DFR8x/xUqEo7wCixpVBKPelgUUmDrmjPPRkAjfeNK7NOwgLHx8Lu 4TCuj62+KXfxsPQ4O9piBqSLav1E4zjiaagPtFDnO41zvbLMoXJh81DADmLg3qmkP4Q6ajMRR 5NuQ6ssKkybqNEWEh4iZZSFDswlz/K3iZXIVil3rbdrZPPofPDn3mo/phMf4hx23NZjXeLPjz e3tskSzoCnuHm/guz27UQu10voY/MMKusfQJ5maIPIttWoMYjX620IoMPlyE/1em5yNAoycWM lK0qGiK1+teOULxM4pH6VDPZEggD4un+fNJ7Hbq1SYdfXaxQWc0EdNu4X7BbWztEqK/zvfAcL TSIG5ywW7FsxUggQHX+v1b0UDCp7x8/k2/Ptd//NxHWHKp6ZT88PeBSywnSOJaK4nLttDBalb trPTkuhOohXdBWB4IjA5ZJe3y9aqpCwpvtHZkBqc+0WgWYvr6Njeq2t2X3Y2mGK5atZupwehm Q1ssxskPFQTs94wRYFmKevZDvTzUht4wEmCNJXtzzdwqtt57OEWZp0HQMkprktRBiJA1MSBhM 42cypF2kfc5WuxaB7kYS9ynJHTSFb5CU9PmijMmWb6fk71iqpwHJ5mguh6msI9lTrNoefwoe2 JSRjjJz8wYAHXMOZ7yceB5yTSSRMAwJ+fpMPEJEuk0fGcpoK2Pw1cf/JKrTVNoLdnVyIptpM7 XjPwsLazD6F4C6a0LUGWZqT6f9OBU4WPxuxtW6hHGZaSGSeP1gCZONccYYNkuqoR4nxVpCUPX /LLn7/rLmFc40MMcapj3tptHEXHEPWF0o3o6aYgk9rH0vTxfO+DULy0wrnyhu205ypdTS4kKM HZdtMAJsjhk/E8YRJ+Bud3pRT0I/haHapH+/gbc6bn3/EFY8+Xze7NDYyoBWgRa/DoLIo= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf Use watchdog_set_nowayout() to process param setting and change param type to bool. Signed-off-by: Armin Wolf --- drivers/hwmon/sch56xx-common.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/drivers/hwmon/sch56xx-common.c b/drivers/hwmon/sch56xx-common.c index 0b3250fc57b8..180801f80118 100644 --- a/drivers/hwmon/sch56xx-common.c +++ b/drivers/hwmon/sch56xx-common.c @@ -20,8 +20,8 @@ #include "sch56xx-common.h" /* Insmod parameters */ -static int nowayout = WATCHDOG_NOWAYOUT; -module_param(nowayout, int, 0); +static bool nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, bool, 0); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); @@ -420,8 +420,7 @@ void sch56xx_watchdog_register(struct device *parent, u16 addr, u32 revision, data->wddev.timeout = 60; data->wddev.min_timeout = 1; data->wddev.max_timeout = 255 * 60; - if (nowayout) - set_bit(WDOG_NO_WAY_OUT, &data->wddev.status); + watchdog_set_nowayout(&data->wddev, nowayout); if (output_enable & SCH56XX_WDOG_OUTPUT_ENABLE) set_bit(WDOG_ACTIVE, &data->wddev.status); From patchwork Sat May 8 13:14:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 12246067 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 711C0C43461 for ; Sat, 8 May 2021 13:15:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 525FA6140F for ; Sat, 8 May 2021 13:15:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230473AbhEHNQm (ORCPT ); Sat, 8 May 2021 09:16:42 -0400 Received: from mout.gmx.net ([212.227.15.19]:53371 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230488AbhEHNQj (ORCPT ); Sat, 8 May 2021 09:16:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1620479722; bh=2JjXJ+A1EbPiAra4s+rtm3TZY1uXz383PTvaOIjdhWo=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=f6gv8E7m68eRGyHVhIq+QYjQKv13G3qCBLTRT5typmclqDN0wMzJHuNf9g3BzMlTs LR8BnhPt+f3L3jy9H8Xra414s1fzGaLXx2wdT12tR3/zFDJbrurHe2CHht5mOSDVnM pjVy2bFcTIpFJk845DX5v9W7Krrg0dNEDc/3Slss= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from esprimo-mx.fritz.box ([84.154.223.76]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MDQeK-1lmXnT3QSE-00AVmI; Sat, 08 May 2021 15:15:21 +0200 From: W_Armin@gmx.de To: hdegoede@redhat.com Cc: linux-hwmon@vger.kernel.org, linux@roeck-us.net, jdelvare@suse.com Subject: [PATCH v2 4/4] hwmon: (sch56xx-common) Simplify sch56xx_device_add Date: Sat, 8 May 2021 15:14:57 +0200 Message-Id: <20210508131457.12780-5-W_Armin@gmx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210508131457.12780-1-W_Armin@gmx.de> References: <20210508131457.12780-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:SSuNa8bmb/4pXXm0IfbRn8xwF/URj0V5W6E4sy6fsKn7HuIvN/u KtNSknQ6l7JelWNV33+/w+aBzlKIDUSlMWaTPgBtbsdJbEllMFPVRdfTH6qp7EQhoT0+DFb /DuMkdoI4Km+/7dB8lH7wl3koGgeStYlUKhCcjicEUB0COyqsGyMmpMprocIf/FhFNcQ1bn LqD2OPT234ZfbIWdNA/8w== X-UI-Out-Filterresults: notjunk:1;V03:K0:Y52HckMlXmQ=:xXFFgR1y1eXPwLIKuXJXlw p6pYJjkaDOB7+cnX9ofraH0A7qWOoiAX228SXqANmHlY1unyUB1GzKLxN7NLeUGccJMb42lak CDErbhvGLpY6IHhUJYjZTpIOhfHHw6Sqy5HFIcW8XK5Rs2K/HAHeBA3zsUtbwbBmcfERtGY99 rGOKjW6SXkULesLMHGdFEzo6BXMWnzuftivQ44kVki7a+qU7llwCyWLWYdiw44mfOS7Onokoc GSgaZuPSkBaAQmsd4epNPRzT5sblUAhAaXN4yPcWxnDrVbne9dfNGpTkE1YUIjNCZ8QPWzN3M zo9OYSlMdYSo2muik2+3vjA2Cgjhq3HC21RgThvUt/tVv3Jroqss5PuxQ5LqBmPP3d2j+VKmc XZgi+sSd6CjQ99LWEvb26RahuLBj58jdixmQy4KU+pswMBkYvUJC/GW1ax2MxWjY4PI5/0lsV UCtn6xa15qq1VwZewbA7e1N2LD0zJiYLc4KQ6cUt/8gXx0KjvHg+faSXbUsucff1ZYEg0tVhW vz6CwUv+ID7S51LAOQJ+OJwE53zysF0ZYJcdaPflV184NGm4JoC6cRsSN5cqlEbTvrgJvkZOS zYLLhugPvL9PsDMXP68WlQ94ylvAAmZ92xWuq57B/71LKI4dXQFb7J2pJONFtBgbfJ3ypUvq2 Zi7ofIDmk5YyYP0XggdeevbPSoI5tXuRTC23ngGrwAP/3ZMtsgBkEOxF6isf40LIAMDR5WyVC 1+yzPHAKt7E5EhN9VNxS/tm1RwZC6ULyOLGW41tyFulS9x3h0BMh/ynneYsFQb+M8Y1pSvygx N1lL8e8wkJ2ABFcPNEnGOZ1dasU51MgZsYXDnorsd3YF3Ay7MBsSZH+jrLnFtzlz/rahReffb cE8Zl9YywhqILiFb95GUGqljuUTrFNKGya00TsldNXhHD2bT9utgG3ATLoqZlgnZFa6wwLlG4 HTN8HsgZH6DDPIF2rLcwlKu82Kx+ixGDvo1p+vdjHQuT1Ym02K1w5+edIdn+Q8Ul4Zuo8yviO 5tmz/CVLCH1LNYkG8xyb+xSLp8UzYX9yiY7e1tCgYtb9aOeFspnIEZ+Hfx0lw88jSQo7gW5Kb 3r1sLIhzSAEQMEz98pfD/R0PgGes052lE8vtd1PnWAfaX7pU9tTZHNjl0Pupy5QXk5cbLOEVv q6kAwcMPM/Ad3thOqhtsBECFiyiNNXn/cJ59PFYlMXkWA+157Qai5aYe4ANpcPHZOvJxk= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Armin Wolf Use platform_device_register_simple() instead of manually calling platform_device_alloc()/platform_device_add(). Signed-off-by: Armin Wolf --- drivers/hwmon/sch56xx-common.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) -- 2.20.1 diff --git a/drivers/hwmon/sch56xx-common.c b/drivers/hwmon/sch56xx-common.c index 180801f80118..5307fda73e70 100644 --- a/drivers/hwmon/sch56xx-common.c +++ b/drivers/hwmon/sch56xx-common.c @@ -506,37 +506,18 @@ static int __init sch56xx_device_add(int address, const char *name) struct resource res = { .start = address, .end = address + REGION_LENGTH - 1, + .name = name, .flags = IORESOURCE_IO, }; int err; - sch56xx_pdev = platform_device_alloc(name, address); - if (!sch56xx_pdev) - return -ENOMEM; - - res.name = sch56xx_pdev->name; err = acpi_check_resource_conflict(&res); if (err) - goto exit_device_put; - - err = platform_device_add_resources(sch56xx_pdev, &res, 1); - if (err) { - pr_err("Device resource addition failed\n"); - goto exit_device_put; - } - - err = platform_device_add(sch56xx_pdev); - if (err) { - pr_err("Device addition failed\n"); - goto exit_device_put; - } - - return 0; + return err; -exit_device_put: - platform_device_put(sch56xx_pdev); + sch56xx_pdev = platform_device_register_simple(name, -1, &res, 1); - return err; + return PTR_ERR_OR_ZERO(sch56xx_pdev); } static int __init sch56xx_init(void)