[PATCH] powerpc/usb: use ioremap instead of base plus offset to access regs
Xie Shaohui-B21989
B21989 at freescale.com
Wed Nov 2 20:39:21 EST 2011
>-----Original Message-----
>From: David Laight [mailto:David.Laight at ACULAB.COM]
>Sent: Wednesday, November 02, 2011 5:07 PM
>To: Xie Shaohui-B21989; linuxppc-dev at lists.ozlabs.org
>Cc: linux-usb at vger.kernel.org
>Subject: RE: [PATCH] powerpc/usb: use ioremap instead of base plus offset
>to access regs
>
>
>> #ifndef CONFIG_ARCH_MXC
>> if (pdata->have_sysif_regs)
>> - usb_sys_regs = (struct usb_sys_interface *)
>> - ((u32)dr_regs + USB_DR_SYS_OFFSET);
>> + usb_sys_regs = ioremap(res->start + USB_DR_SYS_OFFSET,
>> + sizeof(struct
>usb_sys_interface)/sizeof(int));
>> #endif
>
>That ioremap() doesn't look right.
>Isn't the 'size' in bytes??
[Xie Shaohui] Yes, should not use sizeof(int).
>(Although it will only matter if it crosses a page boundary.) Mind you,
>I'd have though the original ioremap() should have covered the entire
>structure??
[Xie Shaohui] The original ioremap() did cover the entire structure, but the sysif_regs are not defined in dr_regs,
So regs of sysif_regs cannot be accessed as a member of a structure, current driver handle this by type casting, this did work in 32-bit, but in 64-bit, this is not safe. So I use ioremap() to cover it again.
Best Regards,
Shaohui Xie
More information about the Linuxppc-dev
mailing list