linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] rtc: sunxi: fix signedness issues
@ 2015-11-19 10:50 LABBE Corentin
  2015-11-19 10:50 ` [PATCH 2/3] rtc: sunxi: constify the data_year_param structure LABBE Corentin
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: LABBE Corentin @ 2015-11-19 10:50 UTC (permalink / raw)
  To: alexandre.belloni, a.zummo, linux-arm-kernel, maxime.ripard, wens
  Cc: LABBE Corentin, linux-kernel, rtc-linux

The variable year must be set as unsigned since it is used with
sunxi_rtc_data_year{.min|.max} and as parameter of is_leap_year() which
wait for unsigned int.
Only tm_year is not unsigned, but it is long.
This patch fix also the format of printing of min/max. (must use %u since
they are unsigned)

The parameter to of sunxi_rtc_setaie() must be set to uint since callers
give always uint data.

Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
 drivers/rtc/rtc-sunxi.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-sunxi.c b/drivers/rtc/rtc-sunxi.c
index 52543ae..b4f35ac 100644
--- a/drivers/rtc/rtc-sunxi.c
+++ b/drivers/rtc/rtc-sunxi.c
@@ -175,7 +175,7 @@ static irqreturn_t sunxi_rtc_alarmirq(int irq, void *id)
 	return IRQ_NONE;
 }
 
-static void sunxi_rtc_setaie(int to, struct sunxi_rtc_dev *chip)
+static void sunxi_rtc_setaie(unsigned int to, struct sunxi_rtc_dev *chip)
 {
 	u32 alrm_val = 0;
 	u32 alrm_irq_val = 0;
@@ -343,7 +343,7 @@ static int sunxi_rtc_settime(struct device *dev, struct rtc_time *rtc_tm)
 	struct sunxi_rtc_dev *chip = dev_get_drvdata(dev);
 	u32 date = 0;
 	u32 time = 0;
-	int year;
+	unsigned int year;
 
 	/*
 	 * the input rtc_tm->tm_year is the offset relative to 1900. We use
@@ -353,8 +353,8 @@ static int sunxi_rtc_settime(struct device *dev, struct rtc_time *rtc_tm)
 
 	year = rtc_tm->tm_year + 1900;
 	if (year < chip->data_year->min || year > chip->data_year->max) {
-		dev_err(dev, "rtc only supports year in range %d - %d\n",
-				chip->data_year->min, chip->data_year->max);
+		dev_err(dev, "rtc only supports year in range %u - %u\n",
+			chip->data_year->min, chip->data_year->max);
 		return -EINVAL;
 	}
 
-- 
2.4.10


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/3] rtc: sunxi: constify the data_year_param structure
  2015-11-19 10:50 [PATCH 1/3] rtc: sunxi: fix signedness issues LABBE Corentin
@ 2015-11-19 10:50 ` LABBE Corentin
  2015-11-23  7:18   ` Chen-Yu Tsai
  2015-11-30 19:04   ` Alexandre Belloni
  2015-11-19 10:50 ` [PATCH 3/3] rtc: sunxi: use of_device_get_match_data LABBE Corentin
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 9+ messages in thread
From: LABBE Corentin @ 2015-11-19 10:50 UTC (permalink / raw)
  To: alexandre.belloni, a.zummo, linux-arm-kernel, maxime.ripard, wens
  Cc: LABBE Corentin, linux-kernel, rtc-linux

The data_year_param struct is never modified, so lets constify it.
This permit to remove cast since of_device_id is const also.

Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
 drivers/rtc/rtc-sunxi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-sunxi.c b/drivers/rtc/rtc-sunxi.c
index b4f35ac..0c08a5b 100644
--- a/drivers/rtc/rtc-sunxi.c
+++ b/drivers/rtc/rtc-sunxi.c
@@ -133,7 +133,7 @@ struct sunxi_rtc_data_year {
 	unsigned char leap_shift;	/* bit shift to get the leap year */
 };
 
-static struct sunxi_rtc_data_year data_year_param[] = {
+static const struct sunxi_rtc_data_year data_year_param[] = {
 	[0] = {
 		.min		= 2010,
 		.max		= 2073,
@@ -151,7 +151,7 @@ static struct sunxi_rtc_data_year data_year_param[] = {
 struct sunxi_rtc_dev {
 	struct rtc_device *rtc;
 	struct device *dev;
-	struct sunxi_rtc_data_year *data_year;
+	const struct sunxi_rtc_data_year *data_year;
 	void __iomem *base;
 	int irq;
 };
@@ -468,7 +468,7 @@ static int sunxi_rtc_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "Unable to setup RTC data\n");
 		return -ENODEV;
 	}
-	chip->data_year = (struct sunxi_rtc_data_year *) of_id->data;
+	chip->data_year = of_id->data;
 
 	/* clear the alarm count value */
 	writel(0, chip->base + SUNXI_ALRM_DHMS);
-- 
2.4.10


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/3] rtc: sunxi: use of_device_get_match_data
  2015-11-19 10:50 [PATCH 1/3] rtc: sunxi: fix signedness issues LABBE Corentin
  2015-11-19 10:50 ` [PATCH 2/3] rtc: sunxi: constify the data_year_param structure LABBE Corentin
