]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
usb: dwc2: Show dr_mode via debugfs
authorJohn Youn <John.Youn@synopsys.com>
Mon, 23 Jan 2017 22:58:52 +0000 (14:58 -0800)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Tue, 24 Jan 2017 14:19:08 +0000 (16:19 +0200)
Show the value of dr_mode via a debufs file.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/dwc2/debugfs.c

index 57747b0df59507860f88117dd7057876a1ab661e..794b959a7c8c1fd30d39b2fc8128c444c153f6f9 100644 (file)
@@ -839,6 +839,29 @@ static const struct file_operations hw_params_fops = {
        .release        = single_release,
 };
 
+static int dr_mode_show(struct seq_file *seq, void *v)
+{
+       struct dwc2_hsotg *hsotg = seq->private;
+       const char *dr_mode = "";
+
+       device_property_read_string(hsotg->dev, "dr_mode", &dr_mode);
+       seq_printf(seq, "%s\n", dr_mode);
+       return 0;
+}
+
+static int dr_mode_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, dr_mode_show, inode->i_private);
+}
+
+static const struct file_operations dr_mode_fops = {
+       .owner          = THIS_MODULE,
+       .open           = dr_mode_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
 int dwc2_debugfs_init(struct dwc2_hsotg *hsotg)
 {
        int                     ret;
@@ -863,6 +886,12 @@ int dwc2_debugfs_init(struct dwc2_hsotg *hsotg)
                dev_err(hsotg->dev, "%s: failed to create hw_params\n",
                        __func__);
 
+       file = debugfs_create_file("dr_mode", 0444,
+                                  hsotg->debug_root,
+                                  hsotg, &dr_mode_fops);
+       if (IS_ERR(file))
+               dev_err(hsotg->dev, "%s: failed to create dr_mode\n", __func__);
+
        /* Add gadget debugfs nodes */
        dwc2_hsotg_create_debug(hsotg);