Commit b50df7d1 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/dvrabel/uwb

* 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/dvrabel/uwb:
  uwb: remove duplicate cpu_to_le16()
  uwb: declare MODULE_FIRMWARE() in i1480 DFU driver
  uwb: make USB device id table constant
  uwb: wlp: refactor wlp_get_<attribute>() macros
parents 352d4657 bcf59e2c
...@@ -891,7 +891,7 @@ static int hwarc_post_reset(struct usb_interface *iface) ...@@ -891,7 +891,7 @@ static int hwarc_post_reset(struct usb_interface *iface)
} }
/** USB device ID's that we handle */ /** USB device ID's that we handle */
static struct usb_device_id hwarc_id_table[] = { static const struct usb_device_id hwarc_id_table[] = {
/* D-Link DUB-1210 */ /* D-Link DUB-1210 */
{ USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3d02, 0xe0, 0x01, 0x02), { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3d02, 0xe0, 0x01, 0x02),
.driver_info = WUSB_QUIRK_WHCI_CMD_EVT }, .driver_info = WUSB_QUIRK_WHCI_CMD_EVT },
......
...@@ -120,8 +120,7 @@ int i1480_usb_write(struct i1480 *i1480, u32 memory_address, ...@@ -120,8 +120,7 @@ int i1480_usb_write(struct i1480 *i1480, u32 memory_address,
result = usb_control_msg( result = usb_control_msg(
i1480_usb->usb_dev, usb_sndctrlpipe(i1480_usb->usb_dev, 0), i1480_usb->usb_dev, usb_sndctrlpipe(i1480_usb->usb_dev, 0),
0xf0, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0xf0, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
cpu_to_le16(memory_address & 0xffff), memory_address, (memory_address >> 16),
cpu_to_le16((memory_address >> 16) & 0xffff),
i1480->cmd_buf, buffer_size, 100 /* FIXME: arbitrary */); i1480->cmd_buf, buffer_size, 100 /* FIXME: arbitrary */);
if (result < 0) if (result < 0)
break; break;
...@@ -166,8 +165,7 @@ int i1480_usb_read(struct i1480 *i1480, u32 addr, size_t size) ...@@ -166,8 +165,7 @@ int i1480_usb_read(struct i1480 *i1480, u32 addr, size_t size)
result = usb_control_msg( result = usb_control_msg(
i1480_usb->usb_dev, usb_rcvctrlpipe(i1480_usb->usb_dev, 0), i1480_usb->usb_dev, usb_rcvctrlpipe(i1480_usb->usb_dev, 0),
0xf0, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0xf0, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
cpu_to_le16(itr_addr & 0xffff), itr_addr, (itr_addr >> 16),
cpu_to_le16((itr_addr >> 16) & 0xffff),
i1480->cmd_buf + itr, itr_size, i1480->cmd_buf + itr, itr_size,
100 /* FIXME: arbitrary */); 100 /* FIXME: arbitrary */);
if (result < 0) { if (result < 0) {
...@@ -413,6 +411,10 @@ error: ...@@ -413,6 +411,10 @@ error:
return result; return result;
} }
MODULE_FIRMWARE("i1480-pre-phy-0.0.bin");
MODULE_FIRMWARE("i1480-usb-0.0.bin");
MODULE_FIRMWARE("i1480-phy-0.0.bin");
#define i1480_USB_DEV(v, p) \ #define i1480_USB_DEV(v, p) \
{ \ { \
.match_flags = USB_DEVICE_ID_MATCH_DEVICE \ .match_flags = USB_DEVICE_ID_MATCH_DEVICE \
...@@ -430,7 +432,7 @@ error: ...@@ -430,7 +432,7 @@ error:
/** USB device ID's that we handle */ /** USB device ID's that we handle */
static struct usb_device_id i1480_usb_id_table[] = { static const struct usb_device_id i1480_usb_id_table[] = {
i1480_USB_DEV(0x8086, 0xdf3b), i1480_USB_DEV(0x8086, 0xdf3b),
i1480_USB_DEV(0x15a9, 0x0005), i1480_USB_DEV(0x15a9, 0x0005),
i1480_USB_DEV(0x07d1, 0x3802), i1480_USB_DEV(0x07d1, 0x3802),
......
...@@ -259,6 +259,63 @@ out: ...@@ -259,6 +259,63 @@ out:
} }
static ssize_t wlp_get_attribute(struct wlp *wlp, u16 type_code,
struct wlp_attr_hdr *attr_hdr, void *value, ssize_t value_len,
ssize_t buflen)
{
struct device *dev = &wlp->rc->uwb_dev.dev;
ssize_t attr_len = sizeof(*attr_hdr) + value_len;
if (buflen < 0)
return -EINVAL;
if (buflen < attr_len) {
dev_err(dev, "WLP: Not enough space in buffer to parse"
" attribute field. Need %d, received %zu\n",
(int)attr_len, buflen);
return -EIO;
}
if (wlp_check_attr_hdr(wlp, attr_hdr, type_code, value_len) < 0) {
dev_err(dev, "WLP: Header verification failed. \n");
return -EINVAL;
}
memcpy(value, (void *)attr_hdr + sizeof(*attr_hdr), value_len);
return attr_len;
}
static ssize_t wlp_vget_attribute(struct wlp *wlp, u16 type_code,
struct wlp_attr_hdr *attr_hdr, void *value, ssize_t max_value_len,
ssize_t buflen)
{
struct device *dev = &wlp->rc->uwb_dev.dev;
size_t len;
if (buflen < 0)
return -EINVAL;
if (buflen < sizeof(*attr_hdr)) {
dev_err(dev, "WLP: Not enough space in buffer to parse"
" header.\n");
return -EIO;
}
if (le16_to_cpu(attr_hdr->type) != type_code) {
dev_err(dev, "WLP: Unexpected attribute type. Got %u, "
"expected %u.\n", le16_to_cpu(attr_hdr->type),
type_code);
return -EINVAL;
}
len = le16_to_cpu(attr_hdr->length);
if (len > max_value_len) {
dev_err(dev, "WLP: Attribute larger than maximum "
"allowed. Received %zu, max is %d.\n", len,
(int)max_value_len);
return -EFBIG;
}
if (buflen < sizeof(*attr_hdr) + len) {
dev_err(dev, "WLP: Not enough space in buffer to parse "
"variable data.\n");
return -EIO;
}
memcpy(value, (void *)attr_hdr + sizeof(*attr_hdr), len);
return sizeof(*attr_hdr) + len;
}
/** /**
* Get value of attribute from fixed size attribute field. * Get value of attribute from fixed size attribute field.
* *
...@@ -274,22 +331,8 @@ out: ...@@ -274,22 +331,8 @@ out:
ssize_t wlp_get_##name(struct wlp *wlp, struct wlp_attr_##name *attr, \ ssize_t wlp_get_##name(struct wlp *wlp, struct wlp_attr_##name *attr, \
type *value, ssize_t buflen) \ type *value, ssize_t buflen) \
{ \ { \
struct device *dev = &wlp->rc->uwb_dev.dev; \ return wlp_get_attribute(wlp, (type_code), &attr->hdr, \
if (buflen < 0) \ value, sizeof(*value), buflen); \
return -EINVAL; \
if (buflen < sizeof(*attr)) { \
dev_err(dev, "WLP: Not enough space in buffer to parse" \
" attribute field. Need %d, received %zu\n", \
(int)sizeof(*attr), buflen); \
return -EIO; \
} \
if (wlp_check_attr_hdr(wlp, &attr->hdr, type_code, \
sizeof(attr->name)) < 0) { \
dev_err(dev, "WLP: Header verification failed. \n"); \
return -EINVAL; \
} \
*value = attr->name; \
return sizeof(*attr); \
} }
#define wlp_get_sparse(type, type_code, name) \ #define wlp_get_sparse(type, type_code, name) \
...@@ -313,35 +356,8 @@ static ssize_t wlp_get_##name(struct wlp *wlp, \ ...@@ -313,35 +356,8 @@ static ssize_t wlp_get_##name(struct wlp *wlp, \
struct wlp_attr_##name *attr, \ struct wlp_attr_##name *attr, \
type_val *value, ssize_t buflen) \ type_val *value, ssize_t buflen) \
{ \ { \
struct device *dev = &wlp->rc->uwb_dev.dev; \ return wlp_vget_attribute(wlp, (type_code), &attr->hdr, \
size_t len; \ value, (max), buflen); \
if (buflen < 0) \
return -EINVAL; \
if (buflen < sizeof(*attr)) { \
dev_err(dev, "WLP: Not enough space in buffer to parse" \
" header.\n"); \
return -EIO; \
} \
if (le16_to_cpu(attr->hdr.type) != type_code) { \
dev_err(dev, "WLP: Unexpected attribute type. Got %u, " \
"expected %u.\n", le16_to_cpu(attr->hdr.type), \
type_code); \
return -EINVAL; \
} \
len = le16_to_cpu(attr->hdr.length); \
if (len > max) { \
dev_err(dev, "WLP: Attribute larger than maximum " \
"allowed. Received %zu, max is %d.\n", len, \
(int)max); \
return -EFBIG; \
} \
if (buflen < sizeof(*attr) + len) { \
dev_err(dev, "WLP: Not enough space in buffer to parse "\
"variable data.\n"); \
return -EIO; \
} \
memcpy(value, (void *) attr + sizeof(*attr), len); \
return sizeof(*attr) + len; \
} }
wlp_get(u8, WLP_ATTR_WLP_VER, version) wlp_get(u8, WLP_ATTR_WLP_VER, version)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment