From patchwork Sat Mar 4 16:56:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13159970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F0C2C678DB for ; Sat, 4 Mar 2023 16:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0QF1jdolUl1ebrkWO/Hfwv2OsvpU5uW07ekIbAAGAJM=; b=QtdoKB5bk+uoMf 5mVyW0LAtBKsIfgCNnHa5u5Q2lw0FRrod3lA2cWRvec+/oOZt1SpLsZDWnn9FjXEGtfb2Afw3q1SK CkT28Zl7aBaqy5aaM1zlHRR8wvyuzMdNRskLyocdc/5bqPur020hQ2k7lmRsY60/zJhLHvu4EmCvt ADoiNeztE9zLZ8cfRM6pv5Uy2SoGJhfRCG8QJYG0slHfX/QZv2lwyHoXK5Wx5m+1KoimIZ52DuHJ7 Z/n1GFxJ9agqwaSpevLKfPO8MekQh1la/e/r8lGk1paYgv0WgMc0hYTPVaHXODenj1xqLXf5Id8n6 emQJ+OPJGofUhoXA1iag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pYVC5-009GnV-JG; Sat, 04 Mar 2023 16:57:13 +0000 Received: from mail-il1-x12e.google.com ([2607:f8b0:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pYVBt-009Glb-DQ for linux-arm-kernel@lists.infradead.org; Sat, 04 Mar 2023 16:57:06 +0000 Received: by mail-il1-x12e.google.com with SMTP id k9so3296636ilu.13 for ; Sat, 04 Mar 2023 08:56:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677949018; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=NHhEJVEVzLbDVPR+ROK20RK4K6MlBOfgj289iHs9gU8=; b=Y1aqvHe5PU4IB69r3bRAP6PbuXYJyil0hzZH2e1oumTsiO0cpIgcSwKJARNBVv+sZ+ wlMkTK3Hfph0qZSPdFkghXdW2uNM+y75lQilOOdUcwXRF2kRKFqrrBldQCRIx2uip2Uq vGfb83a1tDsYGAfdhp18v3UE27yk6YrsceuUqKXAbbyfTvIvcR8FniaBd0vCsJPRq6kz RrTEo4Pavqf6fVgWVELGg1LaskPAxolDuuLehIQY5oEHwhpX45MDHjEOmmYgBckge/Qd iSpJcVVZcDrlwQfv9cJz82JlGVcHRQb7Gl14Eol89njt/HVBaQraUFPVJal3vNn1u6G/ 1y9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677949018; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=NHhEJVEVzLbDVPR+ROK20RK4K6MlBOfgj289iHs9gU8=; b=ZG1yUP6KhlJ5TnunkDfpkz2ySMt2D8/LAKgVsuGv/kI/Ru9wC4i665JfXxaQyR0TyB 64JkumQqtNC4FQM9gFb6XIhLM1zTHMO2KGL9bhS0EAkn/D+xihpBGxjW+fgJ5Jg9JGTd CHkUUdUnVixuED1gKgw8aIQCrndRpit2kseN2qiPae5q2G4EBR9npV8Avdi1tiVl5W63 Aj7NKVy4wjVhdg6t1E5720uQhfDuUiv3lRf2Yr9NDGH4wxxx+8s+bBWmPBPZesyLFZ0A z/IFPR5PepmgOz2ZDm856MBQbP8bXovrbvP5T+SissFTHUS3Vdp6/cdCJYpjNDrGTRdQ 1ZSQ== X-Gm-Message-State: AO0yUKUS/kcGiAlCbXQW5NYzFODdeCCHiWXn0+YCrfMIVhjKfpRjq5QX eFwzD0bcK2lUr99ceBi6kVo= X-Google-Smtp-Source: AK7set8HNAYpV75qv/aHc3DCVpUZt9UazbUxX9z1XkSHC4ogijZZcyZzS+4Zk0HVYuTj3IRbSOWzXA== X-Received: by 2002:a92:c54f:0:b0:316:dcfd:1b6e with SMTP id a15-20020a92c54f000000b00316dcfd1b6emr5001055ilj.30.1677949018184; Sat, 04 Mar 2023 08:56:58 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id m2-20020a056638224200b003c4f55da7easm1712349jas.45.2023.03.04.08.56.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Mar 2023 08:56:57 -0800 (PST) From: Guenter Roeck To: Krzysztof Kozlowski Cc: Alim Akhtar , Wim Van Sebroeck , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [PATCH 2/2] watchdog: s3c2410_wdt: Use devm_add_action_or_reset() to disable watchdog Date: Sat, 4 Mar 2023 08:56:53 -0800 Message-Id: <20230304165653.2179835-2-linux@roeck-us.net> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230304165653.2179835-1-linux@roeck-us.net> References: <20230304165653.2179835-1-linux@roeck-us.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230304_085705_250773_4BCCE743 X-CRM114-Status: GOOD ( 16.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Use devm_add_action_or_reset() to disable the watchdog when the driver is removed to simplify the code. With this in place, we can use devm_watchdog_register_device() to register the watchdog, and the removal function is no longer necessary. Cc: Uwe Kleine-König Signed-off-by: Guenter Roeck Acked-by: Uwe Kleine-König --- drivers/watchdog/s3c2410_wdt.c | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index a1fcb79b0b7c..58b262ca4e88 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -623,6 +623,11 @@ s3c2410_get_wdt_drv_data(struct platform_device *pdev) return variant; } +static void s3c2410wdt_wdt_disable_action(void *data) +{ + s3c2410wdt_enable(data, false); +} + static int s3c2410wdt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -724,13 +729,17 @@ static int s3c2410wdt_probe(struct platform_device *pdev) s3c2410wdt_stop(&wdt->wdt_device); } - ret = watchdog_register_device(&wdt->wdt_device); + ret = devm_watchdog_register_device(dev, &wdt->wdt_device); if (ret) return ret; ret = s3c2410wdt_enable(wdt, true); if (ret < 0) - goto err_unregister; + return ret; + + ret = devm_add_action_or_reset(dev, s3c2410wdt_wdt_disable_action, wdt); + if (ret) + return ret; platform_set_drvdata(pdev, wdt); @@ -744,25 +753,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev) (wtcon & S3C2410_WTCON_INTEN) ? "en" : "dis"); return 0; - - err_unregister: - watchdog_unregister_device(&wdt->wdt_device); - - return ret; -} - -static int s3c2410wdt_remove(struct platform_device *dev) -{ - int ret; - struct s3c2410_wdt *wdt = platform_get_drvdata(dev); - - ret = s3c2410wdt_enable(wdt, false); - if (ret < 0) - return ret; - - watchdog_unregister_device(&wdt->wdt_device); - - return 0; } static void s3c2410wdt_shutdown(struct platform_device *dev) @@ -817,7 +807,6 @@ static DEFINE_SIMPLE_DEV_PM_OPS(s3c2410wdt_pm_ops, static struct platform_driver s3c2410wdt_driver = { .probe = s3c2410wdt_probe, - .remove = s3c2410wdt_remove, .shutdown = s3c2410wdt_shutdown, .id_table = s3c2410_wdt_ids, .driver = {