[PATCH 374/437] drivers/thunderbolt: convert to read/write iterators

Jens Axboe
2024-04-11T15:42:10Z

drivers/thunderbolt/debugfs.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/thunderbolt/debugfs.c b/drivers/thunderbolt/debugfs.c
index e324cd899719..fbe0fb7d40a6 100644
--- a/drivers/thunderbolt/debugfs.c
+++ b/drivers/thunderbolt/debugfs.c
@@ -43,8 +43,8 @@ static const struct file_operations __space ## _fops = { \
.owner = THIS_MODULE, \
.open = __space ## _open, \
.release = single_release, \
- .read = seq_read, \
- .write = __write, \
+ .read_iter = seq_read_iter, \
+ .write_iter = __write, \
.llseek = seq_lseek, \
}

@@ -52,7 +52,7 @@ static const struct file_operations __space ## _fops = { \
DEBUGFS_ATTR(__space, NULL)

#define DEBUGFS_ATTR_RW(__space) \
- DEBUGFS_ATTR(__space, __space ## _write)
+ DEBUGFS_ATTR(__space, __space ## _write ## _iter)

static struct dentry *tb_debugfs_root;

@@ -175,6 +175,7 @@ static ssize_t port_regs_write(struct file *file, const char __user *user_buf,

return regs_write(port->sw, port, user_buf, count, ppos);
}
+FOPS_WRITE_ITER_HELPER(port_regs_write);

static ssize_t switch_regs_write(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos)
@@ -184,10 +185,11 @@ static ssize_t switch_regs_write(struct file *file, const char __user *user_buf,

return regs_write(sw, NULL, user_buf, count, ppos);
}
+FOPS_WRITE_ITER_HELPER(switch_regs_write);
#define DEBUGFS_MODE 0600
#else
-#define port_regs_write NULL
-#define switch_regs_write NULL
+#define port_regs_write_iter NULL
+#define switch_regs_write_iter NULL
#define DEBUGFS_MODE 0400
#endif

@@ -305,6 +307,7 @@ margining_ber_level_write(struct file *file, const char __user *user_buf,

return ret < 0 ? ret : count;
}
+FOPS_WRITE_ITER_HELPER(margining_ber_level_write);

static void ber_level_show(struct seq_file *s, unsigned int val)
{
@@ -445,6 +448,7 @@ margining_lanes_write(struct file *file, const char __user *user_buf,
free_page((unsigned long)buf);
return ret < 0 ? ret : count;
}
+FOPS_WRITE_ITER_HELPER(margining_lanes_write);

static int margining_lanes_show(struct seq_file *s, void *not_used)
{
@@ -518,6 +522,7 @@ static ssize_t margining_mode_write(struct file *file,
free_page((unsigned long)buf);
return ret ? ret : count;
}
+FOPS_WRITE_ITER_HELPER(margining_mode_write);

static int margining_mode_show(struct seq_file *s, void *not_used)
{
@@ -646,6 +651,7 @@ static ssize_t margining_results_write(struct file *file,
mutex_unlock(&tb->lock);
return count;
}
+FOPS_WRITE_ITER_HELPER(margining_results_write);

static void voltage_margin_show(struct seq_file *s,
const struct tb_margining *margining, u8 val)
@@ -775,6 +781,7 @@ static ssize_t margining_test_write(struct file *file,
free_page((unsigned long)buf);
return ret ? ret : count;
}
+FOPS_WRITE_ITER_HELPER(margining_test_write);

static int margining_test_show(struct seq_file *s, void *not_used)
{
@@ -843,6 +850,7 @@ static ssize_t margining_margin_write(struct file *file,
free_page((unsigned long)buf);
return ret ? ret : count;
}
+FOPS_WRITE_ITER_HELPER(margining_margin_write);

static int margining_margin_show(struct seq_file *s, void *not_used)
{
@@ -1089,6 +1097,7 @@ static ssize_t counters_write(struct file *file, const char __user *user_buf,

return ret < 0 ? ret : count;
}
+FOPS_WRITE_ITER_HELPER(counters_write);

static void cap_show_by_dw(struct seq_file *s, struct tb_switch *sw,
struct tb_port *port, unsigned int cap,
--
2.43.0