* [PATCH] musb: omap: Fix: pass all the resources to musb core @ 2013-07-08 10:55 Kishon Vijay Abraham I 2013-07-08 12:22 ` Sergei Shtylyov 0 siblings, 1 reply; 5+ messages in thread From: Kishon Vijay Abraham I @ 2013-07-08 10:55 UTC (permalink / raw) To: kishon-l0cyMroinI0, balbi-l0cyMroinI0 Cc: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-omap-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA commit 09fc7d (usb: musb: fix incorrect usage of resource pointer) assumes musb core will always have only 2 resources. But for OMAP platforms there can be 3 resources (2 irq resource and 1 iomem resource). Fixed it here. Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org> --- drivers/usb/musb/omap2430.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 5b6113a..5bbef78 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -481,7 +481,7 @@ static u64 omap2430_dmamask = DMA_BIT_MASK(32); static int omap2430_probe(struct platform_device *pdev) { - struct resource musb_resources[2]; + struct resource musb_resources[3]; struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct omap_musb_board_data *data; struct platform_device *musb; @@ -489,6 +489,7 @@ static int omap2430_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct musb_hdrc_config *config; int ret = -ENOMEM; + int i = 0; glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); if (!glue) { @@ -571,15 +572,12 @@ static int omap2430_probe(struct platform_device *pdev) memset(musb_resources, 0x00, sizeof(*musb_resources) * ARRAY_SIZE(musb_resources)); - musb_resources[0].name = pdev->resource[0].name; - musb_resources[0].start = pdev->resource[0].start; - musb_resources[0].end = pdev->resource[0].end; - musb_resources[0].flags = pdev->resource[0].flags; ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] musb: omap: Fix: pass all the resources to musb core 2013-07-08 10:55 [PATCH] musb: omap: Fix: pass all the resources to musb core Kishon Vijay Abraham I @ 2013-07-08 12:22 ` Sergei Shtylyov [not found] ` <51DAAEEA.60409-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Sergei Shtylyov @ 2013-07-08 12:22 UTC (permalink / raw) To: Kishon Vijay Abraham I; +Cc: balbi, gregkh, linux-usb, linux-omap, linux-kernel Hello. On 08-07-2013 14:55, Kishon Vijay Abraham I wrote: > commit 09fc7d (usb: musb: fix incorrect usage of resource pointer) > assumes musb core will always have only 2 resources. But for OMAP > platforms there can be 3 resources (2 irq resource and 1 iomem > resource). Fixed it here. > Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> > --- > drivers/usb/musb/omap2430.c | 18 ++++++++---------- > 1 file changed, 8 insertions(+), 10 deletions(-) > diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c > index 5b6113a..5bbef78 100644 > --- a/drivers/usb/musb/omap2430.c > +++ b/drivers/usb/musb/omap2430.c [...] > @@ -489,6 +489,7 @@ static int omap2430_probe(struct platform_device *pdev) > struct device_node *np = pdev->dev.of_node; > struct musb_hdrc_config *config; > int ret = -ENOMEM; > + int i = 0; Redundant initialization. > glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); > if (!glue) { > @@ -571,15 +572,12 @@ static int omap2430_probe(struct platform_device *pdev) > memset(musb_resources, 0x00, sizeof(*musb_resources) * > ARRAY_SIZE(musb_resources)); > > - musb_resources[0].name = pdev->resource[0].name; > - musb_resources[0].start = pdev->resource[0].start; > - musb_resources[0].end = pdev->resource[0].end; > - musb_resources[0].flags = pdev->resource[0].flags; > - > - musb_resources[1].name = pdev->resource[1].name; > - musb_resources[1].start = pdev->resource[1].start; > - musb_resources[1].end = pdev->resource[1].end; > - musb_resources[1].flags = pdev->resource[1].flags; > + for (i = 0; i < ARRAY_SIZE(musb_resources); i++) { > + musb_resources[i].name = pdev->resource[i].name; > + musb_resources[i].start = pdev->resource[i].start; > + musb_resources[i].end = pdev->resource[i].end; > + musb_resources[i].flags = pdev->resource[i].flags; > + } WBR, Sergei ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <51DAAEEA.60409-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>]
* [PATCH v2] musb: omap: Fix: pass all the resources to musb core [not found] ` <51DAAEEA.60409-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org> @ 2013-07-10 10:59 ` Kishon Vijay Abraham I [not found] ` <1373453962-21344-1-git-send-email-kishon-l0cyMroinI0@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Kishon Vijay Abraham I @ 2013-07-10 10:59 UTC (permalink / raw) To: balbi-l0cyMroinI0, sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8 Cc: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-omap-u79uwXL29TY76Z2rM5mHXA, inux-kernel-u79uwXL29TY76Z2rM5mHXA, Kishon Vijay Abraham I commit 09fc7d (usb: musb: fix incorrect usage of resource pointer) assumes musb core will always have only 2 resources. But for OMAP platforms there can be 3 resources (2 irq resource and 1 iomem resource). Fixed it here. Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org> --- Changes from v1: *) Removed redundant initialization of *i* drivers/usb/musb/omap2430.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index 5b6113a..5bbef78 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -481,7 +481,7 @@ static u64 omap2430_dmamask = DMA_BIT_MASK(32); static int omap2430_probe(struct platform_device *pdev) { - struct resource musb_resources[2]; + struct resource musb_resources[3]; struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; struct omap_musb_board_data *data; struct platform_device *musb; @@ -489,6 +489,7 @@ static int omap2430_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct musb_hdrc_config *config; int ret = -ENOMEM; + int i; glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); if (!glue) { @@ -571,15 +572,12 @@ static int omap2430_probe(struct platform_device *pdev) memset(musb_resources, 0x00, sizeof(*musb_resources) * ARRAY_SIZE(musb_resources)); - musb_resources[0].name = pdev->resource[0].name; - musb_resources[0].start = pdev->resource[0].start; - musb_resources[0].end = pdev->resource[0].end; - musb_resources[0].flags = pdev->resource[0].flags; ^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <1373453962-21344-1-git-send-email-kishon-l0cyMroinI0@public.gmane.org>]
* Re: [PATCH v2] musb: omap: Fix: pass all the resources to musb core [not found] ` <1373453962-21344-1-git-send-email-kishon-l0cyMroinI0@public.gmane.org> @ 2013-07-10 11:27 ` Felipe Balbi [not found] ` <20130710112746.GA18966-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org> 0 siblings, 1 reply; 5+ messages in thread From: Felipe Balbi @ 2013-07-10 11:27 UTC (permalink / raw) To: Kishon Vijay Abraham I Cc: balbi-l0cyMroinI0, sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8, gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-omap-u79uwXL29TY76Z2rM5mHXA, inux-kernel-u79uwXL29TY76Z2rM5mHXA [-- Attachment #1: Type: text/plain, Size: 2827 bytes --] On Wed, Jul 10, 2013 at 04:29:22PM +0530, Kishon Vijay Abraham I wrote: > commit 09fc7d (usb: musb: fix incorrect usage of resource pointer) > assumes musb core will always have only 2 resources. But for OMAP > platforms there can be 3 resources (2 irq resource and 1 iomem > resource). Fixed it here. > > Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org> > --- > Changes from v1: > *) Removed redundant initialization of *i* > > drivers/usb/musb/omap2430.c | 18 ++++++++---------- > 1 file changed, 8 insertions(+), 10 deletions(-) > > diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c > index 5b6113a..5bbef78 100644 > --- a/drivers/usb/musb/omap2430.c > +++ b/drivers/usb/musb/omap2430.c > @@ -481,7 +481,7 @@ static u64 omap2430_dmamask = DMA_BIT_MASK(32); > > static int omap2430_probe(struct platform_device *pdev) > { > - struct resource musb_resources[2]; > + struct resource musb_resources[3]; > struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; > struct omap_musb_board_data *data; > struct platform_device *musb; > @@ -489,6 +489,7 @@ static int omap2430_probe(struct platform_device *pdev) > struct device_node *np = pdev->dev.of_node; > struct musb_hdrc_config *config; > int ret = -ENOMEM; > + int i; > > glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); > if (!glue) { > @@ -571,15 +572,12 @@ static int omap2430_probe(struct platform_device *pdev) > memset(musb_resources, 0x00, sizeof(*musb_resources) * > ARRAY_SIZE(musb_resources)); > > - musb_resources[0].name = pdev->resource[0].name; > - musb_resources[0].start = pdev->resource[0].start; > - musb_resources[0].end = pdev->resource[0].end; > - musb_resources[0].flags = pdev->resource[0].flags; > - > - musb_resources[1].name = pdev->resource[1].name; > - musb_resources[1].start = pdev->resource[1].start; > - musb_resources[1].end = pdev->resource[1].end; > - musb_resources[1].flags = pdev->resource[1].flags; > + for (i = 0; i < ARRAY_SIZE(musb_resources); i++) { then this is not enough, what if one device using omap2430.c has 2 resources and the other has 3 ? and what if a new one has 4 ? How about using pdev->num_resources to dynamically allocate musb_resources array and using the same thing iterate here ? Something like: struct resource *musb_resources; musb_resources = kcalloc(pdev->num_resources, struct resource, GPF_KERNEL); if (!musb_resources) bail(); for (i = 0; i < pdev->num_resources, i++) { musb_resources[i].name = pdev->resource[i].name; musb_resources[i].start = pdev->resource[i].start; musb_resources[i].end = pdev->resource[i].end; musb_resources[i].flags = pdev->resource[i].flags; } cheers -- balbi [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 836 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <20130710112746.GA18966-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>]
* Re: [PATCH v2] musb: omap: Fix: pass all the resources to musb core [not found] ` <20130710112746.GA18966-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org> @ 2013-07-10 13:39 ` Kishon Vijay Abraham I 0 siblings, 0 replies; 5+ messages in thread From: Kishon Vijay Abraham I @ 2013-07-10 13:39 UTC (permalink / raw) To: balbi-l0cyMroinI0 Cc: sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8, gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r, linux-usb-u79uwXL29TY76Z2rM5mHXA, linux-omap-u79uwXL29TY76Z2rM5mHXA, inux-kernel-u79uwXL29TY76Z2rM5mHXA On Wednesday 10 July 2013 04:57 PM, Felipe Balbi wrote: > On Wed, Jul 10, 2013 at 04:29:22PM +0530, Kishon Vijay Abraham I wrote: >> commit 09fc7d (usb: musb: fix incorrect usage of resource pointer) >> assumes musb core will always have only 2 resources. But for OMAP >> platforms there can be 3 resources (2 irq resource and 1 iomem >> resource). Fixed it here. >> >> Signed-off-by: Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org> >> --- >> Changes from v1: >> *) Removed redundant initialization of *i* >> >> drivers/usb/musb/omap2430.c | 18 ++++++++---------- >> 1 file changed, 8 insertions(+), 10 deletions(-) >> >> diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c >> index 5b6113a..5bbef78 100644 >> --- a/drivers/usb/musb/omap2430.c >> +++ b/drivers/usb/musb/omap2430.c >> @@ -481,7 +481,7 @@ static u64 omap2430_dmamask = DMA_BIT_MASK(32); >> >> static int omap2430_probe(struct platform_device *pdev) >> { >> - struct resource musb_resources[2]; >> + struct resource musb_resources[3]; >> struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; >> struct omap_musb_board_data *data; >> struct platform_device *musb; >> @@ -489,6 +489,7 @@ static int omap2430_probe(struct platform_device *pdev) >> struct device_node *np = pdev->dev.of_node; >> struct musb_hdrc_config *config; >> int ret = -ENOMEM; >> + int i; >> >> glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); >> if (!glue) { >> @@ -571,15 +572,12 @@ static int omap2430_probe(struct platform_device *pdev) >> memset(musb_resources, 0x00, sizeof(*musb_resources) * >> ARRAY_SIZE(musb_resources)); >> >> - musb_resources[0].name = pdev->resource[0].name; >> - musb_resources[0].start = pdev->resource[0].start; >> - musb_resources[0].end = pdev->resource[0].end; >> - musb_resources[0].flags = pdev->resource[0].flags; >> - >> - musb_resources[1].name = pdev->resource[1].name; >> - musb_resources[1].start = pdev->resource[1].start; >> - musb_resources[1].end = pdev->resource[1].end; >> - musb_resources[1].flags = pdev->resource[1].flags; >> + for (i = 0; i < ARRAY_SIZE(musb_resources); i++) { > > then this is not enough, what if one device using omap2430.c has 2 > resources and the other has 3 ? and what if a new one has 4 ? > > How about using pdev->num_resources to dynamically allocate > musb_resources array and using the same thing iterate here ? Yeah. This looks better. Thanks Kishon -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-07-10 13:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-08 10:55 [PATCH] musb: omap: Fix: pass all the resources to musb core Kishon Vijay Abraham I
2013-07-08 12:22 ` Sergei Shtylyov
[not found] ` <51DAAEEA.60409-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
2013-07-10 10:59 ` [PATCH v2] " Kishon Vijay Abraham I
[not found] ` <1373453962-21344-1-git-send-email-kishon-l0cyMroinI0@public.gmane.org>
2013-07-10 11:27 ` Felipe Balbi
[not found] ` <20130710112746.GA18966-S8G//mZuvNWo5Im9Ml3/Zg@public.gmane.org>
2013-07-10 13:39 ` Kishon Vijay Abraham I
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).