RE: [PATCHv3 7/17] dmtimer: use list instead of static array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 

> -----Original Message-----
> From: linux-omap-owner@xxxxxxxxxxxxxxx 
> [mailto:linux-omap-owner@xxxxxxxxxxxxxxx] On Behalf Of 
> DebBarma, Tarun Kanti
> Sent: Tuesday, September 21, 2010 2:23 PM
> To: linux-omap@xxxxxxxxxxxxxxx
> Cc: DebBarma, Tarun Kanti; Cousson, Benoit; Paul Walmsley; 
> Kevin Hilman; Tony Lindgren
> Subject: [PATCHv3 7/17] dmtimer: use list instead of static array
> 
> This patch converts the use of dmtimers static array in 
> functions into list structure. Please note that the static 
> arrays will be completely removed in subsequent patches when 
> dmtimer is converted into a platform driver.
> 
> Signed-off-by: Tarun Kanti DebBarma <tarun.kanti@xxxxxx>
> Cc: Cousson, Benoit <b-cousson@xxxxxx>
> Cc: Paul Walmsley <paul@xxxxxxxxx>
> Cc: Kevin Hilman <khilman@xxxxxxxxxxxxxxxxxxx>
> Cc: Tony Lindgren <tony@xxxxxxxxxxx>
> ---
>  arch/arm/plat-omap/dmtimer.c |   61 
> ++++++++++++++++++++++--------------------
>  1 files changed, 32 insertions(+), 29 deletions(-)
> 
> diff --git a/arch/arm/plat-omap/dmtimer.c 
> b/arch/arm/plat-omap/dmtimer.c index a7b1679..2d4805d 100644
> --- a/arch/arm/plat-omap/dmtimer.c
> +++ b/arch/arm/plat-omap/dmtimer.c
> @@ -169,6 +169,7 @@ struct omap_dm_timer {
>  	unsigned enabled:1;
>  	unsigned posted:1;
>  	struct platform_device *pdev;
> +	struct list_head node;
>  };
>  
>  static int dm_timer_count;
> @@ -291,7 +292,8 @@ static struct omap_dm_timer *dm_timers;  
> static const char **dm_source_names;  static struct clk 
> **dm_source_clocks;
>  
> -static spinlock_t dm_timer_lock;
> +static LIST_HEAD(omap_timer_list);
> +static DEFINE_SPINLOCK(dm_timer_lock);
>  
>  /*
>   * Reads timer registers in posted and non-posted mode. The 
> posted mode bit @@ -341,7 +343,7 @@ static void 
> omap_dm_timer_reset(struct omap_dm_timer *timer)  {
>  	u32 l;
>  
> -	if (!cpu_class_is_omap2() || timer != &dm_timers[0]) {
> +	if (!cpu_class_is_omap2() || timer->id != 0) {
>  		omap_dm_timer_write_reg(timer, 
> OMAP_TIMER_IF_CTRL_REG, 0x06);
>  		omap_dm_timer_wait_for_reset(timer);
>  	}
> @@ -374,20 +376,17 @@ struct omap_dm_timer 
> *omap_dm_timer_request(void)  {
>  	struct omap_dm_timer *timer = NULL;
>  	unsigned long flags;
> -	int i;
>  
>  	spin_lock_irqsave(&dm_timer_lock, flags);
> -	for (i = 0; i < dm_timer_count; i++) {
> -		if (dm_timers[i].reserved)
> +	list_for_each_entry(timer, &omap_timer_list, node) {
> +		if (timer->reserved)
>  			continue;
> -
> -		timer = &dm_timers[i];
>  		timer->reserved = 1;
>  		break;
>  	}
>  	spin_unlock_irqrestore(&dm_timer_lock, flags);
>  
> -	if (timer != NULL)
> +	if (timer)
>  		omap_dm_timer_prepare(timer);
>  
>  	return timer;
> @@ -396,23 +395,20 @@ EXPORT_SYMBOL_GPL(omap_dm_timer_request);
>  
>  struct omap_dm_timer *omap_dm_timer_request_specific(int id)  {
> -	struct omap_dm_timer *timer;
> +	struct omap_dm_timer *timer = NULL;
>  	unsigned long flags;
>  
>  	spin_lock_irqsave(&dm_timer_lock, flags);
> -	if (id <= 0 || id > dm_timer_count || 
> dm_timers[id-1].reserved) {
> -		spin_unlock_irqrestore(&dm_timer_lock, flags);
> -		printk("BUG: warning at %s:%d/%s(): unable to 
> get timer %d\n",
> -		       __FILE__, __LINE__, __func__, id);
> -		dump_stack();
> -		return NULL;
> +	list_for_each_entry(timer, &omap_timer_list, node) {
> +		if (timer->id == id - 1 && !timer->reserved) {
> +			timer->reserved = 1;
> +			break;
> +		}
>  	}
> -
> -	timer = &dm_timers[id-1];
> -	timer->reserved = 1;
>  	spin_unlock_irqrestore(&dm_timer_lock, flags);
>  
> -	omap_dm_timer_prepare(timer);
> +	if (timer)
> +		omap_dm_timer_prepare(timer);

if timer is null, atleast warning message to the caller will be useful
incase requested timer is not available.

-Manjunath
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux