RE: [PATCH V2 4/8]usb : musb:Using omap_device_build for musb device registration

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

 



 Hi,

>-----Original Message-----
>From: Cousson, Benoit 
>Sent: Monday, August 09, 2010 6:15 PM
>To: Kalliguddi, Hema
>Cc: linux-usb@xxxxxxxxxxxxxxx; linux-omap@xxxxxxxxxxxxxxx; 
>Felipe Balbi; Tony Lindgren; Kevin Hilman
>Subject: Re: [PATCH V2 4/8]usb : musb:Using omap_device_build 
>for musb device registration
>
>On 8/6/2010 5:57 PM, Kalliguddi, Hema wrote:
>> From: Hema HK<hemahk@xxxxxx>
>
><snip>
>
>>   void __init usb_musb_init(struct omap_musb_board_data *board_data)
>>   {
>> -	if (cpu_is_omap243x()) {
>> -		musb_resources[0].start = OMAP243X_HS_BASE;
>> -	} else if (cpu_is_omap34xx()) {
>> -		musb_resources[0].start = OMAP34XX_HSUSB_OTG_BASE;
>> -	} else if (cpu_is_omap44xx()) {
>> -		musb_resources[0].start = OMAP44XX_HSUSB_OTG_BASE;
>> -		musb_resources[1].start = OMAP44XX_IRQ_HS_USB_MC_N;
>> -		musb_resources[2].start = OMAP44XX_IRQ_HS_USB_DMA_N;
>> +	char oh_name[MAX_OMAP_MUSB_HWMOD_NAME_LEN];
>> +	struct omap_hwmod *oh;
>> +	struct omap_device *od;
>> +	struct platform_device *pdev;
>> +	struct device	*dev;
>> +	int l, bus_id = -1;
>> +	struct musb_hdrc_platform_data *pdata;
>> +
>> +	l = snprintf(oh_name, MAX_OMAP_MUSB_HWMOD_NAME_LEN,
>> +						"usb_otg_hs");
>> +	WARN(l>= MAX_OMAP_MUSB_HWMOD_NAME_LEN,
>> +			"String buffer overflow in MUSB device 
>setup\n");
>
>This is not needed in your case. Just use a const char*, and you will 
>avoid the useless snprintf and test.

Ok.
>
>> +
>> +	oh = omap_hwmod_lookup(oh_name);
>> +
>> +	if (!oh) {
>> +		pr_err("Could not look up %s\n", oh_name);
>> +	} else {
>
>You can avoid that indentation be returning in case of failure.

 Agreed.
>
>> +		/*
>> +		 * REVISIT: This line can be removed once all 
>the platforms
>> +		 * using musb_core.c have been converted to use 
>use clkdev.
>> +		 */
>> +		musb_plat.clock = "ick";
>> +		musb_plat.board_data = board_data;
>> +		musb_plat.power = board_data->power>>  1;
>> +		musb_plat.mode = board_data->mode;
>> +		pdata =&musb_plat;
>> +
>> +		od = omap_device_build(name, bus_id, oh, pdata,
>> +				       sizeof(struct 
>musb_hdrc_platform_data),
>> +							
>omap_musb_latency,
>> +				       
>ARRAY_SIZE(omap_musb_latency), false);
>> +		if (IS_ERR(od)) {
>> +			pr_err("Could not build omap_device for 
>%s %s\n",
>> +						name, oh_name);
> > +		} else {
>
>You can avoid that second level of indentation be returning in case of 
>failure as well.

Agreed.
>
>Benoit
>--
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