Skip to content

Commit e12a76f

Browse files
Al Virogregkh
authored andcommitted
mediatek: stop messing with ->d_iname
use debgufs_{create_file,get}_aux_num() instead. Signed-off-by: Al Viro <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1eb8700 commit e12a76f

File tree

1 file changed

+10
-30
lines changed

1 file changed

+10
-30
lines changed

drivers/phy/mediatek/phy-mtk-tphy.c

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -381,17 +381,12 @@ static const char *const u3_phy_files[] = {
381381
static int u2_phy_params_show(struct seq_file *sf, void *unused)
382382
{
383383
struct mtk_phy_instance *inst = sf->private;
384-
const char *fname = file_dentry(sf->file)->d_iname;
385384
struct u2phy_banks *u2_banks = &inst->u2_banks;
386385
void __iomem *com = u2_banks->com;
387386
u32 max = 0;
388387
u32 tmp = 0;
389388
u32 val = 0;
390-
int ret;
391-
392-
ret = match_string(u2_phy_files, ARRAY_SIZE(u2_phy_files), fname);
393-
if (ret < 0)
394-
return ret;
389+
int ret = debugfs_get_aux_num(sf->file);
395390

396391
switch (ret) {
397392
case U2P_EYE_VRT:
@@ -438,7 +433,7 @@ static int u2_phy_params_show(struct seq_file *sf, void *unused)
438433
break;
439434
}
440435

441-
seq_printf(sf, "%s : %d [0, %d]\n", fname, val, max);
436+
seq_printf(sf, "%s : %d [0, %d]\n", u2_phy_files[ret], val, max);
442437

443438
return 0;
444439
}
@@ -451,23 +446,18 @@ static int u2_phy_params_open(struct inode *inode, struct file *file)
451446
static ssize_t u2_phy_params_write(struct file *file, const char __user *ubuf,
452447
size_t count, loff_t *ppos)
453448
{
454-
const char *fname = file_dentry(file)->d_iname;
455449
struct seq_file *sf = file->private_data;
456450
struct mtk_phy_instance *inst = sf->private;
457451
struct u2phy_banks *u2_banks = &inst->u2_banks;
458452
void __iomem *com = u2_banks->com;
459453
ssize_t rc;
460454
u32 val;
461-
int ret;
455+
int ret = debugfs_get_aux_num(file);
462456

463457
rc = kstrtouint_from_user(ubuf, USER_BUF_LEN(count), 0, &val);
464458
if (rc)
465459
return rc;
466460

467-
ret = match_string(u2_phy_files, ARRAY_SIZE(u2_phy_files), fname);
468-
if (ret < 0)
469-
return (ssize_t)ret;
470-
471461
switch (ret) {
472462
case U2P_EYE_VRT:
473463
mtk_phy_update_field(com + U3P_USBPHYACR1, PA1_RG_VRT_SEL, val);
@@ -516,23 +506,18 @@ static void u2_phy_dbgfs_files_create(struct mtk_phy_instance *inst)
516506
int i;
517507

518508
for (i = 0; i < count; i++)
519-
debugfs_create_file(u2_phy_files[i], 0644, inst->phy->debugfs,
520-
inst, &u2_phy_fops);
509+
debugfs_create_file_aux_num(u2_phy_files[i], 0644, inst->phy->debugfs,
510+
inst, i, &u2_phy_fops);
521511
}
522512

523513
static int u3_phy_params_show(struct seq_file *sf, void *unused)
524514
{
525515
struct mtk_phy_instance *inst = sf->private;
526-
const char *fname = file_dentry(sf->file)->d_iname;
527516
struct u3phy_banks *u3_banks = &inst->u3_banks;
528517
u32 val = 0;
529518
u32 max = 0;
530519
u32 tmp;
531-
int ret;
532-
533-
ret = match_string(u3_phy_files, ARRAY_SIZE(u3_phy_files), fname);
534-
if (ret < 0)
535-
return ret;
520+
int ret = debugfs_get_aux_num(sf->file);
536521

537522
switch (ret) {
538523
case U3P_EFUSE_EN:
@@ -564,7 +549,7 @@ static int u3_phy_params_show(struct seq_file *sf, void *unused)
564549
break;
565550
}
566551

567-
seq_printf(sf, "%s : %d [0, %d]\n", fname, val, max);
552+
seq_printf(sf, "%s : %d [0, %d]\n", u3_phy_files[ret], val, max);
568553

569554
return 0;
570555
}
@@ -577,23 +562,18 @@ static int u3_phy_params_open(struct inode *inode, struct file *file)
577562
static ssize_t u3_phy_params_write(struct file *file, const char __user *ubuf,
578563
size_t count, loff_t *ppos)
579564
{
580-
const char *fname = file_dentry(file)->d_iname;
581565
struct seq_file *sf = file->private_data;
582566
struct mtk_phy_instance *inst = sf->private;
583567
struct u3phy_banks *u3_banks = &inst->u3_banks;
584568
void __iomem *phyd = u3_banks->phyd;
585569
ssize_t rc;
586570
u32 val;
587-
int ret;
571+
int ret = debugfs_get_aux_num(sf->file);
588572

589573
rc = kstrtouint_from_user(ubuf, USER_BUF_LEN(count), 0, &val);
590574
if (rc)
591575
return rc;
592576

593-
ret = match_string(u3_phy_files, ARRAY_SIZE(u3_phy_files), fname);
594-
if (ret < 0)
595-
return (ssize_t)ret;
596-
597577
switch (ret) {
598578
case U3P_EFUSE_EN:
599579
mtk_phy_update_field(phyd + U3P_U3_PHYD_RSV,
@@ -636,8 +616,8 @@ static void u3_phy_dbgfs_files_create(struct mtk_phy_instance *inst)
636616
int i;
637617

638618
for (i = 0; i < count; i++)
639-
debugfs_create_file(u3_phy_files[i], 0644, inst->phy->debugfs,
640-
inst, &u3_phy_fops);
619+
debugfs_create_file_aux_num(u3_phy_files[i], 0644, inst->phy->debugfs,
620+
inst, i, &u3_phy_fops);
641621
}
642622

643623
static int phy_type_show(struct seq_file *sf, void *unused)

0 commit comments

Comments
 (0)