Skip to contentSkip to conversation

usb: core: endpoint: Add error messages for usb_create_ep_devs()

PATCH Suwan Kim 1 participant 1 message Jan 21, 2019 USB

lore
Share & tools
lore

Suwan Kim

author
#0 lore raw

usb_create_ep_devs() returns error code if an error occurs. But usb_new_device() and create_intf_ep_devs() which use usb_create_ep_devs() to create endpoint devices ignore the error and cut the propagation of the error when usb_create_ep_devs() fails. So, usb_create_ep_devs() prints an error message for debugging or notification purposes if an error occurs.

---
 drivers/usb/core/endpoint.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/core/endpoint.c +4 -1
index 1c2c04079676..ad3902c023d9 100644
@@ -182,6 +182,7 @@ int usb_create_ep_devs(struct device *parent,
 
 	ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL);
 	if (!ep_dev) {
+		dev_err(parent, "endpoint device alloc failed\n");
 		retval = -ENOMEM;
 		goto exit;
 	}
@@ -194,8 +195,10 @@ int usb_create_ep_devs(struct device *parent,
 	dev_set_name(&ep_dev->dev, "ep_%02x", endpoint->desc.bEndpointAddress);
 
 	retval = device_register(&ep_dev->dev);
-	if (retval)
+	if (retval) {
+		dev_err(parent, "endpoint device register failed\n");
 		goto error_register;
+	}
 
 	device_enable_async_suspend(&ep_dev->dev);
 	endpoint->ep_dev = ep_dev;