Skip to content

Commit 234e340

Browse files
bebarinotorvalds
authored andcommitted
simple_open: automatically convert to simple_open()
Many users of debugfs copy the implementation of default_open() when they want to support a custom read/write function op. This leads to a proliferation of the default_open() implementation across the entire tree. Now that the common implementation has been consolidated into libfs we can replace all the users of this function with simple_open(). This replacement was done with the following semantic patch: <smpl> @ open @ identifier open_f != simple_open; identifier i, f; @@ -int open_f(struct inode *i, struct file *f) -{ ( -if (i->i_private) -f->private_data = i->i_private; | -f->private_data = i->i_private; ) -return 0; -} @ has_open depends on open @ identifier fops; identifier open.open_f; @@ struct file_operations fops = { ... -.open = open_f, +.open = simple_open, ... }; </smpl> [[email protected]: checkpatch fixes] Signed-off-by: Stephen Boyd <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Al Viro <[email protected]> Cc: Julia Lawall <[email protected]> Acked-by: Ingo Molnar <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9b3ae64 commit 234e340

File tree

63 files changed

+176
-572
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+176
-572
lines changed

arch/arm/mach-msm/smd_debug.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,15 +203,9 @@ static ssize_t debug_read(struct file *file, char __user *buf,
203203
return simple_read_from_buffer(buf, count, ppos, debug_buffer, bsize);
204204
}
205205

206-
static int debug_open(struct inode *inode, struct file *file)
207-
{
208-
file->private_data = inode->i_private;
209-
return 0;
210-
}
211-
212206
static const struct file_operations debug_ops = {
213207
.read = debug_read,
214-
.open = debug_open,
208+
.open = simple_open,
215209
.llseek = default_llseek,
216210
};
217211

arch/x86/kernel/kdebugfs.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,9 @@ static ssize_t setup_data_read(struct file *file, char __user *user_buf,
6868
return count;
6969
}
7070

71-
static int setup_data_open(struct inode *inode, struct file *file)
72-
{
73-
file->private_data = inode->i_private;
74-
75-
return 0;
76-
}
77-
7871
static const struct file_operations fops_setup_data = {
7972
.read = setup_data_read,
80-
.open = setup_data_open,
73+
.open = simple_open,
8174
.llseek = default_llseek,
8275
};
8376

