Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: chipidea: debug: remove redundant 'role' debug file

Two 'role' file exist in different position but with totally same function.

1. /sys/devices/platform/soc@0/xxxxxxxx.usb/ci_hdrc.0/role
2. /sys/kernel/debug/usb/ci_hdrc.0/role

This will remove the 2rd redundant 'role' debug file (under debugfs) and
keep the one which is more closer to user.

Acked-by: Peter Chen <peter.chen@kernel.org>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Link: https://lore.kernel.org/r/20230317061651.2457567-1-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Xu Yang and committed by
Greg Kroah-Hartman
a0c7f9f6 9abe15d5

-55
-55
drivers/usb/chipidea/debug.c
··· 247 247 } 248 248 DEFINE_SHOW_ATTRIBUTE(ci_otg); 249 249 250 - static int ci_role_show(struct seq_file *s, void *data) 251 - { 252 - struct ci_hdrc *ci = s->private; 253 - 254 - if (ci->role != CI_ROLE_END) 255 - seq_printf(s, "%s\n", ci_role(ci)->name); 256 - 257 - return 0; 258 - } 259 - 260 - static ssize_t ci_role_write(struct file *file, const char __user *ubuf, 261 - size_t count, loff_t *ppos) 262 - { 263 - struct seq_file *s = file->private_data; 264 - struct ci_hdrc *ci = s->private; 265 - enum ci_role role; 266 - char buf[8]; 267 - int ret; 268 - 269 - if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count))) 270 - return -EFAULT; 271 - 272 - for (role = CI_ROLE_HOST; role < CI_ROLE_END; role++) 273 - if (ci->roles[role] && 274 - !strncmp(buf, ci->roles[role]->name, 275 - strlen(ci->roles[role]->name))) 276 - break; 277 - 278 - if (role == CI_ROLE_END || role == ci->role) 279 - return -EINVAL; 280 - 281 - pm_runtime_get_sync(ci->dev); 282 - disable_irq(ci->irq); 283 - ci_role_stop(ci); 284 - ret = ci_role_start(ci, role); 285 - enable_irq(ci->irq); 286 - pm_runtime_put_sync(ci->dev); 287 - 288 - return ret ? ret : count; 289 - } 290 - 291 - static int ci_role_open(struct inode *inode, struct file *file) 292 - { 293 - return single_open(file, ci_role_show, inode->i_private); 294 - } 295 - 296 - static const struct file_operations ci_role_fops = { 297 - .open = ci_role_open, 298 - .write = ci_role_write, 299 - .read = seq_read, 300 - .llseek = seq_lseek, 301 - .release = single_release, 302 - }; 303 - 304 250 static int ci_registers_show(struct seq_file *s, void *unused) 305 251 { 306 252 struct ci_hdrc *ci = s->private; ··· 300 354 if (ci_otg_is_fsm_mode(ci)) 301 355 debugfs_create_file("otg", S_IRUGO, dir, ci, &ci_otg_fops); 302 356 303 - debugfs_create_file("role", S_IRUGO | S_IWUSR, dir, ci, &ci_role_fops); 304 357 debugfs_create_file("registers", S_IRUGO, dir, ci, &ci_registers_fops); 305 358 } 306 359