Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5129409yba; Wed, 10 Apr 2019 12:01:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHMVmKUVkNXBAPnQnn3x/qhVmuIOEjKmDjatdP8gWR+W3a5ExN514x3S/rIQikuq5okn5g X-Received: by 2002:a17:902:7247:: with SMTP id c7mr45477169pll.255.1554922872535; Wed, 10 Apr 2019 12:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554922872; cv=none; d=google.com; s=arc-20160816; b=PbvR4Ej0pCPJ+8Keazw06dH15ifCHs+NOZEe47NktD7Nipz7Xze7CSpnJeYygZmQFT kA5qqFi9NiSc1zxQVk9Md/N1StU6/FaYaqOKdtfsxkzopb8sXet5+KXf11DB/QO/FVz2 5FzF1BvUbBt4n/jAFNc6dNCNWS0L0dA0GyDKiwXIiubfBZiZ5Pzs6fiOKd20t50AIe/X H7ro6UrBPtIbSnHPmt46dv69kr7Ame254CEnrgg5sHOnjymLw+VS7ijIjc6GQdUeMi+K vMzAOuCFdBwy0FdgisJtBEVYTpLVSm7/168OhZrOLz3naWWXA+4BPZBhbTMb8rukR3hC Iysw== 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=ni05DFO6BTYbaFzG8C2LxYO4iAiA1+2nom8reemvhW0=; b=QEhU+npPnbH+5id5WGIpwhBn8BdvPeTRJLJvWdeHbh93lHWLcFfLx/rjjKKVzPeUKt +nag3zGdhc6X7PTO+nbBzMArWOpdXzbIpZCU0lSmNEVGatfHgxj0Mx22iBRZS0PjHEXv krfJWxsbDf/OeUUrNlzsHzS1psIjHCaoQ+DWazdaQLhpjJJ4KntkAkSAnoBjtsCy/uAH nnodWgD9RO5c9jQ+BL5lBAQebSFjKEn2f0K4aZ9sGIKZ263db35qNKUDrSEKPl3Fx+7S 1mj88cK3P/vvhIMNHLlREirV/29BjtD5tBvs/+Af+x4iQvSeygidbDVvgKodfv4fK7Yq A0iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=BHV49RXl; 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 l39si33959324plb.143.2019.04.10.12.00.55; Wed, 10 Apr 2019 12:01:12 -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=BHV49RXl; 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 S2387971AbfDJQ3W (ORCPT + 99 others); Wed, 10 Apr 2019 12:29:22 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:43129 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387888AbfDJQ22 (ORCPT ); Wed, 10 Apr 2019 12:28:28 -0400 Received: by mail-pg1-f194.google.com with SMTP id z9so1848328pgu.10; Wed, 10 Apr 2019 09:28:27 -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=ni05DFO6BTYbaFzG8C2LxYO4iAiA1+2nom8reemvhW0=; b=BHV49RXlJ+LnAtzJUDLJPBhI6oftKO6ggo/tYg0beVFFgGFAW16TVzGY40c/oJEEgk vNeuc8lzC9LA6gxb/yJVVXncXZIxI7+g8OfLcSTJX1UGp8Gm8ezKtli/pWus7gxFUPOn zbVrFOxv1EOooPOAP9RvsHipose3la9DuBlPhJ9Qxbr6wAiTufnE8mi8c2Eu8bH7JEKg xveVNLFEoxWiWTSUncEbE9fs1UGE1htExMsX9EBKONdSnzezcgLVcYDlzxFb1/IkDOCP LgllhIPyUALWJMClljI4d68Xhq7A8rl5EX0YcBCe+DObGvQx91zzXvJK6O4vlyeZtu8+ 5yxg== 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=ni05DFO6BTYbaFzG8C2LxYO4iAiA1+2nom8reemvhW0=; b=K7bPFDxEU0lWI9pWT28aqe9A1IaBsQk8NgikJnPq5xDhYCaFwcarZKw1EZkorWqnK3 hk9MDK9nffxe13iYduw+r6ZEvxUkFG8RcL5Fh7dYvIkfX6u/1SoRu5LwMdQO2aGc5yGC UvESxwWK+sSorQELtsV3O/bMcw/tj6Tt2S16y5ofPueNls7DBR3c5fevNrF+nN2sSQfY cuH6bAW7K0rTcfUquKM7psQN4h7xdlrTfpyl30ol7sgfFuI7aB1hB23Nm5yFlQKgH728 Yls9f+0Nwy8wTfWTiWeuOJIxXSrZMUiT97+NJKUCku0Ja08DOZDnGkZYzLws65K0mJPk AFzw== X-Gm-Message-State: APjAAAVxGGtXj6DP2z43zeDnyOsHvrkgadXSsEjT8/c8kS122SxI3LWp mn0cDL/sWtYwyDFGn+mE+Sg= X-Received: by 2002:aa7:943b:: with SMTP id y27mr20615184pfo.59.1554913707408; Wed, 10 Apr 2019 09:28:27 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id m23sm54815037pfa.117.2019.04.10.09.28.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:26 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 14/22] watchdog: ux500_wdt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:27:55 -0700 Message-Id: <1554913683-25454-15-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554913683-25454-1-git-send-email-linux@roeck-us.net> References: <1554913683-25454-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. Other improvements as listed below. 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 - Drop empty remove function - Introduce local variable 'struct device *dev' and use it instead of dereferencing it repeatedly - Use devm_watchdog_register_driver() to register watchdog device Signed-off-by: Guenter Roeck --- drivers/watchdog/ux500_wdt.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/drivers/watchdog/ux500_wdt.c b/drivers/watchdog/ux500_wdt.c index 37c084353cce..9fa7f95f7554 100644 --- a/drivers/watchdog/ux500_wdt.c +++ b/drivers/watchdog/ux500_wdt.c @@ -86,8 +86,9 @@ static struct watchdog_device ux500_wdt = { static int ux500_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; int ret; - struct ux500_wdt_data *pdata = dev_get_platdata(&pdev->dev); + struct ux500_wdt_data *pdata = dev_get_platdata(dev); if (pdata) { if (pdata->timeout > 0) @@ -96,7 +97,7 @@ static int ux500_wdt_probe(struct platform_device *pdev) ux500_wdt.max_timeout = WATCHDOG_MAX28; } - ux500_wdt.parent = &pdev->dev; + ux500_wdt.parent = dev; watchdog_set_nowayout(&ux500_wdt, nowayout); /* disable auto off on sleep */ @@ -105,18 +106,11 @@ static int ux500_wdt_probe(struct platform_device *pdev) /* set HW initial value */ prcmu_load_a9wdog(PRCMU_WDOG_ALL, timeout * 1000); - ret = watchdog_register_device(&ux500_wdt); + ret = devm_watchdog_register_device(dev, &ux500_wdt); if (ret) return ret; - dev_info(&pdev->dev, "initialized\n"); - - return 0; -} - -static int ux500_wdt_remove(struct platform_device *dev) -{ - watchdog_unregister_device(&ux500_wdt); + dev_info(dev, "initialized\n"); return 0; } @@ -153,7 +147,6 @@ static int ux500_wdt_resume(struct platform_device *pdev) static struct platform_driver ux500_wdt_driver = { .probe = ux500_wdt_probe, - .remove = ux500_wdt_remove, .suspend = ux500_wdt_suspend, .resume = ux500_wdt_resume, .driver = { -- 2.7.4