Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3242276yba; Mon, 8 Apr 2019 14:21:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwbpEYg6Zu6nC3pZoAHy6ZDWl87gOVEQMd2W5n1nhPiovmakhv19ZW/b/HOh+HJXixYDiNV X-Received: by 2002:a65:6489:: with SMTP id e9mr30429264pgv.364.1554758486969; Mon, 08 Apr 2019 14:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554758486; cv=none; d=google.com; s=arc-20160816; b=ZaUs/b9mUYzVA76oHFRqiOBU1k0pDj4n6GWa5WA2uEfn/h57IJ/2iruziQjK8rkHSn CXF/nzGqdtaxeG8KZ5uO6xjy+DVuwdd3zfzXUp7opbKoxCsGXeBQ6ZbmPD94ZDHm08SG BXXgblprnviix/6oh/Axm3gjso/rgkuU2mCk2bDagJcylpKSR6vY1UDHto7xhR0EZrPK Uo3DvV5g+QzecHnN033xWniPzUKGXnHMXmDFj6+PEJt6JLkZLZr+JiDe/J8K/URxxVzo z0OGihp6FDcHbIo0KuZfcUZi2lWzkQnSF7BFg/WJK1MwNtWfGXFNUzfn/8QcVt3MsM1j 17Kg== 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=dhq23W063Hg+OizeeK28CfYTYMrp8EDUYCfhW6z14sY=; b=O4U0whtfAnDKh4I8swWizuzxry0BLhWk5spwlesgX6GcZ6zNyUOOFsaJvJ5f9f3tc1 A8r634WU0f9SXqG33qjSF0BzKkkJpORINBDjBahEJlXcUTy+srwabYaYTXGngIdd9b4a 8wtNd71Ux8NOEmVspirAOWKdHnnOQn0HbdPi6o576wnCqhzzPiXJPJ7oYANYaMCnDsEV 1/YwKRebIELecNLvLmUGaG32H4bemx/ddrno2GL0PRdyw4O4WXW/hMVion01U2TkIZ9o eA4ddi6WwfkNbBWQliYY1GTMf+Jv7h5Oyzf3EaUAcpHN88/MXgs081Rux2o8PTMrlg70 mcWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=bLElhYcY; 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 j15si27459945pfi.8.2019.04.08.14.21.09; Mon, 08 Apr 2019 14:21: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=bLElhYcY; 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 S1729169AbfDHTkM (ORCPT + 99 others); Mon, 8 Apr 2019 15:40:12 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42325 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729125AbfDHTkI (ORCPT ); Mon, 8 Apr 2019 15:40:08 -0400 Received: by mail-pf1-f194.google.com with SMTP id w25so6762432pfi.9; Mon, 08 Apr 2019 12:40:08 -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=dhq23W063Hg+OizeeK28CfYTYMrp8EDUYCfhW6z14sY=; b=bLElhYcYFIHUI4PMLwo+mkkxO1LdYxsFvtg8QtUX72PU72XksZD8ID77vf1r8FIEXB qHyQqeGM5QO1ZMcTpAFyF7fdoN8ox6W8an4WuOmcuhk5hLbtspDGhCluxB0CAwOHbMxf X3pcKjgBn4ux7pe638ktbKNbp+6izk36gJCL4VyyakriwMrmaVLnVISC3ZhyNYlGbI/E dsHn7lxqi8GIJfTlhvE+r8hJdtAzC8xz49iqE6HSHqKSp1PML2F2OfImg68PnZR+YbcD +ftkcheXb5nwxWoKwrLmr04rTqEZw2F2XRCPECI2IN/HqGZmo2Z1jZJWCkILB3FmqPg9 0dPA== 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=dhq23W063Hg+OizeeK28CfYTYMrp8EDUYCfhW6z14sY=; b=Mgy1LrJZ8AavhXmUjX/4Qsv0A6RvvaDtz0GU27ClFF4LrgUcMf+CnR6Bl/l+VGsEHu 0Am7cuz9/Ucz/RgJBAiZzIjlLbHByWcMBH9syJNTllS3SGEQO6PKE3I8OPHP2cTC4woB ZbfrWE3+ywo9SSkAbF2BwU6BaUzfZ/iiwRTxNoNFkiplj1BNqF+ZXTaEks5Z4ocQmKc9 FJdNz72wNitCItuAYXSLtwDtgKbzMcv+6z8LqkTHXthuI0F0Jm8FkE0vdEYEKEfF0mml +u4jkx7DyJKVRrHDQtq/3v1Ypz9t0BtR2cugT9CcbulM+mKlWSVm7M88P87dA+l8//80 DQ8Q== X-Gm-Message-State: APjAAAV22Gk+YoY8AnFBxUyFZQOQGmOEmQ2yibPeVSQxzzKLSP9XXIGY 1MIM4tEvkE1XfBosXkzH3Os= X-Received: by 2002:a63:1918:: with SMTP id z24mr28803475pgl.406.1554752408016; Mon, 08 Apr 2019 12:40:08 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id e4sm51663676pfh.146.2019.04.08.12.40.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:40:07 -0700 (PDT) From: Guenter Roeck To: Wim Van Sebroeck Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck Subject: [PATCH 22/22] watchdog: max63xx_wdt: Convert to use device managed functions and other improvements Date: Mon, 8 Apr 2019 12:38:46 -0700 Message-Id: <1554752326-13319-23-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554752326-13319-1-git-send-email-linux@roeck-us.net> References: <1554752326-13319-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/max63xx_wdt.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/watchdog/max63xx_wdt.c b/drivers/watchdog/max63xx_wdt.c index 5aaf13e5115a..3a899628a834 100644 --- a/drivers/watchdog/max63xx_wdt.c +++ b/drivers/watchdog/max63xx_wdt.c @@ -200,11 +200,12 @@ static int max63xx_mmap_init(struct platform_device *p, struct max63xx_wdt *wdt) static int max63xx_wdt_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct max63xx_wdt *wdt; struct max63xx_timeout *table; int err; - wdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL); + wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL); if (!wdt) return -ENOMEM; @@ -215,7 +216,7 @@ static int max63xx_wdt_probe(struct platform_device *pdev) wdt->timeout = max63xx_select_timeout(table, heartbeat); if (!wdt->timeout) { - dev_err(&pdev->dev, "unable to satisfy %ds heartbeat request\n", + dev_err(dev, "unable to satisfy %ds heartbeat request\n", heartbeat); return -EINVAL; } @@ -227,30 +228,22 @@ static int max63xx_wdt_probe(struct platform_device *pdev) platform_set_drvdata(pdev, &wdt->wdd); watchdog_set_drvdata(&wdt->wdd, wdt); - wdt->wdd.parent = &pdev->dev; + wdt->wdd.parent = dev; wdt->wdd.timeout = wdt->timeout->twd; wdt->wdd.info = &max63xx_wdt_info; wdt->wdd.ops = &max63xx_wdt_ops; watchdog_set_nowayout(&wdt->wdd, nowayout); - err = watchdog_register_device(&wdt->wdd); + err = devm_watchdog_register_device(dev, &wdt->wdd); if (err) return err; - dev_info(&pdev->dev, "using %ds heartbeat with %ds initial delay\n", + dev_info(dev, "using %ds heartbeat with %ds initial delay\n", wdt->timeout->twd, wdt->timeout->tdelay); return 0; } -static int max63xx_wdt_remove(struct platform_device *pdev) -{ - struct watchdog_device *wdd = platform_get_drvdata(pdev); - - watchdog_unregister_device(wdd); - return 0; -} - static const struct platform_device_id max63xx_id_table[] = { { "max6369_wdt", (kernel_ulong_t)max6369_table, }, { "max6370_wdt", (kernel_ulong_t)max6369_table, }, @@ -264,7 +257,6 @@ MODULE_DEVICE_TABLE(platform, max63xx_id_table); static struct platform_driver max63xx_wdt_driver = { .probe = max63xx_wdt_probe, - .remove = max63xx_wdt_remove, .id_table = max63xx_id_table, .driver = { .name = "max63xx_wdt", -- 2.7.4