drivers/usb: use aligned-endian get/put helpers
Subsystems (8)
PATCH 5/21 drivers/usb: use aligned-endian get/put helpers
Signed-off-by Harvey Harrison <[email protected]>
--- drivers/usb/c67x00/c67x00-hcd.c | 4 ++-- drivers/usb/core/devio.c | 12 ++++++------ drivers/usb/gadget/net2280.c | 2 +- drivers/usb/host/ehci.h | 6 ++---- drivers/usb/host/isp116x-hcd.c | 4 ++-- drivers/usb/host/ohci.h | 16 ++++++---------- drivers/usb/host/uhci-hub.c | 6 +++--- drivers/usb/misc/auerswald.c | 2 +- drivers/usb/serial/garmin_gps.c | 9 ++++----- drivers/usb/storage/isd200.c | 4 ++-- 10 files changed, 29 insertions(+), 36 deletions(-)
drivers/usb/c67x00/c67x00-hcd.c +2 -2
@@ -117,8 +117,8 @@ static int c67x00_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,if (usb_status &SOF_EOP_EN (port)) wPortStatus |=USB_PORT_STAT_ENABLE ; - *(__le16 *) buf =cpu_to_le16 (wPortStatus); - *(__le16 *) (buf +2 ) =cpu_to_le16 (wPortChange); +put_le16 (wPortStatus, buf); +put_le16 (wPortChange, buf +2 ); len =4 ;break ;
drivers/usb/core/devio.c +6 -6
@@ -993,18 +993,18 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,kfree (dr);return -EFAULT ; } -if (uurb->buffer_length < (le16_to_cpup (&dr->wLength) +8 )) { + if (uurb->buffer_length < get_le16(&dr->wLength) + 8)) {kfree (dr);return -EINVAL ; } ret =check_ctrlrecip (ps, dr->bRequestType, -le16_to_cpup (&dr->wIndex)); +get_le16 (&dr->wIndex));if (ret) {kfree (dr);return ret; } uurb->number_of_packets =0 ; - uurb->buffer_length =le16_to_cpup (&dr->wLength); + uurb->buffer_length =get_le16 (&dr->wLength); uurb->buffer +=8 ;if ((dr->bRequestType &USB_DIR_IN ) && uurb->buffer_length) { is_in =1 ;
@@ -1022,9 +1022,9 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,"bRrequestType=%02x wValue=%04x " "wIndex=%04x wLength=%04x\n" , dr->bRequest, dr->bRequestType, -__le16_to_cpup (&dr->wValue), -__le16_to_cpup (&dr->wIndex), - __le16_to_cpup(&dr->wLength)); +get_le16 (&dr->wValue), +get_le16 (&dr->wIndex), + get_le16(&dr->wLength));break ;case USBDEVFS_URB_TYPE_BULK :
drivers/usb/gadget/net2280.c +1 -1
@@ -982,7 +982,7 @@ static void scan_dma_completions (struct net2280_ep *ep)if (!req->valid)break ;rmb (); - tmp =le32_to_cpup (&req->td->dmacount); + tmp =get_le32 (&req->td->dmacount);if ((tmp & (1 <<VALID_BIT )) !=0 )break ;
drivers/usb/host/ehci.h +2 -4
@@ -804,9 +804,7 @@ static inline u32 hc32_to_cpu (const struct ehci_hcd *ehci, const __hc32 x)static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci,const __hc32 *x) { -return ehci_big_endian_desc (ehci) - ?be32_to_cpup ((__force __be32 *)x) - :le32_to_cpup ((__force __le32 *)x); +return ehci_big_endian_desc (ehci) ?get_be32 (x) :get_le32 (x); }#else
@@ -825,7 +823,7 @@ static inline u32 hc32_to_cpu (const struct ehci_hcd *ehci, const __hc32 x)static inline u32 hc32_to_cpup (const struct ehci_hcd *ehci,const __hc32 *x) { -return le32_to_cpup (x); +return get_le32 (x); }#endif
drivers/usb/host/isp116x-hcd.c +2 -2
@@ -1024,7 +1024,7 @@ static int isp116x_hub_control(struct usb_hcd *hcd,break ;case GetHubStatus:DBG ("GetHubStatus\n" ); - *(__le32 *) buf =0 ; +put_le32 (0 , buf);break ;case GetPortStatus:DBG ("GetPortStatus\n" );
@@ -1033,7 +1033,7 @@ static int isp116x_hub_control(struct usb_hcd *hcd,spin_lock_irqsave (&isp116x->lock, flags); tmp =isp116x_read_reg32 (isp116x, (--wIndex) ?HCRHPORT2 :HCRHPORT1 );spin_unlock_irqrestore (&isp116x->lock, flags); - *(__le32 *) buf =cpu_to_le32 (tmp); +put_le32 (tmp, buf);DBG ("GetPortStatus: port[%d] %08x\n" , wIndex +1 , tmp);break ;case ClearPortFeature:
drivers/usb/host/ohci.h +6 -10
@@ -615,11 +615,9 @@ static inline u16 hc16_to_cpu (const struct ohci_hcd *ohci, const __hc16 x)le16_to_cpu ((__force __le16 )x); } -static inline u16 hc16_to_cpup (const struct ohci_hcd *ohci,const __hc16 *x) +static inline u16 hc16_to_cpup (const struct ohci_hcd *ohci,const __hc16 *x) { -return big_endian_desc (ohci) ? -be16_to_cpup ((__force __be16 *)x) : -le16_to_cpup ((__force __le16 *)x); +return big_endian_desc (ohci) ?get_be16 (x) :get_le16 (x); }static inline u32 hc32_to_cpu (const struct ohci_hcd *ohci,const __hc32 x)
@@ -629,11 +627,9 @@ static inline u32 hc32_to_cpu (const struct ohci_hcd *ohci, const __hc32 x)le32_to_cpu ((__force __le32 )x); } -static inline u32 hc32_to_cpup (const struct ohci_hcd *ohci,const __hc32 *x) +static inline u32 hc32_to_cpup (const struct ohci_hcd *ohci,const __hc32 *x) { -return big_endian_desc (ohci) ? -be32_to_cpup ((__force __be32 *)x) : -le32_to_cpup ((__force __le32 *)x); +return big_endian_desc (ohci) ?get_be32 (x) :get_le32 (x); }/*-------------------------------------------------------------------------*/
@@ -653,11 +649,11 @@ static inline u16 ohci_frame_no(const struct ohci_hcd *ohci) {u32 tmp;if (big_endian_desc (ohci)) { - tmp =be32_to_cpup ((__force __be32 *)&ohci->hcca->frame_no); + tmp =get_be32 (&ohci->hcca->frame_no);if (!big_endian_frame_no_quirk (ohci)) tmp >>=16 ; }else - tmp =le32_to_cpup ((__force __le32 *)&ohci->hcca->frame_no); + tmp =get_le32 (&ohci->hcca->frame_no);return (u16 )tmp; }
drivers/usb/host/uhci-hub.c +3 -3
@@ -253,7 +253,7 @@ static int uhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,switch (typeReq) {case GetHubStatus: - *(__le32 *)buf =cpu_to_le32 (0 ); +put_le32 (0 , buf);OK (4 );/* hub power */ case GetPortStatus:if (port >= uhci->rh_numports)
@@ -306,8 +306,8 @@ static int uhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,dev_dbg (uhci_dev (uhci),"port %d portsc %04x,%02x\n" , wIndex, status, lstatus); - *(__le16 *)buf =cpu_to_le16 (wPortStatus); - *(__le16 *)(buf +2 ) =cpu_to_le16 (wPortChange); +put_le16 (wPortStatus, buf); +put_le16 (wPortChange, buf +2 );OK (4 );case SetHubFeature:/* We don't implement these */ case ClearHubFeature:
drivers/usb/misc/auerswald.c +1 -1
@@ -1982,7 +1982,7 @@ static int auerswald_probe (struct usb_interface *intf,2 ,/* length of the buffer */ 2000); /* time to wait for the message to complete before timing out */if (ret ==2 ) { - cp->maxControlLength =le16_to_cpup (pbuf); + cp->maxControlLength =get_le16 (pbuf);kfree (pbuf);dbg ("setup: max. allowed control transfersize is %d bytes" , cp->maxControlLength); }else {
drivers/usb/serial/garmin_gps.c +4 -5
@@ -241,17 +241,17 @@ static inline int noResponseFromAppLayer(struct garmin_data * garmin_data_p)static inline int getLayerId (const __u8 *usbPacket) { -return __le32_to_cpup ((__le32 *)(usbPacket)); +return get_le32 (usbPacket); }static inline int getPacketId (const __u8 *usbPacket) { -return __le32_to_cpup ((__le32 *)(usbPacket+4 )); +return get_le32 (usbPacket +4 ); }static inline int getDataLength (const __u8 *usbPacket) { -return __le32_to_cpup ((__le32 *)(usbPacket+8 )); +return get_le32 (usbPacket +8 ); }
@@ -1413,8 +1413,7 @@ static void garmin_read_int_callback (struct urb *urb)spin_unlock_irqrestore (&garmin_data_p->lock, flags);/* save the serial number */ - garmin_data_p->serial_num - =__le32_to_cpup ((__le32 *)(data+GARMIN_PKTHDR_LENGTH )); + garmin_data_p->serial_num =get_le32 (data +GARMIN_PKTHDR_LENGTH );dbg ("%s - start-of-session reply seen - serial %u." , __func__, garmin_data_p->serial_num);
drivers/usb/storage/isd200.c +2 -2
@@ -1344,7 +1344,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,case READ_10 :US_DEBUGP (" ATA OUT - SCSIOP_READ\n" ); - lba =be32_to_cpu (*(__be32 *)&srb->cmnd[2 ]); + lba =get_be32 (&srb->cmnd[2 ]); blockCount = (unsigned long )srb->cmnd[7 ]<<8 | (unsigned long )srb->cmnd[8 ];if (id->capability &CAPABILITY_LBA ) {
@@ -1376,7 +1376,7 @@ static int isd200_scsi_to_ata(struct scsi_cmnd *srb, struct us_data *us,case WRITE_10 :US_DEBUGP (" ATA OUT - SCSIOP_WRITE\n" ); - lba =be32_to_cpu (*(__be32 *)&srb->cmnd[2 ]); + lba =get_be32 (&srb->cmnd[2 ]); blockCount = (unsigned long )srb->cmnd[7 ]<<8 | (unsigned long )srb->cmnd[8 ];if (id->capability &CAPABILITY_LBA ) {
Signature · 1 line
1.5.5.1.570.g26b5e
Quoted 2 lines · Harvey Harrison
Signed-off-by Harvey Harrison <[email protected]>---
After all that I compiled with the wrong config to make sure it all compiled after splitting, extra bracket in devio.c
Quoted 17 lines
drivers/usb/c67x00/c67x00-hcd.c | 4 ++-- drivers/usb/core/devio.c | 12 ++++++------ drivers/usb/gadget/net2280.c | 2 +- drivers/usb/host/ehci.h | 6 ++---- drivers/usb/host/isp116x-hcd.c | 4 ++-- drivers/usb/host/ohci.h | 16 ++++++---------- drivers/usb/host/uhci-hub.c | 6 +++--- drivers/usb/misc/auerswald.c | 2 +- drivers/usb/serial/garmin_gps.c | 9 ++++----- drivers/usb/storage/isd200.c | 4 ++-- 10 files changed, 29 insertions(+), 36 deletions(-)drivers/usb/core/devio.c +0
-0
drivers/usb/core/devio.c static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb, · line 996
Quoted 5 lines
drivers/usb/core/devio.c +1
-1@@ -993,18 +993,18 @@ static int proc_do_submiturb(struct dev_state *ps, struct usbdevfs_urb *uurb,kfree (dr);return -EFAULT ; } -if (uurb->buffer_length < (le16_to_cpup (&dr->wLength) +8 )) { + if (uurb->buffer_length < get_le16(&dr->wLength) + 8)) {
^
Sorry.
Harvey