@ 2015-11-19 10:50 ` LABBE Corentin
  2015-11-23  7:18   ` Chen-Yu Tsai
  2015-11-30 19:05   ` Alexandre Belloni
  2015-11-23  7:18 ` [PATCH 1/3] rtc: sunxi: fix signedness issues Chen-Yu Tsai
  2015-11-30 19:04 ` Alexandre Belloni
  3 siblings, 2 replies; 9+ messages in thread
From: LABBE Corentin @ 2015-11-19 10:50 UTC (permalink / raw)
  To: alexandre.belloni, a.zummo, linux-arm-kernel, maxime.ripard, wens
  Cc: LABBE Corentin, linux-kernel, rtc-linux

The usage of of_device_get_match_data reduce the code size a bit.

Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
 drivers/rtc/rtc-sunxi.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/rtc/rtc-sunxi.c b/drivers/rtc/rtc-sunxi.c
index 0c08a5b..abada60 100644
--- a/drivers/rtc/rtc-sunxi.c
+++ b/drivers/rtc/rtc-sunxi.c
@@ -436,7 +436,6 @@ static int sunxi_rtc_probe(struct platform_device *pdev)
 {
 	struct sunxi_rtc_dev *chip;
 	struct resource *res;
-	const struct of_device_id *of_id;
 	int ret;
 
 	chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
@@ -463,12 +462,11 @@ static int sunxi_rtc_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	of_id = of_match_device(sunxi_rtc_dt_ids, &pdev->dev);
-	if (!of_id) {
+	chip->data_year = of_device_get_match_data(&pdev->dev);
+	if (!chip->data_year) {
 		dev_err(&pdev->dev, "Unable to setup RTC data\n");
 		return -ENODEV;
 	}
-	chip->data_year = of_id->data;
 
 	/* clear the alarm count value */
 	writel(0, chip->base + SUNXI_ALRM_DHMS);
-- 
2.4.10


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] rtc: sunxi: fix signedness issues
  2015-11-19 10:50 [PATCH 1/3] rtc: sunxi: fix signedness issues LABBE Corentin
  2015-11-19 10:50 ` [PATCH 2/3] rtc: sunxi: constify the data_year_param structure LABBE Corentin
  2015-11-19 10:50 ` [PATCH 3/3] rtc: sunxi: use of_device_get_match_data LABBE Corentin
@ 2015-11-23  7:18 ` Chen-Yu Tsai
  2015-11-30 19:04 ` Alexandre Belloni
  3 siblings, 0 replies; 9+ messages in thread
From: Chen-Yu Tsai @ 2015-11-23  7:18 UTC (permalink / raw)
  To: LABBE Corentin
  Cc: Alexandre Belloni, Alessandro Zummo, linux-arm-kernel,
	Maxime Ripard, Chen-Yu Tsai, linux-kernel, rtc-linux

On Thu, Nov 19, 2015 at 6:50 PM, LABBE Corentin
<clabbe.montjoie@gmail.com> wrote:
> The variable year must be set as unsigned since it is used with
> sunxi_rtc_data_year{.min|.max} and as parameter of is_leap_year() which
> wait for unsigned int.
> Only tm_year is not unsigned, but it is long.
> This patch fix also the format of printing of min/max. (must use %u since
> they are unsigned)
>
> The parameter to of sunxi_rtc_setaie() must be set to uint since callers
> give always uint data.
>
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>

Acked-by: Chen-Yu Tsai <wens@csie.org>

Would've preferred you not changing the whitespace on the dev_err line though.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] rtc: sunxi: constify the data_year_param structure
  2015-11-19 10:50 ` [PATCH 2/3] rtc: sunxi: constify the data_year_param structure LABBE Corentin
@ 2015-11-23  7:18   ` Chen-Yu Tsai
  2015-11-30 19:04   ` Alexandre Belloni
  1 sibling, 0 replies; 9+ messages in thread
From: Chen-Yu Tsai @ 2015-11-23  7:18 UTC (permalink / raw)
  To: LABBE Corentin
  Cc: Alexandre Belloni, Alessandro Zummo, linux-arm-kernel,
	Maxime Ripard, Chen-Yu Tsai, linux-kernel, rtc-linux

On Thu, Nov 19, 2015 at 6:50 PM, LABBE Corentin
<clabbe.montjoie@gmail.com> wrote:
> The data_year_param struct is never modified, so lets constify it.
> This permit to remove cast since of_device_id is const also.
>
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>

