Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5120918yba; Wed, 10 Apr 2019 11:47:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzxq+3v4BdW/tTy5YLlcQJgnwSwjqkjMv1Lp3mbIbGjtiJWGDaQIYYMH7VagsN9vZbdAis X-Received: by 2002:a17:902:be0a:: with SMTP id r10mr43975171pls.4.1554922071470; Wed, 10 Apr 2019 11:47:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554922071; cv=none; d=google.com; s=arc-20160816; b=Bn2T0BLWI7b/BP0dric+fVZEtlTu4lrgVa5upolp8GByzWiBgYT+njO5qmC3DDb59h pgXUa97wBScNhj2qY6QAWL6lG95vgEFVI2b0Mqnxg5mMYSzBsAn+C3awBxthICX/2R16 YTBbT6SHRJWv9X1Rq4TOZ4/NsfXu6TFEtBP+Sf6SLQ5r/EyiPnUIWMUATQbukGdxHnw/ ucMPxsUU8EnVO2EORgS4mpgBGBFgYYz1s2EJ6HMQPxtvcPuMHBlm+wCw8baxewA9NKC5 7/O/p1AJG9VYokhq1okuW5eGlowayaKP4HsoHOTN3hmC0qqYgu766uF/tAHRRJst79Z/ oI5Q== 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=7d8y9AaFPQzWfMw+rRzXEYOrli0Bj0Hj+AuP2Kt4PtY=; b=mV3L3R/HTFlGFDtDaxp9iuyoQecn2e9t9Pf33vPMajA24n3/k6lejl3GYoCXs+wwJ/ zcLUH85JI9ctuqpxM0XF97Q72GbJtly3B6bidYv0Y4LioH+0PwLzoSR2QkuA3iLcMJuu zNzu6SBn7KH7TlMdgAZS5fCOKe7y3AsPHxYMSXA5jfdqprvKybxfqnZG7rQt19px2UOo Z+aimWp6T1dp94GbRJvCyv39XMP/tm3LF20BhQIk7V9P9Rv7dyOozKwnlr1ORJlD6gus QX+SWxgIRLJRFRSKlknisMFb5NS9OXYx9gzSOQGe0lS/ZyPv0AdBrbBZvDIs1q+uX3ja Y7mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=PFsQFKHP; 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 v6si14200306plp.296.2019.04.10.11.47.35; Wed, 10 Apr 2019 11:47:51 -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=PFsQFKHP; 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 S2388013AbfDJQaH (ORCPT + 99 others); Wed, 10 Apr 2019 12:30:07 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:34163 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387826AbfDJQ2P (ORCPT ); Wed, 10 Apr 2019 12:28:15 -0400 Received: by mail-pg1-f195.google.com with SMTP id v12so1877911pgq.1; Wed, 10 Apr 2019 09:28:15 -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=7d8y9AaFPQzWfMw+rRzXEYOrli0Bj0Hj+AuP2Kt4PtY=; b=PFsQFKHPY7fZi5sHcitxzm8lzcIf3CbKyaLPucO7NXshFKZHyg5ca4llgbbnUlTQU6 HeAurxc/iQhctxiIuPbX3l0XO69QjGoMa6bY8hKvXiLMtJSrjzhN8aDOKFUyhz4ReVga 2h70mgrrnwlTOYz+gnnVRw6CjdIS28hCNi/RnitrxvlSoh63bmaxbQn+ScPCG0uQbt6A dyOvr9dB+fk3A5J+oY+C2oeAnTXoGMJH32oWW3p5oG9JE4T2NDkeLIy9SDEkGLkj0xbL LfTajllZwcYaaXExukomxlEbrBbtGKKPgBiycfusdEPAmqePDUx7WrJ22rD0QyJECgeq RZyg== 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=7d8y9AaFPQzWfMw+rRzXEYOrli0Bj0Hj+AuP2Kt4PtY=; b=SOaBPzW5qbHO7u5ehf2HVYWe+ar/P4inp4BFmz3/qCIv/YOAhG5V6WOFtKXz4D5Ngx LQJImuDAwWuzA47d+YRq5beW7f79dnoJ4hJ+P5fyVu+/d5v+Td9J5qW2c/n8a3ST9hY1 yjrcGW3fbwE3uHloMa018tCGYegCTBP7xJklX/2Hnj2Q+VJqWzO1raO+Q5WbFgP0EaJU 7qqDfwGyJr6lC00rGS73G240Dy1E4wD6eAzddQ8jw5jbFrVUmpex5/br1AG9J8g+Hd2X ZjPrtOWHOOdqIdsGvkrYJDe6DjPSctdqa4N98aInMdsO10Hz9ei4Vp8IUpx0OKRhycyF twRg== X-Gm-Message-State: APjAAAX6GBb37AF77s77IYTQR5qxjkXJGbpSXdg1/wKfXIE103qX43sl Pt9c1ixV7CsD8bOfat0pN7bFiYdY X-Received: by 2002:a62:4602:: with SMTP id t2mr44116656pfa.26.1554913694884; Wed, 10 Apr 2019 09:28:14 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id x8sm28585202pgp.48.2019.04.10.09.28.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:14 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 05/22] watchdog: twl4030_wdt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:27:46 -0700 Message-Id: <1554913683-25454-6-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 assignments to otherwise unused variables - 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/twl4030_wdt.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/drivers/watchdog/twl4030_wdt.c b/drivers/watchdog/twl4030_wdt.c index 569fe85e52da..74c5737cd934 100644 --- a/drivers/watchdog/twl4030_wdt.c +++ b/drivers/watchdog/twl4030_wdt.c @@ -70,10 +70,10 @@ static const struct watchdog_ops twl4030_wdt_ops = { static int twl4030_wdt_probe(struct platform_device *pdev) { - int ret = 0; + struct device *dev = &pdev->dev; struct watchdog_device *wdt; - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -83,27 +83,14 @@ static int twl4030_wdt_probe(struct platform_device *pdev) wdt->timeout = 30; wdt->min_timeout = 1; wdt->max_timeout = 30; - wdt->parent = &pdev->dev; + wdt->parent = dev; watchdog_set_nowayout(wdt, nowayout); platform_set_drvdata(pdev, wdt); twl4030_wdt_stop(wdt); - ret = watchdog_register_device(wdt); - if (ret) - return ret; - - return 0; -} - -static int twl4030_wdt_remove(struct platform_device *pdev) -{ - struct watchdog_device *wdt = platform_get_drvdata(pdev); - - watchdog_unregister_device(wdt); - - return 0; + return devm_watchdog_register_device(dev, wdt); } #ifdef CONFIG_PM @@ -137,7 +124,6 @@ MODULE_DEVICE_TABLE(of, twl_wdt_of_match); static struct platform_driver twl4030_wdt_driver = { .probe = twl4030_wdt_probe, - .remove = twl4030_wdt_remove, .suspend = twl4030_wdt_suspend, .resume = twl4030_wdt_resume, .driver = { -- 2.7.4