Skip to content

Commit 8ceb294

Browse files
TinyWindzzstorulf
authored andcommitted
mmc: convert to DEFINE_SHOW_ATTRIBUTE
Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. Signed-off-by: Yangtao Li <tiny.windzz@gmail.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent feb3574 commit 8ceb294

File tree

4 files changed

+13
-76
lines changed

4 files changed

+13
-76
lines changed

drivers/mmc/core/mmc_test.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3145,17 +3145,7 @@ static int mtf_testlist_show(struct seq_file *sf, void *data)
31453145
return 0;
31463146
}
31473147

3148-
static int mtf_testlist_open(struct inode *inode, struct file *file)
3149-
{
3150-
return single_open(file, mtf_testlist_show, inode->i_private);
3151-
}
3152-
3153-
static const struct file_operations mmc_test_fops_testlist = {
3154-
.open = mtf_testlist_open,
3155-
.read = seq_read,
3156-
.llseek = seq_lseek,
3157-
.release = single_release,
3158-
};
3148+
DEFINE_SHOW_ATTRIBUTE(mtf_testlist);
31593149

31603150
static void mmc_test_free_dbgfs_file(struct mmc_card *card)
31613151
{
@@ -3216,7 +3206,7 @@ static int mmc_test_register_dbgfs_file(struct mmc_card *card)
32163206
goto err;
32173207

32183208
ret = __mmc_test_register_dbgfs_file(card, "testlist", S_IRUGO,
3219-
&mmc_test_fops_testlist);
3209+
&mtf_testlist_fops);
32203210
if (ret)
32213211
goto err;
32223212

drivers/mmc/host/atmel-mci.c

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -446,18 +446,7 @@ static int atmci_req_show(struct seq_file *s, void *v)
446446
return 0;
447447
}
448448

449-
static int atmci_req_open(struct inode *inode, struct file *file)
450-
{
451-
return single_open(file, atmci_req_show, inode->i_private);
452-
}
453-
454-
static const struct file_operations atmci_req_fops = {
455-
.owner = THIS_MODULE,
456-
.open = atmci_req_open,
457-
.read = seq_read,
458-
.llseek = seq_lseek,
459-
.release = single_release,
460-
};
449+
DEFINE_SHOW_ATTRIBUTE(atmci_req);
461450

462451
static void atmci_show_status_reg(struct seq_file *s,
463452
const char *regname, u32 value)
@@ -583,18 +572,7 @@ static int atmci_regs_show(struct seq_file *s, void *v)
583572
return ret;
584573
}
585574

586-
static int atmci_regs_open(struct inode *inode, struct file *file)
587-
{
588-
return single_open(file, atmci_regs_show, inode->i_private);
589-
}
590-
591-
static const struct file_operations atmci_regs_fops = {
592-
.owner = THIS_MODULE,
593-
.open = atmci_regs_open,
594-
.read = seq_read,
595-
.llseek = seq_lseek,
596-
.release = single_release,
597-
};
575+
DEFINE_SHOW_ATTRIBUTE(atmci_regs);
598576

599577
static void atmci_init_debugfs(struct atmel_mci_slot *slot)
600578
{
@@ -608,13 +586,14 @@ static void atmci_init_debugfs(struct atmel_mci_slot *slot)
608586
return;
609587

610588
node = debugfs_create_file("regs", S_IRUSR, root, host,
611-
&atmci_regs_fops);
589+
&atmci_regs_fops);
612590
if (IS_ERR(node))
613591
return;
614592
if (!node)
615593
goto err;
616594

617-
node = debugfs_create_file("req", S_IRUSR, root, slot, &atmci_req_fops);
595+
node = debugfs_create_file("req", S_IRUSR, root, slot,
596+
&atmci_req_fops);
618597
if (!node)
619598
goto err;
620599

drivers/mmc/host/omap_hsmmc.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,7 @@ static struct mmc_host_ops omap_hsmmc_ops = {
16521652

16531653
#ifdef CONFIG_DEBUG_FS
16541654

1655-
static int omap_hsmmc_regs_show(struct seq_file *s, void *data)
1655+
static int mmc_regs_show(struct seq_file *s, void *data)
16561656
{
16571657
struct mmc_host *mmc = s->private;
16581658
struct omap_hsmmc_host *host = mmc_priv(mmc);
@@ -1691,17 +1691,7 @@ static int omap_hsmmc_regs_show(struct seq_file *s, void *data)
16911691
return 0;
16921692
}
16931693

1694-
static int omap_hsmmc_regs_open(struct inode *inode, struct file *file)
1695-
{
1696-
return single_open(file, omap_hsmmc_regs_show, inode->i_private);
1697-
}
1698-
1699-
static const struct file_operations mmc_regs_fops = {
1700-
.open = omap_hsmmc_regs_open,
1701-
.read = seq_read,
1702-
.llseek = seq_lseek,
1703-
.release = single_release,
1704-
};
1694+
DEFINE_SHOW_ATTRIBUTE(mmc_regs);
17051695

17061696
static void omap_hsmmc_debugfs(struct mmc_host *mmc)
17071697
{

drivers/mmc/host/s3cmci.c

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,18 +1405,7 @@ static int s3cmci_state_show(struct seq_file *seq, void *v)
14051405
return 0;
14061406
}
14071407

1408-
static int s3cmci_state_open(struct inode *inode, struct file *file)
1409-
{
1410-
return single_open(file, s3cmci_state_show, inode->i_private);
1411-
}
1412-
1413-
static const struct file_operations s3cmci_fops_state = {
1414-
.owner = THIS_MODULE,
1415-
.open = s3cmci_state_open,
1416-
.read = seq_read,
1417-
.llseek = seq_lseek,
1418-
.release = single_release,
1419-
};
1408+
DEFINE_SHOW_ATTRIBUTE(s3cmci_state);
14201409

14211410
#define DBG_REG(_r) { .addr = S3C2410_SDI##_r, .name = #_r }
14221411

@@ -1458,18 +1447,7 @@ static int s3cmci_regs_show(struct seq_file *seq, void *v)
14581447
return 0;
14591448
}
14601449

1461-
static int s3cmci_regs_open(struct inode *inode, struct file *file)
1462-
{
1463-
return single_open(file, s3cmci_regs_show, inode->i_private);
1464-
}
1465-
1466-
static const struct file_operations s3cmci_fops_regs = {
1467-
.owner = THIS_MODULE,
1468-
.open = s3cmci_regs_open,
1469-
.read = seq_read,
1470-
.llseek = seq_lseek,
1471-
.release = single_release,
1472-
};
1450+
DEFINE_SHOW_ATTRIBUTE(s3cmci_regs);
14731451

14741452
static void s3cmci_debugfs_attach(struct s3cmci_host *host)
14751453
{
@@ -1483,14 +1461,14 @@ static void s3cmci_debugfs_attach(struct s3cmci_host *host)
14831461

14841462
host->debug_state = debugfs_create_file("state", 0444,
14851463
host->debug_root, host,
1486-
&s3cmci_fops_state);
1464+
&s3cmci_state_fops);
14871465

14881466
if (IS_ERR(host->debug_state))
14891467
dev_err(dev, "failed to create debug state file\n");
14901468

14911469
host->debug_regs = debugfs_create_file("regs", 0444,
14921470
host->debug_root, host,
1493-
&s3cmci_fops_regs);
1471+
&s3cmci_regs_fops);
14941472

14951473
if (IS_ERR(host->debug_regs))
14961474
dev_err(dev, "failed to create debug regs file\n");

0 commit comments

Comments
 (0)