drivers/acpi/ec_sys.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ MODULE_PARM_DESC(write_support, "Dangerous, reboot and removal of battery may "
2727

2828
static struct dentry *acpi_ec_debugfs_dir;
2929

30-
static int acpi_ec_open_io(struct inode *i, struct file *f)
31-
{
32-
f->private_data = i->i_private;
33-
return 0;
34-
}
35-
3630
static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
3731
size_t count, loff_t *off)
3832
{
@@ -95,7 +89,7 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
9589

9690
static const struct file_operations acpi_ec_io_ops = {
9791
.owner = THIS_MODULE,
98-
.open = acpi_ec_open_io,
92+
.open = simple_open,
9993
.read = acpi_ec_read_io,
10094
.write = acpi_ec_write_io,
10195
.llseek = default_llseek,

drivers/base/regmap/regmap-debugfs.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ static size_t regmap_calc_reg_len(int max_val, char *buf, size_t buf_size)
2727
return strlen(buf);
2828
}
2929

30-
static int regmap_open_file(struct inode *inode, struct file *file)
31-
{
32-
file->private_data = inode->i_private;
33-
return 0;
34-
}
35-
3630
static ssize_t regmap_name_read_file(struct file *file,
3731
char __user *user_buf, size_t count,
3832
loff_t *ppos)
@@ -57,7 +51,7 @@ static ssize_t regmap_name_read_file(struct file *file,
5751
}
5852

5953
static const struct file_operations regmap_name_fops = {
60-
.open = regmap_open_file,
54+
.open = simple_open,
6155
.read = regmap_name_read_file,
6256
.llseek = default_llseek,
6357
};
@@ -174,7 +168,7 @@ static ssize_t regmap_map_write_file(struct file *file,
174168
#endif
175169

176170
static const struct file_operations regmap_map_fops = {
177-
.open = regmap_open_file,
171+
.open = simple_open,
178172
.read = regmap_map_read_file,
179173
.write = regmap_map_write_file,
180174
.llseek = default_llseek,
@@ -243,7 +237,7 @@ static ssize_t regmap_access_read_file(struct file *file,
243237
}
244238

245239
static const struct file_operations regmap_access_fops = {
246-
.open = regmap_open_file,
240+
.open = simple_open,
247241
.read = regmap_access_read_file,
248242
.llseek = default_llseek,
249243
};

drivers/bluetooth/btmrvl_debugfs.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,6 @@ struct btmrvl_debugfs_data {
4545
struct dentry *txdnldready;
4646
};
4747

48-
static int btmrvl_open_generic(struct inode *inode, struct file *file)
49-
{
50-
file->private_data = inode->i_private;
51-
return 0;
52-
}
53-
5448
static ssize_t btmrvl_hscfgcmd_write(struct file *file,
5549
const char __user *ubuf, size_t count, loff_t *ppos)
5650
{
@@ -93,7 +87,7 @@ static ssize_t btmrvl_hscfgcmd_read(struct file *file, char __user *userbuf,
9387
static const struct file_operations btmrvl_hscfgcmd_fops = {
9488
.read = btmrvl_hscfgcmd_read,
9589
.write = btmrvl_hscfgcmd_write,
96-
.open = btmrvl_open_generic,
90+
.open = simple_open,
9791
.llseek = default_llseek,
9892
};
9993

@@ -134,7 +128,7 @@ static ssize_t btmrvl_psmode_read(struct file *file, char __user *userbuf,
134128
static const struct file_operations btmrvl_psmode_fops = {
135129
.read = btmrvl_psmode_read,
136130
.write = btmrvl_psmode_write,
137-
.open = btmrvl_open_generic,
131+
.open = simple_open,
138132
.llseek = default_llseek,
139133
};
140134

@@ -180,7 +174,7 @@ static ssize_t btmrvl_pscmd_read(struct file *file, char __user *userbuf,
180174
static const struct file_operations btmrvl_pscmd_fops = {
181175
.read = btmrvl_pscmd_read,
182176
.write = btmrvl_pscmd_write,
183-
.open = btmrvl_open_generic,
177+
.open = simple_open,
184178
.llseek = default_llseek,
185179
};
186180

@@ -221,7 +215,7 @@ static ssize_t btmrvl_gpiogap_read(struct file *file, char __user *userbuf,
221215
static const struct file_operations btmrvl_gpiogap_fops = {
222216
.read = btmrvl_gpiogap_read,
223217
.write = btmrvl_gpiogap_write,
224-
.open = btmrvl_open_generic,
218+
.open = simple_open,
225219
.llseek = default_llseek,
226220
};
227221

@@ -265,7 +259,7 @@ static ssize_t btmrvl_hscmd_read(struct file *file, char __user *userbuf,
265259
static const struct file_operations btmrvl_hscmd_fops = {
266260
.read = btmrvl_hscmd_read,
267261
.write = btmrvl_hscmd_write,
268-
.open = btmrvl_open_generic,
262+
.open = simple_open,
269263
.llseek = default_llseek,
270264
};
271265

@@ -305,7 +299,7 @@ static ssize_t btmrvl_hsmode_read(struct file *file, char __user * userbuf,
305299
static const struct file_operations btmrvl_hsmode_fops = {
306300
.read = btmrvl_hsmode_read,
307301
.write = btmrvl_hsmode_write,
308-
.open = btmrvl_open_generic,
302+
.open = simple_open,
309303
.llseek = default_llseek,
310304
};
311305

@@ -323,7 +317,7 @@ static ssize_t btmrvl_curpsmode_read(struct file *file, char __user *userbuf,
323317

324318
static const struct file_operations btmrvl_curpsmode_fops = {
325319
.read = btmrvl_curpsmode_read,
326-
.open = btmrvl_open_generic,
320+
.open = simple_open,
327321
.llseek = default_llseek,
328322
};
329323

@@ -341,7 +335,7 @@ static ssize_t btmrvl_psstate_read(struct file *file, char __user * userbuf,
341335

342336
static const struct file_operations btmrvl_psstate_fops = {
343337
.read = btmrvl_psstate_read,
344-
.open = btmrvl_open_generic,
338+
.open = simple_open,
345339
.llseek = default_llseek,
346340
};
347341

@@ -359,7 +353,7 @@ static ssize_t btmrvl_hsstate_read(struct file *file, char __user *userbuf,
359353

360354
static const struct file_operations btmrvl_hsstate_fops = {
361355
.read = btmrvl_hsstate_read,
362-
.open = btmrvl_open_generic,
356+
.open = simple_open,
363357
.llseek = default_llseek,
364358
};
365359

@@ -378,7 +372,7 @@ static ssize_t btmrvl_txdnldready_read(struct file *file, char __user *userbuf,
378372

379373
static const struct file_operations btmrvl_txdnldready_fops = {
380374
.read = btmrvl_txdnldready_read,
381-
.open = btmrvl_open_generic,
375+
.open = simple_open,
382376
.llseek = default_llseek,
383377
};
384378

drivers/char/virtio_console.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,12 +1038,6 @@ static struct attribute_group port_attribute_group = {
10381038
.attrs = port_sysfs_entries,
10391039
};
10401040

1041-
static int debugfs_open(struct inode *inode, struct file *filp)
1042-
{
1043-
filp->private_data = inode->i_private;
1044-
return 0;
1045-
}
1046-
10471041
static ssize_t debugfs_read(struct file *filp, char __user *ubuf,
10481042
size_t count, loff_t *offp)
10491043
{
@@ -1087,7 +1081,7 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf,
10871081

10881082
static const struct file_operations port_debugfs_ops = {
10891083
.owner = THIS_MODULE,
1090-
.open = debugfs_open,
1084+
.open = simple_open,
10911085
.read = debugfs_read,
10921086
};
10931087

drivers/dma/coh901318.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,6 @@ static void coh901318_list_print(struct coh901318_chan *cohc,
104104
static struct coh901318_base *debugfs_dma_base;
105105
static struct dentry *dma_dentry;
106106

107-
static int coh901318_debugfs_open(struct inode *inode, struct file *file)
108-
{
109-
110-
file->private_data = inode->i_private;
111-
return 0;
112-
}
113-
114107
static int coh901318_debugfs_read(struct file *file, char __user *buf,
115108
size_t count, loff_t *f_pos)
116109
{
@@ -158,7 +151,7 @@ static int coh901318_debugfs_read(struct file *file, char __user *buf,
158151

159152
static const struct file_operations coh901318_debugfs_status_operations = {
160153
.owner = THIS_MODULE,
161-
.open = coh901318_debugfs_open,
154+
.open = simple_open,
162155
.read = coh901318_debugfs_read,
163156
.llseek = default_llseek,
164157
};

drivers/gpu/drm/i915/i915_debugfs.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,14 +1502,6 @@ static int i915_ppgtt_info(struct seq_file *m, void *data)
15021502
return 0;
15031503
}
15041504

1505-
static int
1506-
i915_debugfs_common_open(struct inode *inode,
1507-
struct file *filp)
1508-
{
1509-
filp->private_data = inode->i_private;
1510-
return 0;
1511-
}
1512-
15131505
static ssize_t
15141506
i915_wedged_read(struct file *filp,
15151507
char __user *ubuf,
@@ -1560,7 +1552,7 @@ i915_wedged_write(struct file *filp,
15601552

15611553
static const struct file_operations i915_wedged_fops = {
15621554
.owner = THIS_MODULE,
1563-
.open = i915_debugfs_common_open,
1555+
.open = simple_open,
15641556
.read = i915_wedged_read,
15651557
.write = i915_wedged_write,
15661558
.llseek = default_llseek,
@@ -1622,7 +1614,7 @@ i915_max_freq_write(struct file *filp,
16221614

16231615
static const struct file_operations i915_max_freq_fops = {
16241616
.owner = THIS_MODULE,
1625-
.open = i915_debugfs_common_open,
1617+
.open = simple_open,
16261618
.read = i915_max_freq_read,
16271619
.write = i915_max_freq_write,
16281620
.llseek = default_llseek,
@@ -1693,7 +1685,7 @@ i915_cache_sharing_write(struct file *filp,
16931685

16941686
static const struct file_operations i915_cache_sharing_fops = {
16951687
.owner = THIS_MODULE,
1696-
.open = i915_debugfs_common_open,
1688+
.open = simple_open,
16971689
.read = i915_cache_sharing_read,
16981690
.write = i915_cache_sharing_write,
16991691
.llseek = default_llseek,

drivers/hid/hid-picolcd.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,12 +1525,6 @@ static const struct file_operations picolcd_debug_reset_fops = {
15251525
/*
15261526
* The "eeprom" file
15271527
*/
1528-
static int picolcd_debug_eeprom_open(struct inode *i, struct file *f)
1529-
{
1530-
f->private_data = i->i_private;
1531-
return 0;
1532-
}
1533-
15341528
static ssize_t picolcd_debug_eeprom_read(struct file *f, char __user *u,
15351529
size_t s, loff_t *off)
15361530
{
@@ -1618,7 +1612,7 @@ static ssize_t picolcd_debug_eeprom_write(struct file *f, const char __user *u,
16181612
*/
16191613
static const struct file_operations picolcd_debug_eeprom_fops = {
16201614
.owner = THIS_MODULE,
1621-
.open = picolcd_debug_eeprom_open,
1615+
.open = simple_open,
16221616
.read = picolcd_debug_eeprom_read,
16231617
.write = picolcd_debug_eeprom_write,
16241618
.llseek = generic_file_llseek,
@@ -1627,12 +1621,6 @@ static const struct file_operations picolcd_debug_eeprom_fops = {
16271621
/*
16281622
* The "flash" file
16291623
*/
1630-
static int picolcd_debug_flash_open(struct inode *i, struct file *f)
1631-
{
1632-
f->private_data = i->i_private;
1633-
return 0;
1634-
}
1635-
16361624
/* record a flash address to buf (bounds check to be done by caller) */
16371625
static int _picolcd_flash_setaddr(struct picolcd_data *data, u8 *buf, long off)
16381626
{
@@ -1817,7 +1805,7 @@ static ssize_t picolcd_debug_flash_write(struct file *f, const char __user *u,
18171805
*/
18181806
static const struct file_operations picolcd_debug_flash_fops = {
18191807
.owner = THIS_MODULE,
1820-
.open = picolcd_debug_flash_open,
1808+
.open = simple_open,
18211809
.read = picolcd_debug_flash_read,
18221810
.write = picolcd_debug_flash_write,
18231811
.llseek = generic_file_llseek,

drivers/hid/hid-wiimote-debug.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ struct wiimote_debug {
2323
struct dentry *drm;
2424
};
2525

26-
static int wiidebug_eeprom_open(struct inode *i, struct file *f)
27-
{
28-
f->private_data = i->i_private;
29-
return 0;
30-
}
31-
3226
static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
3327
loff_t *off)
3428
{
@@ -83,7 +77,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
8377

8478
static const struct file_operations wiidebug_eeprom_fops = {
8579
.owner = THIS_MODULE,
86-
.open = wiidebug_eeprom_open,
80+
.open = simple_open,
8781
.read = wiidebug_eeprom_read,
8882
.llseek = generic_file_llseek,
8983
};

drivers/idle/i7300_idle.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -516,12 +516,6 @@ static struct notifier_block i7300_idle_nb = {
516516

517517
MODULE_DEVICE_TABLE(pci, pci_tbl);
518518

519-
int stats_open_generic(struct inode *inode, struct file *fp)
520-
{
521-
fp->private_data = inode->i_private;
522-
return 0;
523-
}
524-
525519
static ssize_t stats_read_ul(struct file *fp, char __user *ubuf, size_t count,
526520
loff_t *off)
527521
{
@@ -534,7 +528,7 @@ static ssize_t stats_read_ul(struct file *fp, char __user *ubuf, size_t count,
534528
}
535529

536530
static const struct file_operations idle_fops = {
537-
.open = stats_open_generic,
531+
.open = simple_open,
538532
.read = stats_read_ul,
539533
.llseek = default_llseek,
540534
};

0 commit comments

Comments
 (0)