From patchwork Mon Sep 24 14:49:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 10612513 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2054F161F for ; Mon, 24 Sep 2018 14:50:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6F5927BA5 for ; Mon, 24 Sep 2018 14:50:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4E192A05A; Mon, 24 Sep 2018 14:50:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SUSPICIOUS_RECIPS autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 42C602A092 for ; Mon, 24 Sep 2018 14:50:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Gja8+MFOcuvTSRiWaWbgcuLn30DvBuaYcPgBhEjlKvU=; b=O76681LdaRtoJM zNhcY3LO5OALLWJzBuoVha1xCnWITpM1ib1mMzWP4/Jy8X9ejviRZDxn+PIFZYB78/VlbGoJzDlwO dZouftHKMhl90eM25mwty9q2Fk4oeUstmcOHUZbz9I79cHqQniKgCm9T2sRvnCiLYCNX6kLZt8np6 um5qMzhxUoZnZCE6pSN4MJ3lDr1L/QerTlJ7HgAxcGhU50DdOfsZfpa5YsJRSmIgD1F0abJltHzVb zgfPTIRactFgC7E38ZL0tNneleKeDGl/sQlhjTDAbna4lfYdl/J51VsvLVMk+8A2WciPy8F4NzEHa 3xWccEHSkHeS3foRTltQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g4SBS-0008A8-32; Mon, 24 Sep 2018 14:49:58 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g4SB3-00086N-0H for linux-arm-kernel@lists.infradead.org; Mon, 24 Sep 2018 14:49:35 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id 7112E20731; Mon, 24 Sep 2018 16:49:08 +0200 (CEST) Received: from localhost (unknown [37.71.171.242]) by mail.bootlin.com (Postfix) with ESMTPSA id 0C8D9204AE; Mon, 24 Sep 2018 16:49:08 +0200 (CEST) From: Alexandre Belloni To: linux-rtc@vger.kernel.org Subject: [PATCH 1/3] rtc: ab8500: use rtc_add_group Date: Mon, 24 Sep 2018 16:49:00 +0200 Message-Id: <20180924144902.607-1-alexandre.belloni@bootlin.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180924_074933_193171_5B056CEF X-CRM114-Status: GOOD ( 12.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Linus Walleij , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Use rtc_add_group to add the sysfs group in a race free manner. Signed-off-by: Alexandre Belloni Reviewed-by: Linus Walleij --- drivers/rtc/rtc-ab8500.c | 41 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c index e28f4401fd35..e97015e5c63e 100644 --- a/drivers/rtc/rtc-ab8500.c +++ b/drivers/rtc/rtc-ab8500.c @@ -360,15 +360,14 @@ static DEVICE_ATTR(rtc_calibration, S_IRUGO | S_IWUSR, ab8500_sysfs_show_rtc_calibration, ab8500_sysfs_store_rtc_calibration); -static int ab8500_sysfs_rtc_register(struct device *dev) -{ - return device_create_file(dev, &dev_attr_rtc_calibration); -} +static struct attribute *ab8500_rtc_attrs[] = { + &dev_attr_rtc_calibration.attr, + NULL +}; -static void ab8500_sysfs_rtc_unregister(struct device *dev) -{ - device_remove_file(dev, &dev_attr_rtc_calibration); -} +static const struct attribute_group ab8500_rtc_sysfs_files = { + .attrs = ab8500_rtc_attrs, +}; static irqreturn_t rtc_alarm_handler(int irq, void *data) { @@ -429,14 +428,11 @@ static int ab8500_rtc_probe(struct platform_device *pdev) device_init_wakeup(&pdev->dev, true); - rtc = devm_rtc_device_register(&pdev->dev, "ab8500-rtc", - (struct rtc_class_ops *)platid->driver_data, - THIS_MODULE); - if (IS_ERR(rtc)) { - dev_err(&pdev->dev, "Registration failed\n"); - err = PTR_ERR(rtc); - return err; - } + rtc = devm_rtc_allocate_device(&pdev->dev); + if (IS_ERR(rtc)) + return PTR_ERR(rtc); + + rtc->ops = (struct rtc_class_ops *)platid->driver_data; err = devm_request_threaded_irq(&pdev->dev, irq, NULL, rtc_alarm_handler, IRQF_ONESHOT, @@ -447,22 +443,19 @@ static int ab8500_rtc_probe(struct platform_device *pdev) dev_pm_set_wake_irq(&pdev->dev, irq); platform_set_drvdata(pdev, rtc); - err = ab8500_sysfs_rtc_register(&pdev->dev); - if (err) { - dev_err(&pdev->dev, "sysfs RTC failed to register\n"); - return err; - } - rtc->uie_unsupported = 1; - return 0; + err = rtc_add_group(rtc, &ab8500_rtc_sysfs_files); + if (err) + return err; + + return rtc_register_device(rtc); } static int ab8500_rtc_remove(struct platform_device *pdev) { dev_pm_clear_wake_irq(&pdev->dev); device_init_wakeup(&pdev->dev, false); - ab8500_sysfs_rtc_unregister(&pdev->dev); return 0; }