aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/chipidea/debug.c
diff options
context:
space:
mode:
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>2013-03-30 06:53:52 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-30 11:08:39 -0400
commitc8e333a3b17050800a5aa536feb628f18d2a01a2 (patch)
treeffb59bccb212e3e28802d3deed5cf43869e6c2b0 /drivers/usb/chipidea/debug.c
parent2d6512892c106556f07e502939005e73cdc6e2cc (diff)
usb: chipidea: move role to debugfs
Manual role switching function is there for debugging purposes, so has to move to debugfs. Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/chipidea/debug.c')
-rw-r--r--drivers/usb/chipidea/debug.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c
index 057ae09025bf..5738079734e3 100644
--- a/drivers/usb/chipidea/debug.c
+++ b/drivers/usb/chipidea/debug.c
@@ -199,6 +199,55 @@ static const struct file_operations ci_requests_fops = {
199 .release = single_release, 199 .release = single_release,
200}; 200};
201 201
202static int ci_role_show(struct seq_file *s, void *data)
203{
204 struct ci13xxx *ci = s->private;
205
206 seq_printf(s, "%s\n", ci_role(ci)->name);
207
208 return 0;
209}
210
211static ssize_t ci_role_write(struct file *file, const char __user *ubuf,
212 size_t count, loff_t *ppos)
213{
214 struct seq_file *s = file->private_data;
215 struct ci13xxx *ci = s->private;
216 enum ci_role role;
217 char buf[8];
218 int ret;
219
220 if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
221 return -EFAULT;
222
223 for (role = CI_ROLE_HOST; role < CI_ROLE_END; role++)
224 if (ci->roles[role] &&
225 !strncmp(buf, ci->roles[role]->name,
226 strlen(ci->roles[role]->name)))
227 break;
228
229 if (role == CI_ROLE_END || role == ci->role)
230 return -EINVAL;
231
232 ci_role_stop(ci);
233 ret = ci_role_start(ci, role);
234
235 return ret ? ret : count;
236}
237
238static int ci_role_open(struct inode *inode, struct file *file)
239{
240 return single_open(file, ci_role_show, inode->i_private);
241}
242
243static const struct file_operations ci_role_fops = {
244 .open = ci_role_open,
245 .write = ci_role_write,
246 .read = seq_read,
247 .llseek = seq_lseek,
248 .release = single_release,
249};
250
202/** 251/**
203 * dbg_create_files: initializes the attribute interface 252 * dbg_create_files: initializes the attribute interface
204 * @ci: device 253 * @ci: device
@@ -230,6 +279,11 @@ int dbg_create_files(struct ci13xxx *ci)
230 279
231 dent = debugfs_create_file("requests", S_IRUGO, ci->debugfs, ci, 280 dent = debugfs_create_file("requests", S_IRUGO, ci->debugfs, ci,
232 &ci_requests_fops); 281 &ci_requests_fops);
282 if (!dent)
283 goto err;
284
285 dent = debugfs_create_file("role", S_IRUGO | S_IWUSR, ci->debugfs, ci,
286 &ci_role_fops);
233 if (dent) 287 if (dent)
234 return 0; 288 return 0;
235err: 289err: