usb/core: add uevent notification interface for usb warnings
authorWu, Hao <hao.wu@intel.com>
Thu, 17 May 2012 07:23:19 +0000 (15:23 +0800)
committerbuildbot <buildbot@intel.com>
Tue, 22 May 2012 10:22:41 +0000 (03:22 -0700)
BZ: 30607

This patch added basic notification function used to send uevents
to userspace for usb warnings.

Change-Id: I8cac8481d087a59eb069971207e75bb97ab7f3b5
Signed-off-by: Wu, Hao <hao.wu@intel.com>
Reviewed-on: http://android.intel.com:8080/49176
Reviewed-by: Zhuang, Jin Can <jin.can.zhuang@intel.com>
Reviewed-by: Tang, Richard <richard.tang@intel.com>
Reviewed-by: Tang, Jianqiang <jianqiang.tang@intel.com>
Reviewed-by: Meng, Zhe <zhe.meng@intel.com>
Tested-by: Meng, Zhe <zhe.meng@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
drivers/usb/core/notify.c
drivers/usb/core/usb.h

index 7542dce..cc35a8b 100644 (file)
@@ -66,3 +66,17 @@ void usb_notify_remove_bus(struct usb_bus *ubus)
 {
        blocking_notifier_call_chain(&usb_notifier_list, USB_BUS_REMOVE, ubus);
 }
+
+void usb_notify_warning(struct usb_device *udev, int error)
+{
+       char *notsupport[2] = { "USB_WARNING=DEVICE_NOT_SUPPORT", NULL };
+       char *notrespond[2] = { "USB_WARNING=DEVICE_NOT_RESPONDING", NULL };
+       char **uevent_envp = NULL;
+
+       if (error == -ETIMEDOUT)
+               uevent_envp = notrespond;
+       else
+               uevent_envp = notsupport;
+
+       kobject_uevent_env(&udev->dev.kobj, KOBJ_CHANGE, uevent_envp);
+}
index d44d4b7..39099f5 100644 (file)
@@ -162,3 +162,5 @@ extern void usb_notify_remove_device(struct usb_device *udev);
 extern void usb_notify_add_bus(struct usb_bus *ubus);
 extern void usb_notify_remove_bus(struct usb_bus *ubus);
 
+/* uevent notify stuff */
+extern void usb_notify_warning(struct usb_device *udev, int error);