Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5120057yba; Wed, 10 Apr 2019 11:46:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzUXi8974uQp7sBgxvas7Ws7ge+htx3FAk0WmEZDY5U3X/S+ri7OVtdpMd+PpT0HPuX2xOW X-Received: by 2002:a63:fc43:: with SMTP id r3mr42075271pgk.44.1554921994228; Wed, 10 Apr 2019 11:46:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554921994; cv=none; d=google.com; s=arc-20160816; b=0pLqu5FiUVdCqSKAPXL0QsoBxSk8sF4cZjT9/EMkY6Pez1LlNuvEA1CHT5EwgVB50w nQh+zuaQCtTHRMvAOfxLSr4WtYHX0/HM44mTVI6nEvdOwdAhncT28At/iM+nt9A41zR6 hPtub3AFSJkH5U1eVFpAZhlE+99ZF5twZwK76XHR0qzg71WQr0iajKgWNjU7mDwjBHRL uxNj7Ab7/C1rhzM12pZb9Y148FBpfJwbpl/SVlzJDK2rMqPpd5gHDtXCfIu23U2XYhU8 isVhFyiltPB0LDTw18yjaLCaEnbpzrAdbb0z0bYrfaMMTf4IIvf12ikJ1+zxyLi9FE2I 4ISg== 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=Y3q0kgdoTOk/eYTK2ErICl6tYKEu68Zi7htktucMeOA=; b=XyMN169NwNGlRWzKIbeet2jQ8KjCUG2APPC9PHL9Z/fWuLEqjTfjoseg8bJ67pEDir LQSy3VjxQRrxjGEN7MU0CLZbZczwYfFewiQVdQeYK/4OEAV16T139mE1fZuiakxhKTQm KLMFky5k23CwhoQUbfKfdQ53Ax1LMARj+46ZTxJ/I2p1qrKjm+rBn7wcih4rJ0dvD6Ny uq3MJlpbeBZnDpJ67sQfFvu85KyRunhHfdCMaboxPDNIskNPvQ35uipUwS3Vw4GC1+TM hkjv7ZufD+g7Kg66uVDaMHaqQZ99nS6gSMfBafD1lvw550VvtLlk/5RwULunhhZ4uQor 2Jyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=SYGZRtP8; 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 h9si27645332pgn.145.2019.04.10.11.46.18; Wed, 10 Apr 2019 11:46:34 -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=SYGZRtP8; 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 S2387955AbfDJQ2j (ORCPT + 99 others); Wed, 10 Apr 2019 12:28:39 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:37306 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387953AbfDJQ2h (ORCPT ); Wed, 10 Apr 2019 12:28:37 -0400 Received: by mail-pl1-f195.google.com with SMTP id w23so1737093ply.4; Wed, 10 Apr 2019 09:28:37 -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=Y3q0kgdoTOk/eYTK2ErICl6tYKEu68Zi7htktucMeOA=; b=SYGZRtP85ydvrBfzCxF3iJZJkmnJCQuMpxv6Ziq4bMU2tmZ+dORYAzFK2kBV24ssFk AXAWhIZh79xPKCfoWdAZlWzvjMUbl6Z836KZdh7xBAyzccE+2YX34BMjzcpONPFdqRxc OEoiMFdrn6RhEBs6LXCOXQ1oDc/+/qhtZx+4qj5Hlz9fkOSfhHdj2/1J7InBg44FJu8o FpsYvJBDBbG/Muu8A5gYk3d7IkYnxNx36v4Qrhe+Y0Y6TlzCRUCzzthUHRiEseQsectq wuab7nhI+msT6rYCJrXhIitVikO0XcCWblLjt4c5NTHKH5rvO8pElMuJhV4W80ab+Ar+ tsLA== 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=Y3q0kgdoTOk/eYTK2ErICl6tYKEu68Zi7htktucMeOA=; b=crva7mcpSaisBMVd1tlKiwReT4qGLV2gp6UbR2yfsVSYgMXfkKA6QI0iwLiNUtMVAs sPqVGaBIVwwv+KR8vVjanJrGTGJHB9Er0WfV4dHm4MjozybA41CP5SK0LCNH4uzpwtUo /Ev44BweppSQXhbuD2OVRJ0Lmpu1IMVQbopd4VIeyiQs7SurQtgBo4UUBCHtNm7vXDZ0 1hU+zdGsOQ7zCULJ+RuAuWirtSPpiwBS3vBEkfWfttPACU7iohOSXlEcPTZzH7pVhX1V zX8/XlF1OTOCPEPVXppK2514EL7gKwn6zkvMMqRIB2+t12v0uTnZWS7F9HawTwPc5T43 Xr5w== X-Gm-Message-State: APjAAAVRT84RPG2KrIQ7ZRcpVV3WXPoAkaFkPPHxZBaHQhq2/4Ggenx7 giCNTF7Ivo51tgEjHkPSVschNbNm X-Received: by 2002:a17:902:b597:: with SMTP id a23mr43264926pls.284.1554913717080; Wed, 10 Apr 2019 09:28:37 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id t82sm97448554pfa.153.2019.04.10.09.28.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2019 09:28:36 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 21/22] watchdog: mpc8xxx_wdt: Convert to use device managed functions and other improvements Date: Wed, 10 Apr 2019 09:28:02 -0700 Message-Id: <1554913683-25454-22-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 This also drops the inaccurate message on remove; the driver won't be removed if the hardware watchdog is running, no matter if the watchdog device is open or not. - Use local variable 'struct device *dev' consistently - Use devm_watchdog_register_driver() to register watchdog device Signed-off-by: Guenter Roeck --- drivers/watchdog/mpc8xxx_wdt.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/watchdog/mpc8xxx_wdt.c b/drivers/watchdog/mpc8xxx_wdt.c index 3b5b446b690c..9b6d6a5a27ad 100644 --- a/drivers/watchdog/mpc8xxx_wdt.c +++ b/drivers/watchdog/mpc8xxx_wdt.c @@ -204,9 +204,10 @@ static int mpc8xxx_wdt_probe(struct platform_device *ofdev) if (ddata->wdd.timeout < ddata->wdd.min_timeout) ddata->wdd.timeout = ddata->wdd.min_timeout; - ret = watchdog_register_device(&ddata->wdd); + ret = devm_watchdog_register_device(dev, &ddata->wdd); if (ret) { - dev_err(dev, "cannot register watchdog device (err=%d)\n", ret); + dev_err(dev, "cannot register watchdog device (err=%d)\n", + ret); return ret; } @@ -218,17 +219,6 @@ static int mpc8xxx_wdt_probe(struct platform_device *ofdev) return 0; } -static int mpc8xxx_wdt_remove(struct platform_device *ofdev) -{ - struct mpc8xxx_wdt_ddata *ddata = platform_get_drvdata(ofdev); - - dev_crit(&ofdev->dev, "Watchdog removed, expect the %s soon!\n", - reset ? "reset" : "machine check exception"); - watchdog_unregister_device(&ddata->wdd); - - return 0; -} - static const struct of_device_id mpc8xxx_wdt_match[] = { { .compatible = "mpc83xx_wdt", @@ -259,7 +249,6 @@ MODULE_DEVICE_TABLE(of, mpc8xxx_wdt_match); static struct platform_driver mpc8xxx_wdt_driver = { .probe = mpc8xxx_wdt_probe, - .remove = mpc8xxx_wdt_remove, .driver = { .name = "mpc8xxx_wdt", .of_match_table = mpc8xxx_wdt_match, -- 2.7.4