From patchwork Fri Aug 14 11:07:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 1344955 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-rtc-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=glider.be Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BSglD5Nyzz9sTW for ; Fri, 14 Aug 2020 21:12:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727021AbgHNLMk (ORCPT ); Fri, 14 Aug 2020 07:12:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbgHNLMj (ORCPT ); Fri, 14 Aug 2020 07:12:39 -0400 X-Greylist: delayed 301 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 14 Aug 2020 04:12:39 PDT Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [IPv6:2a02:1800:110:4::f00:19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FBD0C061384 for ; Fri, 14 Aug 2020 04:12:39 -0700 (PDT) Received: from ramsan ([84.195.186.194]) by laurent.telenet-ops.be with bizsmtp id FP7Y230064C55Sk01P7YZ9; Fri, 14 Aug 2020 13:07:33 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1k6XYa-0003r6-Bz; Fri, 14 Aug 2020 13:07:32 +0200 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1k6XYa-0007Z2-Ag; Fri, 14 Aug 2020 13:07:32 +0200 From: Geert Uytterhoeven To: Alessandro Zummo , Alexandre Belloni Cc: Nobuhiro Iwamatsu , kogiidena , Adrian Glaubitz , linux-rtc@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 1/3] rtc: rtc-rs5c313: Drop obsolete platform_set_drvdata() call Date: Fri, 14 Aug 2020 13:07:29 +0200 Message-Id: <20200814110731.29029-2-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200814110731.29029-1-geert+renesas@glider.be> References: <20200814110731.29029-1-geert+renesas@glider.be> Sender: linux-rtc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rtc@vger.kernel.org Commit 284e2fa1da00a998 ("rtc: rtc-rs5c313: use devm_rtc_device_register()"), removed the last user of the driver-specific data. Hence there is no longer a need to set it. Signed-off-by: Geert Uytterhoeven --- drivers/rtc/rtc-rs5c313.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/rtc/rtc-rs5c313.c b/drivers/rtc/rtc-rs5c313.c index 89f38e3e917d3d11..00b5ef753935ec8a 100644 --- a/drivers/rtc/rtc-rs5c313.c +++ b/drivers/rtc/rtc-rs5c313.c @@ -369,12 +369,7 @@ static int rs5c313_rtc_probe(struct platform_device *pdev) struct rtc_device *rtc = devm_rtc_device_register(&pdev->dev, "rs5c313", &rs5c313_rtc_ops, THIS_MODULE); - if (IS_ERR(rtc)) - return PTR_ERR(rtc); - - platform_set_drvdata(pdev, rtc); - - return 0; + return PTR_ERR_OR_ZERO(rtc); } static struct platform_driver rs5c313_rtc_platform_driver = { From patchwork Fri Aug 14 11:07:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 1344952 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-rtc-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=glider.be Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BSgdS6vrmz9sPf for ; Fri, 14 Aug 2020 21:07:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726609AbgHNLHj (ORCPT ); Fri, 14 Aug 2020 07:07:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726139AbgHNLHi (ORCPT ); Fri, 14 Aug 2020 07:07:38 -0400 Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBCB9C061384 for ; Fri, 14 Aug 2020 04:07:37 -0700 (PDT) Received: from ramsan ([84.195.186.194]) by albert.telenet-ops.be with bizsmtp id FP7Y2300P4C55Sk06P7YYG; Fri, 14 Aug 2020 13:07:33 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1k6XYa-0003r9-Cb; Fri, 14 Aug 2020 13:07:32 +0200 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1k6XYa-0007Z4-Bj; Fri, 14 Aug 2020 13:07:32 +0200 From: Geert Uytterhoeven To: Alessandro Zummo , Alexandre Belloni Cc: Nobuhiro Iwamatsu , kogiidena , Adrian Glaubitz , linux-rtc@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 2/3] rtc: rtc-rs5c313: Fix late hardware init Date: Fri, 14 Aug 2020 13:07:30 +0200 Message-Id: <20200814110731.29029-3-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200814110731.29029-1-geert+renesas@glider.be> References: <20200814110731.29029-1-geert+renesas@glider.be> Sender: linux-rtc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rtc@vger.kernel.org rs5c313_rtc_init() calls platform_driver_register(), and initializes the hardware. This is wrong because of two reasons: 1. As soon as the driver has been registered, the device may be probed. If devm_rtc_device_register() is called before hardware initialization, reading the current time will fail: rs5c313 rs5c313: rs5c313_rtc_read_time: timeout error rs5c313 rs5c313: registered as rtc0 rs5c313 rs5c313: rs5c313_rtc_read_time: timeout error rs5c313 rs5c313: hctosys: unable to read the hardware clock 2. If the platform device does not exist, the driver will still write to a hardware device that may not be present. Fix this by moving the hardware initialization sequence to the driver's .probe() method. Signed-off-by: Geert Uytterhoeven --- drivers/rtc/rtc-rs5c313.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/rtc/rtc-rs5c313.c b/drivers/rtc/rtc-rs5c313.c index 00b5ef753935ec8a..af72e428b218173e 100644 --- a/drivers/rtc/rtc-rs5c313.c +++ b/drivers/rtc/rtc-rs5c313.c @@ -366,8 +366,13 @@ static const struct rtc_class_ops rs5c313_rtc_ops = { static int rs5c313_rtc_probe(struct platform_device *pdev) { - struct rtc_device *rtc = devm_rtc_device_register(&pdev->dev, "rs5c313", - &rs5c313_rtc_ops, THIS_MODULE); + struct rtc_device *rtc; + + rs5c313_init_port(); + rs5c313_check_xstp_bit(); + + rtc = devm_rtc_device_register(&pdev->dev, "rs5c313", &rs5c313_rtc_ops, + THIS_MODULE); return PTR_ERR_OR_ZERO(rtc); } @@ -381,16 +386,7 @@ static struct platform_driver rs5c313_rtc_platform_driver = { static int __init rs5c313_rtc_init(void) { - int err; - - err = platform_driver_register(&rs5c313_rtc_platform_driver); - if (err) - return err; - - rs5c313_init_port(); - rs5c313_check_xstp_bit(); - - return 0; + return platform_driver_register(&rs5c313_rtc_platform_driver); } static void __exit rs5c313_rtc_exit(void) From patchwork Fri Aug 14 11:07:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 1344953 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-rtc-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=glider.be Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BSgdV36J6z9sTW for ; Fri, 14 Aug 2020 21:07:42 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726599AbgHNLHj (ORCPT ); Fri, 14 Aug 2020 07:07:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726444AbgHNLHi (ORCPT ); Fri, 14 Aug 2020 07:07:38 -0400 Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25C80C061385 for ; Fri, 14 Aug 2020 04:07:37 -0700 (PDT) Received: from ramsan ([84.195.186.194]) by michel.telenet-ops.be with bizsmtp id FP7Y230064C55Sk06P7Y3w; Fri, 14 Aug 2020 13:07:33 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1k6XYa-0003rB-DJ; Fri, 14 Aug 2020 13:07:32 +0200 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1k6XYa-0007Z8-CL; Fri, 14 Aug 2020 13:07:32 +0200 From: Geert Uytterhoeven To: Alessandro Zummo , Alexandre Belloni Cc: Nobuhiro Iwamatsu , kogiidena , Adrian Glaubitz , linux-rtc@vger.kernel.org, linux-sh@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 3/3] rtc: rtc-rs5c313: Convert to module_platform_driver() Date: Fri, 14 Aug 2020 13:07:31 +0200 Message-Id: <20200814110731.29029-4-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200814110731.29029-1-geert+renesas@glider.be> References: <20200814110731.29029-1-geert+renesas@glider.be> Sender: linux-rtc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rtc@vger.kernel.org Reduce boilerplate by using the module_platform_driver() helper. Signed-off-by: Geert Uytterhoeven --- drivers/rtc/rtc-rs5c313.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/rtc/rtc-rs5c313.c b/drivers/rtc/rtc-rs5c313.c index af72e428b218173e..e98f85f34206f16c 100644 --- a/drivers/rtc/rtc-rs5c313.c +++ b/drivers/rtc/rtc-rs5c313.c @@ -384,18 +384,7 @@ static struct platform_driver rs5c313_rtc_platform_driver = { .probe = rs5c313_rtc_probe, }; -static int __init rs5c313_rtc_init(void) -{ - return platform_driver_register(&rs5c313_rtc_platform_driver); -} - -static void __exit rs5c313_rtc_exit(void) -{ - platform_driver_unregister(&rs5c313_rtc_platform_driver); -} - -module_init(rs5c313_rtc_init); -module_exit(rs5c313_rtc_exit); +module_platform_driver(rs5c313_rtc_platform_driver); MODULE_AUTHOR("kogiidena , Nobuhiro Iwamatsu "); MODULE_DESCRIPTION("Ricoh RS5C313 RTC device driver");