From patchwork Thu Jul 9 06:55:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaibhav Hiremath X-Patchwork-Id: 6753381 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 75B81C05AC for ; Thu, 9 Jul 2015 07:02:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EFB93205E9 for ; Thu, 9 Jul 2015 07:01:55 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 157B0205E7 for ; Thu, 9 Jul 2015 07:01:55 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZD5n1-0004s6-TL; Thu, 09 Jul 2015 06:58:35 +0000 Received: from mail-pa0-f41.google.com ([209.85.220.41]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZD5my-0004pH-Da for linux-arm-kernel@lists.infradead.org; Thu, 09 Jul 2015 06:58:33 +0000 Received: by pacws9 with SMTP id ws9so147017276pac.0 for ; Wed, 08 Jul 2015 23:58:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=eL4Ag/d97Gz6IwWtGMizxpA1zY9PDQYhcbw//uznkns=; b=e534ox9ZT8tF6pRc05Jwc96hZ47qVvEz/kqEeyjr9hkT75Y4XS9ijL6TzUNnmxBcFS /+F/k+mk+6yMvloUD83HvxAL1RH7zyDFouBmnHQpNGFw4pMOr0TX4xy82rvayzd2k71C LrrSR4vSf4KAAny/si2htqASLAWYQZTdLHl5qOb3TwIQVKWuB6tb2fQE0OtZc9G4+F3I 7cpoPaOyK6FwTnPgH3ieV4GNcqM3Xr9Wzmm03GcGWUbOe7p4/KExS3dH5lKXjCDJHUId cq/ZZzSyM+Pi8Vi4YGEp++RWZe9TWaUIsnSH2f5ld0ySFaS1YV83e/YOmUR+xsPOA+DC Zzlg== X-Gm-Message-State: ALoCoQmwypFW6vQ2t/GOLKFXfm1CSNXWRDfKhlDkvaWCHaZi7d4hrxXlV9L3EqVXsWzs8QNf9lHV X-Received: by 10.70.102.11 with SMTP id fk11mr28084569pdb.144.1436425088294; Wed, 08 Jul 2015 23:58:08 -0700 (PDT) Received: from localhost.localdomain ([202.62.77.106]) by smtp.gmail.com with ESMTPSA id h12sm4701100pdk.77.2015.07.08.23.58.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jul 2015 23:58:06 -0700 (PDT) From: Vaibhav Hiremath To: linux-arm-kernel@lists.infradead.org Subject: [RESEND PATCH-v2] rtc: 88pm80x: add device tree support Date: Thu, 9 Jul 2015 12:25:51 +0530 Message-Id: <1436424952-29680-1-git-send-email-vaibhav.hiremath@linaro.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150708_235832_493495_802DB9F9 X-CRM114-Status: GOOD ( 15.11 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alessandro Zummo , "open list:REAL TIME CLOCK RTC SUBSYSTEM" , open list , Vaibhav Hiremath , Alexandre Belloni , Chao Xie MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Along with DT support, this patch also cleans up the unnecessary code around 'rtc_wakeup' initialization. Signed-off-by: Chao Xie Signed-off-by: Vaibhav Hiremath --- drivers/rtc/rtc-88pm80x.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/drivers/rtc/rtc-88pm80x.c b/drivers/rtc/rtc-88pm80x.c index 7df0579..8f66519 100644 --- a/drivers/rtc/rtc-88pm80x.c +++ b/drivers/rtc/rtc-88pm80x.c @@ -251,17 +251,26 @@ static SIMPLE_DEV_PM_OPS(pm80x_rtc_pm_ops, pm80x_rtc_suspend, pm80x_rtc_resume); static int pm80x_rtc_probe(struct platform_device *pdev) { struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent); - struct pm80x_platform_data *pm80x_pdata = - dev_get_platdata(pdev->dev.parent); - struct pm80x_rtc_pdata *pdata = NULL; + struct pm80x_rtc_pdata *pdata = dev_get_platdata(&pdev->dev); struct pm80x_rtc_info *info; + struct device_node *node = pdev->dev.of_node; struct rtc_time tm; unsigned long ticks = 0; int ret; - pdata = dev_get_platdata(&pdev->dev); - if (pdata == NULL) - dev_warn(&pdev->dev, "No platform data!\n"); + if (!pdata && !node) { + dev_err(&pdev->dev, + "pm80x-rtc requires platform data or of_node\n"); + return -EINVAL; + } + + if (!pdata) { + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) { + dev_err(&pdev->dev, "failed to allocate memory\n"); + return -ENOMEM; + } + } info = devm_kzalloc(&pdev->dev, sizeof(struct pm80x_rtc_info), GFP_KERNEL); @@ -327,11 +336,8 @@ static int pm80x_rtc_probe(struct platform_device *pdev) regmap_update_bits(info->map, PM800_RTC_CONTROL, PM800_RTC1_USE_XO, PM800_RTC1_USE_XO); - if (pm80x_pdata) { - pdata = pm80x_pdata->rtc; - if (pdata) - info->rtc_dev->dev.platform_data = &pdata->rtc_wakeup; - } + /* remeber whether this power up is caused by PMIC RTC or not */ + info->rtc_dev->dev.platform_data = &pdata->rtc_wakeup; device_init_wakeup(&pdev->dev, 1);