summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorJack Pham <jackp@codeaurora.org>2017-03-02 11:10:38 -0800
committerJack Pham <jackp@codeaurora.org>2017-03-02 11:46:29 -0800
commit563b2f7a6bed72d34560df5f4358e948eb52a43f (patch)
tree8f659ae4d900d6826db1ea662113d780fe01af97 /drivers/usb
parent660ab6c3a2409a5de73575976a321b8ae7a4889b (diff)
usb: phy: dual-role: update sysfs attrs when changed
dual_role_instance_changed() is called by drivers when updating the state of the dual_role port device. In some cases a driver may wish to dynamically update the visibility, in particular the write permissions of some of its attributes. For instance, 'data_role' and 'power_role' can be writeable if they can be changed independently, as in the case of a USB PD capable device, but may need to be set back to non-writeable when a non-PD device is attached. Add a call to sysfs_update_group() in dual_role_changed_work() which updates the attributes by calling the .is_visible() callback again, which in turn calls dual_role_property_is_writeable() to re-check whether write permission should be set or not. Move dual_role_changed_work() toward the end of the file as it now needs the definition of dual_role_attr_group. Change-Id: Ie58b37b63f052aced24db00b91e87deff9ffed7e Signed-off-by: Jack Pham <jackp@codeaurora.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/phy/class-dual-role.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/drivers/usb/phy/class-dual-role.c b/drivers/usb/phy/class-dual-role.c
index 51fcb545a9d5..9ef889593ef5 100644
--- a/drivers/usb/phy/class-dual-role.c
+++ b/drivers/usb/phy/class-dual-role.c
@@ -70,15 +70,7 @@ static char *kstrdupcase(const char *str, gfp_t gfp, bool to_upper)
return ret;
}
-static void dual_role_changed_work(struct work_struct *work)
-{
- struct dual_role_phy_instance *dual_role =
- container_of(work, struct dual_role_phy_instance,
- changed_work);
-
- dev_dbg(&dual_role->dev, "%s\n", __func__);
- kobject_uevent(&dual_role->dev.kobj, KOBJ_CHANGE);
-}
+static void dual_role_changed_work(struct work_struct *work);
void dual_role_instance_changed(struct dual_role_phy_instance *dual_role)
{
@@ -505,6 +497,17 @@ out:
return ret;
}
+static void dual_role_changed_work(struct work_struct *work)
+{
+ struct dual_role_phy_instance *dual_role =
+ container_of(work, struct dual_role_phy_instance,
+ changed_work);
+
+ dev_dbg(&dual_role->dev, "%s\n", __func__);
+ sysfs_update_group(&dual_role->dev.kobj, &dual_role_attr_group);
+ kobject_uevent(&dual_role->dev.kobj, KOBJ_CHANGE);
+}
+
/******************* Module Init ***********************************/
static int __init dual_role_class_init(void)