All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@deeprootsystems.com>
To: balbi@ti.com
Cc: "Kalliguddi, Hema" <hemahk@ti.com>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	Tony Lindgren <tony@atomide.com>,
	"Cousson, Benoit" <b-cousson@ti.com>,
	Paul Walmsley <paul@pwsan.com>
Subject: Re: [PATCH 5/9 v3] usb: musb: Using omap_device_build for musb device registration
Date: Thu, 23 Sep 2010 08:23:17 -0700	[thread overview]
Message-ID: <87bp7o5vru.fsf@deeprootsystems.com> (raw)
In-Reply-To: <20100923062044.GB2563@legolas.emea.dhcp.ti.com> (Felipe Balbi's message of "Thu, 23 Sep 2010 09:20:44 +0300")

Felipe Balbi <balbi@ti.com> writes:

> Hi,
>
> On Wed, Sep 22, 2010 at 07:29:10PM -0500, Kalliguddi, Hema wrote:
>>+#define MAX_OMAP_MUSB_HWMOD_NAME_LEN	16
>
> this isn't used anywhere.
>
>>@@ -75,31 +62,30 @@ static struct musb_hdrc_platform_data mu
>>
>> static u64 musb_dmamask = DMA_BIT_MASK(32);
>>
>>-static struct platform_device musb_device = {
>>-	.name		= "musb_hdrc",
>>-	.id		= -1,
>>-	.dev = {
>>-		.dma_mask		= &musb_dmamask,
>>-		.coherent_dma_mask	= DMA_BIT_MASK(32),
>>-		.platform_data		= &musb_plat,
>>+static struct omap_device_pm_latency omap_musb_latency[] = {
>>+	{
>>+		.deactivate_func = omap_device_idle_hwmods,
>>+		.activate_func   = omap_device_enable_hwmods,
>>+		.flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,
>> 	},
>>-	.num_resources	= ARRAY_SIZE(musb_resources),
>>-	.resource	= musb_resources,
>> };
>>
>> 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;
>>+	struct omap_hwmod *oh;
>>+	struct omap_device *od;
>>+	struct platform_device *pdev;
>>+	struct device	*dev;
>>+	int bus_id = -1;
>>+	const char *oh_name = "usb_otg_hs";
>>+	struct musb_hdrc_platform_data *pdata;
>>+
>>+	oh = omap_hwmod_lookup(oh_name);
>>+
>>+	if (!oh) {
>>+		pr_err("Could not look up %s\n", oh_name);
>>+		return;
>> 	}
>
> Paul, Kevin, to me it looks like a duplication that all devices will
> have to:
>
> oh = omap_hwmod_lookup("my_hwmod_name");
> omap_device_build("my_device_name", bus_id, oh, pdata, sizeof(*pdata));
>
> could the omap_hwmod_lookup() part be moved to omap_device_build ? Or
> maybe create a omap_hwmod_lookup_and_build(oh_name, dev_name, bus_id,
> pdata, sizeof(*pdata)) ??

I don't think that this is too much extra work.

Also, many drivers are not doing a single hwmod lookup, they are using
an iterator to iterate over a bunch of hwmods in a given class (c.f.
omap_hwmod_for_each_by_class)

So, IMO, keeping the lookup and build separate is better.

>>@@ -110,8 +96,23 @@ void __init usb_musb_init(struct omap_mu
>> 	musb_plat.mode = board_data->mode;
>> 	musb_plat.extvbus = board_data->extvbus;
>>
>>-	if (platform_device_register(&musb_device) < 0)
>>-		printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
>>+	pdata = &musb_plat;
>>+
>>+	od = omap_device_build(name, bus_id, oh, pdata,
>>+			       sizeof(struct musb_hdrc_platform_data),
>
> use sizeof(*pdata), if we change the name of that structure (very
> unlikely, but still) it'll avoid unwanted compile breakage.
>
>>+	pdev = &od->pdev;
>>+	dev = &pdev->dev;
>>+	get_device(dev);
>>+	dev->dma_mask = &musb_dmamask;
>>+	dev->coherent_dma_mask = musb_dmamask;
>>+	put_device(dev);
>
> I think this is also a duplication, it's gonna on all hwmod device
> registration, no ?

Only for devices setting DMA masks.

This is no more duplication than we have today for all platform_devices.

Kevin



  parent reply	other threads:[~2010-09-23 15:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-23  0:29 [PATCH 5/9 v3] usb: musb: Using omap_device_build for musb device registration Hema HK
     [not found] ` <1285201750-26438-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org>
2010-09-23  6:20   ` Felipe Balbi
2010-09-23  6:46     ` Kalliguddi, Hema
2010-09-23  6:51       ` Felipe Balbi
2010-09-23 15:23     ` Kevin Hilman [this message]
     [not found]       ` <87bp7o5vru.fsf-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
2010-09-24  7:25         ` Felipe Balbi
2010-09-24 16:01     ` Paul Walmsley

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=87bp7o5vru.fsf@deeprootsystems.com \
    --to=khilman@deeprootsystems.com \
    --cc=b-cousson@ti.com \
    --cc=balbi@ti.com \
    --cc=hemahk@ti.com \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=paul@pwsan.com \
    --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.