|
@@ -1671,17 +1671,20 @@ musb_mode_store(struct device *dev, struct device_attribute *attr,
|
|
|
{
|
|
|
struct musb *musb = dev_to_musb(dev);
|
|
|
unsigned long flags;
|
|
|
+ int status;
|
|
|
|
|
|
spin_lock_irqsave(&musb->lock, flags);
|
|
|
- if (!strncmp(buf, "host", 4))
|
|
|
- musb_platform_set_mode(musb, MUSB_HOST);
|
|
|
- if (!strncmp(buf, "peripheral", 10))
|
|
|
- musb_platform_set_mode(musb, MUSB_PERIPHERAL);
|
|
|
- if (!strncmp(buf, "otg", 3))
|
|
|
- musb_platform_set_mode(musb, MUSB_OTG);
|
|
|
+ if (sysfs_streq(buf, "host"))
|
|
|
+ status = musb_platform_set_mode(musb, MUSB_HOST);
|
|
|
+ else if (sysfs_streq(buf, "peripheral"))
|
|
|
+ status = musb_platform_set_mode(musb, MUSB_PERIPHERAL);
|
|
|
+ else if (sysfs_streq(buf, "otg"))
|
|
|
+ status = musb_platform_set_mode(musb, MUSB_OTG);
|
|
|
+ else
|
|
|
+ status = -EINVAL;
|
|
|
spin_unlock_irqrestore(&musb->lock, flags);
|
|
|
|
|
|
- return n;
|
|
|
+ return (status == 0) ? n : status;
|
|
|
}
|
|
|
static DEVICE_ATTR(mode, 0644, musb_mode_show, musb_mode_store);
|
|
|
|