usb: typec: Return size of buffer if pd_set operation succeeds
Subsystems (3)
PATCH 1/1 usb: typec: Return size of buffer if pd_set operation succeeds
The attribute writing should return the number of bytes used from the buffer on success.
Fixes a7cff92f0635 ("usb: typec: USB Power Delivery helpers for ports and partners")
Signed-off-by Kyle Tso <[email protected]>
--- drivers/usb/typec/class.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/usb/typec/class.c +6 -1
@@ -1310,6 +1310,7 @@ static ssize_t select_usb_power_delivery_store(struct device *dev, {struct typec_port *port =to_typec_port (dev);struct usb_power_delivery *pd; +int ret;if (!port->ops || !port->ops->pd_set)return -EOPNOTSUPP ;
@@ -1318,7 +1319,11 @@ static ssize_t select_usb_power_delivery_store(struct device *dev,if (!pd)return -EINVAL ; -return port->ops->pd_set (port, pd); + ret = port->ops->pd_set (port, pd); +if (ret) +return ret; + +return size; } static ssize_t select_usb_power_delivery_show(struct device *dev,
Signature · 1 line
2.44.0.291.gc1ea87d7ee-goog
Quoted 6 lines · Kyle Tso
The attribute writing should return the number of bytes used from the buffer on success.
Fixes a7cff92f0635 ("usb: typec: USB Power Delivery helpers for ports and partners")Signed-off-by Kyle Tso <[email protected]>
Reviewed-by Guenter Roeck <[email protected]>
Quoted 29 lines
--- drivers/usb/typec/class.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/usb/typec/class.c +6
-1@@ -1310,6 +1310,7 @@ static ssize_t select_usb_power_delivery_store(struct device *dev, {struct typec_port *port =to_typec_port (dev);struct usb_power_delivery *pd; +int ret;if (!port->ops || !port->ops->pd_set)return -EOPNOTSUPP ;@@ -1318,7 +1319,11 @@ static ssize_t select_usb_power_delivery_store(struct device *dev,if (!pd)return -EINVAL ; -return port->ops->pd_set (port, pd); + ret = port->ops->pd_set (port, pd); +if (ret) +return ret; + +return size; } static ssize_t select_usb_power_delivery_show(struct device *dev,
Quoted 6 lines · Kyle Tso
The attribute writing should return the number of bytes used from the buffer on success.
Fixes a7cff92f0635 ("usb: typec: USB Power Delivery helpers for ports and partners")Signed-off-by Kyle Tso <[email protected]>
Reviewed-by Heikki Krogerus <[email protected]>
Quoted 31 lines
--- drivers/usb/typec/class.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/usb/typec/class.c +6
-1@@ -1310,6 +1310,7 @@ static ssize_t select_usb_power_delivery_store(struct device *dev, {struct typec_port *port =to_typec_port (dev);struct usb_power_delivery *pd; +int ret;if (!port->ops || !port->ops->pd_set)return -EOPNOTSUPP ;@@ -1318,7 +1319,11 @@ static ssize_t select_usb_power_delivery_store(struct device *dev,if (!pd)return -EINVAL ; -return port->ops->pd_set (port, pd); + ret = port->ops->pd_set (port, pd); +if (ret) +return ret; + +return size; } static ssize_t select_usb_power_delivery_show(struct device *dev,Signature · 1 line
2.44.0.291.gc1ea87d7ee-goog
Signature · 1 line
heikki