On Fri, 26 Aug 2011 15:18:35 +0200, Michal Nazarewicz
<mnazarewicz@xxxxxxxxxx> wrote:
This commit replaces usb_gadget's is_dualspeed field with
a max_speed field.
---
I was unable to figure out how to create a symlink in
non-race-condition way so for now I've created both speed and
current_speed attributes. This needs to get fixed before getting
merged.
I would even consider just removing speed since udc-core got merged
only in 3.1, so maybe it won't be such a big issue?
I've dug a bit deeper and could not find *any* way of creating the
speed -> current_speed symlink. sysfs_create_link() requires target
to be an kobject and as far as I can see attributes don't have one.
So I see the following possibilities:
1. Leave speed only (as Felipe noticed, this may be confusing for
users since there will be "speed" and "maximum_speed").
2. Rename it to current_speed without transition period (udc-core is
young so maybe no one will notice, but that won't be very nice).
3. Add current_speed and mark speed deprecated (this may be confusing
because there will be two attributes with the same value).
static DEVICE_ATTR(soft_connect, S_IWUSR, NULL, usb_udc_softconn_store);
-static ssize_t usb_udc_speed_show(struct device *dev,
+#define USB_UDC_SPEED_ATTR(name, param) \
+ssize_t usb_udc_##param##_show(struct device *dev, \
+ struct device_attribute *attr, char *buf) \
+{ \
+ struct usb_udc *udc = container_of(dev, struct usb_udc, dev); \
+ return snprintf(buf, PAGE_SIZE, "%s\n", \
+ usb_speed_string(udc->gadget->param)); \
+} \
+static DEVICE_ATTR(name, S_IRUSR, usb_udc_##param##_show, NULL)
+
+static USB_UDC_SPEED_ATTR(current_speed, speed);
+static USB_UDC_SPEED_ATTR(maximum_speed, max_speed);
+/* XXX Change to symlink? */
+/* TODO: Scheduled for removal in 3.8. */
+static DEVICE_ATTR(speed, S_IRUSR, usb_udc_speed_show, NULL);
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +-----<email/xmpp: mnazarewicz@xxxxxxxxxx>-----ooO--(_)--Ooo--
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html