diff options
author | Rui Miguel Silva <rui.silva@linaro.org> | 2016-01-11 13:46:33 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@google.com> | 2016-01-12 17:00:19 -0800 |
commit | 2c92bd5235ac72aa659150ebac309dd4f1c01079 (patch) | |
tree | ec6f4269e7fcdfd1c6e4490f04eb3864a8d58e98 /drivers/staging/greybus/svc.c | |
parent | c5d55fb3596db4064491e7e5db6df8bf8f046078 (diff) |
greybus: svc: add intf_eject attribute
Add a new write-only svc attribute to send an eject request to the svc
giving the interface number.
So, doing:
echo 3 > /sys/bus/greybus/devices/1-svc/intf_eject
will force eject the module on interface 3 (module slot 1 on EVT1).
This can take some seconds as the pulse width for module release is
large.
Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Reviewed-by: Jeffrey Carlyle <jcarlyle@google.com>
Diffstat (limited to 'drivers/staging/greybus/svc.c')
-rw-r--r-- | drivers/staging/greybus/svc.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/drivers/staging/greybus/svc.c b/drivers/staging/greybus/svc.c index ef10b67c7bf5..be62d308d1c9 100644 --- a/drivers/staging/greybus/svc.c +++ b/drivers/staging/greybus/svc.c @@ -40,9 +40,38 @@ static ssize_t ap_intf_id_show(struct device *dev, } static DEVICE_ATTR_RO(ap_intf_id); + +// FIXME +// This is a hack, we need to do this "right" and clean the interface up +// properly, not just forcibly yank the thing out of the system and hope for the +// best. But for now, people want their modules to come out without having to +// throw the thing to the ground or get out a screwdriver. +static ssize_t intf_eject_store(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t len) +{ + struct gb_svc *svc = to_gb_svc(dev); + unsigned short intf_id; + int ret; + + ret = kstrtou16(buf, 10, &intf_id); + if (ret < 0) + return ret; + + dev_warn(dev, "Forcibly trying to eject interface %d\n", intf_id); + + ret = gb_svc_intf_eject(svc, intf_id); + if (ret < 0) + return ret; + + return len; +} +static DEVICE_ATTR_WO(intf_eject); + static struct attribute *svc_attrs[] = { &dev_attr_endo_id.attr, &dev_attr_ap_intf_id.attr, + &dev_attr_intf_eject.attr, NULL, }; ATTRIBUTE_GROUPS(svc); |