summaryrefslogtreecommitdiffstats
path: root/firmware/usbstack
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2011-12-29 21:58:34 +0000
committerRafaël Carré <rafael.carre@gmail.com>2011-12-29 21:58:34 +0000
commit4c2126b5a8b0bea04d4c5ba8bee032f9bc0efbe0 (patch)
treee98a32588e3919908590b3c9ddac89dbc24caea3 /firmware/usbstack
parent6a6269ffd8dfaf921588bae47cd55716abb78abb (diff)
downloadrockbox-4c2126b5a8b0bea04d4c5ba8bee032f9bc0efbe0.tar.gz
rockbox-4c2126b5a8b0bea04d4c5ba8bee032f9bc0efbe0.tar.bz2
rockbox-4c2126b5a8b0bea04d4c5ba8bee032f9bc0efbe0.zip
usb PACK_DATA: use a static inline to enable type checking
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31467 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/usbstack')
-rw-r--r--firmware/usbstack/usb_charging_only.c2
-rw-r--r--firmware/usbstack/usb_class_driver.h12
-rw-r--r--firmware/usbstack/usb_hid.c6
-rw-r--r--firmware/usbstack/usb_serial.c6
-rw-r--r--firmware/usbstack/usb_storage.c6
5 files changed, 16 insertions, 16 deletions
diff --git a/firmware/usbstack/usb_charging_only.c b/firmware/usbstack/usb_charging_only.c
index 7a8389e620..6bd17a92de 100644
--- a/firmware/usbstack/usb_charging_only.c
+++ b/firmware/usbstack/usb_charging_only.c
@@ -64,7 +64,7 @@ int usb_charging_only_get_config_descriptor(unsigned char *dest,int max_packet_s
unsigned char *orig_dest = dest;
interface_descriptor.bInterfaceNumber=usb_interface;
- PACK_DATA(dest, interface_descriptor);
+ PACK_DATA(&dest, interface_descriptor);
return (dest-orig_dest);
}
diff --git a/firmware/usbstack/usb_class_driver.h b/firmware/usbstack/usb_class_driver.h
index c8d1e7047d..20ee26a3d0 100644
--- a/firmware/usbstack/usb_class_driver.h
+++ b/firmware/usbstack/usb_class_driver.h
@@ -85,10 +85,10 @@ struct usb_class_driver {
#endif
};
-#define PACK_DATA(dest, data) \
- do { \
- memcpy(dest, &(data), sizeof(data)); \
- dest += sizeof(data); \
- } while (0)
-
+#define PACK_DATA(dest, data) pack_data(dest, &(data), sizeof(data))
+static inline void pack_data(uint8_t **dest, const void *data, size_t size)
+{
+ memcpy(*dest, data, size);
+ *dest += size;
+}
#endif
diff --git a/firmware/usbstack/usb_hid.c b/firmware/usbstack/usb_hid.c
index b89e46f291..ed0816395a 100644
--- a/firmware/usbstack/usb_hid.c
+++ b/firmware/usbstack/usb_hid.c
@@ -561,7 +561,7 @@ static void descriptor_hid_get(unsigned char **dest)
logf("hid: desc len %u", hid_descriptor.wDescriptorLength0);
buf_dump(report_descriptor, hid_descriptor.wDescriptorLength0, "desc");
- PACK_DATA(*dest, hid_descriptor);
+ PACK_DATA(dest, hid_descriptor);
}
int usb_hid_get_config_descriptor(unsigned char *dest, int max_packet_size)
@@ -574,7 +574,7 @@ int usb_hid_get_config_descriptor(unsigned char *dest, int max_packet_size)
/* Interface descriptor */
interface_descriptor.bInterfaceNumber = usb_interface;
- PACK_DATA(dest, interface_descriptor);
+ PACK_DATA(&dest, interface_descriptor);
/* HID descriptor */
descriptor_hid_get(&dest);
@@ -583,7 +583,7 @@ int usb_hid_get_config_descriptor(unsigned char *dest, int max_packet_size)
endpoint_descriptor.wMaxPacketSize = 8;
endpoint_descriptor.bInterval = 8;
endpoint_descriptor.bEndpointAddress = ep_in;
- PACK_DATA(dest, endpoint_descriptor);
+ PACK_DATA(&dest, endpoint_descriptor);
return (int)(dest - orig_dest);
}
diff --git a/firmware/usbstack/usb_serial.c b/firmware/usbstack/usb_serial.c
index e7159099fe..4a80433435 100644
--- a/firmware/usbstack/usb_serial.c
+++ b/firmware/usbstack/usb_serial.c
@@ -100,15 +100,15 @@ int usb_serial_get_config_descriptor(unsigned char *dest, int max_packet_size)
unsigned char *orig_dest = dest;
interface_descriptor.bInterfaceNumber = usb_interface;
- PACK_DATA(dest, interface_descriptor);
+ PACK_DATA(&dest, interface_descriptor);
endpoint_descriptor.wMaxPacketSize = max_packet_size;
endpoint_descriptor.bEndpointAddress = ep_in;
- PACK_DATA(dest, endpoint_descriptor);
+ PACK_DATA(&dest, endpoint_descriptor);
endpoint_descriptor.bEndpointAddress = ep_out;
- PACK_DATA(dest, endpoint_descriptor);
+ PACK_DATA(&dest, endpoint_descriptor);
return (dest - orig_dest);
}
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c
index c156d80396..8d1b94bf7a 100644
--- a/firmware/usbstack/usb_storage.c
+++ b/firmware/usbstack/usb_storage.c
@@ -430,15 +430,15 @@ int usb_storage_get_config_descriptor(unsigned char *dest,int max_packet_size)
unsigned char *orig_dest = dest;
interface_descriptor.bInterfaceNumber = usb_interface;
- PACK_DATA(dest, interface_descriptor);
+ PACK_DATA(&dest, interface_descriptor);
endpoint_descriptor.wMaxPacketSize = max_packet_size;
endpoint_descriptor.bEndpointAddress = ep_in;
- PACK_DATA(dest, endpoint_descriptor);
+ PACK_DATA(&dest, endpoint_descriptor);
endpoint_descriptor.bEndpointAddress = ep_out;
- PACK_DATA(dest, endpoint_descriptor);
+ PACK_DATA(&dest, endpoint_descriptor);
return (dest - orig_dest);
}