mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: "Opensource [Steve Twiss]" <stwiss.opensource@diasemi.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
	Lee Jones <lee.jones@linaro.org>, Mark Brown <broonie@linaro.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Samuel Ortiz <sameo@linux.intel.com>,
	David Dajun Chen <david.chen@diasemi.com>,
	LKML <linux-kernel@vger.kernel.org>,
	RTC linux <rtc-linux@googlegroups.com>
Subject: Re: [RESEND] [PATCH V1 2/2] rtc: da9063: RTC driver
Date: Wed, 7 May 2014 13:01:06 -0700	[thread overview]
Message-ID: <20140507130106.409f65f673317710104d7681@linux-foundation.org> (raw)
In-Reply-To: <3cca26c6dedcfd95df75d44e10a27447350c6e35.1399465372.git.stwiss.opensource@diasemi.com>

On Wed, 7 May 2014 13:22:52 +0100 "Opensource [Steve Twiss]" <stwiss.opensource@diasemi.com> wrote:

> Add the RTC driver for DA9063.

A few minor things:

>
> ...
>
> +static int da9063_rtc_stop_alarm(struct device *dev)
> +{
> +	struct da9063_rtc *rtc = dev_get_drvdata(dev);
> +	return regmap_update_bits(rtc->hw->regmap, DA9063_REG_ALARM_Y,
> +				  DA9063_ALARM_ON, 0);
> +}
> +
> +static int da9063_rtc_start_alarm(struct device *dev)
> +{
> +	struct da9063_rtc *rtc = dev_get_drvdata(dev);
> +	return regmap_update_bits(rtc->hw->regmap, DA9063_REG_ALARM_Y,
> +				  DA9063_ALARM_ON, DA9063_ALARM_ON);
> +}

It's conventional to put a newline between end-of-locals and
start-of-code.  My version of checkpatch warns about this and soon
everyone's will.

> +static int da9063_rtc_read_time(struct device *dev, struct rtc_time *tm)
> +{
> +	struct da9063_rtc *rtc = dev_get_drvdata(dev);
> +	unsigned long tm_secs;
> +	unsigned long al_secs;
> +	u8 data[RTC_DATA_LEN];
> +	int ret;
> +
> +	ret = regmap_bulk_read(rtc->hw->regmap, DA9063_REG_COUNT_S,
> +			       data, RTC_DATA_LEN);
> +	if (ret < 0) {
> +		dev_err(dev, "Failed to read RTC time data: %d\n", ret);
> +		return ret;
> +	}
> +
> +	if (!(data[RTC_SEC] & DA9063_RTC_READ)) {
> +		dev_dbg(dev, "RTC not yet ready to be read by the host\n");
> +		return -EINVAL;
> +	}
> +
> +	da9063_data_to_tm(data, tm);
> +
> +	(void)rtc_tm_to_time(tm, &tm_secs);
> +	(void)rtc_tm_to_time(&rtc->alarm_time, &al_secs);

The void casts are a bit useful - they tell the reader that the author
deliberately chose to ignore the return value.  But kernel code
generally doesn't do this trick.


> +	/* handle the rtc synchronisation delay */
> +	if (rtc->rtc_sync == true && al_secs - tm_secs == 1)
> +		(void)memcpy((void *)tm, (const void *)&rtc->alarm_time,
> +			     sizeof(struct rtc_time));

And all three casts here are unneeded.

And they're actually a bit harmful.  If rtc->alarm_time has type `int'
then we really want the warning, but this cast will suppress it.

> +	else
> +		rtc->rtc_sync = false;
> +
> +	return rtc_valid_tm(tm);
> +}


So how does this look?

--- a/drivers/rtc/rtc-da9063.c~rtc-da9063-rtc-driver-fix
+++ a/drivers/rtc/rtc-da9063.c
@@ -82,6 +82,7 @@ static void da9063_tm_to_data(struct rtc
 static int da9063_rtc_stop_alarm(struct device *dev)
 {
 	struct da9063_rtc *rtc = dev_get_drvdata(dev);
+
 	return regmap_update_bits(rtc->hw->regmap, DA9063_REG_ALARM_Y,
 				  DA9063_ALARM_ON, 0);
 }
@@ -89,6 +90,7 @@ static int da9063_rtc_stop_alarm(struct
 static int da9063_rtc_start_alarm(struct device *dev)
 {
 	struct da9063_rtc *rtc = dev_get_drvdata(dev);
+
 	return regmap_update_bits(rtc->hw->regmap, DA9063_REG_ALARM_Y,
 				  DA9063_ALARM_ON, DA9063_ALARM_ON);
 }
@@ -115,13 +117,12 @@ static int da9063_rtc_read_time(struct d
 
 	da9063_data_to_tm(data, tm);
 
-	(void)rtc_tm_to_time(tm, &tm_secs);
-	(void)rtc_tm_to_time(&rtc->alarm_time, &al_secs);
+	rtc_tm_to_time(tm, &tm_secs);
+	rtc_tm_to_time(&rtc->alarm_time, &al_secs);
 
 	/* handle the rtc synchronisation delay */
 	if (rtc->rtc_sync == true && al_secs - tm_secs == 1)
-		(void)memcpy((void *)tm, (const void *)&rtc->alarm_time,
-			     sizeof(struct rtc_time));
+		memcpy(tm, &rtc->alarm_time, sizeof(struct rtc_time));
 	else
 		rtc->rtc_sync = false;
 
_


  reply	other threads:[~2014-05-07 20:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-07 12:22 [RESEND] [PATCH V1 0/2] da9063: Support for RTC and register definition updates Opensource [Steve Twiss]
2014-05-07 12:22 ` [RESEND] [PATCH V1 1/2] mfd: da9063: Upgrade of register definitions to support production silicon Opensource [Steve Twiss]
2014-05-08  8:00   ` Lee Jones
2014-05-07 12:22 ` [RESEND] [PATCH V1 2/2] rtc: da9063: RTC driver Opensource [Steve Twiss]
2014-05-07 20:01   ` Andrew Morton [this message]
2014-05-08 14:25     ` Opensource [Steve Twiss]
  -- strict thread matches above, loose matches on Subject: below --
2014-03-06 16:40 [PATCH V1 0/2] da9063: Support for RTC and register definition updates Opensource [Steve Twiss]
2014-03-06 16:40 ` [PATCH V1 2/2] rtc: da9063: RTC driver Opensource [Steve Twiss]
2014-03-11 12:27   ` [RESEND] " Lee Jones
2014-03-11 13:21     ` Opensource [Steve Twiss]
2014-03-21 14:17     ` Opensource [Steve Twiss]
2014-03-25 16:46     ` Opensource [Steve Twiss]
2014-03-26  7:52       ` Lee Jones
2014-03-26  8:11         ` Opensource [Steve Twiss]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140507130106.409f65f673317710104d7681@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=a.zummo@towertech.it \
    --cc=broonie@linaro.org \
    --cc=david.chen@diasemi.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=rtc-linux@googlegroups.com \
    --cc=sameo@linux.intel.com \
    --cc=stwiss.opensource@diasemi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®