Skip to content

Commit cc006a2

Browse files
committed
Merge tag 'platform-drivers-x86-v4.16-2' of git://git.infradead.org/linux-platform-drivers-x86
Pull more x86 platform-drivers updates from Andy Shevchenko: "The DEFINE_SHOW_ATTRIBUTE() macro was defined privately in three locations and is useful for new and old users to avoid a lot of code duplication. Move the macro to seq_file.h. Along with above, clean up three drivers to use that macro. This, due to dependencies, was sent separately since affected changes weren't upstream originally yet. The rationale of doing this now is to allow use of new macro in v4.17 cycle in a conflictless manner" * tag 'platform-drivers-x86-v4.16-2' of git://git.infradead.org/linux-platform-drivers-x86: platform/x86: samsung-laptop: Re-use DEFINE_SHOW_ATTRIBUTE() macro platform/x86: ideapad-laptop: Re-use DEFINE_SHOW_ATTRIBUTE() macro platform/x86: dell-laptop: Re-use DEFINE_SHOW_ATTRIBUTE() macro seq_file: Introduce DEFINE_SHOW_ATTRIBUTE() helper macro
2 parents 7590e37 + 9a7c551 commit cc006a2

7 files changed

Lines changed: 20 additions & 95 deletions

File tree

‎drivers/mfd/ab8500-debugfs.c‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,20 +1258,6 @@ static struct ab8500_prcmu_ranges ab8540_debug_ranges[AB8500_NUM_BANKS] = {
12581258
},
12591259
};
12601260

1261-
#define DEFINE_SHOW_ATTRIBUTE(__name) \
1262-
static int __name ## _open(struct inode *inode, struct file *file) \
1263-
{ \
1264-
return single_open(file, __name ## _show, inode->i_private); \
1265-
} \
1266-
\
1267-
static const struct file_operations __name ## _fops = { \
1268-
.owner = THIS_MODULE, \
1269-
.open = __name ## _open, \
1270-
.read = seq_read, \
1271-
.llseek = seq_lseek, \
1272-
.release = single_release, \
1273-
} \
1274-
12751261
static irqreturn_t ab8500_debug_handler(int irq, void *data)
12761262
{
12771263
char buf[16];

‎drivers/platform/x86/dell-laptop.c‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -636,19 +636,7 @@ static int dell_debugfs_show(struct seq_file *s, void *data)
636636

637637
return 0;
638638
}
639-
640-
static int dell_debugfs_open(struct inode *inode, struct file *file)
641-
{
642-
return single_open(file, dell_debugfs_show, inode->i_private);
643-
}
644-
645-
static const struct file_operations dell_debugfs_fops = {
646-
.owner = THIS_MODULE,
647-
.open = dell_debugfs_open,
648-
.read = seq_read,
649-
.llseek = seq_lseek,
650-
.release = single_release,
651-
};
639+
DEFINE_SHOW_ATTRIBUTE(dell_debugfs);
652640

653641
static void dell_update_rfkill(struct work_struct *ignored)
654642
{

‎drivers/platform/x86/ideapad-laptop.c‎

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -284,19 +284,7 @@ static int debugfs_status_show(struct seq_file *s, void *data)
284284

285285
return 0;
286286
}
287-
288-
static int debugfs_status_open(struct inode *inode, struct file *file)
289-
{
290-
return single_open(file, debugfs_status_show, inode->i_private);
291-
}
292-
293-
static const struct file_operations debugfs_status_fops = {
294-
.owner = THIS_MODULE,
295-
.open = debugfs_status_open,
296-
.read = seq_read,
297-
.llseek = seq_lseek,
298-
.release = single_release,
299-
};
287+
DEFINE_SHOW_ATTRIBUTE(debugfs_status);
300288

301289
static int debugfs_cfg_show(struct seq_file *s, void *data)
302290
{
@@ -337,19 +325,7 @@ static int debugfs_cfg_show(struct seq_file *s, void *data)
337325
}
338326
return 0;
339327
}
340-
341-
static int debugfs_cfg_open(struct inode *inode, struct file *file)
342-
{
343-
return single_open(file, debugfs_cfg_show, inode->i_private);
344-
}
345-
346-
static const struct file_operations debugfs_cfg_fops = {
347-
.owner = THIS_MODULE,
348-
.open = debugfs_cfg_open,
349-
.read = seq_read,
350-
.llseek = seq_lseek,
351-
.release = single_release,
352-
};
328+
DEFINE_SHOW_ATTRIBUTE(debugfs_cfg);
353329

