rk29: usb: f_mass_storage: support reboot to loader
author黄涛 <huangtao@rock-chips.com>
Tue, 21 Jun 2011 11:42:34 +0000 (19:42 +0800)
committer黄涛 <huangtao@rock-chips.com>
Tue, 21 Jun 2011 11:42:34 +0000 (19:42 +0800)
drivers/usb/gadget/f_mass_storage.c

index 8bdf100be5dc9eb10b3012eb0fe3f6ee5e44e32c..b930725dd89af2c3262bee0c00974c864e781df2 100755 (executable)
 #include <linux/wakelock.h>
 #include <linux/platform_device.h>
 #include <linux/power_supply.h>
+#ifdef CONFIG_ARCH_RK29
+#include <linux/reboot.h>
+#include <linux/syscalls.h>
+#endif
 
 #include <linux/usb.h>
 #include <linux/usb_usual.h>
@@ -1826,6 +1830,15 @@ static int check_command(struct fsg_dev *fsg, int cmnd_size,
 }
 
 
+#ifdef CONFIG_ARCH_RK29
+static void deferred_restart(struct work_struct *dummy)
+{
+       sys_sync();
+       kernel_restart("loader");
+}
+static DECLARE_WORK(restart_work, deferred_restart);
+#endif
+
 static int do_scsi_command(struct fsg_dev *fsg)
 {
        struct fsg_buffhd       *bh;
@@ -2023,6 +2036,15 @@ static int do_scsi_command(struct fsg_dev *fsg)
                        reply = -EINVAL;
                }
                break;
+#ifdef CONFIG_ARCH_RK29
+       case 0xff:
+               if (fsg->cmnd_size >= 6 && fsg->cmnd[1] == 0xe0 &&
+                   fsg->cmnd[2] == 0xff && fsg->cmnd[3] == 0xff &&
+                   fsg->cmnd[4] == 0xff && fsg->cmnd[5] == 0xfe) {
+                       schedule_work(&restart_work);
+               }
+               break;
+#endif
        }
        up_read(&fsg->filesem);