From patchwork Fri Aug 22 20:42:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 4767041 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 18DE6C0338 for ; Fri, 22 Aug 2014 20:42:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2F88420158 for ; Fri, 22 Aug 2014 20:42:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 44DC42013D for ; Fri, 22 Aug 2014 20:42:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751327AbaHVUmH (ORCPT ); Fri, 22 Aug 2014 16:42:07 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36661 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751234AbaHVUmG (ORCPT ); Fri, 22 Aug 2014 16:42:06 -0400 Received: from akpm3.mtv.corp.google.com (unknown [216.239.45.95]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3B21498F; Fri, 22 Aug 2014 20:42:05 +0000 (UTC) Date: Fri, 22 Aug 2014 13:42:04 -0700 From: Andrew Morton To: y@samsung.com Cc: a.zummo@towertech.it, kgene.kim@samsung.com, kyungmin.park@samsung.com, rtc-linux@googlegroups.com, linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, Chanwoo Choi Subject: Re: [PATCHv2 1/5] rtc: s3c: Define s3c_rtc structure to remove global variables. Message-Id: <20140822134204.1fa5be7aeb76a50b45ccc5f5@linux-foundation.org> In-Reply-To: <1407808871-6046-2-git-send-email-y@samsung.com> References: <1407808871-6046-1-git-send-email-y@samsung.com> <1407808871-6046-2-git-send-email-y@samsung.com> X-Mailer: Sylpheed 3.2.0beta5 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 On Tue, 12 Aug 2014 11:01:07 +0900 y@samsung.com wrote: > This patch define s3c_rtc structure including necessary variables for S3C RTC > device instead of global variables. This patch improves the readability by > removing global variables. Below is the v1->v2 delta. Why were all those tests of info->base added? Can it really be zero? I don't see how. --- a/drivers/rtc/rtc-s3c.c~rtc-s3c-define-s3c_rtc-structure-to-remove-global-variables-v2 +++ a/drivers/rtc/rtc-s3c.c @@ -121,6 +121,9 @@ static int s3c_rtc_setaie(struct device struct s3c_rtc *info = dev_get_drvdata(dev); unsigned int tmp; + if (!info->base) + return -EINVAL; + dev_dbg(info->dev, "%s: aie=%d\n", __func__, enabled); clk_enable(info->rtc_clk); @@ -180,6 +183,9 @@ static int s3c_rtc_gettime(struct device struct s3c_rtc *info = dev_get_drvdata(dev); unsigned int have_retried = 0; + if (!info->base) + return -EINVAL; + clk_enable(info->rtc_clk); retry_get_time: rtc_tm->tm_min = readb(info->base + S3C2410_RTCMIN); @@ -224,6 +230,9 @@ static int s3c_rtc_settime(struct device struct s3c_rtc *info = dev_get_drvdata(dev); int year = tm->tm_year - 100; + if (!info->base) + return -EINVAL; + dev_dbg(dev, "set time %04d.%02d.%02d %02d:%02d:%02d\n", 1900 + tm->tm_year, tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); @@ -255,6 +264,9 @@ static int s3c_rtc_getalarm(struct devic struct rtc_time *alm_tm = &alrm->time; unsigned int alm_en; + if (!info->base) + return -EINVAL; + clk_enable(info->rtc_clk); alm_tm->tm_sec = readb(info->base + S3C2410_ALMSEC); alm_tm->tm_min = readb(info->base + S3C2410_ALMMIN); @@ -317,6 +329,9 @@ static int s3c_rtc_setalarm(struct devic struct rtc_time *tm = &alrm->time; unsigned int alrm_en; + if (!info->base) + return -EINVAL; + clk_enable(info->rtc_clk); dev_dbg(dev, "s3c_rtc_setalarm: %d, %04d.%02d.%02d %02d:%02d:%02d\n", alrm->enabled, @@ -357,6 +372,9 @@ static int s3c_rtc_proc(struct device *d struct s3c_rtc *info = dev_get_drvdata(dev); unsigned int ticnt; + if (!info->base) + return -EINVAL; + clk_enable(info->rtc_clk); if (info->cpu_type == TYPE_S3C64XX) { ticnt = readw(info->base + S3C2410_RTCCON); @@ -548,7 +566,7 @@ static int s3c_rtc_probe(struct platform rtc_tm.tm_min = 0; rtc_tm.tm_sec = 0; - s3c_rtc_settime(NULL, &rtc_tm); + s3c_rtc_settime(&pdev->dev, &rtc_tm); dev_warn(&pdev->dev, "warning: invalid RTC value so initializing it\n"); }