Re: [PATCH 8/10] omap mailbox: OMAP4-Mailbox - Adds code changes to support OMAP4 mailbox.

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

 



On Fri, Sep 04, 2009 at 05:18:11PM +0530, C.A, Subramaniam wrote:
> @@ -70,31 +89,37 @@ static inline void mbox_write_reg(u32 val, size_t ofs)
>  static int omap2_mbox_startup(struct omap_mbox *mbox)
>  {
>  	unsigned int l;
> +	if (!mbox_configured) {
> +		mbox_ick_handle = clk_get(NULL, "mailboxes_ick");
> +		if (IS_ERR(mbox_ick_handle)) {
> +			printk(KERN_ERR "Could not get mailboxes_ick\n");
> +			return -ENODEV;
> +		}
> +		clk_enable(mbox_ick_handle);
>  
> -	mbox_ick_handle = clk_get(NULL, "mailboxes_ick");
> -	if (IS_ERR(mbox_ick_handle)) {
> -		printk("Could not get mailboxes_ick\n");
> -		return -ENODEV;
> -	}
> -	clk_enable(mbox_ick_handle);
> -
> -	l = mbox_read_reg(MAILBOX_REVISION);
> -	pr_info("omap mailbox rev %d.%d\n", (l & 0xf0) >> 4, (l & 0x0f));
> -
> -	/* set smart-idle & autoidle */
> -	l = mbox_read_reg(MAILBOX_SYSCONFIG);
> -	l |= 0x00000011;
> -	mbox_write_reg(l, MAILBOX_SYSCONFIG);
> +		l = mbox_read_reg(MAILBOX_REVISION);
> +		pr_info("omap mailbox rev %d.%d\n", (l & 0xf0) >> 4,
> +							(l & 0x0f));
>  
> +		/* set smart-idle & autoidle */
> +		l = mbox_read_reg(MAILBOX_SYSCONFIG);
> +		l |= 0x00000011;
> +		mbox_write_reg(l, MAILBOX_SYSCONFIG);
> +	}
> +	mbox_configured++;

I assume you're doing this because this function can be called multiple
times.  What protects this against races?

>  	omap2_mbox_enable_irq(mbox, IRQ_RX);
>  
>  	return 0;
>  }
>  
>  static void omap2_mbox_shutdown(struct omap_mbox *mbox)
> -{
> -	clk_disable(mbox_ick_handle);
> -	clk_put(mbox_ick_handle);
> +{	if (mbox_configured > 0)
> +		mbox_configured--;
> +		if (!mbox_configured) {
> +			clk_disable(mbox_ick_handle);
> +			clk_put(mbox_ick_handle);
> +			mbox_ick_handle = NULL;
> +		}

Same concern - what protects mbox_configured and the associated code against
races?

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:
--
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