diff options
author | Andreas Larsson <andreas@gaisler.com> | 2014-03-27 16:15:56 +0100 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2014-04-21 14:07:27 -0500 |
commit | 73e1c093e83a421d24d54a94cb87031e7c222cd1 (patch) | |
tree | 6631b028c1d2906e8a734183ec90ba6edc2a7f8a /drivers/usb/gadget/gr_udc.c | |
parent | 196800da39a142e2952ad5e1cb58a84838956764 (diff) | |
download | op-kernel-dev-73e1c093e83a421d24d54a94cb87031e7c222cd1.zip op-kernel-dev-73e1c093e83a421d24d54a94cb87031e7c222cd1.tar.gz |
usb: gadget: gr_udc: Use of_property_read_u32_index to access arrays
Use an appropriate accessor function for property arrays to make the code nicer
and make the code correct if it would ever run on little endian architectures.
Suggested by Mark Rutland.
Signed-off-by: Andreas Larsson <andreas@gaisler.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/gr_udc.c')
-rw-r--r-- | drivers/usb/gadget/gr_udc.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/drivers/usb/gadget/gr_udc.c b/drivers/usb/gadget/gr_udc.c index 7a99254..0f3a953 100644 --- a/drivers/usb/gadget/gr_udc.c +++ b/drivers/usb/gadget/gr_udc.c @@ -2020,9 +2020,7 @@ static int gr_udc_init(struct gr_udc *dev) u32 dmactrl_val; int i; int ret = 0; - u32 *bufsizes; u32 bufsize; - int len; gr_set_address(dev, 0); @@ -2033,19 +2031,17 @@ static int gr_udc_init(struct gr_udc *dev) INIT_LIST_HEAD(&dev->ep_list); gr_set_ep0state(dev, GR_EP0_DISCONNECT); - bufsizes = (u32 *)of_get_property(np, "epobufsizes", &len); - len /= sizeof(u32); for (i = 0; i < dev->nepo; i++) { - bufsize = (bufsizes && i < len) ? bufsizes[i] : 1024; + if (of_property_read_u32_index(np, "epobufsizes", i, &bufsize)) + bufsize = 1024; ret = gr_ep_init(dev, i, 0, bufsize); if (ret) return ret; } - bufsizes = (u32 *)of_get_property(np, "epibufsizes", &len); - len /= sizeof(u32); for (i = 0; i < dev->nepi; i++) { - bufsize = (bufsizes && i < len) ? bufsizes[i] : 1024; + if (of_property_read_u32_index(np, "epibufsizes", i, &bufsize)) + bufsize = 1024; ret = gr_ep_init(dev, i, 1, bufsize); if (ret) return ret; |