Acked-by: Chen-Yu Tsai <wens@csie.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/3] rtc: sunxi: use of_device_get_match_data
  2015-11-19 10:50 ` [PATCH 3/3] rtc: sunxi: use of_device_get_match_data LABBE Corentin
@ 2015-11-23  7:18   ` Chen-Yu Tsai
  2015-11-30 19:05   ` Alexandre Belloni
  1 sibling, 0 replies; 9+ messages in thread
From: Chen-Yu Tsai @ 2015-11-23  7:18 UTC (permalink / raw)
  To: LABBE Corentin
  Cc: Alexandre Belloni, Alessandro Zummo, linux-arm-kernel,
	Maxime Ripard, Chen-Yu Tsai, linux-kernel, rtc-linux

On Thu, Nov 19, 2015 at 6:50 PM, LABBE Corentin
<clabbe.montjoie@gmail.com> wrote:
> The usage of of_device_get_match_data reduce the code size a bit.
>
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>

Acked-by: Chen-Yu Tsai <wens@csie.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/3] rtc: sunxi: fix signedness issues
  2015-11-19 10:50 [PATCH 1/3] rtc: sunxi: fix signedness issues LABBE Corentin
                   ` (2 preceding siblings ...)
  2015-11-23  7:18 ` [PATCH 1/3] rtc: sunxi: fix signedness issues Chen-Yu Tsai
@ 2015-11-30 19:04 ` Alexandre Belloni
  3 siblings, 0 replies; 9+ messages in thread
From: Alexandre Belloni @ 2015-11-30 19:04 UTC (permalink / raw)
  To: LABBE Corentin
  Cc: a.zummo, linux-arm-kernel, maxime.ripard, wens, linux-kernel, rtc-linux

On 19/11/2015 at 11:50:08 +0100, LABBE Corentin wrote :
> The variable year must be set as unsigned since it is used with
> sunxi_rtc_data_year{.min|.max} and as parameter of is_leap_year() which
> wait for unsigned int.
> Only tm_year is not unsigned, but it is long.
> This patch fix also the format of printing of min/max. (must use %u since
> they are unsigned)
> 
> The parameter to of sunxi_rtc_setaie() must be set to uint since callers
> give always uint data.
> 
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
> ---
>  drivers/rtc/rtc-sunxi.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/3] rtc: sunxi: constify the data_year_param structure
  2015-11-19 10:50 ` [PATCH 2/3] rtc: sunxi: constify the data_year_param structure LABBE Corentin
  2015-11-23  7:18   ` Chen-Yu Tsai
@ 2015-11-30 19:04   ` Alexandre Belloni
  1 sibling, 0 replies; 9+ messages in thread
From: Alexandre Belloni @ 2015-11-30 19:04 UTC (permalink / raw)
  To: LABBE Corentin
  Cc: a.zummo, linux-arm-kernel, maxime.ripard, wens, linux-kernel, rtc-linux

On 19/11/2015 at 11:50:09 +0100, LABBE Corentin wrote :
> The data_year_param struct is never modified, so lets constify it.
> This permit to remove cast since of_device_id is const also.
> 
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
> ---
>  drivers/rtc/rtc-sunxi.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/3] rtc: sunxi: use of_device_get_match_data
  2015-11-19 10:50 ` [PATCH 3/3] rtc: sunxi: use of_device_get_match_data LABBE Corentin
  2015-11-23  7:18   ` Chen-Yu Tsai
@ 2015-11-30 19:05   ` Alexandre Belloni
  1 sibling, 0 replies; 9+ messages in thread
From: Alexandre Belloni @ 2015-11-30 19:05 UTC (permalink / raw)
  To: LABBE Corentin
  Cc: a.zummo, linux-arm-kernel, maxime.ripard, wens, linux-kernel, rtc-linux

On 19/11/2015 at 11:50:10 +0100, LABBE Corentin wrote :
> The usage of of_device_get_match_data reduce the code size a bit.
> 
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
> ---
>  drivers/rtc/rtc-sunxi.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
Applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-11-30 19:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-19 10:50 [PATCH 1/3] rtc: sunxi: fix signedness issues LABBE Corentin
2015-11-19 10:50 ` [PATCH 2/3] rtc: sunxi: constify the data_year_param structure LABBE Corentin
2015-11-23  7:18   ` Chen-Yu Tsai
2015-11-30 19:04   ` Alexandre Belloni
2015-11-19 10:50 ` [PATCH 3/3] rtc: sunxi: use of_device_get_match_data LABBE Corentin
2015-11-23  7:18   ` Chen-Yu Tsai
2015-11-30 19:05   ` Alexandre Belloni
2015-11-23  7:18 ` [PATCH 1/3] rtc: sunxi: fix signedness issues Chen-Yu Tsai
2015-11-30 19:04 ` Alexandre Belloni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).