Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4068779yba; Tue, 9 Apr 2019 10:26:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqx7ZPSdndJb4U8Lp+SuJ/rYoX2uep8mV8iZ6xWOWgNAWYDf02U5oUfOqxc6P0t+P2usq0Om X-Received: by 2002:aa7:8c86:: with SMTP id p6mr38655193pfd.37.1554830786575; Tue, 09 Apr 2019 10:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554830786; cv=none; d=google.com; s=arc-20160816; b=GMjTHfpr7C8+v84tQyBkqQtREKaxka27SHY/ZWOx3pxXhR85mgw9B/cwczddccZI4r Eaa0YkW9pftmTXc31uGG5OoTQWhnfjdnNDCUns/LcNA186AhcUZyQCceKbgGPI0f/s0B Pvs29H1RrWCsJCUSi0IxHu6TutRqGrtxD/VyIB5d14o/hXE7E3drVBSJzGKxOcs3p7Cr oHnHDrrDF7aEJg6u0j0MVwAQnr0A88+n5W+5lQ7PuYquua5rv3YHOkQqmn1j2KMZ91a9 MEls5DNOzgYARWU7/kKmjxaTqhX8cIAr5/Qibio/zv6iKJJVP0zhdsqQBfPa9Wwwn/y6 r3Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=RQNFeFQAIS9IcQnzgiGsF4bv+r8/UL2D7gAeGH/2zP8=; b=xzKNTgAmaU6agkx5mfxE1iTfoNz+zmhThrZ6fZ080fE0WcldjBERfmSZyFWwFU8ZIM iXr6LAK8XZ5rsTViT3IwT7D0991qU2s58ZnBYWawaOtc0EiJzOpklwEoR6Fv/rLcldEm +Hq4d7kxFgKQOz1OaJ2Dzc6Ae4potQ66e2jE600JjYh1p3d0G5fRmUr5P8Zpgl5YV7vr 1faStRAYoWPMl42YZCbWlqbd4GorfSP2IJ/44FBz5lAEQbxHBB1/0WyYy6lPPyqx+efU r6f12g+o1oaxVQEbmcyVCP58Z4+FtSwlbqgnAGeJgXVKrRqFnc+Kdn2lO5d3iwegU75b CUCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="u/uDCxMf"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h40si7561637plb.261.2019.04.09.10.26.10; Tue, 09 Apr 2019 10:26:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="u/uDCxMf"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727049AbfDIRZJ (ORCPT + 99 others); Tue, 9 Apr 2019 13:25:09 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:46531 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726894AbfDIRYk (ORCPT ); Tue, 9 Apr 2019 13:24:40 -0400 Received: by mail-pl1-f195.google.com with SMTP id y6so9786214pll.13; Tue, 09 Apr 2019 10:24:40 -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=RQNFeFQAIS9IcQnzgiGsF4bv+r8/UL2D7gAeGH/2zP8=; b=u/uDCxMfyJYUC9wKKiiREszTvY2wHTAHAVAQagHKdh/JWWn7ZEZu3fHo0vAbbRIkF9 GrrJa3PGVbIynVHH8fqTAFF9/INzvtFcpSlYq/qaSLzVknty0zTPdMUsEFL5nLV0EOxJ XuV/yHBg8kWIq4ThmK8yKu3iP1efUgcfnaAjg84gA/bigRNOQ1xpAH6Q/sMxfzkEug20 w6Q8v1HlYuMcriOokxWzLYcgDL+Aaj5aiP58dImiCQVtRkiSnGqmK3c1sHg3wjSMdMQP 9Y1QFGWhpSeSXB/WO6W/gv8m+ml6mHHSmJxoHtfqAd94lfz+lkkTrfP4jATVyiBY3k/7 /ufA== 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=RQNFeFQAIS9IcQnzgiGsF4bv+r8/UL2D7gAeGH/2zP8=; b=e/q9U6/0YZ/VtKCeErVk75OUBqnT1zEHDWp8Z15vNn4o/PRCmfpRn7VLFPXdLmVaxX k0Xim15PEYwgwE5nKHtzxNZOrfmq+aonv5XhI/kI+EBA6DzqvjTK6cQT73cm4e8SaV4R Kq7t3L6mMC5xr7uBgCQdKsXzZ1a+Yi+9+ho0Dlx+dkqj9A38jI+uD51YkXGiaFMbxSx8 86ZSRPDpZE3YLdOp8SibqgMpXPEkoy07OtNTO1MhmoLFeV/oDG06el6SbeLuDBYByvW+ QAA4uPkEmC9Wrucb7UXPpC+AX4wEuKF7yOIM0g5C0RY6IkRpQ2R0WOZiYgF3E8zHvLOt a9oA== X-Gm-Message-State: APjAAAW4QqudpfWRxiMh+shCeQXg14n8IeKWZhKDOIVDTQdYVTni5wGW M0gszp25cS2SamKI4nGDiwVZaXGG X-Received: by 2002:a17:902:8a4:: with SMTP id 33mr38847467pll.7.1554830679831; Tue, 09 Apr 2019 10:24:39 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id q11sm47414470pgs.94.2019.04.09.10.24.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:24:39 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Maxime Coquelin , Alexandre Torgue Subject: [PATCH 20/23] watchdog: stmp3xxx_rtc_wdt: Convert to use device managed functions Date: Tue, 9 Apr 2019 10:23:58 -0700 Message-Id: <1554830641-9247-21-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554830641-9247-1-git-send-email-linux@roeck-us.net> References: <1554830641-9247-1-git-send-email-linux@roeck-us.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use device managed functions to simplify error handling, reduce source code size, improve readability, and reduce the likelyhood of bugs. The conversion was done automatically with coccinelle using the following semantic patches. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches - Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly - Use devm_watchdog_register_driver() to register watchdog device Cc: Maxime Coquelin Cc: Alexandre Torgue Signed-off-by: Guenter Roeck --- drivers/watchdog/stmp3xxx_rtc_wdt.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/watchdog/stmp3xxx_rtc_wdt.c b/drivers/watchdog/stmp3xxx_rtc_wdt.c index 994c54cc68e9..671f4ba7b4ed 100644 --- a/drivers/watchdog/stmp3xxx_rtc_wdt.c +++ b/drivers/watchdog/stmp3xxx_rtc_wdt.c @@ -89,31 +89,31 @@ static struct notifier_block wdt_notifier = { static int stmp3xxx_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret; - watchdog_set_drvdata(&stmp3xxx_wdd, &pdev->dev); + watchdog_set_drvdata(&stmp3xxx_wdd, dev); stmp3xxx_wdd.timeout = clamp_t(unsigned, heartbeat, 1, STMP3XXX_MAX_TIMEOUT); - stmp3xxx_wdd.parent = &pdev->dev; + stmp3xxx_wdd.parent = dev; - ret = watchdog_register_device(&stmp3xxx_wdd); + ret = devm_watchdog_register_device(dev, &stmp3xxx_wdd); if (ret < 0) { - dev_err(&pdev->dev, "cannot register watchdog device\n"); + dev_err(dev, "cannot register watchdog device\n"); return ret; } if (register_reboot_notifier(&wdt_notifier)) - dev_warn(&pdev->dev, "cannot register reboot notifier\n"); + dev_warn(dev, "cannot register reboot notifier\n"); - dev_info(&pdev->dev, "initialized watchdog with heartbeat %ds\n", - stmp3xxx_wdd.timeout); + dev_info(dev, "initialized watchdog with heartbeat %ds\n", + stmp3xxx_wdd.timeout); return 0; } static int stmp3xxx_wdt_remove(struct platform_device *pdev) { unregister_reboot_notifier(&wdt_notifier); - watchdog_unregister_device(&stmp3xxx_wdd); return 0; } -- 2.7.4