354330
static int ideapad_debugfs_init(struct ideapad_private *priv)
355331
{

‎drivers/platform/x86/pmc_atom.c‎

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -208,20 +208,6 @@ static const struct pmc_data cht_data = {
208208
.clks = cht_clks,
209209
};
210210

211-
#define DEFINE_SHOW_ATTRIBUTE(__name) \
212-
static int __name ## _open(struct inode *inode, struct file *file) \
213-
{ \
214-
return single_open(file, __name ## _show, inode->i_private); \
215-
} \
216-
\
217-
static const struct file_operations __name ## _fops = { \
218-
.owner = THIS_MODULE, \
219-
.open = __name ## _open, \
220-
.read = seq_read, \
221-
.llseek = seq_lseek, \
222-
.release = single_release, \
223-
}
224-
225211
static inline u32 pmc_reg_read(struct pmc_dev *pmc, int reg_offset)
226212
{
227213
return readl(pmc->regmap + reg_offset);

‎drivers/platform/x86/samsung-laptop.c‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ static int __init samsung_sysfs_init(struct samsung_laptop *samsung)
12521252

12531253
}
12541254

1255-
static int show_call(struct seq_file *m, void *data)
1255+
static int samsung_laptop_call_show(struct seq_file *m, void *data)
12561256
{
12571257
struct samsung_laptop *samsung = m->private;
12581258
struct sabi_data *sdata = &samsung->debug.data;
@@ -1274,19 +1274,7 @@ static int show_call(struct seq_file *m, void *data)
12741274
sdata->d0, sdata->d1, sdata->d2, sdata->d3);
12751275
return 0;
12761276
}
1277-
1278-
static int samsung_debugfs_open(struct inode *inode, struct file *file)
1279-
{
1280-
return single_open(file, show_call, inode->i_private);
1281-
}
1282-
1283-
static const struct file_operations samsung_laptop_call_io_ops = {
1284-
.owner = THIS_MODULE,
1285-
.open = samsung_debugfs_open,
1286-
.read = seq_read,
1287-
.llseek = seq_lseek,
1288-
.release = single_release,
1289-
};
1277+
DEFINE_SHOW_ATTRIBUTE(samsung_laptop_call);
12901278

12911279
static void samsung_debugfs_exit(struct samsung_laptop *samsung)
12921280
{
@@ -1351,7 +1339,7 @@ static int samsung_debugfs_init(struct samsung_laptop *samsung)
13511339

13521340
dent = debugfs_create_file("call", S_IFREG | S_IRUGO,
13531341
samsung->debug.root, samsung,
1354-
&samsung_laptop_call_io_ops);
1342+
&samsung_laptop_call_fops);
13551343
if (!dent)
13561344
goto error_debugfs;
13571345

‎include/linux/seq_file.h‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,20 @@ void *__seq_open_private(struct file *, const struct seq_operations *, int);
140140
int seq_open_private(struct file *, const struct seq_operations *, int);
141141
int seq_release_private(struct inode *, struct file *);
142142

143+
#define DEFINE_SHOW_ATTRIBUTE(__name) \
144+
static int __name ## _open(struct inode *inode, struct file *file) \
145+
{ \
146+
return single_open(file, __name ## _show, inode->i_private); \
147+
} \
148+
\
149+
static const struct file_operations __name ## _fops = { \
150+
.owner = THIS_MODULE, \
151+
.open = __name ## _open, \
152+
.read = seq_read, \
153+
.llseek = seq_lseek, \
154+
.release = single_release, \
155+
}
156+
143157
static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
144158
{
145159
#ifdef CONFIG_USER_NS

‎net/bluetooth/hci_debugfs.c‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,6 @@ static int __name ## _show(struct seq_file *f, void *ptr) \
9090
\
9191
DEFINE_SHOW_ATTRIBUTE(__name)
9292

93-
#define DEFINE_SHOW_ATTRIBUTE(__name) \
94-
static int __name ## _open(struct inode *inode, struct file *file) \
95-
{ \
96-
return single_open(file, __name ## _show, inode->i_private); \
97-
} \
98-
\
99-
static const struct file_operations __name ## _fops = { \
100-
.open = __name ## _open, \
101-
.read = seq_read, \
102-
.llseek = seq_lseek, \
103-
.release = single_release, \
104-
} \
105-
10693
static int features_show(struct seq_file *f, void *ptr)
10794
{
10895
struct hci_dev *hdev = f->private;

0 commit comments

Comments
 (0)