lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120220150648.GE26840@n2100.arm.linux.org.uk>
Date:	Mon, 20 Feb 2012 15:06:48 +0000
From:	Russell King - ARM Linux <linux@....linux.org.uk>
To:	Nicolas Ferre <nicolas.ferre@...el.com>
Cc:	rmallon@...il.com, plagnioj@...osoft.com,
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ARM: at91/rtc-at91sam9: rework resources assignment

On Mon, Feb 20, 2012 at 03:45:42PM +0100, Nicolas Ferre wrote:
> Signed-off-by: Nicolas Ferre <nicolas.ferre@...el.com>
> ---
> Russell, Ryan,
> 
> As I do think that these changes need explanation, here is my rework of Jean's
> patch. I would like to know if the little comment and general rework of
> resources assignment sound ok...

Nicolas, thanks for this.

This is way better by miles than Jean's patch, and shows how it should
have been done in the first place.

> I plan to merge this patch with the one discussed previously:
> "[PATCH 13/18] ARM: at91/rtc-at91sam9: pass the GPBR to use via ressources"
> 
> If you agree, I will repost the whole series afterwards.
> 
> 
>  arch/arm/mach-at91/at91sam9260_devices.c |   13 ++++++++++---
>  arch/arm/mach-at91/at91sam9261_devices.c |   13 ++++++++++---
>  arch/arm/mach-at91/at91sam9263_devices.c |   22 ++++++++++++++++------
>  arch/arm/mach-at91/at91sam9g45_devices.c |   13 ++++++++++---
>  arch/arm/mach-at91/at91sam9rl_devices.c  |   13 ++++++++++---
>  5 files changed, 56 insertions(+), 18 deletions(-)
> 
> diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
> index f8a88fb..df487ce 100644
> --- a/arch/arm/mach-at91/at91sam9260_devices.c
> +++ b/arch/arm/mach-at91/at91sam9260_devices.c
> @@ -727,7 +727,6 @@ static struct platform_device at91sam9260_rtt_device = {
>  	.name		= "at91_rtt",
>  	.id		= 0,
>  	.resource	= rtt_resources,
> -	.num_resources	= 1,
>  };
>  
>  
> @@ -735,13 +734,21 @@ static struct platform_device at91sam9260_rtt_device = {
>  static void __init at91_add_device_rtt_rtc(void)
>  {
>  	at91sam9260_rtt_device.name = "rtc-at91sam9";
> -	at91sam9260_rtt_device.num_resources++;
> +	/*
> +	 * The second resource is needed:
> +	 * GPBR will serve as the storage for RTC time offset
> +	 */
> +	at91sam9260_rtt_device.num_resources = 2;
>  	rtt_resources[1].start = AT91SAM9260_BASE_GPBR +
>  				 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
>  	rtt_resources[1].end = rtt_resources[1].start + 3;
>  }
>  #else
> -static void __init at91_add_device_rtt_rtc(void) {}
> +static void __init at91_add_device_rtt_rtc(void)
> +{
> +	/* Only one resource is needed: RTT not used as RTC */
> +	at91sam9260_rtt_device.num_resources = 1;
> +}
>  #endif
>  
>  static void __init at91_add_device_rtt(void)
> diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
> index 32a20ef..3bd10ce 100644
> --- a/arch/arm/mach-at91/at91sam9261_devices.c
> +++ b/arch/arm/mach-at91/at91sam9261_devices.c
> @@ -613,20 +613,27 @@ static struct platform_device at91sam9261_rtt_device = {
>  	.name		= "at91_rtt",
>  	.id		= 0,
>  	.resource	= rtt_resources,
> -	.num_resources	= 1,
>  };
>  
>  #if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
>  static void __init at91_add_device_rtt_rtc(void)
>  {
>  	at91sam9261_rtt_device.name = "rtc-at91sam9";
> -	at91sam9261_rtt_device.num_resources++;
> +	/*
> +	 * The second resource is needed:
> +	 * GPBR will serve as the storage for RTC time offset
> +	 */
> +	at91sam9261_rtt_device.num_resources = 2;
>  	rtt_resources[1].start = AT91SAM9261_BASE_GPBR +
>  				 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
>  	rtt_resources[1].end = rtt_resources[1].start + 3;
>  }
>  #else
> -static void __init at91_add_device_rtt_rtc(void) {}
> +static void __init at91_add_device_rtt_rtc(void)
> +{
> +	/* Only one resource is needed: RTT not used as RTC */
> +	at91sam9261_rtt_device.num_resources = 1;
> +}
>  #endif
>  
>  static void __init at91_add_device_rtt(void)
> diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
> index 28cb074..7792de5 100644
> --- a/arch/arm/mach-at91/at91sam9263_devices.c
> +++ b/arch/arm/mach-at91/at91sam9263_devices.c
> @@ -976,7 +976,6 @@ static struct platform_device at91sam9263_rtt0_device = {
>  	.name		= "at91_rtt",
>  	.id		= 0,
>  	.resource	= rtt0_resources,
> -	.num_resources	= 1,
>  };
>  
>  static struct resource rtt1_resources[] = {
> @@ -993,7 +992,6 @@ static struct platform_device at91sam9263_rtt1_device = {
>  	.name		= "at91_rtt",
>  	.id		= 1,
>  	.resource	= rtt1_resources,
> -	.num_resources	= 1,
>  };
>  
>  #if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
> @@ -1004,26 +1002,38 @@ static void __init at91_add_device_rtt_rtc(void)
>  
>  	switch (CONFIG_RTC_DRV_AT91SAM9_RTT) {
>  	case 0:
> +		/*
> +		 * The second resource is needed only for the chosen RTT:
> +		 * GPBR will serve as the storage for RTC time offset
> +		 */
> +		at91sam9263_rtt0_device.num_resources = 2;
> +		at91sam9263_rtt1_device.num_resources = 1;
>  		pdev = &at91sam9263_rtt0_device;
>  		r = rtt0_resources;
>  		break;
>  	case 1:
> +		at91sam9263_rtt0_device.num_resources = 1;
> +		at91sam9263_rtt1_device.num_resources = 2;
>  		pdev = &at91sam9263_rtt1_device;
>  		r = rtt1_resources;
>  		break;
>  	default:
> -		pr_err("at91sam9263: support only 2 RTT (%d)\n",
> +		pr_err("at91sam9263: only supports 2 RTT (%d)\n",
>  		       CONFIG_RTC_DRV_AT91SAM9_RTT);
>  		return;
>  	}
>  
> +	pdev->name = "rtc-at91sam9";
>  	r[1].start = AT91SAM9263_BASE_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
>  	r[1].end = r[1].start + 3;
> -	pdev->name = "rtc-at91sam9";
> -	pdev->num_resources++;
>  }
>  #else
> -static void __init at91_add_device_rtt_rtc(void) {}
> +static void __init at91_add_device_rtt_rtc(void)
> +{
> +	/* Only one resource is needed: RTT not used as RTC */
> +	at91sam9263_rtt0_device.num_resources = 1;
> +	at91sam9263_rtt1_device.num_resources = 1;
> +}
>  #endif
>  
>  static void __init at91_add_device_rtt(void)
> diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
> index bb7e2ce..4108295 100644
> --- a/arch/arm/mach-at91/at91sam9g45_devices.c
> +++ b/arch/arm/mach-at91/at91sam9g45_devices.c
> @@ -1203,20 +1203,27 @@ static struct platform_device at91sam9g45_rtt_device = {
>  	.name		= "at91_rtt",
>  	.id		= 0,
>  	.resource	= rtt_resources,
> -	.num_resources	= 1,
>  };
>  
>  #if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
>  static void __init at91_add_device_rtt_rtc(void)
>  {
>  	at91sam9g45_rtt_device.name = "rtc-at91sam9";
> -	at91sam9g45_rtt_device.num_resources++;
> +	/*
> +	 * The second resource is needed:
> +	 * GPBR will serve as the storage for RTC time offset
> +	 */
> +	at91sam9g45_rtt_device.num_resources = 2;
>  	rtt_resources[1].start = AT91SAM9G45_BASE_GPBR +
>  				 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
>  	rtt_resources[1].end = rtt_resources[1].start + 3;
>  }
>  #else
> -static void __init at91_add_device_rtt_rtc(void) {}
> +static void __init at91_add_device_rtt_rtc(void)
> +{
> +	/* Only one resource is needed: RTT not used as RTC */
> +	at91sam9g45_rtt_device.num_resources = 1;
> +}
>  #endif
>  
>  static void __init at91_add_device_rtt(void)
> diff --git a/arch/arm/mach-at91/at91sam9rl_devices.c b/arch/arm/mach-at91/at91sam9rl_devices.c
> index 16fd20b..eda72e8 100644
> --- a/arch/arm/mach-at91/at91sam9rl_devices.c
> +++ b/arch/arm/mach-at91/at91sam9rl_devices.c
> @@ -692,20 +692,27 @@ static struct platform_device at91sam9rl_rtt_device = {
>  	.name		= "at91_rtt",
>  	.id		= 0,
>  	.resource	= rtt_resources,
> -	.num_resources	= 1,
>  };
>  
>  #if IS_ENABLED(CONFIG_RTC_DRV_AT91SAM9)
>  static void __init at91_add_device_rtt_rtc(void)
>  {
>  	at91sam9rl_rtt_device.name = "rtc-at91sam9";
> -	at91sam9rl_rtt_device.num_resources++;
> +	/*
> +	 * The second resource is needed:
> +	 * GPBR will serve as the storage for RTC time offset
> +	 */
> +	at91sam9rl_rtt_device.num_resources = 2;
>  	rtt_resources[1].start = AT91SAM9RL_BASE_GPBR +
>  				 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR;
>  	rtt_resources[1].end = rtt_resources[1].start + 3;
>  }
>  #else
> -static void __init at91_add_device_rtt_rtc(void) {}
> +static void __init at91_add_device_rtt_rtc(void)
> +{
> +	/* Only one resource is needed: RTT not used as RTC */
> +	at91sam9rl_rtt_device.num_resources = 1;
> +}
>  #endif
>  
>  static void __init at91_add_device_rtt(void)
> -- 
> 1.7.9
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