All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Cousson, Benoit" <b-cousson@ti.com>
To: "Kalliguddi, Hema" <hemahk@ti.com>
Cc: "linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	Felipe Balbi <felipe.balbi@nokia.com>,
	Tony Lindgren <tony@atomide.com>,
	Kevin Hilman <khilman@deeprootsystems.com>
Subject: Re: [PATCH V2 4/8]usb : musb:Using omap_device_build for musb device registration
Date: Mon, 09 Aug 2010 14:45:10 +0200	[thread overview]
Message-ID: <4C5FF856.4020301@ti.com> (raw)
In-Reply-To: <1281110270-4185-1-git-send-email-hemahk@ti.com>

On 8/6/2010 5:57 PM, Kalliguddi, Hema wrote:
> From: Hema HK<hemahk@ti.com>

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

> +
> +	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.

> +		/*
> +		 * 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.

Benoit

  reply	other threads:[~2010-08-09 12:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-06 15:57 [PATCH V2 4/8]usb : musb:Using omap_device_build for musb device registration Hema HK
2010-08-09 12:45 ` Cousson, Benoit [this message]
     [not found]   ` <4C5FF856.4020301-l0cyMroinI0@public.gmane.org>
2010-08-10  5:03     ` Kalliguddi, Hema

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C5FF856.4020301@ti.com \
    --to=b-cousson@ti.com \
    --cc=felipe.balbi@nokia.com \
    --cc=hemahk@ti.com \
    --cc=khilman@deeprootsystems.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.