Skip to contentSkip to conversation

Kill off old fops ->read() and ->write()

RFC PATCH In review Jens Axboe 4 participants 451 messages Apr 11, 2024 – May 5, 2024 Page 4 of 5

Subsystems (424)
lore
Share & tools
lore
author maintainer
#301 lore raw

PATCH 295/437 drivers/net/wireless/ti: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/ti/wl1251/debugfs.c |  38 ++-
 drivers/net/wireless/ti/wl18xx/debugfs.c |  73 ++---
 drivers/net/wireless/ti/wlcore/debugfs.c | 373 ++++++++++-------------
 drivers/net/wireless/ti/wlcore/debugfs.h |  37 +--
 4 files changed, 231 insertions(+), 290 deletions(-)
drivers/net/wireless/ti/wl1251/debugfs.c +17 -21
index a1b778a0fda0..66e57dd0add4 100644
@@ -20,19 +20,18 @@
 /* debugfs macros idea from mac80211 */
 
 #define DEBUGFS_READONLY_FILE(name, buflen, fmt, value...)		\
-static ssize_t name## _read(struct file *file, char __user *userbuf,	\
-			    size_t count, loff_t *ppos)			\
+static ssize_t name## _read(struct kiocb *iocb, struct iov_iter *to)	\
 {									\
-	struct wl1251 *wl = file->private_data;				\
+	struct wl1251 *wl = iocb->ki_filp->private_data;			\
 	char buf[buflen];						\
 	int res;							\
 									\
 	res = scnprintf(buf, buflen, fmt "\n", ##value);		\
-	return simple_read_from_buffer(userbuf, count, ppos, buf, res);	\
+	return simple_copy_to_iter(buf, &iocb->ki_pos, res, to);	\
 }									\
 									\
 static const struct file_operations name## _ops = {			\
-	.read = name## _read,						\
+	.read_iter = name## _read,					\
 	.open = simple_open,						\
 	.llseek	= generic_file_llseek,					\
 };
@@ -48,11 +47,10 @@ static const struct file_operations name## _ops = {			\
 	} while (0)
 
 #define DEBUGFS_FWSTATS_FILE(sub, name, buflen, fmt)			\
-static ssize_t sub## _ ##name## _read(struct file *file,		\
-				      char __user *userbuf,		\
-				      size_t count, loff_t *ppos)	\
+static ssize_t sub## _ ##name## _read(struct kiocb *iocb,		\
+				      struct iov_iter *to)		\
 {									\
-	struct wl1251 *wl = file->private_data;				\
+	struct wl1251 *wl = iocb->ki_filp->private_data;		\
 	char buf[buflen];						\
 	int res;							\
 									\
@@ -60,11 +58,11 @@ static ssize_t sub## _ ##name## _read(struct file *file,		\
 									\
 	res = scnprintf(buf, buflen, fmt "\n",				\
 			wl->stats.fw_stats->sub.name);			\
-	return simple_read_from_buffer(userbuf, count, ppos, buf, res);	\
+	return simple_copy_to_iter(buf, &iocb->ki_pos, res, to);	\
 }									\
 									\
 static const struct file_operations sub## _ ##name## _ops = {		\
-	.read = sub## _ ##name## _read,					\
+	.read_iter = sub## _ ##name## _read,				\
 	.open = simple_open,						\
 	.llseek	= generic_file_llseek,					\
 };
@@ -194,10 +192,9 @@ DEBUGFS_READONLY_FILE(retry_count, 20, "%u", wl->stats.retry_count);
 DEBUGFS_READONLY_FILE(excessive_retries, 20, "%u",
 		      wl->stats.excessive_retries);
 
-static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t tx_queue_len_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1251 *wl = file->private_data;
+	struct wl1251 *wl = iocb->ki_filp->private_data;
 	u32 queue_len;
 	char buf[20];
 	int res;
@@ -205,19 +202,18 @@ static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf,
 	queue_len = skb_queue_len(&wl->tx_queue);
 
 	res = scnprintf(buf, sizeof(buf), "%u\n", queue_len);
-	return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, res, to);
 }
 
 static const struct file_operations tx_queue_len_ops = {
-	.read = tx_queue_len_read,
+	.read_iter = tx_queue_len_read,
 	.open = simple_open,
 	.llseek = generic_file_llseek,
 };
 
-static ssize_t tx_queue_status_read(struct file *file, char __user *userbuf,
-				    size_t count, loff_t *ppos)
+static ssize_t tx_queue_status_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wl1251 *wl = file->private_data;
+	struct wl1251 *wl = iocb->ki_filp->private_data;
 	char buf[3], status;
 	int len;
 
@@ -227,11 +223,11 @@ static ssize_t tx_queue_status_read(struct file *file, char __user *userbuf,
 		status = 'r';
 
 	len = scnprintf(buf, sizeof(buf), "%c\n", status);
-	return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations tx_queue_status_ops = {
-	.read = tx_queue_status_read,
+	.read_iter = tx_queue_status_read,
 	.open = simple_open,
 	.llseek = generic_file_llseek,
 };
drivers/net/wireless/ti/wl18xx/debugfs.c +31 -42

156 lines not on this page · raw message

drivers/net/wireless/ti/wlcore/debugfs.c +167 -206

779 lines not on this page · raw message

drivers/net/wireless/ti/wlcore/debugfs.h +16 -21
index a9e13e6d65c5..294ac6e29c5f 100644
@@ -12,8 +12,8 @@
 
 #include "wlcore.h"
 
-__printf(4, 5) int wl1271_format_buffer(char __user *userbuf, size_t count,
-					loff_t *ppos, char *fmt, ...);
+__printf(3, 4) int wl1271_format_buffer(struct kiocb *iocb, struct iov_iter *to,
+					char *fmt, ...);
 
 int wl1271_debugfs_init(struct wl1271 *wl);
 void wl1271_debugfs_exit(struct wl1271 *wl);
@@ -23,16 +23,14 @@ void wl1271_debugfs_update_stats(struct wl1271 *wl);
 #define DEBUGFS_FORMAT_BUFFER_SIZE 256
 
 #define DEBUGFS_READONLY_FILE(name, fmt, value...)			\
-static ssize_t name## _read(struct file *file, char __user *userbuf,	\
-			    size_t count, loff_t *ppos)			\
+static ssize_t name## _read(struct kiocb *iocb, struct iov_iter *to)	\
 {									\
-	struct wl1271 *wl = file->private_data;				\
-	return wl1271_format_buffer(userbuf, count, ppos,		\
-				    fmt "\n", ##value);			\
+	struct wl1271 *wl = iocb->ki_filp->private_data;		\
+	return wl1271_format_buffer(iocb, to, fmt "\n", ##value);	\
 }									\
 									\
 static const struct file_operations name## _ops = {			\
-	.read = name## _read,						\
+	.read_iter = name## _read,					\
 	.open = simple_open,						\
 	.llseek	= generic_file_llseek,					\
 };
@@ -51,31 +49,28 @@ static const struct file_operations name## _ops = {			\
 	} while (0)
 
 #define DEBUGFS_FWSTATS_FILE(sub, name, fmt, struct_type)		\
-static ssize_t sub## _ ##name## _read(struct file *file,		\
-				      char __user *userbuf,		\
-				      size_t count, loff_t *ppos)	\
+static ssize_t sub## _ ##name## _read(struct kiocb *iocb,		\
+				      struct iov_iter *to)		\
 {									\
-	struct wl1271 *wl = file->private_data;				\
+	struct wl1271 *wl = iocb->ki_filp->private_data;		\
 	struct struct_type *stats = wl->stats.fw_stats;			\
 									\
 	wl1271_debugfs_update_stats(wl);				\
 									\
-	return wl1271_format_buffer(userbuf, count, ppos, fmt "\n",	\
-				    stats->sub.name);			\
+	return wl1271_format_buffer(iocb, to, fmt "\n", stats->sub.name);\
 }									\
 									\
 static const struct file_operations sub## _ ##name## _ops = {		\
-	.read = sub## _ ##name## _read,					\
+	.read_iter = sub## _ ##name## _read,				\
 	.open = simple_open,						\
 	.llseek	= generic_file_llseek,					\
 };
 
 #define DEBUGFS_FWSTATS_FILE_ARRAY(sub, name, len, struct_type)		\
-static ssize_t sub## _ ##name## _read(struct file *file,		\
-				      char __user *userbuf,		\
-				      size_t count, loff_t *ppos)	\
+static ssize_t sub## _ ##name## _read(struct kiocb *iocb,		\
+				      struct iov_iter *to)		\
 {									\
-	struct wl1271 *wl = file->private_data;				\
+	struct wl1271 *wl = iocb->ki_filp->private_data;		\
 	struct struct_type *stats = wl->stats.fw_stats;			\
 	char buf[DEBUGFS_FORMAT_BUFFER_SIZE] = "";			\
 	int pos = 0;							\
@@ -87,11 +82,11 @@ static ssize_t sub## _ ##name## _read(struct file *file,		\
 		pos += snprintf(buf + pos, sizeof(buf) - pos,		\
 			 "[%d] = %d\n", i, stats->sub.name[i]);		\
 									\
-	return wl1271_format_buffer(userbuf, count, ppos, "%s", buf);	\
+	return wl1271_format_buffer(iocb, to, "%s", buf);		\
 }									\
 									\
 static const struct file_operations sub## _ ##name## _ops = {		\
-	.read = sub## _ ##name## _read,					\
+	.read_iter = sub## _ ##name## _read,				\
 	.open = simple_open,						\
 	.llseek	= generic_file_llseek,					\
 };
Signature · 1 line
2.43.0
author maintainer
#302 lore raw

PATCH 296/437 drivers/net/wireless/intel: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/intel/iwlegacy/3945-rs.c |   9 +-
 drivers/net/wireless/intel/iwlegacy/4965-rs.c |  39 +-
 drivers/net/wireless/intel/iwlegacy/debug.c   | 280 +++++------
 .../net/wireless/intel/iwlwifi/dvm/debugfs.c  | 455 ++++++++----------
 drivers/net/wireless/intel/iwlwifi/dvm/rs.c   |  42 +-
 .../net/wireless/intel/iwlwifi/fw/debugfs.c   |  23 +-
 drivers/net/wireless/intel/iwlwifi/mei/main.c |  18 +-
 drivers/net/wireless/intel/iwlwifi/mvm/d3.c   |   7 +-
 .../wireless/intel/iwlwifi/mvm/debugfs-vif.c  |  81 ++--
 .../net/wireless/intel/iwlwifi/mvm/debugfs.c  | 227 ++++-----
 .../net/wireless/intel/iwlwifi/mvm/debugfs.h  |   9 +-
 drivers/net/wireless/intel/iwlwifi/mvm/rs.c   |  62 ++-
 .../net/wireless/intel/iwlwifi/pcie/trans.c   |  85 ++--
 13 files changed, 609 insertions(+), 728 deletions(-)
drivers/net/wireless/intel/iwlegacy/3945-rs.c +4 -5
index 0eaad980c85c..1a14dce71bff 100644
@@ -801,14 +801,13 @@ il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta,
 #ifdef CONFIG_MAC80211_DEBUGFS
 
 static ssize_t
-il3945_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf,
-				  size_t count, loff_t *ppos)
+il3945_sta_dbgfs_stats_table_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *buff;
 	int desc = 0;
 	int j;
 	ssize_t ret;
-	struct il3945_rs_sta *lq_sta = file->private_data;
+	struct il3945_rs_sta *lq_sta = iocb->ki_filp->private_data;
 
 	buff = kmalloc(1024, GFP_KERNEL);
 	if (!buff)
@@ -827,13 +826,13 @@ il3945_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf,
 			    lq_sta->win[j].success_counter,
 			    lq_sta->win[j].success_ratio);
 	}
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 	kfree(buff);
 	return ret;
 }
 
 static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
-	.read = il3945_sta_dbgfs_stats_table_read,
+	.read_iter = il3945_sta_dbgfs_stats_table_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
drivers/net/wireless/intel/iwlegacy/4965-rs.c +17 -22
index 718efb1aa1b0..958d7e8e26d6 100644
@@ -2527,11 +2527,10 @@ il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx)
 }
 
 static ssize_t
-il4965_rs_sta_dbgfs_scale_table_write(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+il4965_rs_sta_dbgfs_scale_table_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct il_lq_sta *lq_sta = file->private_data;
+	struct il_lq_sta *lq_sta = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct il_priv *il;
 	char buf[64];
 	size_t buf_size;
@@ -2540,7 +2539,7 @@ il4965_rs_sta_dbgfs_scale_table_write(struct file *file,
 	il = lq_sta->drv;
 	memset(buf, 0, sizeof(buf));
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	if (sscanf(buf, "%x", &parsed_rate) == 1)
@@ -2564,8 +2563,7 @@ il4965_rs_sta_dbgfs_scale_table_write(struct file *file,
 }
 
 static ssize_t
-il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+il4965_rs_sta_dbgfs_scale_table_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *buff;
 	int desc = 0;
@@ -2573,7 +2571,7 @@ il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user *user_buf,
 	int idx = 0;
 	ssize_t ret;
 
-	struct il_lq_sta *lq_sta = file->private_data;
+	struct il_lq_sta *lq_sta = iocb->ki_filp->private_data;
 	struct il_priv *il;
 	struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]);
 
@@ -2659,28 +2657,27 @@ il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user *user_buf,
 		}
 	}
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 	kfree(buff);
 	return ret;
 }
 
 static const struct file_operations rs_sta_dbgfs_scale_table_ops = {
-	.write = il4965_rs_sta_dbgfs_scale_table_write,
-	.read = il4965_rs_sta_dbgfs_scale_table_read,
+	.write_iter = il4965_rs_sta_dbgfs_scale_table_write,
+	.read_iter = il4965_rs_sta_dbgfs_scale_table_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
 static ssize_t
-il4965_rs_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+il4965_rs_sta_dbgfs_stats_table_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char *buff;
 	int desc = 0;
 	int i, j;
 	ssize_t ret;
 
-	struct il_lq_sta *lq_sta = file->private_data;
+	struct il_lq_sta *lq_sta = iocb->ki_filp->private_data;
 
 	buff = kmalloc(1024, GFP_KERNEL);
 	if (!buff)
@@ -2705,25 +2702,23 @@ il4965_rs_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf,
 				    lq_sta->lq_info[i].win[j].success_ratio);
 		}
 	}
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 	kfree(buff);
 	return ret;
 }
 
 static const struct file_operations rs_sta_dbgfs_stats_table_ops = {
-	.read = il4965_rs_sta_dbgfs_stats_table_read,
+	.read_iter = il4965_rs_sta_dbgfs_stats_table_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
 static ssize_t
-il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file,
-					 char __user *user_buf, size_t count,
-					 loff_t *ppos)
+il4965_rs_sta_dbgfs_rate_scale_data_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buff[120];
 	int desc = 0;
-	struct il_lq_sta *lq_sta = file->private_data;
+	struct il_lq_sta *lq_sta = iocb->ki_filp->private_data;
 	struct il_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl];
 
 	if (is_Ht(tbl->lq_type))
@@ -2735,11 +2730,11 @@ il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file,
 		    sprintf(buff + desc, "Bit Rate= %d Mb/s\n",
 			    il_rates[lq_sta->last_txrate_idx].ieee >> 1);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	return simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 }
 
 static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = {
-	.read = il4965_rs_sta_dbgfs_rate_scale_data_read,
+	.read_iter = il4965_rs_sta_dbgfs_rate_scale_data_read,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
drivers/net/wireless/intel/iwlegacy/debug.c +124 -156

652 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/dvm/debugfs.c +207 -248

956 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/dvm/rs.c +21 -21

114 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/fw/debugfs.c +12 -11
index 751a125a1566..7378c6fed447 100644
@@ -33,10 +33,10 @@ static int _iwl_dbgfs_##name##_open(struct inode *inode,		\
 }
 
 #define FWRT_DEBUGFS_READ_WRAPPER(name)					\
-static ssize_t _iwl_dbgfs_##name##_read(struct file *file,		\
-					char __user *user_buf,		\
-					size_t count, loff_t *ppos)	\
+static ssize_t _iwl_dbgfs_##name##_read(struct kiocb *iocb,		\
+					struct iov_iter *to)		\
 {									\
+	struct file *file = iocb->ki_filp;				\
 	struct dbgfs_##name##_data *data = file->private_data;		\
 									\
 	if (!data->read_done) {						\
@@ -48,8 +48,8 @@ static ssize_t _iwl_dbgfs_##name##_read(struct file *file,		\
 									\
 	if (data->rlen < 0)						\
 		return data->rlen;					\
-	return simple_read_from_buffer(user_buf, count, ppos,		\
-				       data->rbuf, data->rlen);		\
+	return simple_copy_to_iter(data->rbuf, &iocb->ki_pos,		\
+					data->rlen, to);		\
 }
 
 static int _iwl_dbgfs_release(struct inode *inode, struct file *file)
@@ -63,7 +63,7 @@ static int _iwl_dbgfs_release(struct inode *inode, struct file *file)
 FWRT_DEBUGFS_OPEN_WRAPPER(name, buflen, argtype)			\
 FWRT_DEBUGFS_READ_WRAPPER(name)						\
 static const struct file_operations iwl_dbgfs_##name##_ops = {		\
-	.read = _iwl_dbgfs_##name##_read,				\
+	.read_iter = _iwl_dbgfs_##name##_read,				\
 	.open = _iwl_dbgfs_##name##_open,				\
 	.llseek = generic_file_llseek,					\
 	.release = _iwl_dbgfs_release,					\
@@ -83,15 +83,16 @@ static ssize_t _iwl_dbgfs_##name##_write(struct file *file,		\
 		return -EFAULT;						\
 									\
 	return iwl_dbgfs_##name##_write(arg, buf, buf_size);		\
-}
+}									\
+FOPS_WRITE_ITER_HELPER(_iwl_dbgfs_##name##_write);			\
 
 #define _FWRT_DEBUGFS_READ_WRITE_FILE_OPS(name, buflen, argtype)	\
 FWRT_DEBUGFS_OPEN_WRAPPER(name, buflen, argtype)			\
 FWRT_DEBUGFS_WRITE_WRAPPER(name, buflen, argtype)			\
 FWRT_DEBUGFS_READ_WRAPPER(name)						\
 static const struct file_operations iwl_dbgfs_##name##_ops = {		\
-	.write = _iwl_dbgfs_##name##_write,				\
-	.read = _iwl_dbgfs_##name##_read,				\
+	.write_iter = _iwl_dbgfs_##name##_write_iter,			\
+	.read_iter = _iwl_dbgfs_##name##_read,				\
 	.open = _iwl_dbgfs_##name##_open,				\
 	.llseek = generic_file_llseek,					\
 	.release = _iwl_dbgfs_release,					\
@@ -101,7 +102,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = {		\
 FWRT_DEBUGFS_OPEN_WRAPPER(name, buflen, argtype)			\
 FWRT_DEBUGFS_WRITE_WRAPPER(name, buflen, argtype)			\
 static const struct file_operations iwl_dbgfs_##name##_ops = {		\
-	.write = _iwl_dbgfs_##name##_write,				\
+	.write_iter = _iwl_dbgfs_##name##_write_iter,			\
 	.open = _iwl_dbgfs_##name##_open,				\
 	.llseek = generic_file_llseek,					\
 	.release = _iwl_dbgfs_release,					\
@@ -391,7 +392,7 @@ static int iwl_dbgfs_fw_info_open(struct inode *inode, struct file *filp)
 static const struct file_operations iwl_dbgfs_fw_info_ops = {
 	.owner = THIS_MODULE,
 	.open = iwl_dbgfs_fw_info_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release_private,
 };
drivers/net/wireless/intel/iwlwifi/mei/main.c +8 -10
index 1dd9106c6513..5ad9530659be 100644
@@ -1849,9 +1849,8 @@ EXPORT_SYMBOL_GPL(iwl_mei_unregister_complete);
 #if IS_ENABLED(CONFIG_DEBUG_FS)
 
 static ssize_t
-iwl_mei_dbgfs_send_start_message_write(struct file *file,
-				       const char __user *user_buf,
-				       size_t count, loff_t *ppos)
+iwl_mei_dbgfs_send_start_message_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
 	int ret;
 
@@ -1866,26 +1865,25 @@ iwl_mei_dbgfs_send_start_message_write(struct file *file,
 
 out:
 	mutex_unlock(&iwl_mei_mutex);
-	return ret ?: count;
+	return ret ?: iov_iter_count(from);
 }
 
 static const struct file_operations iwl_mei_dbgfs_send_start_message_ops = {
-	.write = iwl_mei_dbgfs_send_start_message_write,
+	.write_iter = iwl_mei_dbgfs_send_start_message_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
 
-static ssize_t iwl_mei_dbgfs_req_ownership_write(struct file *file,
-						 const char __user *user_buf,
-						 size_t count, loff_t *ppos)
+static ssize_t iwl_mei_dbgfs_req_ownership_write(struct kiocb *iocb,
+						 struct iov_iter *from)
 {
 	iwl_mei_get_ownership();
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations iwl_mei_dbgfs_req_ownership_ops = {
-	.write = iwl_mei_dbgfs_req_ownership_write,
+	.write_iter = iwl_mei_dbgfs_req_ownership_write,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
drivers/net/wireless/intel/iwlwifi/mvm/d3.c +3 -4
index 52518a47554e..1d911bbef018 100644
@@ -3405,10 +3405,9 @@ static int iwl_mvm_d3_test_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t iwl_mvm_d3_test_read(struct file *file, char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t iwl_mvm_d3_test_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iwl_mvm *mvm = file->private_data;
+	struct iwl_mvm *mvm = iocb->ki_filp->private_data;
 	unsigned long end = jiffies + 60 * HZ;
 	u32 pme_asserted;
 
@@ -3492,7 +3491,7 @@ static int iwl_mvm_d3_test_release(struct inode *inode, struct file *file)
 const struct file_operations iwl_dbgfs_d3_test_ops = {
 	.llseek = no_llseek,
 	.open = iwl_mvm_d3_test_open,
-	.read = iwl_mvm_d3_test_read,
+	.read_iter = iwl_mvm_d3_test_read,
 	.release = iwl_mvm_d3_test_release,
 };
 #endif
drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c +36 -45

181 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +105 -122

581 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/mvm/debugfs.h +5 -4
index cc2c45b45ddc..911c4f97709d 100644
@@ -6,7 +6,7 @@
  */
 #define MVM_DEBUGFS_READ_FILE_OPS(name)					\
 static const struct file_operations iwl_dbgfs_##name##_ops = {		\
-	.read = iwl_dbgfs_##name##_read,				\
+	.read_iter = iwl_dbgfs_##name##_read_iter,			\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 }
@@ -25,12 +25,13 @@ static ssize_t _iwl_dbgfs_##name##_write(struct file *file,		\
 									\
 	return iwl_dbgfs_##name##_write(arg, buf, buf_size, ppos);	\
 }									\
+FOPS_WRITE_ITER_HELPER(_iwl_dbgfs_##name##_write);			\
 
 #define _MVM_DEBUGFS_READ_WRITE_FILE_OPS(name, buflen, argtype)		\
 MVM_DEBUGFS_WRITE_WRAPPER(name, buflen, argtype)			\
 static const struct file_operations iwl_dbgfs_##name##_ops = {		\
-	.write = _iwl_dbgfs_##name##_write,				\
-	.read = iwl_dbgfs_##name##_read,				\
+	.write_iter = _iwl_dbgfs_##name##_write_iter,			\
+	.read_iter = iwl_dbgfs_##name##_read_iter,			\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 };
@@ -38,7 +39,7 @@ static const struct file_operations iwl_dbgfs_##name##_ops = {		\
 #define _MVM_DEBUGFS_WRITE_FILE_OPS(name, buflen, argtype)		\
 MVM_DEBUGFS_WRITE_WRAPPER(name, buflen, argtype)			\
 static const struct file_operations iwl_dbgfs_##name##_ops = {		\
-	.write = _iwl_dbgfs_##name##_write,				\
+	.write_iter = _iwl_dbgfs_##name##_write_iter,			\
 	.open = simple_open,						\
 	.llseek = generic_file_llseek,					\
 };
drivers/net/wireless/intel/iwlwifi/mvm/rs.c +30 -32

155 lines not on this page · raw message

drivers/net/wireless/intel/iwlwifi/pcie/trans.c +37 -48

56 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.43.0

Part of the diff is not shown here. View the raw message.

author maintainer
#303 lore raw

PATCH 297/437 drivers/net/wireless/mediatek: convert to read/write iterators

In reply to Jens Axboe
---
 .../wireless/mediatek/mt76/mt7615/debugfs.c   | 20 ++++---
 .../wireless/mediatek/mt76/mt7915/debugfs.c   | 52 +++++++++----------
 .../wireless/mediatek/mt76/mt7996/debugfs.c   | 33 ++++++------
 3 files changed, 48 insertions(+), 57 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/debugfs.c +9 -11
index 2a6d317db5e0..d645550bab86 100644
@@ -436,11 +436,9 @@ mt7615_rf_reg_get(void *data, u64 *val)
 DEFINE_DEBUGFS_ATTRIBUTE(fops_rf_reg, mt7615_rf_reg_get, mt7615_rf_reg_set,
 			 "0x%08llx\n");
 
-static ssize_t
-mt7615_ext_mac_addr_read(struct file *file, char __user *userbuf,
-			 size_t count, loff_t *ppos)
+static ssize_t mt7615_ext_mac_addr_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mt7615_dev *dev = file->private_data;
+	struct mt7615_dev *dev = iocb->ki_filp->private_data;
 	u32 len = 32 * ((ETH_ALEN * 3) + 4) + 1;
 	u8 addr[ETH_ALEN];
 	char *buf;
@@ -464,17 +462,17 @@ mt7615_ext_mac_addr_read(struct file *file, char __user *userbuf,
 		ofs += snprintf(buf + ofs, len - ofs, "%d=%pM\n", i, addr);
 	}
 
-	ofs = simple_read_from_buffer(userbuf, count, ppos, buf, ofs);
+	ofs = simple_copy_to_iter(buf, &iocb->ki_pos, ofs, to);
 
 	kfree(buf);
 	return ofs;
 }
 
 static ssize_t
-mt7615_ext_mac_addr_write(struct file *file, const char __user *userbuf,
-			  size_t count, loff_t *ppos)
+mt7615_ext_mac_addr_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mt7615_dev *dev = file->private_data;
+	struct mt7615_dev *dev = iocb->ki_filp->private_data;;
+	size_t count = iov_iter_count(from);
 	unsigned long idx = 0;
 	u8 addr[ETH_ALEN];
 	char buf[32];
@@ -483,7 +481,7 @@ mt7615_ext_mac_addr_write(struct file *file, const char __user *userbuf,
 	if (count > sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[sizeof(buf) - 1] = '\0';
@@ -526,8 +524,8 @@ mt7615_ext_mac_addr_write(struct file *file, const char __user *userbuf,
 static const struct file_operations fops_ext_mac_addr = {
 	.open = simple_open,
 	.llseek = generic_file_llseek,
-	.read = mt7615_ext_mac_addr_read,
-	.write = mt7615_ext_mac_addr_write,
+	.read_iter = mt7615_ext_mac_addr_read,
+	.write_iter = mt7615_ext_mac_addr_write,
 	.owner = THIS_MODULE,
 };
 
drivers/net/wireless/mediatek/mt76/mt7915/debugfs.c +24 -28

136 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt7996/debugfs.c +15 -18
index 9bd953586b04..afd8a6623b9c 100644
@@ -47,11 +47,10 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_implicit_txbf, mt7996_implicit_txbf_get,
 			 mt7996_implicit_txbf_set, "%lld\n");
 
 /* test knob of system error recovery */
-static ssize_t
-mt7996_sys_recovery_set(struct file *file, const char __user *user_buf,
-			size_t count, loff_t *ppos)
+static ssize_t mt7996_sys_recovery_set(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mt7996_phy *phy = file->private_data;
+	struct mt7996_phy *phy = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct mt7996_dev *dev = phy->dev;
 	bool band = phy->mt76->band_idx;
 	char buf[16];
@@ -61,7 +60,7 @@ mt7996_sys_recovery_set(struct file *file, const char __user *user_buf,
 	if (count >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, user_buf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	if (count && buf[count - 1] == '\n')
@@ -122,11 +121,9 @@ mt7996_sys_recovery_set(struct file *file, const char __user *user_buf,
 	return ret ? ret : count;
 }
 
-static ssize_t
-mt7996_sys_recovery_get(struct file *file, char __user *user_buf,
-			size_t count, loff_t *ppos)
+static ssize_t mt7996_sys_recovery_get(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mt7996_phy *phy = file->private_data;
+	struct mt7996_phy *phy = iocb->ki_filp->private_data;
 	struct mt7996_dev *dev = phy->dev;
 	char *buff;
 	int desc = 0;
@@ -205,14 +202,14 @@ mt7996_sys_recovery_get(struct file *file, char __user *user_buf,
 			  dev->recovery.wm_reset_count,
 			  dev->recovery.wa_reset_count);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc);
+	ret = simple_copy_to_iter(buff, &iocb->ki_pos, desc, to);
 	kfree(buff);
 	return ret;
 }
 
 static const struct file_operations mt7996_sys_recovery_ops = {
-	.write = mt7996_sys_recovery_set,
-	.read = mt7996_sys_recovery_get,
+	.write_iter = mt7996_sys_recovery_set,
+	.read_iter = mt7996_sys_recovery_get,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
@@ -886,15 +883,15 @@ bool mt7996_debugfs_rx_log(struct mt7996_dev *dev, const void *data, int len)
 #ifdef CONFIG_MAC80211_DEBUGFS
 /** per-station debugfs **/
 
-static ssize_t mt7996_sta_fixed_rate_set(struct file *file,
-					 const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t mt7996_sta_fixed_rate_set(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
 #define SHORT_PREAMBLE 0
 #define LONG_PREAMBLE 1
-	struct ieee80211_sta *sta = file->private_data;
+	struct ieee80211_sta *sta = iocb->ki_filp->private_data;
 	struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;
 	struct mt7996_dev *dev = msta->vif->phy->dev;
+	size_t count = iov_iter_count(from);
 	struct ra_rate phy = {};
 	char buf[100];
 	int ret;
@@ -903,7 +900,7 @@ static ssize_t mt7996_sta_fixed_rate_set(struct file *file,
 	if (count >= sizeof(buf))
 		return -EINVAL;
 
-	if (copy_from_user(buf, user_buf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	if (count && buf[count - 1] == '\n')
@@ -944,7 +941,7 @@ static ssize_t mt7996_sta_fixed_rate_set(struct file *file,
 }
 
 static const struct file_operations fops_fixed_rate = {
-	.write = mt7996_sta_fixed_rate_set,
+	.write_iter = mt7996_sta_fixed_rate_set,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
Signature · 1 line
2.43.0
author maintainer
#304 lore raw

PATCH 298/437 drivers/net/wireless/ath/ath5k: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/ath/ath5k/debug.c | 148 +++++++++++--------------
 1 file changed, 66 insertions(+), 82 deletions(-)
drivers/net/wireless/ath/ath5k/debug.c +66 -82
index ec130510aeb2..22f19957887c 100644
@@ -172,10 +172,9 @@ DEFINE_SEQ_ATTRIBUTE(registers);
 
 /* debugfs: beacons */
 
-static ssize_t read_file_beacon(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_beacon(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	char buf[500];
 	unsigned int len = 0;
 	unsigned int v;
@@ -217,18 +216,17 @@ static ssize_t read_file_beacon(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_beacon(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_beacon(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[20];
 
 	count = min_t(size_t, count, sizeof(buf) - 1);
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[count] = '\0';
@@ -243,8 +241,8 @@ static ssize_t write_file_beacon(struct file *file,
 }
 
 static const struct file_operations fops_beacon = {
-	.read = read_file_beacon,
-	.write = write_file_beacon,
+	.read_iter = read_file_beacon,
+	.write_iter = write_file_beacon,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -253,18 +251,16 @@ static const struct file_operations fops_beacon = {
 
 /* debugfs: reset */
 
-static ssize_t write_file_reset(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_reset(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "debug file triggered reset\n");
 	ieee80211_queue_work(ah->hw, &ah->reset_work);
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations fops_reset = {
-	.write = write_file_reset,
+	.write_iter = write_file_reset,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = noop_llseek,
@@ -293,10 +289,9 @@ static const struct {
 	{ ATH5K_DEBUG_ANY,	"all",		"show all debug levels" },
 };
 
-static ssize_t read_file_debug(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_debug(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	char buf[700];
 	unsigned int len = 0;
 	unsigned int i;
@@ -318,19 +313,18 @@ static ssize_t read_file_debug(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_debug(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_debug(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned int i;
 	char buf[20];
 
 	count = min_t(size_t, count, sizeof(buf) - 1);
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[count] = '\0';
@@ -345,8 +339,8 @@ static ssize_t write_file_debug(struct file *file,
 }
 
 static const struct file_operations fops_debug = {
-	.read = read_file_debug,
-	.write = write_file_debug,
+	.read_iter = read_file_debug,
+	.write_iter = write_file_debug,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -355,10 +349,9 @@ static const struct file_operations fops_debug = {
 
 /* debugfs: antenna */
 
-static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_antenna(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	char buf[700];
 	unsigned int len = 0;
 	unsigned int i;
@@ -423,19 +416,18 @@ static ssize_t read_file_antenna(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_antenna(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_antenna(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned int i;
 	char buf[20];
 
 	count = min_t(size_t, count, sizeof(buf) - 1);
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[count] = '\0';
@@ -459,8 +451,8 @@ static ssize_t write_file_antenna(struct file *file,
 }
 
 static const struct file_operations fops_antenna = {
-	.read = read_file_antenna,
-	.write = write_file_antenna,
+	.read_iter = read_file_antenna,
+	.write_iter = write_file_antenna,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -468,10 +460,9 @@ static const struct file_operations fops_antenna = {
 
 /* debugfs: misc */
 
-static ssize_t read_file_misc(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_misc(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	char buf[700];
 	unsigned int len = 0;
 	u32 filt = ath5k_hw_get_rx_filter(ah);
@@ -511,11 +502,11 @@ static ssize_t read_file_misc(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_misc = {
-	.read = read_file_misc,
+	.read_iter = read_file_misc,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 };
@@ -523,10 +514,9 @@ static const struct file_operations fops_misc = {
 
 /* debugfs: frameerrors */
 
-static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_frameerrors(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	struct ath5k_statistics *st = &ah->stats;
 	char buf[700];
 	unsigned int len = 0;
@@ -596,19 +586,18 @@ static ssize_t read_file_frameerrors(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_frameerrors(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_frameerrors(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath5k_statistics *st = &ah->stats;
 	char buf[20];
 
 	count = min_t(size_t, count, sizeof(buf) - 1);
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[count] = '\0';
@@ -631,8 +620,8 @@ static ssize_t write_file_frameerrors(struct file *file,
 }
 
 static const struct file_operations fops_frameerrors = {
-	.read = read_file_frameerrors,
-	.write = write_file_frameerrors,
+	.read_iter = read_file_frameerrors,
+	.write_iter = write_file_frameerrors,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -641,10 +630,9 @@ static const struct file_operations fops_frameerrors = {
 
 /* debugfs: ani */
 
-static ssize_t read_file_ani(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_ani(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	struct ath5k_statistics *st = &ah->stats;
 	struct ath5k_ani_state *as = &ah->ani_state;
 
@@ -746,18 +734,17 @@ static ssize_t read_file_ani(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_ani(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_ani(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[20];
 
 	count = min_t(size_t, count, sizeof(buf) - 1);
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[count] = '\0';
@@ -796,8 +783,8 @@ static ssize_t write_file_ani(struct file *file,
 }
 
 static const struct file_operations fops_ani = {
-	.read = read_file_ani,
-	.write = write_file_ani,
+	.read_iter = read_file_ani,
+	.write_iter = write_file_ani,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -806,10 +793,9 @@ static const struct file_operations fops_ani = {
 
 /* debugfs: queues etc */
 
-static ssize_t read_file_queue(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_queue(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
 	char buf[700];
 	unsigned int len = 0;
 
@@ -844,18 +830,17 @@ static ssize_t read_file_queue(struct file *file, char __user *user_buf,
 	if (len > sizeof(buf))
 		len = sizeof(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_queue(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t write_file_queue(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath5k_hw *ah = file->private_data;
+	struct ath5k_hw *ah = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[20];
 
 	count = min_t(size_t, count, sizeof(buf) - 1);
-	if (copy_from_user(buf, userbuf, count))
+	if (!copy_from_iter_full(buf, count, from))
 		return -EFAULT;
 
 	buf[count] = '\0';
@@ -869,8 +854,8 @@ static ssize_t write_file_queue(struct file *file,
 
 
 static const struct file_operations fops_queue = {
-	.read = read_file_queue,
-	.write = write_file_queue,
+	.read_iter = read_file_queue,
+	.write_iter = write_file_queue,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -948,12 +933,11 @@ static int open_file_eeprom(struct inode *inode, struct file *file)
 
 }
 
-static ssize_t read_file_eeprom(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_eeprom(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct eeprom_private *ep = file->private_data;
+	struct eeprom_private *ep = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(user_buf, count, ppos, ep->buf, ep->len);
+	return simple_copy_to_iter(ep->buf, &iocb->ki_pos, ep->len, to);
 }
 
 static int release_file_eeprom(struct inode *inode, struct file *file)
@@ -968,7 +952,7 @@ static int release_file_eeprom(struct inode *inode, struct file *file)
 
 static const struct file_operations fops_eeprom = {
 	.open = open_file_eeprom,
-	.read = read_file_eeprom,
+	.read_iter = read_file_eeprom,
 	.release = release_file_eeprom,
 	.owner = THIS_MODULE,
 };
Signature · 1 line
2.43.0
author maintainer
#305 lore raw

PATCH 299/437 drivers/net/wireless/ath/ath6kl: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/ath/ath6kl/debug.c | 312 +++++++++++-------------
 1 file changed, 144 insertions(+), 168 deletions(-)
drivers/net/wireless/ath/ath6kl/debug.c +144 -168
index b837d31416df..f3a7385cf7e5 100644
@@ -297,10 +297,9 @@ void ath6kl_debug_war(struct ath6kl *ar, enum ath6kl_war war)
 	}
 }
 
-static ssize_t read_file_war_stats(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_war_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	char *buf;
 	unsigned int len = 0, buf_len = 1500;
 	ssize_t ret_cnt;
@@ -320,14 +319,14 @@ static ssize_t read_file_war_stats(struct file *file, char __user *user_buf,
 	if (WARN_ON(len > buf_len))
 		len = buf_len;
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	kfree(buf);
 	return ret_cnt;
 }
 
 static const struct file_operations fops_war_stats = {
-	.read = read_file_war_stats,
+	.read_iter = read_file_war_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -395,10 +394,10 @@ static int ath6kl_fwlog_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath6kl_fwlog_read(struct file *file, char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t ath6kl_fwlog_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct sk_buff *skb;
 	ssize_t ret_cnt;
 	size_t len = 0;
@@ -431,7 +430,7 @@ static ssize_t ath6kl_fwlog_read(struct file *file, char __user *user_buf,
 
 	/* FIXME: what to do if len == 0? */
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	vfree(buf);
 
@@ -441,17 +440,15 @@ static ssize_t ath6kl_fwlog_read(struct file *file, char __user *user_buf,
 static const struct file_operations fops_fwlog = {
 	.open = ath6kl_fwlog_open,
 	.release = ath6kl_fwlog_release,
-	.read = ath6kl_fwlog_read,
+	.read_iter = ath6kl_fwlog_read,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_fwlog_block_read(struct file *file,
-				       char __user *user_buf,
-				       size_t count,
-				       loff_t *ppos)
+static ssize_t ath6kl_fwlog_block_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct sk_buff *skb;
 	ssize_t ret_cnt;
 	size_t len = 0, not_copied;
@@ -498,13 +495,13 @@ static ssize_t ath6kl_fwlog_block_read(struct file *file,
 
 	/* FIXME: what to do if len == 0? */
 
-	not_copied = copy_to_user(user_buf, buf, len);
+	not_copied = !copy_to_iter_full(buf, len, to);
 	if (not_copied != 0) {
 		ret_cnt = -EFAULT;
 		goto out;
 	}
 
-	*ppos = *ppos + len;
+	iocb->ki_pos += len;
 
 	ret_cnt = len;
 
@@ -517,31 +514,29 @@ static ssize_t ath6kl_fwlog_block_read(struct file *file,
 static const struct file_operations fops_fwlog_block = {
 	.open = ath6kl_fwlog_open,
 	.release = ath6kl_fwlog_release,
-	.read = ath6kl_fwlog_block_read,
+	.read_iter = ath6kl_fwlog_block_read,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_fwlog_mask_read(struct file *file, char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath6kl_fwlog_mask_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	char buf[16];
 	int len;
 
 	len = snprintf(buf, sizeof(buf), "0x%x\n", ar->debug.fwlog_mask);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath6kl_fwlog_mask_write(struct file *file,
-				       const char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t ath6kl_fwlog_mask_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 
-	ret = kstrtou32_from_user(user_buf, count, 0, &ar->debug.fwlog_mask);
+	ret = kstrtou32_from_iter(from, count, 0, &ar->debug.fwlog_mask);
 	if (ret)
 		return ret;
 
@@ -556,16 +551,15 @@ static ssize_t ath6kl_fwlog_mask_write(struct file *file,
 
 static const struct file_operations fops_fwlog_mask = {
 	.open = simple_open,
-	.read = ath6kl_fwlog_mask_read,
-	.write = ath6kl_fwlog_mask_write,
+	.read_iter = ath6kl_fwlog_mask_read,
+	.write_iter = ath6kl_fwlog_mask_write,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_tgt_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	struct ath6kl_vif *vif;
 	struct target_stats *tgt_stats;
 	char *buf;
@@ -681,14 +675,14 @@ static ssize_t read_file_tgt_stats(struct file *file, char __user *user_buf,
 	if (len > buf_len)
 		len = buf_len;
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	kfree(buf);
 	return ret_cnt;
 }
 
 static const struct file_operations fops_tgt_stats = {
-	.read = read_file_tgt_stats,
+	.read_iter = read_file_tgt_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -700,11 +694,10 @@ static const struct file_operations fops_tgt_stats = {
 #define CREDIT_INFO_DISPLAY_STRING_LEN	200
 #define CREDIT_INFO_LEN	128
 
-static ssize_t read_file_credit_dist_stats(struct file *file,
-					   char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t read_file_credit_dist_stats(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	struct htc_target *target = ar->htc_target;
 	struct htc_endpoint_credit_dist *ep_list;
 	char *buf;
@@ -747,13 +740,13 @@ static ssize_t read_file_credit_dist_stats(struct file *file,
 	if (len > buf_len)
 		len = buf_len;
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 	return ret_cnt;
 }
 
 static const struct file_operations fops_credit_dist_stats = {
-	.read = read_file_credit_dist_stats,
+	.read_iter = read_file_credit_dist_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -778,11 +771,10 @@ static unsigned int print_endpoint_stat(struct htc_target *target, char *buf,
 	return len;
 }
 
-static ssize_t ath6kl_endpoint_stats_read(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath6kl_endpoint_stats_read(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	struct htc_target *target = ar->htc_target;
 	char *buf;
 	unsigned int buf_len, len = 0;
@@ -828,22 +820,22 @@ static ssize_t ath6kl_endpoint_stats_read(struct file *file,
 	if (len > buf_len)
 		len = buf_len;
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 	return ret_cnt;
 }
 
-static ssize_t ath6kl_endpoint_stats_write(struct file *file,
-					   const char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath6kl_endpoint_stats_write(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	struct htc_target *target = ar->htc_target;
+	size_t count = iov_iter_count(from);
 	int ret, i;
 	u32 val;
 	struct htc_endpoint_stats *ep_st;
 
-	ret = kstrtou32_from_user(user_buf, count, 0, &val);
+	ret = kstrtou32_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 	if (val == 0) {
@@ -858,8 +850,8 @@ static ssize_t ath6kl_endpoint_stats_write(struct file *file,
 
 static const struct file_operations fops_endpoint_stats = {
 	.open = simple_open,
-	.read = ath6kl_endpoint_stats_read,
-	.write = ath6kl_endpoint_stats_write,
+	.read_iter = ath6kl_endpoint_stats_read,
+	.write_iter = ath6kl_endpoint_stats_write,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
@@ -889,10 +881,9 @@ static bool ath6kl_dbg_is_diag_reg_valid(u32 reg_addr)
 	return false;
 }
 
-static ssize_t ath6kl_regread_read(struct file *file, char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t ath6kl_regread_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	u8 buf[50];
 	unsigned int len = 0;
 
@@ -903,17 +894,16 @@ static ssize_t ath6kl_regread_read(struct file *file, char __user *user_buf,
 		len += scnprintf(buf + len, sizeof(buf) - len,
 				 "All diag registers\n");
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath6kl_regread_write(struct file *file,
-				    const char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t ath6kl_regread_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long reg_addr;
 
-	if (kstrtoul_from_user(user_buf, count, 0, &reg_addr))
+	if (kstrtoul_from_iter(from, count, 0, &reg_addr))
 		return -EINVAL;
 
 	if ((reg_addr % 4) != 0)
@@ -928,8 +918,8 @@ static ssize_t ath6kl_regread_write(struct file *file,
 }
 
 static const struct file_operations fops_diag_reg_read = {
-	.read = ath6kl_regread_read,
-	.write = ath6kl_regread_write,
+	.read_iter = ath6kl_regread_read,
+	.write_iter = ath6kl_regread_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1000,11 +990,10 @@ static int ath6kl_regdump_open(struct inode *inode, struct file *file)
 	return -EIO;
 }
 
-static ssize_t ath6kl_regdump_read(struct file *file, char __user *user_buf,
-				  size_t count, loff_t *ppos)
+static ssize_t ath6kl_regdump_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	u8 *buf = file->private_data;
-	return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
+	u8 *buf = iocb->ki_filp->private_data;
+	return simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 }
 
 static int ath6kl_regdump_release(struct inode *inode, struct file *file)
@@ -1015,21 +1004,21 @@ static int ath6kl_regdump_release(struct inode *inode, struct file *file)
 
 static const struct file_operations fops_reg_dump = {
 	.open = ath6kl_regdump_open,
-	.read = ath6kl_regdump_read,
+	.read_iter = ath6kl_regdump_read,
 	.release = ath6kl_regdump_release,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_lrssi_roam_write(struct file *file,
-				       const char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t ath6kl_lrssi_roam_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long lrssi_roam_threshold;
 	int ret;
 
-	if (kstrtoul_from_user(user_buf, count, 0, &lrssi_roam_threshold))
+	if (kstrtoul_from_iter(from, count, 0, &lrssi_roam_threshold))
 		return -EINVAL;
 
 	ar->lrssi_roam_threshold = lrssi_roam_threshold;
@@ -1041,53 +1030,48 @@ static ssize_t ath6kl_lrssi_roam_write(struct file *file,
 	return count;
 }
 
-static ssize_t ath6kl_lrssi_roam_read(struct file *file,
-				      char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath6kl_lrssi_roam_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	unsigned int len;
 
 	len = snprintf(buf, sizeof(buf), "%u\n", ar->lrssi_roam_threshold);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_lrssi_roam_threshold = {
-	.read = ath6kl_lrssi_roam_read,
-	.write = ath6kl_lrssi_roam_write,
+	.read_iter = ath6kl_lrssi_roam_read,
+	.write_iter = ath6kl_lrssi_roam_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_regwrite_read(struct file *file,
-				    char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t ath6kl_regwrite_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	u8 buf[32];
 	unsigned int len = 0;
 
 	len = scnprintf(buf, sizeof(buf), "Addr: 0x%x Val: 0x%x\n",
 			ar->debug.diag_reg_addr_wr, ar->debug.diag_reg_val_wr);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath6kl_regwrite_write(struct file *file,
-				     const char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath6kl_regwrite_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	char *sptr, *token;
 	unsigned int len = 0;
 	u32 reg_addr, reg_val;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -1117,8 +1101,8 @@ static ssize_t ath6kl_regwrite_write(struct file *file,
 }
 
 static const struct file_operations fops_diag_reg_write = {
-	.read = ath6kl_regwrite_read,
-	.write = ath6kl_regwrite_write,
+	.read_iter = ath6kl_regwrite_read,
+	.write_iter = ath6kl_regwrite_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1157,10 +1141,9 @@ int ath6kl_debug_roam_tbl_event(struct ath6kl *ar, const void *buf,
 	return 0;
 }
 
-static ssize_t ath6kl_roam_table_read(struct file *file, char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath6kl_roam_table_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	int ret;
 	long left;
 	struct wmi_target_roam_tbl *tbl;
@@ -1215,31 +1198,31 @@ static ssize_t ath6kl_roam_table_read(struct file *file, char __user *user_buf,
 	if (len > buf_len)
 		len = buf_len;
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	kfree(buf);
 	return ret_cnt;
 }
 
 static const struct file_operations fops_roam_table = {
-	.read = ath6kl_roam_table_read,
+	.read_iter = ath6kl_roam_table_read,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_force_roam_write(struct file *file,
-				       const char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t ath6kl_force_roam_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	char buf[20];
 	size_t len;
 	u8 bssid[ETH_ALEN];
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 	buf[len] = '\0';
 
@@ -1254,24 +1237,23 @@ static ssize_t ath6kl_force_roam_write(struct file *file,
 }
 
 static const struct file_operations fops_force_roam = {
-	.write = ath6kl_force_roam_write,
+	.write_iter = ath6kl_force_roam_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_roam_mode_write(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath6kl_roam_mode_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	char buf[20];
 	size_t len;
 	enum wmi_roam_mode mode;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 	buf[len] = '\0';
 	if (len > 0 && buf[len - 1] == '\n')
@@ -1294,7 +1276,7 @@ static ssize_t ath6kl_roam_mode_write(struct file *file,
 }
 
 static const struct file_operations fops_roam_mode = {
-	.write = ath6kl_roam_mode_write,
+	.write_iter = ath6kl_roam_mode_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1305,27 +1287,25 @@ void ath6kl_debug_set_keepalive(struct ath6kl *ar, u8 keepalive)
 	ar->debug.keepalive = keepalive;
 }
 
-static ssize_t ath6kl_keepalive_read(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath6kl_keepalive_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	char buf[16];
 	int len;
 
 	len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.keepalive);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath6kl_keepalive_write(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath6kl_keepalive_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	u8 val;
 
-	ret = kstrtou8_from_user(user_buf, count, 0, &val);
+	ret = kstrtou8_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -1338,8 +1318,8 @@ static ssize_t ath6kl_keepalive_write(struct file *file,
 
 static const struct file_operations fops_keepalive = {
 	.open = simple_open,
-	.read = ath6kl_keepalive_read,
-	.write = ath6kl_keepalive_write,
+	.read_iter = ath6kl_keepalive_read,
+	.write_iter = ath6kl_keepalive_write,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
@@ -1349,28 +1329,27 @@ void ath6kl_debug_set_disconnect_timeout(struct ath6kl *ar, u8 timeout)
 	ar->debug.disc_timeout = timeout;
 }
 
-static ssize_t ath6kl_disconnect_timeout_read(struct file *file,
-					      char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath6kl_disconnect_timeout_read(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	char buf[16];
 	int len;
 
 	len = snprintf(buf, sizeof(buf), "%u\n", ar->debug.disc_timeout);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath6kl_disconnect_timeout_write(struct file *file,
-					       const char __user *user_buf,
-					       size_t count, loff_t *ppos)
+static ssize_t ath6kl_disconnect_timeout_write(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	u8 val;
 
-	ret = kstrtou8_from_user(user_buf, count, 0, &val);
+	ret = kstrtou8_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 
@@ -1383,17 +1362,17 @@ static ssize_t ath6kl_disconnect_timeout_write(struct file *file,
 
 static const struct file_operations fops_disconnect_timeout = {
 	.open = simple_open,
-	.read = ath6kl_disconnect_timeout_read,
-	.write = ath6kl_disconnect_timeout_write,
+	.read_iter = ath6kl_disconnect_timeout_read,
+	.write_iter = ath6kl_disconnect_timeout_write,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_create_qos_write(struct file *file,
-						const char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t ath6kl_create_qos_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath6kl_vif *vif;
 	char buf[200];
 	ssize_t len;
@@ -1407,7 +1386,7 @@ static ssize_t ath6kl_create_qos_write(struct file *file,
 		return -EIO;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 	buf[len] = '\0';
 	sptr = buf;
@@ -1561,17 +1540,17 @@ static ssize_t ath6kl_create_qos_write(struct file *file,
 }
 
 static const struct file_operations fops_create_qos = {
-	.write = ath6kl_create_qos_write,
+	.write_iter = ath6kl_create_qos_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_delete_qos_write(struct file *file,
-				const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t ath6kl_delete_qos_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath6kl_vif *vif;
 	char buf[100];
 	ssize_t len;
@@ -1584,7 +1563,7 @@ static ssize_t ath6kl_delete_qos_write(struct file *file,
 		return -EIO;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 	buf[len] = '\0';
 	sptr = buf;
@@ -1608,17 +1587,17 @@ static ssize_t ath6kl_delete_qos_write(struct file *file,
 }
 
 static const struct file_operations fops_delete_qos = {
-	.write = ath6kl_delete_qos_write,
+	.write_iter = ath6kl_delete_qos_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_bgscan_int_write(struct file *file,
-				const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t ath6kl_bgscan_int_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath6kl_vif *vif;
 	u16 bgscan_int;
 	char buf[32];
@@ -1629,7 +1608,7 @@ static ssize_t ath6kl_bgscan_int_write(struct file *file,
 		return -EIO;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -1648,17 +1627,16 @@ static ssize_t ath6kl_bgscan_int_write(struct file *file,
 }
 
 static const struct file_operations fops_bgscan_int = {
-	.write = ath6kl_bgscan_int_write,
+	.write_iter = ath6kl_bgscan_int_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_listen_int_write(struct file *file,
-				       const char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t ath6kl_listen_int_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath6kl_vif *vif;
 	u16 listen_interval;
 	char buf[32];
@@ -1669,7 +1647,7 @@ static ssize_t ath6kl_listen_int_write(struct file *file,
 		return -EIO;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -1686,11 +1664,9 @@ static ssize_t ath6kl_listen_int_write(struct file *file,
 	return count;
 }
 
-static ssize_t ath6kl_listen_int_read(struct file *file,
-				      char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath6kl_listen_int_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
 	struct ath6kl_vif *vif;
 	char buf[32];
 	int len;
@@ -1701,22 +1677,22 @@ static ssize_t ath6kl_listen_int_read(struct file *file,
 
 	len = scnprintf(buf, sizeof(buf), "%u\n", vif->listen_intvl_t);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_listen_int = {
-	.read = ath6kl_listen_int_read,
-	.write = ath6kl_listen_int_write,
+	.read_iter = ath6kl_listen_int_read,
+	.write_iter = ath6kl_listen_int_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath6kl_power_params_write(struct file *file,
-						const char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t ath6kl_power_params_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct ath6kl *ar = file->private_data;
+	struct ath6kl *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u8 buf[100];
 	unsigned int len = 0;
 	char *sptr, *token;
@@ -1724,7 +1700,7 @@ static ssize_t ath6kl_power_params_write(struct file *file,
 		tx_wakeup, num_tx;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 	buf[len] = '\0';
 	sptr = buf;
@@ -1766,7 +1742,7 @@ static ssize_t ath6kl_power_params_write(struct file *file,
 }
 
 static const struct file_operations fops_power_params = {
-	.write = ath6kl_power_params_write,
+	.write_iter = ath6kl_power_params_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
Signature · 1 line
2.43.0
author maintainer
#306 lore raw

PATCH 300/437 drivers/net/wireless/ath/carl9170: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/ath/carl9170/debug.c | 25 +++++++++++------------
 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/net/wireless/ath/carl9170/debug.c +12 -13
index bb40889d7c72..1116f7c8ef61 100644
@@ -59,10 +59,10 @@ struct carl9170_debugfs_fops {
 	enum carl9170_device_state req_dev_state;
 };
 
-static ssize_t carl9170_debugfs_read(struct file *file, char __user *userbuf,
-				     size_t count, loff_t *ppos)
+static ssize_t carl9170_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct carl9170_debugfs_fops *dfops;
+	size_t count = iov_iter_count(to);
 	struct ar9170 *ar;
 	char *buf = NULL, *res_buf = NULL;
 	ssize_t ret = 0;
@@ -71,11 +71,11 @@ static ssize_t carl9170_debugfs_read(struct file *file, char __user *userbuf,
 	if (!count)
 		return 0;
 
-	ar = file->private_data;
+	ar = iocb->ki_filp->private_data;
 
 	if (!ar)
 		return -ENODEV;
-	dfops = container_of(debugfs_real_fops(file),
+	dfops = container_of(debugfs_real_fops(iocb->ki_filp),
 			     struct carl9170_debugfs_fops, fops);
 
 	if (!dfops->read)
@@ -97,8 +97,7 @@ static ssize_t carl9170_debugfs_read(struct file *file, char __user *userbuf,
 	res_buf = dfops->read(ar, buf, dfops->read_bufsize, &ret);
 
 	if (ret > 0)
-		err = simple_read_from_buffer(userbuf, count, ppos,
-					      res_buf, ret);
+		err = simple_copy_to_iter(res_buf, &iocb->ki_pos, ret, to);
 	else
 		err = ret;
 
@@ -110,10 +109,10 @@ static ssize_t carl9170_debugfs_read(struct file *file, char __user *userbuf,
 	return err;
 }
 
-static ssize_t carl9170_debugfs_write(struct file *file,
-	const char __user *userbuf, size_t count, loff_t *ppos)
+static ssize_t carl9170_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct carl9170_debugfs_fops *dfops;
+	size_t count = iov_iter_count(from);
 	struct ar9170 *ar;
 	char *buf = NULL;
 	int err = 0;
@@ -124,11 +123,11 @@ static ssize_t carl9170_debugfs_write(struct file *file,
 	if (count > PAGE_SIZE)
 		return -E2BIG;
 
-	ar = file->private_data;
+	ar = iocb->ki_filp->private_data;
 
 	if (!ar)
 		return -ENODEV;
-	dfops = container_of(debugfs_real_fops(file),
+	dfops = container_of(debugfs_real_fops(iocb->ki_filp),
 			     struct carl9170_debugfs_fops, fops);
 
 	if (!dfops->write)
@@ -138,7 +137,7 @@ static ssize_t carl9170_debugfs_write(struct file *file,
 	if (!buf)
 		return -ENOMEM;
 
-	if (copy_from_user(buf, userbuf, count)) {
+	if (!copy_from_iter_full(buf, count, from)) {
 		err = -EFAULT;
 		goto out_free;
 	}
@@ -175,8 +174,8 @@ static const struct carl9170_debugfs_fops carl_debugfs_##name ##_ops = {\
 	.req_dev_state = _dstate,					\
 	.fops = {							\
 		.open	= simple_open,					\
-		.read	= carl9170_debugfs_read,			\
-		.write	= carl9170_debugfs_write,			\
+		.read_iter	= carl9170_debugfs_read,		\
+		.write_iter	= carl9170_debugfs_write,		\
 		.owner	= THIS_MODULE					\
 	},								\
 }
Signature · 1 line
2.43.0
author maintainer
#307 lore raw

PATCH 301/437 drivers/net/wireless/ath/wcn36xx: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/ath/wcn36xx/debug.c | 42 +++++++++++-------------
 1 file changed, 19 insertions(+), 23 deletions(-)
drivers/net/wireless/ath/wcn36xx/debug.c +19 -23
index 58b3c0501bfd..9dbfb831c0fd 100644
@@ -25,10 +25,9 @@
 
 #ifdef CONFIG_WCN36XX_DEBUGFS
 
-static ssize_t read_file_bool_bmps(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_bool_bmps(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wcn36xx *wcn = file->private_data;
+	struct wcn36xx *wcn = iocb->ki_filp->private_data;
 	struct wcn36xx_vif *vif_priv = NULL;
 	struct ieee80211_vif *vif = NULL;
 	char buf[3];
@@ -46,14 +45,13 @@ static ssize_t read_file_bool_bmps(struct file *file, char __user *user_buf,
 	buf[1] = '\n';
 	buf[2] = 0x00;
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t write_file_bool_bmps(struct file *file,
-				    const char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t write_file_bool_bmps(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wcn36xx *wcn = file->private_data;
+	struct wcn36xx *wcn = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wcn36xx_vif *vif_priv = NULL;
 	struct ieee80211_vif *vif = NULL;
 
@@ -61,7 +59,7 @@ static ssize_t write_file_bool_bmps(struct file *file,
 	int buf_size;
 
 	buf_size = min(count, (sizeof(buf)-1));
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	switch (buf[0]) {
@@ -92,15 +90,14 @@ static ssize_t write_file_bool_bmps(struct file *file,
 
 static const struct file_operations fops_wcn36xx_bmps = {
 	.open = simple_open,
-	.read  =       read_file_bool_bmps,
-	.write =       write_file_bool_bmps,
+	.read_iter  =       read_file_bool_bmps,
+	.write_iter =       write_file_bool_bmps,
 };
 
-static ssize_t write_file_dump(struct file *file,
-				    const char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t write_file_dump(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wcn36xx *wcn = file->private_data;
+	struct wcn36xx *wcn = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[255], *tmp;
 	int buf_size;
 	u32 arg[WCN36xx_MAX_DUMP_ARGS];
@@ -110,7 +107,7 @@ static ssize_t write_file_dump(struct file *file,
 	memset(arg, 0, sizeof(arg));
 
 	buf_size = min(count, (sizeof(buf) - 1));
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	tmp = buf;
@@ -134,14 +131,13 @@ static ssize_t write_file_dump(struct file *file,
 
 static const struct file_operations fops_wcn36xx_dump = {
 	.open = simple_open,
-	.write =       write_file_dump,
+	.write_iter =       write_file_dump,
 };
 
-static ssize_t read_file_firmware_feature_caps(struct file *file,
-					       char __user *user_buf,
-					       size_t count, loff_t *ppos)
+static ssize_t read_file_firmware_feature_caps(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct wcn36xx *wcn = file->private_data;
+	struct wcn36xx *wcn = iocb->ki_filp->private_data;
 	size_t len = 0, buf_len = 2048;
 	char *buf;
 	int i;
@@ -162,7 +158,7 @@ static ssize_t read_file_firmware_feature_caps(struct file *file,
 	}
 	mutex_unlock(&wcn->hal_mutex);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return ret;
@@ -170,7 +166,7 @@ static ssize_t read_file_firmware_feature_caps(struct file *file,
 
 static const struct file_operations fops_wcn36xx_firmware_feat_caps = {
 	.open = simple_open,
-	.read = read_file_firmware_feature_caps,
+	.read_iter = read_file_firmware_feature_caps,
 };
 
 #define ADD_FILE(name, mode, fop, priv_data)		\
Signature · 1 line
2.43.0
author maintainer
#308 lore raw

PATCH 302/437 drivers/net/wireless/ath/wil6210: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/ath/wil6210/debugfs.c | 235 ++++++++++-----------
 drivers/net/wireless/ath/wil6210/pmc.c     |  27 ++-
 drivers/net/wireless/ath/wil6210/pmc.h     |   2 +-
 3 files changed, 122 insertions(+), 142 deletions(-)
drivers/net/wireless/ath/wil6210/debugfs.c +109 -126
index c021ebcddee7..9cbbdd9b9b85 100644
@@ -611,14 +611,14 @@ static int memread_show(struct seq_file *s, void *data)
 }
 DEFINE_SHOW_ATTRIBUTE(memread);
 
-static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t wil_read_file_ioblob(struct kiocb *iocb, struct iov_iter *to)
 {
 	enum { max_count = 4096 };
-	struct wil_blob_wrapper *wil_blob = file->private_data;
+	struct wil_blob_wrapper *wil_blob = iocb->ki_filp->private_data;
 	struct wil6210_priv *wil = wil_blob->wil;
-	loff_t aligned_pos, pos = *ppos;
+	loff_t aligned_pos, pos = iocb->ki_pos;
 	size_t available = wil_blob->blob.size;
+	size_t count = iov_iter_count(to);
 	void *buf;
 	size_t unaligned_bytes, aligned_count, ret;
 	int rc;
@@ -659,7 +659,7 @@ static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf,
 	wil_memcpy_fromio_32(buf, (const void __iomem *)
 			     wil_blob->blob.data + aligned_pos, aligned_count);
 
-	ret = copy_to_user(user_buf, buf + unaligned_bytes, count);
+	ret = !copy_to_iter_full(buf + unaligned_bytes, count, to);
 
 	wil_mem_access_unlock(wil);
 	wil_pm_runtime_put(wil);
@@ -669,13 +669,12 @@ static ssize_t wil_read_file_ioblob(struct file *file, char __user *user_buf,
 		return -EFAULT;
 
 	count -= ret;
-	*ppos = pos + count;
-
+	iocb->ki_pos = pos + count;
 	return count;
 }
 
 static const struct file_operations fops_ioblob = {
-	.read =		wil_read_file_ioblob,
+	.read_iter =	wil_read_file_ioblob,
 	.open =		simple_open,
 	.llseek =	default_llseek,
 };
@@ -690,15 +689,15 @@ struct dentry *wil_debugfs_create_ioblob(const char *name,
 }
 
 /*---write channel 1..4 to rxon for it, 0 to rxoff---*/
-static ssize_t wil_write_file_rxon(struct file *file, const char __user *buf,
-				   size_t len, loff_t *ppos)
+static ssize_t wil_write_file_rxon(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	int rc;
 	long channel;
 	bool on;
 
-	char *kbuf = memdup_user_nul(buf, len);
+	char *kbuf = iterdup_nul(from, len);
 
 	if (IS_ERR(kbuf))
 		return PTR_ERR(kbuf);
@@ -727,19 +726,18 @@ static ssize_t wil_write_file_rxon(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations fops_rxon = {
-	.write = wil_write_file_rxon,
+	.write_iter = wil_write_file_rxon,
 	.open  = simple_open,
 };
 
-static ssize_t wil_write_file_rbufcap(struct file *file,
-				      const char __user *buf,
-				      size_t count, loff_t *ppos)
+static ssize_t wil_write_file_rbufcap(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int val;
 	int rc;
 
-	rc = kstrtoint_from_user(buf, count, 0, &val);
+	rc = kstrtoint_from_iter(from, count, 0, &val);
 	if (rc) {
 		wil_err(wil, "Invalid argument\n");
 		return rc;
@@ -765,7 +763,7 @@ static ssize_t wil_write_file_rbufcap(struct file *file,
 }
 
 static const struct file_operations fops_rbufcap = {
-	.write = wil_write_file_rbufcap,
+	.write_iter = wil_write_file_rbufcap,
 	.open  = simple_open,
 };
 
@@ -774,10 +772,10 @@ static const struct file_operations fops_rbufcap = {
  * - "del_tx <ringid> <reason>" to trigger DELBA for Tx side
  * - "del_rx <CID> <TID> <reason>" to trigger DELBA for Rx side
  */
-static ssize_t wil_write_back(struct file *file, const char __user *buf,
-			      size_t len, loff_t *ppos)
+static ssize_t wil_write_back(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	int rc;
 	char *kbuf = kmalloc(len + 1, GFP_KERNEL);
 	char cmd[9];
@@ -786,7 +784,7 @@ static ssize_t wil_write_back(struct file *file, const char __user *buf,
 	if (!kbuf)
 		return -ENOMEM;
 
-	rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
+	rc = simple_copy_from_iter(kbuf, &iocb->ki_pos, len, from);
 	if (rc != len) {
 		kfree(kbuf);
 		return rc >= 0 ? -EIO : rc;
@@ -847,8 +845,7 @@ static ssize_t wil_write_back(struct file *file, const char __user *buf,
 	return len;
 }
 
-static ssize_t wil_read_back(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t wil_read_back(struct kiocb *iocb, struct iov_iter *to)
 {
 	static const char text[] = "block ack control, write:\n"
 	" - \"add <ringid> <agg_size> <timeout>\" to trigger ADDBA\n"
@@ -857,13 +854,12 @@ static ssize_t wil_read_back(struct file *file, char __user *user_buf,
 	" - \"del_rx <CID> <TID> <reason>\" to trigger DELBA for Rx side\n"
 	"If missing, <reason> set to \"STA_LEAVING\" (36)\n";
 
-	return simple_read_from_buffer(user_buf, count, ppos, text,
-				       sizeof(text));
+	return simple_copy_to_iter(text, &iocb->ki_pos, sizeof(text), to);
 }
 
 static const struct file_operations fops_back = {
-	.read = wil_read_back,
-	.write = wil_write_back,
+	.read_iter = wil_read_back,
+	.write_iter = wil_write_back,
 	.open  = simple_open,
 };
 
@@ -871,10 +867,10 @@ static const struct file_operations fops_back = {
  * - "alloc <num descriptors> <descriptor_size>" to allocate PMC
  * - "free" to release memory allocated for PMC
  */
-static ssize_t wil_write_pmccfg(struct file *file, const char __user *buf,
-				size_t len, loff_t *ppos)
+static ssize_t wil_write_pmccfg(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	int rc;
 	char *kbuf = kmalloc(len + 1, GFP_KERNEL);
 	char cmd[9];
@@ -883,7 +879,7 @@ static ssize_t wil_write_pmccfg(struct file *file, const char __user *buf,
 	if (!kbuf)
 		return -ENOMEM;
 
-	rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
+	rc = simple_copy_from_iter(kbuf, &iocb->ki_pos, len, from);
 	if (rc != len) {
 		kfree(kbuf);
 		return rc >= 0 ? -EIO : rc;
@@ -921,10 +917,9 @@ static ssize_t wil_write_pmccfg(struct file *file, const char __user *buf,
 	return len;
 }
 
-static ssize_t wil_read_pmccfg(struct file *file, char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t wil_read_pmccfg(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
 	char text[256];
 	char help[] = "pmc control, write:\n"
 	" - \"alloc <num descriptors> <descriptor_size>\" to allocate pmc\n"
@@ -933,19 +928,18 @@ static ssize_t wil_read_pmccfg(struct file *file, char __user *user_buf,
 	snprintf(text, sizeof(text), "Last command status: %d\n\n%s",
 		 wil_pmc_last_cmd_status(wil), help);
 
-	return simple_read_from_buffer(user_buf, count, ppos, text,
-				       strlen(text) + 1);
+	return simple_copy_to_iter(text, &iocb->ki_pos, strlen(text) + 1, to);
 }
 
 static const struct file_operations fops_pmccfg = {
-	.read = wil_read_pmccfg,
-	.write = wil_write_pmccfg,
+	.read_iter = wil_read_pmccfg,
+	.write_iter = wil_write_pmccfg,
 	.open  = simple_open,
 };
 
 static const struct file_operations fops_pmcdata = {
 	.open		= simple_open,
-	.read		= wil_pmc_read,
+	.read_iter	= wil_pmc_read,
 	.llseek		= wil_pmc_llseek,
 };
 
@@ -957,16 +951,16 @@ static int wil_pmcring_seq_open(struct inode *inode, struct file *file)
 static const struct file_operations fops_pmcring = {
 	.open		= wil_pmcring_seq_open,
 	.release	= single_release,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 };
 
 /*---tx_mgmt---*/
 /* Write mgmt frame to this file to send it */
-static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf,
-				     size_t len, loff_t *ppos)
+static ssize_t wil_write_file_txmgmt(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct wiphy *wiphy = wil_to_wiphy(wil);
 	struct wireless_dev *wdev = wil->main_ndev->ieee80211_ptr;
 	struct cfg80211_mgmt_tx_params params;
@@ -978,7 +972,7 @@ static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf,
 	if (!len)
 		return -EINVAL;
 
-	frame = memdup_user(buf, len);
+	frame = iterdup(from, len);
 	if (IS_ERR(frame))
 		return PTR_ERR(frame);
 
@@ -994,17 +988,17 @@ static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations fops_txmgmt = {
-	.write = wil_write_file_txmgmt,
+	.write_iter = wil_write_file_txmgmt,
 	.open  = simple_open,
 };
 
 /* Write WMI command (w/o mbox header) to this file to send it
  * WMI starts from wil6210_mbox_hdr_wmi header
  */
-static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
-				  size_t len, loff_t *ppos)
+static ssize_t wil_write_file_wmi(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev);
 	struct wmi_cmd_hdr *wmi;
 	void *cmd;
@@ -1012,10 +1006,10 @@ static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
 	u16 cmdid;
 	int rc1;
 
-	if (cmdlen < 0 || *ppos != 0)
+	if (cmdlen < 0 || iocb->ki_pos != 0)
 		return -EINVAL;
 
-	wmi = memdup_user(buf, len);
+	wmi = iterdup(from, len);
 	if (IS_ERR(wmi))
 		return PTR_ERR(wmi);
 
@@ -1031,7 +1025,7 @@ static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations fops_wmi = {
-	.write = wil_write_file_wmi,
+	.write_iter = wil_write_file_wmi,
 	.open  = simple_open,
 };
 
@@ -1484,10 +1478,9 @@ DEFINE_SHOW_ATTRIBUTE(info);
 /* mode = [manual|auto]
  * state = [idle|pending|running]
  */
-static ssize_t wil_read_file_recovery(struct file *file, char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t wil_read_file_recovery(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
 	char buf[80];
 	int n;
 	static const char * const sstate[] = {"idle", "pending", "running"};
@@ -1498,17 +1491,16 @@ static ssize_t wil_read_file_recovery(struct file *file, char __user *user_buf,
 
 	n = min_t(int, n, sizeof(buf));
 
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       buf, n);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, n, to);
 }
 
-static ssize_t wil_write_file_recovery(struct file *file,
-				       const char __user *buf_,
-				       size_t count, loff_t *ppos)
+static ssize_t wil_write_file_recovery(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
 	static const char run_command[] = "run";
 	char buf[sizeof(run_command) + 1]; /* to detect "runx" */
+	size_t count = iov_iter_count(from);
 	ssize_t rc;
 
 	if (wil->recovery_state != fw_recovery_pending) {
@@ -1516,8 +1508,8 @@ static ssize_t wil_write_file_recovery(struct file *file,
 		return -EINVAL;
 	}
 
-	if (*ppos != 0) {
-		wil_err(wil, "Offset [%d]\n", (int)*ppos);
+	if (iocb->ki_pos != 0) {
+		wil_err(wil, "Offset [%d]\n", (int)iocb->ki_pos);
 		return -EINVAL;
 	}
 
@@ -1526,7 +1518,7 @@ static ssize_t wil_write_file_recovery(struct file *file,
 		return -EINVAL;
 	}
 
-	rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, buf_, count);
+	rc = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (rc < 0)
 		return rc;
 
@@ -1540,8 +1532,8 @@ static ssize_t wil_write_file_recovery(struct file *file,
 }
 
 static const struct file_operations fops_recovery = {
-	.read = wil_read_file_recovery,
-	.write = wil_write_file_recovery,
+	.read_iter = wil_read_file_recovery,
+	.write_iter = wil_write_file_recovery,
 	.open  = simple_open,
 };
 
@@ -1766,15 +1758,15 @@ static int wil_tx_latency_seq_open(struct inode *inode, struct file *file)
 			   inode->i_private);
 }
 
-static ssize_t wil_tx_latency_write(struct file *file, const char __user *buf,
-				    size_t len, loff_t *ppos)
+static ssize_t wil_tx_latency_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct wil6210_priv *wil = s->private;
 	int val, rc, i;
 	bool enable;
 
-	rc = kstrtoint_from_user(buf, len, 0, &val);
+	rc = kstrtoint_from_iter(from, len, 0, &val);
 	if (rc) {
 		wil_err(wil, "Invalid argument\n");
 		return rc;
@@ -1818,8 +1810,8 @@ static ssize_t wil_tx_latency_write(struct file *file, const char __user *buf,
 static const struct file_operations fops_tx_latency = {
 	.open		= wil_tx_latency_seq_open,
 	.release	= single_release,
-	.read		= seq_read,
-	.write		= wil_tx_latency_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= wil_tx_latency_write,
 	.llseek		= seq_lseek,
 };
 
@@ -1930,10 +1922,10 @@ static int wil_link_stats_seq_open(struct inode *inode, struct file *file)
 	return single_open(file, wil_link_stats_debugfs_show, inode->i_private);
 }
 
-static ssize_t wil_link_stats_write(struct file *file, const char __user *buf,
-				    size_t len, loff_t *ppos)
+static ssize_t wil_link_stats_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct wil6210_priv *wil = s->private;
 	int cid, interval, rc, i;
 	struct wil6210_vif *vif;
@@ -1942,7 +1934,7 @@ static ssize_t wil_link_stats_write(struct file *file, const char __user *buf,
 	if (!kbuf)
 		return -ENOMEM;
 
-	rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
+	rc = simple_copy_from_iter(kbuf, &iocb->ki_pos, len, from);
 	if (rc != len) {
 		kfree(kbuf);
 		return rc >= 0 ? -EIO : rc;
@@ -1982,8 +1974,8 @@ static ssize_t wil_link_stats_write(struct file *file, const char __user *buf,
 static const struct file_operations fops_link_stats = {
 	.open		= wil_link_stats_seq_open,
 	.release	= single_release,
-	.read		= seq_read,
-	.write		= wil_link_stats_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= wil_link_stats_write,
 	.llseek		= seq_lseek,
 };
 
@@ -2009,16 +2001,16 @@ wil_link_stats_global_seq_open(struct inode *inode, struct file *file)
 }
 
 static ssize_t
-wil_link_stats_global_write(struct file *file, const char __user *buf,
-			    size_t len, loff_t *ppos)
+wil_link_stats_global_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct wil6210_priv *wil = s->private;
 	int interval, rc;
 	struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev);
 
 	/* specify snapshot interval in ms */
-	rc = kstrtoint_from_user(buf, len, 0, &interval);
+	rc = kstrtoint_from_iter(from, len, 0, &interval);
 	if (rc || interval < 0) {
 		wil_err(wil, "Invalid argument\n");
 		return -EINVAL;
@@ -2036,13 +2028,12 @@ wil_link_stats_global_write(struct file *file, const char __user *buf,
 static const struct file_operations fops_link_stats_global = {
 	.open		= wil_link_stats_global_seq_open,
 	.release	= single_release,
-	.read		= seq_read,
-	.write		= wil_link_stats_global_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= wil_link_stats_global_write,
 	.llseek		= seq_lseek,
 };
 
-static ssize_t wil_read_file_led_cfg(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t wil_read_file_led_cfg(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[80];
 	int n;
@@ -2053,19 +2044,17 @@ static ssize_t wil_read_file_led_cfg(struct file *file, char __user *user_buf,
 
 	n = min_t(int, n, sizeof(buf));
 
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       buf, n);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, n, to);
 }
 
-static ssize_t wil_write_file_led_cfg(struct file *file,
-				      const char __user *buf_,
-				      size_t count, loff_t *ppos)
+static ssize_t wil_write_file_led_cfg(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int val;
 	int rc;
 
-	rc = kstrtoint_from_user(buf_, count, 0, &val);
+	rc = kstrtoint_from_iter(from, count, 0, &val);
 	if (rc) {
 		wil_err(wil, "Invalid argument\n");
 		return rc;
@@ -2083,25 +2072,25 @@ static ssize_t wil_write_file_led_cfg(struct file *file,
 }
 
 static const struct file_operations fops_led_cfg = {
-	.read = wil_read_file_led_cfg,
-	.write = wil_write_file_led_cfg,
+	.read_iter = wil_read_file_led_cfg,
+	.write_iter = wil_write_file_led_cfg,
 	.open  = simple_open,
 };
 
 /* led_blink_time, write:
  * "<blink_on_slow> <blink_off_slow> <blink_on_med> <blink_off_med> <blink_on_fast> <blink_off_fast>
  */
-static ssize_t wil_write_led_blink_time(struct file *file,
-					const char __user *buf,
-					size_t len, loff_t *ppos)
+static ssize_t wil_write_led_blink_time(struct kiocb *iocb,
+					struct iov_iter *from)
 {
 	int rc;
+	size_t len = iov_iter_count(from);
 	char *kbuf = kmalloc(len + 1, GFP_KERNEL);
 
 	if (!kbuf)
 		return -ENOMEM;
 
-	rc = simple_write_to_buffer(kbuf, len, ppos, buf, len);
+	rc = simple_copy_from_iter(kbuf, &iocb->ki_pos, len, from);
 	if (rc != len) {
 		kfree(kbuf);
 		return rc >= 0 ? -EIO : rc;
@@ -2125,8 +2114,7 @@ static ssize_t wil_write_led_blink_time(struct file *file,
 	return len;
 }
 
-static ssize_t wil_read_led_blink_time(struct file *file, char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t wil_read_led_blink_time(struct kiocb *iocb, struct iov_iter *to)
 {
 	static char text[400];
 
@@ -2143,13 +2131,12 @@ static ssize_t wil_read_led_blink_time(struct file *file, char __user *user_buf,
 		 led_blink_time[WIL_LED_TIME_FAST].on_ms,
 		 led_blink_time[WIL_LED_TIME_FAST].off_ms);
 
-	return simple_read_from_buffer(user_buf, count, ppos, text,
-				       sizeof(text));
+	return simple_copy_to_iter(text, &iocb->ki_pos, sizeof(text), to);
 }
 
 static const struct file_operations fops_led_blink_time = {
-	.read = wil_read_led_blink_time,
-	.write = wil_write_led_blink_time,
+	.read_iter = wil_read_led_blink_time,
+	.write_iter = wil_write_led_blink_time,
 	.open  = simple_open,
 };
 
@@ -2180,22 +2167,18 @@ static int fw_version_show(struct seq_file *s, void *data)
 DEFINE_SHOW_ATTRIBUTE(fw_version);
 
 /*---------suspend_stats---------*/
-static ssize_t wil_write_suspend_stats(struct file *file,
-				       const char __user *buf,
-				       size_t len, loff_t *ppos)
+static ssize_t wil_write_suspend_stats(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
 
 	memset(&wil->suspend_stats, 0, sizeof(wil->suspend_stats));
-
-	return len;
+	return iov_iter_count(from);
 }
 
-static ssize_t wil_read_suspend_stats(struct file *file,
-				      char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t wil_read_suspend_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wil6210_priv *wil = file->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
 	char *text;
 	int n, ret, text_size = 500;
 
@@ -2226,7 +2209,7 @@ static ssize_t wil_read_suspend_stats(struct file *file,
 
 	n = min_t(int, n, text_size);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, text, n);
+	ret = simple_copy_to_iter(text, &iocb->ki_pos, n, to);
 
 	kfree(text);
 
@@ -2234,22 +2217,22 @@ static ssize_t wil_read_suspend_stats(struct file *file,
 }
 
 static const struct file_operations fops_suspend_stats = {
-	.read = wil_read_suspend_stats,
-	.write = wil_write_suspend_stats,
+	.read_iter = wil_read_suspend_stats,
+	.write_iter = wil_write_suspend_stats,
 	.open  = simple_open,
 };
 
 /*---------compressed_rx_status---------*/
-static ssize_t wil_compressed_rx_status_write(struct file *file,
-					      const char __user *buf,
-					      size_t len, loff_t *ppos)
+static ssize_t wil_compressed_rx_status_write(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct seq_file *s = file->private_data;
+	struct seq_file *s = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	struct wil6210_priv *wil = s->private;
 	int compressed_rx_status;
 	int rc;
 
-	rc = kstrtoint_from_user(buf, len, 0, &compressed_rx_status);
+	rc = kstrtoint_from_iter(from, len, 0, &compressed_rx_status);
 	if (rc) {
 		wil_err(wil, "Invalid argument\n");
 		return rc;
@@ -2288,8 +2271,8 @@ wil_compressed_rx_status_seq_open(struct inode *inode, struct file *file)
 static const struct file_operations fops_compressed_rx_status = {
 	.open  = wil_compressed_rx_status_seq_open,
 	.release = single_release,
-	.read = seq_read,
-	.write = wil_compressed_rx_status_write,
+	.read_iter = seq_read_iter,
+	.write_iter = wil_compressed_rx_status_write,
 	.llseek	= seq_lseek,
 };
 
drivers/net/wireless/ath/wil6210/pmc.c +12 -15
index a2f7b4c1da48..9bd4bcd5bbcd 100644
@@ -311,10 +311,10 @@ int wil_pmc_last_cmd_status(struct wil6210_priv *wil)
 /* Read from required position up to the end of current descriptor,
  * depends on descriptor size configured during alloc request.
  */
-ssize_t wil_pmc_read(struct file *filp, char __user *buf, size_t count,
-		     loff_t *f_pos)
+ssize_t wil_pmc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wil6210_priv *wil = filp->private_data;
+	struct wil6210_priv *wil = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct pmc_ctx *pmc = &wil->pmc;
 	size_t retval = 0;
 	unsigned long long idx;
@@ -334,33 +334,30 @@ ssize_t wil_pmc_read(struct file *filp, char __user *buf, size_t count,
 
 	wil_dbg_misc(wil,
 		     "pmc_read: size %u, pos %lld\n",
-		     (u32)count, *f_pos);
+		     (u32)count, iocb->ki_pos);
 
 	pmc->last_cmd_status = 0;
 
-	idx = *f_pos;
+	idx = iocb->ki_pos;
 	do_div(idx, pmc->descriptor_size);
-	offset = *f_pos - (idx * pmc->descriptor_size);
+	offset = iocb->ki_pos - (idx * pmc->descriptor_size);
 
-	if (*f_pos >= pmc_size) {
+	if (iocb->ki_pos >= pmc_size) {
 		wil_dbg_misc(wil,
 			     "pmc_read: reached end of pmc buf: %lld >= %u\n",
-			     *f_pos, (u32)pmc_size);
+			     iocb->ki_pos, (u32)pmc_size);
 		pmc->last_cmd_status = -ERANGE;
 		goto out;
 	}
 
 	wil_dbg_misc(wil,
 		     "pmc_read: read from pos %lld (descriptor %llu, offset %llu) %zu bytes\n",
-		     *f_pos, idx, offset, count);
+		     iocb->ki_pos, idx, offset, count);
 
 	/* if no errors, return the copied byte count */
-	retval = simple_read_from_buffer(buf,
-					 count,
-					 &offset,
-					 pmc->descriptors[idx].va,
-					 pmc->descriptor_size);
-	*f_pos += retval;
+	retval = simple_copy_to_iter(pmc->descriptors[idx].va, &iocb->ki_pos,
+					 pmc->descriptor_size, to);
+	iocb->ki_pos += retval;
 out:
 	mutex_unlock(&pmc->lock);
 
drivers/net/wireless/ath/wil6210/pmc.h +1 -1
index b3d79eb50a43..d5ea8e94ccc4 100644
@@ -10,6 +10,6 @@ void wil_pmc_alloc(struct wil6210_priv *wil,
 		   int num_descriptors, int descriptor_size);
 void wil_pmc_free(struct wil6210_priv *wil, int send_pmc_cmd);
 int wil_pmc_last_cmd_status(struct wil6210_priv *wil);
-ssize_t wil_pmc_read(struct file *, char __user *, size_t, loff_t *);
+ssize_t wil_pmc_read(struct kiocb *iocb, struct iov_iter *to);
 loff_t wil_pmc_llseek(struct file *filp, loff_t off, int whence);
 int wil_pmcring_read(struct seq_file *s, void *data);
Signature · 1 line
2.43.0
author maintainer
#309 lore raw

PATCH 303/437 drivers/net/wireless/ath/ath9k: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/ath/ath9k/common-debug.c |  36 ++-
 .../net/wireless/ath/ath9k/common-spectral.c  | 111 +++++----
 drivers/net/wireless/ath/ath9k/debug.c        | 210 ++++++++----------
 drivers/net/wireless/ath/ath9k/debug_sta.c    |  18 +-
 drivers/net/wireless/ath/ath9k/dfs_debug.c    |  30 ++-
 .../net/wireless/ath/ath9k/htc_drv_debug.c    |  82 +++----
 drivers/net/wireless/ath/ath9k/tx99.c         |  40 ++--
 7 files changed, 242 insertions(+), 285 deletions(-)
drivers/net/wireless/ath/ath9k/common-debug.c +16 -20
index 7aefb79f6bed..080a57674c23 100644
@@ -16,10 +16,9 @@
 
 #include "common.h"
 
-static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t read_file_modal_eeprom(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_hw *ah = file->private_data;
+	struct ath_hw *ah = iocb->ki_filp->private_data;
 	u32 len = 0, size = 6000;
 	char *buf;
 	size_t retval;
@@ -30,14 +29,14 @@ static ssize_t read_file_modal_eeprom(struct file *file, char __user *user_buf,
 
 	len = ah->eep_ops->dump_eeprom(ah, false, buf, len, size);
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
 static const struct file_operations fops_modal_eeprom = {
-	.read = read_file_modal_eeprom,
+	.read_iter = read_file_modal_eeprom,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -52,10 +51,9 @@ void ath9k_cmn_debug_modal_eeprom(struct dentry *debugfs_phy,
 }
 EXPORT_SYMBOL(ath9k_cmn_debug_modal_eeprom);
 
-static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t read_file_base_eeprom(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_hw *ah = file->private_data;
+	struct ath_hw *ah = iocb->ki_filp->private_data;
 	u32 len = 0, size = 1500;
 	ssize_t retval = 0;
 	char *buf;
@@ -66,14 +64,14 @@ static ssize_t read_file_base_eeprom(struct file *file, char __user *user_buf,
 
 	len = ah->eep_ops->dump_eeprom(ah, true, buf, len, size);
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
 static const struct file_operations fops_base_eeprom = {
-	.read = read_file_base_eeprom,
+	.read_iter = read_file_base_eeprom,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -120,8 +118,7 @@ void ath9k_cmn_debug_stat_rx(struct ath_rx_stats *rxstats,
 }
 EXPORT_SYMBOL(ath9k_cmn_debug_stat_rx);
 
-static ssize_t read_file_recv(struct file *file, char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t read_file_recv(struct kiocb *iocb, struct iov_iter *to)
 {
 #define RXS_ERR(s, e)					\
 	do {						\
@@ -130,7 +127,7 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
 				 rxstats->e);		\
 	} while (0)
 
-	struct ath_rx_stats *rxstats = file->private_data;
+	struct ath_rx_stats *rxstats = iocb->ki_filp->private_data;
 	char *buf;
 	unsigned int len = 0, size = 1600;
 	ssize_t retval = 0;
@@ -162,7 +159,7 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
 	if (len > size)
 		len = size;
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
@@ -171,7 +168,7 @@ static ssize_t read_file_recv(struct file *file, char __user *user_buf,
 }
 
 static const struct file_operations fops_recv = {
-	.read = read_file_recv,
+	.read_iter = read_file_recv,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -184,14 +181,13 @@ void ath9k_cmn_debug_recv(struct dentry *debugfs_phy,
 }
 EXPORT_SYMBOL(ath9k_cmn_debug_recv);
 
-static ssize_t read_file_phy_err(struct file *file, char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t read_file_phy_err(struct kiocb *iocb, struct iov_iter *to)
 {
 #define PHY_ERR(s, p) \
 	len += scnprintf(buf + len, size - len, "%22s : %10u\n", s, \
 			 rxstats->phy_err_stats[p])
 
-	struct ath_rx_stats *rxstats = file->private_data;
+	struct ath_rx_stats *rxstats = iocb->ki_filp->private_data;
 	char *buf;
 	unsigned int len = 0, size = 1600;
 	ssize_t retval = 0;
@@ -238,7 +234,7 @@ static ssize_t read_file_phy_err(struct file *file, char __user *user_buf,
 	if (len > size)
 		len = size;
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
@@ -247,7 +243,7 @@ static ssize_t read_file_phy_err(struct file *file, char __user *user_buf,
 }
 
 static const struct file_operations fops_phy_err = {
-	.read = read_file_phy_err,
+	.read_iter = read_file_phy_err,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
drivers/net/wireless/ath/ath9k/common-spectral.c +52 -59

236 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/debug.c +97 -113

508 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/debug_sta.c +8 -10
index 1e2a30019fb6..18aa2b6d1c72 100644
@@ -20,10 +20,9 @@
 /* node_aggr */
 /*************/
 
-static ssize_t read_file_node_aggr(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_node_aggr(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_node *an = file->private_data;
+	struct ath_node *an = iocb->ki_filp->private_data;
 	struct ath_softc *sc = an->sc;
 	struct ath_atx_tid *tid;
 	struct ath_txq *txq;
@@ -71,14 +70,14 @@ static ssize_t read_file_node_aggr(struct file *file, char __user *user_buf,
 		ath_txq_unlock(sc, txq);
 	}
 exit:
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
 static const struct file_operations fops_node_aggr = {
-	.read = read_file_node_aggr,
+	.read_iter = read_file_node_aggr,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -165,10 +164,9 @@ void ath_debug_rate_stats(struct ath_softc *sc,
 			 rstats->ofdm_stats[i].ofdm_cnt);	\
 	} while (0)
 
-static ssize_t read_file_node_recv(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t read_file_node_recv(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_node *an = file->private_data;
+	struct ath_node *an = iocb->ki_filp->private_data;
 	struct ath_softc *sc = an->sc;
 	struct ath_hw *ah = sc->sc_ah;
 	struct ath_rx_rate_stats *rstats;
@@ -226,7 +224,7 @@ static ssize_t read_file_node_recv(struct file *file, char __user *user_buf,
 	PRINT_OFDM_RATE("OFDM-48M", 6);
 	PRINT_OFDM_RATE("OFDM-54M", 7);
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
@@ -236,7 +234,7 @@ static ssize_t read_file_node_recv(struct file *file, char __user *user_buf,
 #undef PRINT_CCK_RATE
 
 static const struct file_operations fops_node_recv = {
-	.read = read_file_node_recv,
+	.read_iter = read_file_node_recv,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
drivers/net/wireless/ath/ath9k/dfs_debug.c +14 -16
index 8e18e9b4ef48..709e8be90e99 100644
@@ -31,10 +31,9 @@ static struct ath_dfs_pool_stats dfs_pool_stats = { 0 };
 	len += scnprintf(buf + len, size - len, "%28s : %10u\n", s, \
 			 dfs_pool_stats.p);
 
-static ssize_t read_file_dfs(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t read_file_dfs(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	struct ath9k_hw_version *hw_ver = &sc->sc_ah->hw_version;
 	char *buf;
 	unsigned int len = 0, size = 8000;
@@ -86,7 +85,7 @@ static ssize_t read_file_dfs(struct file *file, char __user *user_buf,
 	if (len > size)
 		len = size;
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
@@ -94,14 +93,14 @@ static ssize_t read_file_dfs(struct file *file, char __user *user_buf,
 
 /* magic number to prevent accidental reset of DFS statistics */
 #define DFS_STATS_RESET_MAGIC	0x80000000
-static ssize_t write_file_dfs(struct file *file, const char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t write_file_dfs(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long val;
 	ssize_t ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &val);
+	ret = kstrtoul_from_iter(from, count, 0, &val);
 	if (ret)
 		return ret;
 	if (val == DFS_STATS_RESET_MAGIC)
@@ -110,27 +109,26 @@ static ssize_t write_file_dfs(struct file *file, const char __user *user_buf,
 	return count;
 }
 
-static ssize_t write_file_simulate_radar(struct file *file,
-					 const char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t write_file_simulate_radar(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 
 	ieee80211_radar_detected(sc->hw);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations fops_simulate_radar = {
-	.write = write_file_simulate_radar,
+	.write_iter = write_file_simulate_radar,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
 static const struct file_operations fops_dfs_stats = {
-	.read = read_file_dfs,
-	.write = write_file_dfs,
+	.read_iter = read_file_dfs,
+	.write_iter = write_file_dfs,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
drivers/net/wireless/ath/ath9k/htc_drv_debug.c +37 -45

217 lines not on this page · raw message

drivers/net/wireless/ath/ath9k/tx99.c +18 -22
index f2144fd39093..349aa30cef9f 100644
@@ -156,21 +156,20 @@ static int ath9k_tx99_init(struct ath_softc *sc)
 	return 0;
 }
 
-static ssize_t read_file_tx99(struct file *file, char __user *user_buf,
-			      size_t count, loff_t *ppos)
+static ssize_t read_file_tx99(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	char buf[3];
 	unsigned int len;
 
 	len = sprintf(buf, "%d\n", sc->tx99_state);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t write_file_tx99(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
 	bool start;
 	ssize_t ret;
@@ -182,7 +181,7 @@ static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
 	if (sc->cur_chan->nvifs > 1)
 		return -EOPNOTSUPP;
 
-	ret = kstrtobool_from_user(user_buf, count, &start);
+	ret = kstrtobool_from_iter(from, count, &start);
 	if (ret)
 		return ret;
 
@@ -211,18 +210,16 @@ static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
 }
 
 static const struct file_operations fops_tx99 = {
-	.read = read_file_tx99,
-	.write = write_file_tx99,
+	.read_iter = read_file_tx99,
+	.write_iter = write_file_tx99,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t read_file_tx99_power(struct file *file,
-				    char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t read_file_tx99_power(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
 	char buf[32];
 	unsigned int len;
 
@@ -230,18 +227,17 @@ static ssize_t read_file_tx99_power(struct file *file,
 		      sc->tx99_power,
 		      sc->tx99_power / 2);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t write_file_tx99_power(struct file *file,
-				     const char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t write_file_tx99_power(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath_softc *sc = file->private_data;
+	struct ath_softc *sc = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int r;
 	u8 tx_power;
 
-	r = kstrtou8_from_user(user_buf, count, 0, &tx_power);
+	r = kstrtou8_from_iter(from, count, 0, &tx_power);
 	if (r)
 		return r;
 
@@ -258,8 +254,8 @@ static ssize_t write_file_tx99_power(struct file *file,
 }
 
 static const struct file_operations fops_tx99_power = {
-	.read = read_file_tx99_power,
-	.write = write_file_tx99_power,
+	.read_iter = read_file_tx99_power,
+	.write_iter = write_file_tx99_power,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
Signature · 1 line
2.43.0
author maintainer
#310 lore raw

PATCH 304/437 drivers/net/wireless/ath/ath10k: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/ath/ath10k/debug.c       | 502 ++++++++----------
 drivers/net/wireless/ath/ath10k/debugfs_sta.c | 119 ++---
 drivers/net/wireless/ath/ath10k/spectral.c    |  65 ++-
 3 files changed, 316 insertions(+), 370 deletions(-)
drivers/net/wireless/ath/ath10k/debug.c +231 -271
index b93a64bf8190..63193a566868 100644
@@ -148,11 +148,9 @@ EXPORT_SYMBOL(ath10k_warn);
 
 #ifdef CONFIG_ATH10K_DEBUGFS
 
-static ssize_t ath10k_read_wmi_services(struct file *file,
-					char __user *user_buf,
-					size_t count, loff_t *ppos)
+static ssize_t ath10k_read_wmi_services(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	char *buf;
 	size_t len = 0, buf_len = 8192;
 	const char *name;
@@ -186,7 +184,7 @@ static ssize_t ath10k_read_wmi_services(struct file *file,
 	}
 	spin_unlock_bh(&ar->data_lock);
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	mutex_unlock(&ar->conf_mutex);
 
@@ -195,7 +193,7 @@ static ssize_t ath10k_read_wmi_services(struct file *file,
 }
 
 static const struct file_operations fops_wmi_services = {
-	.read = ath10k_read_wmi_services,
+	.read_iter = ath10k_read_wmi_services,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -442,28 +440,26 @@ static int ath10k_fw_stats_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath10k_fw_stats_read(struct file *file, char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t ath10k_fw_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	const char *buf = file->private_data;
+	const char *buf = iocb->ki_filp->private_data;
 	size_t len = strlen(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_fw_stats = {
 	.open = ath10k_fw_stats_open,
 	.release = ath10k_fw_stats_release,
-	.read = ath10k_fw_stats_read,
+	.read_iter = ath10k_fw_stats_read,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_debug_fw_reset_stats_read(struct file *file,
-						char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t ath10k_debug_fw_reset_stats_read(struct kiocb *iocb,
+						struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	int ret;
 	size_t len = 0, buf_len = 500;
 	char *buf;
@@ -485,7 +481,7 @@ static ssize_t ath10k_debug_fw_reset_stats_read(struct file *file,
 
 	spin_unlock_bh(&ar->data_lock);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	kfree(buf);
 
@@ -494,7 +490,7 @@ static ssize_t ath10k_debug_fw_reset_stats_read(struct file *file,
 
 static const struct file_operations fops_fw_reset_stats = {
 	.open = simple_open,
-	.read = ath10k_debug_fw_reset_stats_read,
+	.read_iter = ath10k_debug_fw_reset_stats_read,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
@@ -519,9 +515,8 @@ static int ath10k_debug_fw_assert(struct ath10k *ar)
 				   ar->wmi.cmd->vdev_install_key_cmdid);
 }
 
-static ssize_t ath10k_read_simulate_fw_crash(struct file *file,
-					     char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static ssize_t ath10k_read_simulate_fw_crash(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
 	const char buf[] =
 		"To simulate firmware crash write one of the keywords to this file:\n"
@@ -530,7 +525,7 @@ static ssize_t ath10k_read_simulate_fw_crash(struct file *file,
 		"`assert` - this will send special illegal parameter to firmware to cause assert failure and crash.\n"
 		"`hw-restart` - this will simply queue hw restart without fw/hw actually crashing.\n";
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
+	return simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 }
 
 /* Simulate firmware crash:
@@ -540,26 +535,26 @@ static ssize_t ath10k_read_simulate_fw_crash(struct file *file,
  * vdev id. This is hard firmware crash because it is recoverable only by cold
  * firmware reset.
  */
-static ssize_t ath10k_write_simulate_fw_crash(struct file *file,
-					      const char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath10k_write_simulate_fw_crash(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[32] = {0};
 	ssize_t rc;
 	int ret;
 
 	/* filter partial writes and invalid commands */
-	if (*ppos != 0 || count >= sizeof(buf) || count == 0)
+	if (iocb->ki_pos != 0 || count >= sizeof(buf) || count == 0)
 		return -EINVAL;
 
-	rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
+	rc = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (rc < 0)
 		return rc;
 
 	/* drop the possible '\n' from the end */
-	if (buf[*ppos - 1] == '\n')
-		buf[*ppos - 1] = '\0';
+	if (buf[iocb->ki_pos - 1] == '\n')
+		buf[iocb->ki_pos - 1] = '\0';
 
 	mutex_lock(&ar->conf_mutex);
 
@@ -605,37 +600,34 @@ static ssize_t ath10k_write_simulate_fw_crash(struct file *file,
 }
 
 static const struct file_operations fops_simulate_fw_crash = {
-	.read = ath10k_read_simulate_fw_crash,
-	.write = ath10k_write_simulate_fw_crash,
+	.read_iter = ath10k_read_simulate_fw_crash,
+	.write_iter = ath10k_write_simulate_fw_crash,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_read_chip_id(struct file *file, char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t ath10k_read_chip_id(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	size_t len;
 	char buf[50];
 
 	len = scnprintf(buf, sizeof(buf), "0x%08x\n", ar->bus_param.chip_id);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_chip_id = {
-	.read = ath10k_read_chip_id,
+	.read_iter = ath10k_read_chip_id,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_reg_addr_read(struct file *file,
-				    char __user *user_buf,
-				    size_t count, loff_t *ppos)
+static ssize_t ath10k_reg_addr_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	u8 buf[32];
 	size_t len = 0;
 	u32 reg_addr;
@@ -646,18 +638,17 @@ static ssize_t ath10k_reg_addr_read(struct file *file,
 
 	len += scnprintf(buf + len, sizeof(buf) - len, "0x%x\n", reg_addr);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath10k_reg_addr_write(struct file *file,
-				     const char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath10k_reg_addr_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 reg_addr;
 	int ret;
 
-	ret = kstrtou32_from_user(user_buf, count, 0, &reg_addr);
+	ret = kstrtou32_from_iter(from, count, 0, &reg_addr);
 	if (ret)
 		return ret;
 
@@ -672,18 +663,16 @@ static ssize_t ath10k_reg_addr_write(struct file *file,
 }
 
 static const struct file_operations fops_reg_addr = {
-	.read = ath10k_reg_addr_read,
-	.write = ath10k_reg_addr_write,
+	.read_iter = ath10k_reg_addr_read,
+	.write_iter = ath10k_reg_addr_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_reg_value_read(struct file *file,
-				     char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath10k_reg_value_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	u8 buf[48];
 	size_t len;
 	u32 reg_addr, reg_val;
@@ -702,7 +691,7 @@ static ssize_t ath10k_reg_value_read(struct file *file,
 	reg_val = ath10k_hif_read32(ar, reg_addr);
 	len = scnprintf(buf, sizeof(buf), "0x%08x:0x%08x\n", reg_addr, reg_val);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 exit:
 	mutex_unlock(&ar->conf_mutex);
@@ -710,11 +699,10 @@ static ssize_t ath10k_reg_value_read(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_reg_value_write(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath10k_reg_value_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 reg_addr, reg_val;
 	int ret;
 
@@ -728,7 +716,7 @@ static ssize_t ath10k_reg_value_write(struct file *file,
 
 	reg_addr = ar->debug.reg_addr;
 
-	ret = kstrtou32_from_user(user_buf, count, 0, &reg_val);
+	ret = kstrtou32_from_iter(from, count, 0, &reg_val);
 	if (ret)
 		goto exit;
 
@@ -743,22 +731,21 @@ static ssize_t ath10k_reg_value_write(struct file *file,
 }
 
 static const struct file_operations fops_reg_value = {
-	.read = ath10k_reg_value_read,
-	.write = ath10k_reg_value_write,
+	.read_iter = ath10k_reg_value_read,
+	.write_iter = ath10k_reg_value_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_mem_value_read(struct file *file,
-				     char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath10k_mem_value_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	u8 *buf;
 	int ret;
 
-	if (*ppos < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 
 	if (!count)
@@ -778,21 +765,21 @@ static ssize_t ath10k_mem_value_read(struct file *file,
 		goto exit;
 	}
 
-	ret = ath10k_hif_diag_read(ar, *ppos, buf, count);
+	ret = ath10k_hif_diag_read(ar, iocb->ki_pos, buf, count);
 	if (ret) {
 		ath10k_warn(ar, "failed to read address 0x%08x via diagnose window from debugfs: %d\n",
-			    (u32)(*ppos), ret);
+			    (u32)(iocb->ki_pos), ret);
 		goto exit;
 	}
 
-	ret = copy_to_user(user_buf, buf, count);
+	ret = !copy_to_iter_full(buf, count, to);
 	if (ret) {
 		ret = -EFAULT;
 		goto exit;
 	}
 
 	count -= ret;
-	*ppos += count;
+	iocb->ki_pos += count;
 	ret = count;
 
 exit:
@@ -802,15 +789,14 @@ static ssize_t ath10k_mem_value_read(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_mem_value_write(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath10k_mem_value_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u8 *buf;
 	int ret;
 
-	if (*ppos < 0)
+	if (iocb->ki_pos < 0)
 		return -EINVAL;
 
 	if (!count)
@@ -830,20 +816,20 @@ static ssize_t ath10k_mem_value_write(struct file *file,
 		goto exit;
 	}
 
-	ret = copy_from_user(buf, user_buf, count);
+	ret = !copy_from_iter_full(buf, count, from);
 	if (ret) {
 		ret = -EFAULT;
 		goto exit;
 	}
 
-	ret = ath10k_hif_diag_write(ar, *ppos, buf, count);
+	ret = ath10k_hif_diag_write(ar, iocb->ki_pos, buf, count);
 	if (ret) {
 		ath10k_warn(ar, "failed to write address 0x%08x via diagnose window from debugfs: %d\n",
-			    (u32)(*ppos), ret);
+			    (u32)(iocb->ki_pos), ret);
 		goto exit;
 	}
 
-	*ppos += count;
+	iocb->ki_pos += count;
 	ret = count;
 
 exit:
@@ -854,8 +840,8 @@ static ssize_t ath10k_mem_value_write(struct file *file,
 }
 
 static const struct file_operations fops_mem_value = {
-	.read = ath10k_mem_value_read,
-	.write = ath10k_mem_value_write,
+	.read_iter = ath10k_mem_value_read,
+	.write_iter = ath10k_mem_value_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -902,28 +888,27 @@ static void ath10k_debug_htt_stats_dwork(struct work_struct *work)
 	mutex_unlock(&ar->conf_mutex);
 }
 
-static ssize_t ath10k_read_htt_stats_mask(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath10k_read_htt_stats_mask(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	size_t len;
 
 	len = scnprintf(buf, sizeof(buf), "%lu\n", ar->debug.htt_stats_mask);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath10k_write_htt_stats_mask(struct file *file,
-					   const char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath10k_write_htt_stats_mask(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long mask;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &mask);
+	ret = kstrtoul_from_iter(from, count, 0, &mask);
 	if (ret)
 		return ret;
 
@@ -948,18 +933,17 @@ static ssize_t ath10k_write_htt_stats_mask(struct file *file,
 }
 
 static const struct file_operations fops_htt_stats_mask = {
-	.read = ath10k_read_htt_stats_mask,
-	.write = ath10k_write_htt_stats_mask,
+	.read_iter = ath10k_read_htt_stats_mask,
+	.write_iter = ath10k_write_htt_stats_mask,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_read_htt_max_amsdu_ampdu(struct file *file,
-					       char __user *user_buf,
-					       size_t count, loff_t *ppos)
+static ssize_t ath10k_read_htt_max_amsdu_ampdu(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	char buf[64];
 	u8 amsdu, ampdu;
 	size_t len;
@@ -972,20 +956,19 @@ static ssize_t ath10k_read_htt_max_amsdu_ampdu(struct file *file,
 
 	len = scnprintf(buf, sizeof(buf), "%u %u\n", amsdu, ampdu);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath10k_write_htt_max_amsdu_ampdu(struct file *file,
-						const char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t ath10k_write_htt_max_amsdu_ampdu(struct kiocb *iocb,
+						struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int res;
 	char buf[64] = {0};
 	unsigned int amsdu, ampdu;
 
-	res = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
-				     user_buf, count);
+	res = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (res <= 0)
 		return res;
 
@@ -1010,39 +993,35 @@ static ssize_t ath10k_write_htt_max_amsdu_ampdu(struct file *file,
 }
 
 static const struct file_operations fops_htt_max_amsdu_ampdu = {
-	.read = ath10k_read_htt_max_amsdu_ampdu,
-	.write = ath10k_write_htt_max_amsdu_ampdu,
+	.read_iter = ath10k_read_htt_max_amsdu_ampdu,
+	.write_iter = ath10k_write_htt_max_amsdu_ampdu,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_read_fw_dbglog(struct file *file,
-				     char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath10k_read_fw_dbglog(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	size_t len;
 	char buf[96];
 
 	len = scnprintf(buf, sizeof(buf), "0x%16llx %u\n",
 			ar->debug.fw_dbglog_mask, ar->debug.fw_dbglog_level);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath10k_write_fw_dbglog(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath10k_write_fw_dbglog(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	char buf[96] = {0};
 	unsigned int log_level;
 	u64 mask;
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
-				     user_buf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret <= 0)
 		return ret;
 
@@ -1241,8 +1220,8 @@ void ath10k_debug_get_et_stats(struct ieee80211_hw *hw,
 }
 
 static const struct file_operations fops_fw_dbglog = {
-	.read = ath10k_read_fw_dbglog,
-	.write = ath10k_write_fw_dbglog,
+	.read_iter = ath10k_read_fw_dbglog,
+	.write_iter = ath10k_write_fw_dbglog,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1298,32 +1277,31 @@ static int ath10k_debug_cal_data_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath10k_debug_cal_data_read(struct file *file,
-					  char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath10k_debug_cal_data_read(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count;
 
 	mutex_lock(&ar->conf_mutex);
 
-	count = simple_read_from_buffer(user_buf, count, ppos,
-					ar->debug.cal_data,
-					ar->hw_params.cal_data_len);
+	count = simple_copy_to_iter(ar->debug.cal_data, &iocb->ki_pos,
+					ar->hw_params.cal_data_len, to);
 
 	mutex_unlock(&ar->conf_mutex);
 
 	return count;
 }
 
-static ssize_t ath10k_write_ani_enable(struct file *file,
-				       const char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t ath10k_write_ani_enable(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	u8 enable;
 
-	if (kstrtou8_from_user(user_buf, count, 0, &enable))
+	if (kstrtou8_from_iter(from, count, 0, &enable))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1349,21 +1327,20 @@ static ssize_t ath10k_write_ani_enable(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_read_ani_enable(struct file *file, char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath10k_read_ani_enable(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	size_t len;
 	char buf[32];
 
 	len = scnprintf(buf, sizeof(buf), "%d\n", ar->ani_enabled);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_ani_enable = {
-	.read = ath10k_read_ani_enable,
-	.write = ath10k_write_ani_enable,
+	.read_iter = ath10k_read_ani_enable,
+	.write_iter = ath10k_write_ani_enable,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1371,33 +1348,31 @@ static const struct file_operations fops_ani_enable = {
 
 static const struct file_operations fops_cal_data = {
 	.open = ath10k_debug_cal_data_open,
-	.read = ath10k_debug_cal_data_read,
+	.read_iter = ath10k_debug_cal_data_read,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_read_nf_cal_period(struct file *file,
-					 char __user *user_buf,
-					 size_t count, loff_t *ppos)
+static ssize_t ath10k_read_nf_cal_period(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	size_t len;
 	char buf[32];
 
 	len = scnprintf(buf, sizeof(buf), "%d\n", ar->debug.nf_cal_period);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath10k_write_nf_cal_period(struct file *file,
-					  const char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath10k_write_nf_cal_period(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long period;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &period);
+	ret = kstrtoul_from_iter(from, count, 0, &period);
 	if (ret)
 		return ret;
 
@@ -1435,8 +1410,8 @@ static ssize_t ath10k_write_nf_cal_period(struct file *file,
 }
 
 static const struct file_operations fops_nf_cal_period = {
-	.read = ath10k_read_nf_cal_period,
-	.write = ath10k_write_nf_cal_period,
+	.read_iter = ath10k_read_nf_cal_period,
+	.write_iter = ath10k_write_nf_cal_period,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1673,19 +1648,18 @@ static int ath10k_tpc_stats_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath10k_tpc_stats_read(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath10k_tpc_stats_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	const char *buf = file->private_data;
+	const char *buf = iocb->ki_filp->private_data;
 	size_t len = strlen(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_tpc_stats = {
 	.open = ath10k_tpc_stats_open,
 	.release = ath10k_tpc_stats_release,
-	.read = ath10k_tpc_stats_read,
+	.read_iter = ath10k_tpc_stats_read,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
@@ -1759,11 +1733,10 @@ void ath10k_debug_stop(struct ath10k *ar)
 	ath10k_wmi_pdev_pktlog_disable(ar);
 }
 
-static ssize_t ath10k_write_simulate_radar(struct file *file,
-					   const char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath10k_write_simulate_radar(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	struct ath10k_vif *arvif;
 
 	/* Just check for the first vif alone, as all the vifs will be
@@ -1775,12 +1748,11 @@ static ssize_t ath10k_write_simulate_radar(struct file *file,
 		return -EINVAL;
 
 	ieee80211_radar_detected(ar->hw);
-
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations fops_simulate_radar = {
-	.write = ath10k_write_simulate_radar,
+	.write_iter = ath10k_write_simulate_radar,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1794,12 +1766,11 @@ static const struct file_operations fops_simulate_radar = {
 	len += scnprintf(buf + len, size - len, "%-28s : %10u\n", s, \
 			 ar->debug.dfs_pool_stats.p))
 
-static ssize_t ath10k_read_dfs_stats(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath10k_read_dfs_stats(struct kiocb *iocb, struct iov_iter *to)
 {
 	int retval = 0, len = 0;
 	const int size = 8000;
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	char *buf;
 
 	buf = kzalloc(size, GFP_KERNEL);
@@ -1835,28 +1806,28 @@ static ssize_t ath10k_read_dfs_stats(struct file *file, char __user *user_buf,
 	if (len > size)
 		len = size;
 
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
 static const struct file_operations fops_dfs_stats = {
-	.read = ath10k_read_dfs_stats,
+	.read_iter = ath10k_read_dfs_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_write_pktlog_filter(struct file *file,
-					  const char __user *ubuf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath10k_write_pktlog_filter(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 filter;
 	int ret;
 
-	if (kstrtouint_from_user(ubuf, count, 0, &filter))
+	if (kstrtouint_from_iter(from, count, 0, &filter))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1895,11 +1866,10 @@ static ssize_t ath10k_write_pktlog_filter(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_read_pktlog_filter(struct file *file, char __user *ubuf,
-					 size_t count, loff_t *ppos)
+static ssize_t ath10k_read_pktlog_filter(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[32];
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1907,23 +1877,23 @@ static ssize_t ath10k_read_pktlog_filter(struct file *file, char __user *ubuf,
 			ar->pktlog_filter);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_pktlog_filter = {
-	.read = ath10k_read_pktlog_filter,
-	.write = ath10k_write_pktlog_filter,
+	.read_iter = ath10k_read_pktlog_filter,
+	.write_iter = ath10k_write_pktlog_filter,
 	.open = simple_open
 };
 
-static ssize_t ath10k_write_quiet_period(struct file *file,
-					 const char __user *ubuf,
-					 size_t count, loff_t *ppos)
+static ssize_t ath10k_write_quiet_period(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 period;
 
-	if (kstrtouint_from_user(ubuf, count, 0, &period))
+	if (kstrtouint_from_iter(from, count, 0, &period))
 		return -EINVAL;
 
 	if (period < ATH10K_QUIET_PERIOD_MIN) {
@@ -1939,11 +1909,10 @@ static ssize_t ath10k_write_quiet_period(struct file *file,
 	return count;
 }
 
-static ssize_t ath10k_read_quiet_period(struct file *file, char __user *ubuf,
-					size_t count, loff_t *ppos)
+static ssize_t ath10k_read_quiet_period(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[32];
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1951,25 +1920,24 @@ static ssize_t ath10k_read_quiet_period(struct file *file, char __user *ubuf,
 			ar->thermal.quiet_period);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_quiet_period = {
-	.read = ath10k_read_quiet_period,
-	.write = ath10k_write_quiet_period,
+	.read_iter = ath10k_read_quiet_period,
+	.write_iter = ath10k_write_quiet_period,
 	.open = simple_open
 };
 
-static ssize_t ath10k_write_btcoex(struct file *file,
-				   const char __user *ubuf,
-				   size_t count, loff_t *ppos)
+static ssize_t ath10k_write_btcoex(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t ret;
 	bool val;
 	u32 pdev_param;
 
-	ret = kstrtobool_from_user(ubuf, count, &val);
+	ret = kstrtobool_from_iter(from, count, &val);
 	if (ret)
 		return ret;
 
@@ -2016,11 +1984,10 @@ static ssize_t ath10k_write_btcoex(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_read_btcoex(struct file *file, char __user *ubuf,
-				  size_t count, loff_t *ppos)
+static ssize_t ath10k_read_btcoex(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[32];
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 
 	mutex_lock(&ar->conf_mutex);
@@ -2028,24 +1995,24 @@ static ssize_t ath10k_read_btcoex(struct file *file, char __user *ubuf,
 			test_bit(ATH10K_FLAG_BTCOEX, &ar->dev_flags));
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_btcoex = {
-	.read = ath10k_read_btcoex,
-	.write = ath10k_write_btcoex,
+	.read_iter = ath10k_read_btcoex,
+	.write_iter = ath10k_write_btcoex,
 	.open = simple_open
 };
 
-static ssize_t ath10k_write_enable_extd_tx_stats(struct file *file,
-						 const char __user *ubuf,
-						 size_t count, loff_t *ppos)
+static ssize_t ath10k_write_enable_extd_tx_stats(struct kiocb *iocb,
+						 struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 filter;
 	int ret;
 
-	if (kstrtouint_from_user(ubuf, count, 0, &filter))
+	if (kstrtouint_from_iter(from, count, 0, &filter))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -2069,13 +2036,12 @@ static ssize_t ath10k_write_enable_extd_tx_stats(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_read_enable_extd_tx_stats(struct file *file,
-						char __user *ubuf,
-						size_t count, loff_t *ppos)
+static ssize_t ath10k_read_enable_extd_tx_stats(struct kiocb *iocb,
+						struct iov_iter *to)
 
 {
 	char buf[32];
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 
 	mutex_lock(&ar->conf_mutex);
@@ -2083,24 +2049,24 @@ static ssize_t ath10k_read_enable_extd_tx_stats(struct file *file,
 			ar->debug.enable_extd_tx_stats);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_enable_extd_tx_stats = {
-	.read = ath10k_read_enable_extd_tx_stats,
-	.write = ath10k_write_enable_extd_tx_stats,
+	.read_iter = ath10k_read_enable_extd_tx_stats,
+	.write_iter = ath10k_write_enable_extd_tx_stats,
 	.open = simple_open
 };
 
-static ssize_t ath10k_write_peer_stats(struct file *file,
-				       const char __user *ubuf,
-				       size_t count, loff_t *ppos)
+static ssize_t ath10k_write_peer_stats(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t ret;
 	bool val;
 
-	ret = kstrtobool_from_user(ubuf, count, &val);
+	ret = kstrtobool_from_iter(from, count, &val);
 	if (ret)
 		return ret;
 
@@ -2132,12 +2098,10 @@ static ssize_t ath10k_write_peer_stats(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_read_peer_stats(struct file *file, char __user *ubuf,
-				      size_t count, loff_t *ppos)
-
+static ssize_t ath10k_read_peer_stats(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[32];
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 
 	mutex_lock(&ar->conf_mutex);
@@ -2145,20 +2109,19 @@ static ssize_t ath10k_read_peer_stats(struct file *file, char __user *ubuf,
 			test_bit(ATH10K_FLAG_PEER_STATS, &ar->dev_flags));
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_peer_stats = {
-	.read = ath10k_read_peer_stats,
-	.write = ath10k_write_peer_stats,
+	.read_iter = ath10k_read_peer_stats,
+	.write_iter = ath10k_write_peer_stats,
 	.open = simple_open
 };
 
-static ssize_t ath10k_debug_fw_checksums_read(struct file *file,
-					      char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath10k_debug_fw_checksums_read(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	size_t len = 0, buf_len = 4096;
 	ssize_t ret_cnt;
 	char *buf;
@@ -2194,7 +2157,7 @@ static ssize_t ath10k_debug_fw_checksums_read(struct file *file,
 			 crc32_le(0, ar->normal_mode_fw.board_data,
 				  ar->normal_mode_fw.board_len));
 
-	ret_cnt = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret_cnt = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 
 	mutex_unlock(&ar->conf_mutex);
 
@@ -2203,33 +2166,32 @@ static ssize_t ath10k_debug_fw_checksums_read(struct file *file,
 }
 
 static const struct file_operations fops_fw_checksums = {
-	.read = ath10k_debug_fw_checksums_read,
+	.read_iter = ath10k_debug_fw_checksums_read,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_sta_tid_stats_mask_read(struct file *file,
-					      char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath10k_sta_tid_stats_mask_read(struct kiocb *iocb,
+					      struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	size_t len;
 
 	len = scnprintf(buf, sizeof(buf), "0x%08x\n", ar->sta_tid_stats_mask);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t ath10k_sta_tid_stats_mask_write(struct file *file,
-					       const char __user *user_buf,
-					       size_t count, loff_t *ppos)
+static ssize_t ath10k_sta_tid_stats_mask_write(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t ret;
 	u32 mask;
 
-	ret = kstrtoint_from_user(user_buf, count, 0, &mask);
+	ret = kstrtoint_from_iter(from, count, 0, &mask);
 	if (ret)
 		return ret;
 
@@ -2239,8 +2201,8 @@ static ssize_t ath10k_sta_tid_stats_mask_write(struct file *file,
 }
 
 static const struct file_operations fops_sta_tid_stats_mask = {
-	.read = ath10k_sta_tid_stats_mask_read,
-	.write = ath10k_sta_tid_stats_mask_write,
+	.read_iter = ath10k_sta_tid_stats_mask_read,
+	.write_iter = ath10k_sta_tid_stats_mask_write,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -2317,33 +2279,32 @@ static int ath10k_tpc_stats_final_release(struct inode *inode,
 	return 0;
 }
 
-static ssize_t ath10k_tpc_stats_final_read(struct file *file,
-					   char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath10k_tpc_stats_final_read(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	const char *buf = file->private_data;
+	const char *buf = iocb->ki_filp->private_data;
 	unsigned int len = strlen(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_tpc_stats_final = {
 	.open = ath10k_tpc_stats_final_open,
 	.release = ath10k_tpc_stats_final_release,
-	.read = ath10k_tpc_stats_final_read,
+	.read_iter = ath10k_tpc_stats_final_read,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_write_warm_hw_reset(struct file *file,
-					  const char __user *user_buf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath10k_write_warm_hw_reset(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	bool val;
 
-	if (kstrtobool_from_user(user_buf, count, &val))
+	if (kstrtobool_from_iter(from, count, &val))
 		return -EFAULT;
 
 	if (!val)
@@ -2372,7 +2333,7 @@ static ssize_t ath10k_write_warm_hw_reset(struct file *file,
 }
 
 static const struct file_operations fops_warm_hw_reset = {
-	.write = ath10k_write_warm_hw_reset,
+	.write_iter = ath10k_write_warm_hw_reset,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -2389,16 +2350,16 @@ static void ath10k_peer_ps_state_disable(void *data,
 	spin_unlock_bh(&ar->data_lock);
 }
 
-static ssize_t ath10k_write_ps_state_enable(struct file *file,
-					    const char __user *user_buf,
-					    size_t count, loff_t *ppos)
+static ssize_t ath10k_write_ps_state_enable(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	u32 param;
 	u8 ps_state_enable;
 
-	if (kstrtou8_from_user(user_buf, count, 0, &ps_state_enable))
+	if (kstrtou8_from_iter(from, count, 0, &ps_state_enable))
 		return -EINVAL;
 
 	if (ps_state_enable > 1)
@@ -2433,11 +2394,10 @@ static ssize_t ath10k_write_ps_state_enable(struct file *file,
 	return ret;
 }
 
-static ssize_t ath10k_read_ps_state_enable(struct file *file,
-					   char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath10k_read_ps_state_enable(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 	char buf[32];
 
@@ -2446,26 +2406,26 @@ static ssize_t ath10k_read_ps_state_enable(struct file *file,
 			ar->ps_state_enable);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_ps_state_enable = {
-	.read = ath10k_read_ps_state_enable,
-	.write = ath10k_write_ps_state_enable,
+	.read_iter = ath10k_read_ps_state_enable,
+	.write_iter = ath10k_write_ps_state_enable,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath10k_write_reset_htt_stats(struct file *file,
-					    const char __user *user_buf,
-					    size_t count, loff_t *ppos)
+static ssize_t ath10k_write_reset_htt_stats(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct ath10k *ar = file->private_data;
+	struct ath10k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long reset;
 	int ret;
 
-	ret = kstrtoul_from_user(user_buf, count, 0, &reset);
+	ret = kstrtoul_from_iter(from, count, 0, &reset);
 	if (ret)
 		return ret;
 
@@ -2489,7 +2449,7 @@ static ssize_t ath10k_write_reset_htt_stats(struct file *file,
 }
 
 static const struct file_operations fops_reset_htt_stats = {
-	.write = ath10k_write_reset_htt_stats,
+	.write_iter = ath10k_write_reset_htt_stats,
 	.owner = THIS_MODULE,
 	.open = simple_open,
 	.llseek = default_llseek,
drivers/net/wireless/ath/ath10k/debugfs_sta.c +55 -64

278 lines not on this page · raw message

drivers/net/wireless/ath/ath10k/spectral.c +30 -35

140 lines not on this page · raw message

Signature · 1 line
2.43.0
author maintainer
#311 lore raw

PATCH 305/437 drivers/net/wireless/ath/ath11k: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/ath/ath11k/debugfs.c     | 300 ++++++++----------
 .../wireless/ath/ath11k/debugfs_htt_stats.c   |  56 ++--
 drivers/net/wireless/ath/ath11k/debugfs_sta.c | 163 +++++-----
 drivers/net/wireless/ath/ath11k/spectral.c    |  69 ++--
 4 files changed, 274 insertions(+), 314 deletions(-)
drivers/net/wireless/ath/ath11k/debugfs.c +140 -160
index a48e737ef35d..f51afdf83a89 100644
@@ -296,20 +296,18 @@ static int ath11k_release_pdev_stats(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath11k_read_pdev_stats(struct file *file,
-				      char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath11k_read_pdev_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	const char *buf = file->private_data;
+	const char *buf = iocb->ki_filp->private_data;
 	size_t len = strlen(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_pdev_stats = {
 	.open = ath11k_open_pdev_stats,
 	.release = ath11k_release_pdev_stats,
-	.read = ath11k_read_pdev_stats,
+	.read_iter = ath11k_read_pdev_stats,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
@@ -367,20 +365,18 @@ static int ath11k_release_vdev_stats(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath11k_read_vdev_stats(struct file *file,
-				      char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath11k_read_vdev_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	const char *buf = file->private_data;
+	const char *buf = iocb->ki_filp->private_data;
 	size_t len = strlen(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_vdev_stats = {
 	.open = ath11k_open_vdev_stats,
 	.release = ath11k_release_vdev_stats,
-	.read = ath11k_read_vdev_stats,
+	.read_iter = ath11k_read_vdev_stats,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
@@ -451,34 +447,31 @@ static int ath11k_release_bcn_stats(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath11k_read_bcn_stats(struct file *file,
-				     char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath11k_read_bcn_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	const char *buf = file->private_data;
+	const char *buf = iocb->ki_filp->private_data;
 	size_t len = strlen(buf);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_bcn_stats = {
 	.open = ath11k_open_bcn_stats,
 	.release = ath11k_release_bcn_stats,
-	.read = ath11k_read_bcn_stats,
+	.read_iter = ath11k_read_bcn_stats,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_read_simulate_fw_crash(struct file *file,
-					     char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static ssize_t ath11k_read_simulate_fw_crash(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
 	const char buf[] =
 		"To simulate firmware crash write one of the keywords to this file:\n"
 		"`assert` - this will send WMI_FORCE_FW_HANG_CMDID to firmware to cause assert.\n"
 		"`hw-restart` - this will simply queue hw restart without fw/hw actually crashing.\n";
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
+	return simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 }
 
 /* Simulate firmware crash:
@@ -488,11 +481,11 @@ static ssize_t ath11k_read_simulate_fw_crash(struct file *file,
  * vdev id. This is hard firmware crash because it is recoverable only by cold
  * firmware reset.
  */
-static ssize_t ath11k_write_simulate_fw_crash(struct file *file,
-					      const char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath11k_write_simulate_fw_crash(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct ath11k_base *ab = file->private_data;
+	struct ath11k_base *ab = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath11k_pdev *pdev;
 	struct ath11k *ar = ab->pdevs[0].ar;
 	char buf[32] = {0};
@@ -508,16 +501,16 @@ static ssize_t ath11k_write_simulate_fw_crash(struct file *file,
 		}
 	}
 	/* filter partial writes and invalid commands */
-	if (*ppos != 0 || count >= sizeof(buf) || count == 0)
+	if (iocb->ki_pos != 0 || count >= sizeof(buf) || count == 0)
 		return -EINVAL;
 
-	rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, user_buf, count);
+	rc = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (rc < 0)
 		return rc;
 
 	/* drop the possible '\n' from the end */
-	if (buf[*ppos - 1] == '\n')
-		buf[*ppos - 1] = '\0';
+	if (buf[iocb->ki_pos - 1] == '\n')
+		buf[iocb->ki_pos - 1] = '\0';
 
 	if (radioup == 0) {
 		ret = -ENETDOWN;
@@ -550,22 +543,22 @@ static ssize_t ath11k_write_simulate_fw_crash(struct file *file,
 }
 
 static const struct file_operations fops_simulate_fw_crash = {
-	.read = ath11k_read_simulate_fw_crash,
-	.write = ath11k_write_simulate_fw_crash,
+	.read_iter = ath11k_read_simulate_fw_crash,
+	.write_iter = ath11k_write_simulate_fw_crash,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_write_enable_extd_tx_stats(struct file *file,
-						 const char __user *ubuf,
-						 size_t count, loff_t *ppos)
+static ssize_t ath11k_write_enable_extd_tx_stats(struct kiocb *iocb,
+						 struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u32 filter;
 	int ret;
 
-	if (kstrtouint_from_user(ubuf, count, 0, &filter))
+	if (kstrtouint_from_iter(from, count, 0, &filter))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -588,13 +581,11 @@ static ssize_t ath11k_write_enable_extd_tx_stats(struct file *file,
 	return ret;
 }
 
-static ssize_t ath11k_read_enable_extd_tx_stats(struct file *file,
-						char __user *ubuf,
-						size_t count, loff_t *ppos)
-
+static ssize_t ath11k_read_enable_extd_tx_stats(struct kiocb *iocb,
+						struct iov_iter *to)
 {
 	char buf[32] = {0};
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 
 	mutex_lock(&ar->conf_mutex);
@@ -602,27 +593,27 @@ static ssize_t ath11k_read_enable_extd_tx_stats(struct file *file,
 			ar->debug.extd_tx_stats);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_extd_tx_stats = {
-	.read = ath11k_read_enable_extd_tx_stats,
-	.write = ath11k_write_enable_extd_tx_stats,
+	.read_iter = ath11k_read_enable_extd_tx_stats,
+	.write_iter = ath11k_write_enable_extd_tx_stats,
 	.open = simple_open
 };
 
-static ssize_t ath11k_write_extd_rx_stats(struct file *file,
-					  const char __user *ubuf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath11k_write_extd_rx_stats(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath11k_base *ab = ar->ab;
 	struct htt_rx_ring_tlv_filter tlv_filter = {0};
 	u32 enable, rx_filter = 0, ring_id;
 	int i;
 	int ret;
 
-	if (kstrtouint_from_user(ubuf, count, 0, &enable))
+	if (kstrtouint_from_iter(from, count, 0, &enable))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -687,11 +678,9 @@ static ssize_t ath11k_write_extd_rx_stats(struct file *file,
 	return ret;
 }
 
-static ssize_t ath11k_read_extd_rx_stats(struct file *file,
-					 char __user *ubuf,
-					 size_t count, loff_t *ppos)
+static ssize_t ath11k_read_extd_rx_stats(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	int len = 0;
 
@@ -700,12 +689,12 @@ static ssize_t ath11k_read_extd_rx_stats(struct file *file,
 			ar->debug.extd_rx_stats);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_extd_rx_stats = {
-	.read = ath11k_read_extd_rx_stats,
-	.write = ath11k_write_extd_rx_stats,
+	.read_iter = ath11k_read_extd_rx_stats,
+	.write_iter = ath11k_write_extd_rx_stats,
 	.open = simple_open,
 };
 
@@ -775,11 +764,10 @@ static ssize_t ath11k_debugfs_dump_soc_ring_bp_stats(struct ath11k_base *ab,
 	return len;
 }
 
-static ssize_t ath11k_debugfs_dump_soc_dp_stats(struct file *file,
-						char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t ath11k_debugfs_dump_soc_dp_stats(struct kiocb *iocb,
+						struct iov_iter *to)
 {
-	struct ath11k_base *ab = file->private_data;
+	struct ath11k_base *ab = iocb->ki_filp->private_data;
 	struct ath11k_soc_dp_stats *soc_stats = &ab->soc_stats;
 	int len = 0, i, retval;
 	const int size = 4096;
@@ -839,32 +827,30 @@ static ssize_t ath11k_debugfs_dump_soc_dp_stats(struct file *file,
 
 	if (len > size)
 		len = size;
-	retval = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	retval = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return retval;
 }
 
 static const struct file_operations fops_soc_dp_stats = {
-	.read = ath11k_debugfs_dump_soc_dp_stats,
+	.read_iter = ath11k_debugfs_dump_soc_dp_stats,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_write_fw_dbglog(struct file *file,
-				      const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t ath11k_write_fw_dbglog(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[128] = {0};
 	struct ath11k_fw_dbglog dbglog;
 	unsigned int param, mod_id_index, is_end;
 	u64 value;
 	int ret, num;
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos,
-				     user_buf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret <= 0)
 		return ret;
 
@@ -909,7 +895,7 @@ static ssize_t ath11k_write_fw_dbglog(struct file *file,
 }
 
 static const struct file_operations fops_fw_dbglog = {
-	.write = ath11k_write_fw_dbglog,
+	.write_iter = ath11k_write_fw_dbglog,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -940,12 +926,10 @@ static int ath11k_open_sram_dump(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t ath11k_read_sram_dump(struct file *file,
-				     char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t ath11k_read_sram_dump(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct ath11k_base *ab = file->f_inode->i_private;
-	const char *buf = file->private_data;
+	struct ath11k_base *ab = iocb->ki_filp->f_inode->i_private;
+	const char *buf = iocb->ki_filp->private_data;
 	int len;
 	u32 start, end;
 
@@ -953,7 +937,7 @@ static ssize_t ath11k_read_sram_dump(struct file *file,
 	end = ab->hw_params.sram_dump.end;
 	len = end - start + 1;
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static int ath11k_release_sram_dump(struct inode *inode, struct file *file)
@@ -966,7 +950,7 @@ static int ath11k_release_sram_dump(struct inode *inode, struct file *file)
 
 static const struct file_operations fops_sram_dump = {
 	.open = ath11k_open_sram_dump,
-	.read = ath11k_read_sram_dump,
+	.read_iter = ath11k_read_sram_dump,
 	.release = ath11k_release_sram_dump,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1064,11 +1048,11 @@ void ath11k_debugfs_fw_stats_init(struct ath11k *ar)
 			    &fops_bcn_stats);
 }
 
-static ssize_t ath11k_write_pktlog_filter(struct file *file,
-					  const char __user *ubuf,
-					  size_t count, loff_t *ppos)
+static ssize_t ath11k_write_pktlog_filter(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath11k_base *ab = ar->ab;
 	struct htt_rx_ring_tlv_filter tlv_filter = {0};
 	u32 rx_filter = 0, ring_id, filter, mode;
@@ -1082,7 +1066,7 @@ static ssize_t ath11k_write_pktlog_filter(struct file *file,
 		goto out;
 	}
 
-	rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
+	rc = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (rc < 0) {
 		ret = rc;
 		goto out;
@@ -1196,13 +1180,12 @@ static ssize_t ath11k_write_pktlog_filter(struct file *file,
 	return ret;
 }
 
-static ssize_t ath11k_read_pktlog_filter(struct file *file,
-					 char __user *ubuf,
-					 size_t count, loff_t *ppos)
+static ssize_t ath11k_read_pktlog_filter(struct kiocb *iocb,
+					 struct iov_iter *to)
 
 {
 	char buf[32] = {0};
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
 	int len = 0;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1211,20 +1194,20 @@ static ssize_t ath11k_read_pktlog_filter(struct file *file,
 			ar->debug.pktlog_mode);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_pktlog_filter = {
-	.read = ath11k_read_pktlog_filter,
-	.write = ath11k_write_pktlog_filter,
+	.read_iter = ath11k_read_pktlog_filter,
+	.write_iter = ath11k_write_pktlog_filter,
 	.open = simple_open
 };
 
-static ssize_t ath11k_write_simulate_radar(struct file *file,
-					   const char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath11k_write_simulate_radar(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 
 	ret = ath11k_wmi_simulate_radar(ar);
@@ -1235,15 +1218,14 @@ static ssize_t ath11k_write_simulate_radar(struct file *file,
 }
 
 static const struct file_operations fops_simulate_radar = {
-	.write = ath11k_write_simulate_radar,
+	.write_iter = ath11k_write_simulate_radar,
 	.open = simple_open
 };
 
-static ssize_t ath11k_debug_dump_dbr_entries(struct file *file,
-					     char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static ssize_t ath11k_debug_dump_dbr_entries(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct ath11k_dbg_dbr_data *dbr_dbg_data = file->private_data;
+	struct ath11k_dbg_dbr_data *dbr_dbg_data = iocb->ki_filp->private_data;
 	static const char * const event_id_to_string[] = {"empty", "Rx", "Replenish"};
 	int size = ATH11K_DEBUG_DBR_ENTRIES_MAX * 100;
 	char *buf;
@@ -1274,14 +1256,14 @@ static ssize_t ath11k_debug_dump_dbr_entries(struct file *file,
 
 	spin_unlock_bh(&dbr_dbg_data->lock);
 
-	ret = simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 
 	return ret;
 }
 
 static const struct file_operations fops_debug_dump_dbr_entries = {
-	.read = ath11k_debug_dump_dbr_entries,
+	.read_iter = ath11k_debug_dump_dbr_entries,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1350,11 +1332,11 @@ static int ath11k_debugfs_dbr_dbg_init(struct ath11k *ar, int dbr_id)
 	return 0;
 }
 
-static ssize_t ath11k_debugfs_write_enable_dbr_dbg(struct file *file,
-						   const char __user *ubuf,
-						   size_t count, loff_t *ppos)
+static ssize_t ath11k_debugfs_write_enable_dbr_dbg(struct kiocb *iocb,
+						   struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[32] = {0};
 	u32 dbr_id, enable;
 	int ret;
@@ -1366,7 +1348,7 @@ static ssize_t ath11k_debugfs_write_enable_dbr_dbg(struct file *file,
 		goto out;
 	}
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret < 0)
 		goto out;
 
@@ -1396,21 +1378,21 @@ static ssize_t ath11k_debugfs_write_enable_dbr_dbg(struct file *file,
 }
 
 static const struct file_operations fops_dbr_debug = {
-	.write = ath11k_debugfs_write_enable_dbr_dbg,
+	.write_iter = ath11k_debugfs_write_enable_dbr_dbg,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
 };
 
-static ssize_t ath11k_write_ps_timekeeper_enable(struct file *file,
-						 const char __user *user_buf,
-						 size_t count, loff_t *ppos)
+static ssize_t ath11k_write_ps_timekeeper_enable(struct kiocb *iocb,
+						 struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	ssize_t ret;
 	u8 ps_timekeeper_enable;
 
-	if (kstrtou8_from_user(user_buf, count, 0, &ps_timekeeper_enable))
+	if (kstrtou8_from_iter(from, count, 0, &ps_timekeeper_enable))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1433,11 +1415,10 @@ static ssize_t ath11k_write_ps_timekeeper_enable(struct file *file,
 	return ret;
 }
 
-static ssize_t ath11k_read_ps_timekeeper_enable(struct file *file,
-						char __user *user_buf,
-						size_t count, loff_t *ppos)
+static ssize_t ath11k_read_ps_timekeeper_enable(struct kiocb *iocb,
+						struct iov_iter *to)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	int len;
 
@@ -1445,12 +1426,12 @@ static ssize_t ath11k_read_ps_timekeeper_enable(struct file *file,
 	len = scnprintf(buf, sizeof(buf), "%d\n", ar->ps_timekeeper_enable);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_ps_timekeeper_enable = {
-	.read = ath11k_read_ps_timekeeper_enable,
-	.write = ath11k_write_ps_timekeeper_enable,
+	.read_iter = ath11k_read_ps_timekeeper_enable,
+	.write_iter = ath11k_write_ps_timekeeper_enable,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1467,15 +1448,15 @@ static void ath11k_reset_peer_ps_duration(void *data,
 	spin_unlock_bh(&ar->data_lock);
 }
 
-static ssize_t ath11k_write_reset_ps_duration(struct file *file,
-					      const  char __user *user_buf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath11k_write_reset_ps_duration(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	int ret;
 	u8 reset_ps_duration;
 
-	if (kstrtou8_from_user(user_buf, count, 0, &reset_ps_duration))
+	if (kstrtou8_from_iter(from, count, 0, &reset_ps_duration))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1501,7 +1482,7 @@ static ssize_t ath11k_write_reset_ps_duration(struct file *file,
 }
 
 static const struct file_operations fops_reset_ps_duration = {
-	.write = ath11k_write_reset_ps_duration,
+	.write_iter = ath11k_write_reset_ps_duration,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1520,17 +1501,17 @@ static void ath11k_peer_ps_state_disable(void *data,
 	spin_unlock_bh(&ar->data_lock);
 }
 
-static ssize_t ath11k_write_ps_state_enable(struct file *file,
-					    const char __user *user_buf,
-					    size_t count, loff_t *ppos)
+static ssize_t ath11k_write_ps_state_enable(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct ath11k_pdev *pdev = ar->pdev;
 	int ret;
 	u32 param;
 	u8 ps_state_enable;
 
-	if (kstrtou8_from_user(user_buf, count, 0, &ps_state_enable))
+	if (kstrtou8_from_iter(from, count, 0, &ps_state_enable))
 		return -EINVAL;
 
 	mutex_lock(&ar->conf_mutex);
@@ -1566,11 +1547,10 @@ static ssize_t ath11k_write_ps_state_enable(struct file *file,
 	return ret;
 }
 
-static ssize_t ath11k_read_ps_state_enable(struct file *file,
-					   char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath11k_read_ps_state_enable(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct ath11k *ar = file->private_data;
+	struct ath11k *ar = iocb->ki_filp->private_data;
 	char buf[32];
 	int len;
 
@@ -1578,12 +1558,12 @@ static ssize_t ath11k_read_ps_state_enable(struct file *file,
 	len = scnprintf(buf, sizeof(buf), "%d\n", ar->ps_state_enable);
 	mutex_unlock(&ar->conf_mutex);
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations fops_ps_state_enable = {
-	.read = ath11k_read_ps_state_enable,
-	.write = ath11k_write_ps_state_enable,
+	.read_iter = ath11k_read_ps_state_enable,
+	.write_iter = ath11k_write_ps_state_enable,
 	.open = simple_open,
 	.owner = THIS_MODULE,
 	.llseek = default_llseek,
@@ -1671,13 +1651,13 @@ void ath11k_debugfs_unregister(struct ath11k *ar)
 	}
 }
 
-static ssize_t ath11k_write_twt_add_dialog(struct file *file,
-					   const char __user *ubuf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath11k_write_twt_add_dialog(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct ath11k_vif *arvif = file->private_data;
+	struct ath11k_vif *arvif = iocb->ki_filp->private_data;
 	struct wmi_twt_add_dialog_params params = { 0 };
 	struct wmi_twt_enable_params twt_params = {0};
+	size_t count = iov_iter_count(from);
 	struct ath11k *ar = arvif->ar;
 	u8 buf[128] = {0};
 	int ret;
@@ -1687,7 +1667,7 @@ static ssize_t ath11k_write_twt_add_dialog(struct file *file,
 		return -EOPNOTSUPP;
 	}
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret < 0)
 		return ret;
 
@@ -1747,11 +1727,11 @@ static ssize_t ath11k_write_twt_add_dialog(struct file *file,
 	return ret;
 }
 
-static ssize_t ath11k_write_twt_del_dialog(struct file *file,
-					   const char __user *ubuf,
-					   size_t count, loff_t *ppos)
+static ssize_t ath11k_write_twt_del_dialog(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct ath11k_vif *arvif = file->private_data;
+	struct ath11k_vif *arvif = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wmi_twt_del_dialog_params params = { 0 };
 	struct wmi_twt_enable_params twt_params = {0};
 	struct ath11k *ar = arvif->ar;
@@ -1763,7 +1743,7 @@ static ssize_t ath11k_write_twt_del_dialog(struct file *file,
 		return -EOPNOTSUPP;
 	}
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret < 0)
 		return ret;
 
@@ -1794,11 +1774,11 @@ static ssize_t ath11k_write_twt_del_dialog(struct file *file,
 	return count;
 }
 
-static ssize_t ath11k_write_twt_pause_dialog(struct file *file,
-					     const char __user *ubuf,
-					     size_t count, loff_t *ppos)
+static ssize_t ath11k_write_twt_pause_dialog(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct ath11k_vif *arvif = file->private_data;
+	struct ath11k_vif *arvif = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wmi_twt_pause_dialog_params params = { 0 };
 	u8 buf[64] = {0};
 	int ret;
@@ -1808,7 +1788,7 @@ static ssize_t ath11k_write_twt_pause_dialog(struct file *file,
 		return -EOPNOTSUPP;
 	}
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret < 0)
 		return ret;
 
@@ -1833,11 +1813,11 @@ static ssize_t ath11k_write_twt_pause_dialog(struct file *file,
 	return count;
 }
 
-static ssize_t ath11k_write_twt_resume_dialog(struct file *file,
-					      const char __user *ubuf,
-					      size_t count, loff_t *ppos)
+static ssize_t ath11k_write_twt_resume_dialog(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct ath11k_vif *arvif = file->private_data;
+	struct ath11k_vif *arvif = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wmi_twt_resume_dialog_params params = { 0 };
 	u8 buf[64] = {0};
 	int ret;
@@ -1847,7 +1827,7 @@ static ssize_t ath11k_write_twt_resume_dialog(struct file *file,
 		return -EOPNOTSUPP;
 	}
 
-	ret = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf) - 1, from);
 	if (ret < 0)
 		return ret;
 
@@ -1875,22 +1855,22 @@ static ssize_t ath11k_write_twt_resume_dialog(struct file *file,
 }
 
 static const struct file_operations ath11k_fops_twt_add_dialog = {
-	.write = ath11k_write_twt_add_dialog,
+	.write_iter = ath11k_write_twt_add_dialog,
 	.open = simple_open
 };
 
 static const struct file_operations ath11k_fops_twt_del_dialog = {
-	.write = ath11k_write_twt_del_dialog,
+	.write_iter = ath11k_write_twt_del_dialog,
 	.open = simple_open
 };
 
 static const struct file_operations ath11k_fops_twt_pause_dialog = {
-	.write = ath11k_write_twt_pause_dialog,
+	.write_iter = ath11k_write_twt_pause_dialog,
 	.open = simple_open
 };
 
 static const struct file_operations ath11k_fops_twt_resume_dialog = {
-	.write = ath11k_write_twt_resume_dialog,
+	.write_iter = ath11k_write_twt_resume_dialog,
 	.open = simple_open
 };
 
drivers/net/wireless/ath/ath11k/debugfs_htt_stats.c +26 -30

120 lines not on this page · raw message

drivers/net/wireless/ath/ath11k/debugfs_sta.c +75 -88

389 lines not on this page · raw message

drivers/net/wireless/ath/ath11k/spectral.c +33 -36

144 lines not on this page · raw message

Signature · 1 line
2.43.0
author maintainer
#312 lore raw

PATCH 306/437 drivers/net/wireless/broadcom: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/broadcom/b43/debugfs.c   | 30 +++++++++---------
 .../net/wireless/broadcom/b43legacy/debugfs.c | 31 +++++++++----------
 .../broadcom/brcm80211/brcmfmac/core.c        | 10 +++---
 .../broadcom/brcm80211/brcmsmac/debug.c       |  2 +-
 4 files changed, 35 insertions(+), 38 deletions(-)
drivers/net/wireless/broadcom/b43/debugfs.c +14 -16
index efa98444e3fb..bd82fc337500 100644
@@ -487,8 +487,7 @@ static ssize_t loctls_read_file(struct b43_wldev *dev,
 
 #undef fappend
 
-static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t b43_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct b43_wldev *dev;
 	struct b43_debugfs_fops *dfops;
@@ -497,11 +496,12 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
 	char *buf;
 	const size_t bufsize = 1024 * 16; /* 16 kiB buffer */
 	const size_t buforder = get_order(bufsize);
+	size_t count = iov_iter_count(to);
 	int err = 0;
 
 	if (!count)
 		return 0;
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 	if (!dev)
 		return -ENODEV;
 
@@ -511,7 +511,7 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
 		goto out_unlock;
 	}
 
-	dfops = container_of(debugfs_real_fops(file),
+	dfops = container_of(debugfs_real_fops(iocb->ki_filp),
 			     struct b43_debugfs_fops, fops);
 	if (!dfops->read) {
 		err = -ENOSYS;
@@ -536,10 +536,9 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
 		dfile->buffer = buf;
 	}
 
-	ret = simple_read_from_buffer(userbuf, count, ppos,
-				      dfile->buffer,
-				      dfile->data_len);
-	if (*ppos >= dfile->data_len) {
+	ret = simple_copy_to_iter(dfile->buffer, &iocb->ki_pos, dfile->data_len,
+				  to);
+	if (iocb->ki_pos >= dfile->data_len) {
 		free_pages((unsigned long)dfile->buffer, buforder);
 		dfile->buffer = NULL;
 		dfile->data_len = 0;
@@ -550,12 +549,11 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
 	return err ? err : ret;
 }
 
-static ssize_t b43_debugfs_write(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t b43_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct b43_wldev *dev;
 	struct b43_debugfs_fops *dfops;
+	size_t count = iov_iter_count(from);
 	char *buf;
 	int err = 0;
 
@@ -563,7 +561,7 @@ static ssize_t b43_debugfs_write(struct file *file,
 		return 0;
 	if (count > PAGE_SIZE)
 		return -E2BIG;
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 	if (!dev)
 		return -ENODEV;
 
@@ -573,7 +571,7 @@ static ssize_t b43_debugfs_write(struct file *file,
 		goto out_unlock;
 	}
 
-	dfops = container_of(debugfs_real_fops(file),
+	dfops = container_of(debugfs_real_fops(iocb->ki_filp),
 			     struct b43_debugfs_fops, fops);
 	if (!dfops->write) {
 		err = -ENOSYS;
@@ -585,7 +583,7 @@ static ssize_t b43_debugfs_write(struct file *file,
 		err = -ENOMEM;
 		goto out_unlock;
 	}
-	if (copy_from_user(buf, userbuf, count)) {
+	if (!copy_from_iter_full(buf, count, from)) {
 		err = -EFAULT;
 		goto out_freepage;
 	}
@@ -608,8 +606,8 @@ static ssize_t b43_debugfs_write(struct file *file,
 		.write	= _write,				\
 		.fops	= {					\
 			.open	= simple_open,			\
-			.read	= b43_debugfs_read,		\
-			.write	= b43_debugfs_write,		\
+			.read_iter	= b43_debugfs_read,	\
+			.write_iter	= b43_debugfs_write,	\
 			.llseek = generic_file_llseek,		\
 		},						\
 		.file_struct_offset = offsetof(struct b43_dfsentry, \
drivers/net/wireless/broadcom/b43legacy/debugfs.c +15 -16
index 6b0e8d117061..3746e2fab874 100644
@@ -184,8 +184,7 @@ static int restart_write_file(struct b43legacy_wldev *dev, const char *buf, size
 
 #undef fappend
 
-static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
-				size_t count, loff_t *ppos)
+static ssize_t b43legacy_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct b43legacy_wldev *dev;
 	struct b43legacy_debugfs_fops *dfops;
@@ -194,11 +193,12 @@ static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
 	char *buf;
 	const size_t bufsize = 1024 * 16; /* 16 KiB buffer */
 	const size_t buforder = get_order(bufsize);
+	size_t count = iov_iter_count(to);
 	int err = 0;
 
 	if (!count)
 		return 0;
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 	if (!dev)
 		return -ENODEV;
 
@@ -208,7 +208,7 @@ static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
 		goto out_unlock;
 	}
 
-	dfops = container_of(debugfs_real_fops(file),
+	dfops = container_of(debugfs_real_fops(iocb->ki_filp),
 			     struct b43legacy_debugfs_fops, fops);
 	if (!dfops->read) {
 		err = -ENOSYS;
@@ -238,10 +238,9 @@ static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
 		dfile->buffer = buf;
 	}
 
-	ret = simple_read_from_buffer(userbuf, count, ppos,
-				      dfile->buffer,
-				      dfile->data_len);
-	if (*ppos >= dfile->data_len) {
+	ret = simple_copy_to_iter(dfile->buffer, &iocb->ki_pos,
+				  dfile->data_len, to);
+	if (iocb->ki_pos >= dfile->data_len) {
 		free_pages((unsigned long)dfile->buffer, buforder);
 		dfile->buffer = NULL;
 		dfile->data_len = 0;
@@ -252,12 +251,12 @@ static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
 	return err ? err : ret;
 }
 
-static ssize_t b43legacy_debugfs_write(struct file *file,
-				 const char __user *userbuf,
-				 size_t count, loff_t *ppos)
+static ssize_t b43legacy_debugfs_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
 	struct b43legacy_wldev *dev;
 	struct b43legacy_debugfs_fops *dfops;
+	size_t count = iov_iter_count(from);
 	char *buf;
 	int err = 0;
 
@@ -265,7 +264,7 @@ static ssize_t b43legacy_debugfs_write(struct file *file,
 		return 0;
 	if (count > PAGE_SIZE)
 		return -E2BIG;
-	dev = file->private_data;
+	dev = iocb->ki_filp->private_data;
 	if (!dev)
 		return -ENODEV;
 
@@ -275,7 +274,7 @@ static ssize_t b43legacy_debugfs_write(struct file *file,
 		goto out_unlock;
 	}
 
-	dfops = container_of(debugfs_real_fops(file),
+	dfops = container_of(debugfs_real_fops(iocb->ki_filp),
 			     struct b43legacy_debugfs_fops, fops);
 	if (!dfops->write) {
 		err = -ENOSYS;
@@ -287,7 +286,7 @@ static ssize_t b43legacy_debugfs_write(struct file *file,
 		err = -ENOMEM;
 		goto out_unlock;
 	}
-	if (copy_from_user(buf, userbuf, count)) {
+	if (!copy_from_iter_full(buf, count, from)) {
 		err = -EFAULT;
 		goto out_freepage;
 	}
@@ -315,8 +314,8 @@ static ssize_t b43legacy_debugfs_write(struct file *file,
 		.write	= _write,				\
 		.fops	= {					\
 			.open	= simple_open,				\
-			.read	= b43legacy_debugfs_read,		\
-			.write	= b43legacy_debugfs_write,		\
+			.read_iter	= b43legacy_debugfs_read,	\
+			.write_iter	= b43legacy_debugfs_write,	\
 			.llseek = generic_file_llseek,			\
 		},						\
 		.file_struct_offset = offsetof(struct b43legacy_dfsentry, \
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c +5 -5
index bf91b1e1368f..d02dd7944bad 100644
@@ -1165,13 +1165,13 @@ static void brcmf_core_bus_reset(struct work_struct *work)
 	brcmf_bus_reset(drvr->bus_if);
 }
 
-static ssize_t bus_reset_write(struct file *file, const char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t bus_reset_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct brcmf_pub *drvr = file->private_data;
+	struct brcmf_pub *drvr = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	u8 value;
 
-	if (kstrtou8_from_user(user_buf, count, 0, &value))
+	if (kstrtou8_from_iter(from, count, 0, &value))
 		return -EINVAL;
 
 	if (value != 1)
@@ -1185,7 +1185,7 @@ static ssize_t bus_reset_write(struct file *file, const char __user *user_buf,
 static const struct file_operations bus_reset_fops = {
 	.open	= simple_open,
 	.llseek	= no_llseek,
-	.write	= bus_reset_write,
+	.write_iter	= bus_reset_write,
 };
 
 static int brcmf_bus_started(struct brcmf_pub *drvr, struct cfg80211_ops *ops)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c +1 -1
index 6d776ef6ff54..cfc7ff6d3503 100644
@@ -182,7 +182,7 @@ static const struct file_operations brcms_debugfs_def_ops = {
 	.owner = THIS_MODULE,
 	.open = brcms_debugfs_entry_open,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek
 };
 
Signature · 1 line
2.43.0
author maintainer
#313 lore raw

PATCH 307/437 drivers/net/wireless/ralink: convert to read/write iterators

In reply to Jens Axboe
---
 .../net/wireless/ralink/rt2x00/rt2x00debug.c  | 122 ++++++++----------
 1 file changed, 55 insertions(+), 67 deletions(-)
drivers/net/wireless/ralink/rt2x00/rt2x00debug.c +55 -67
index f2395309ec00..80f84dc700be 100644
@@ -238,17 +238,16 @@ static int rt2x00debug_release_queue_dump(struct inode *inode, struct file *file
 	return rt2x00debug_file_release(inode, file);
 }
 
-static ssize_t rt2x00debug_read_queue_dump(struct file *file,
-					   char __user *buf,
-					   size_t length,
-					   loff_t *offset)
+static ssize_t rt2x00debug_read_queue_dump(struct kiocb *iocb,
+					   struct iov_iter *to)
 {
-	struct rt2x00debug_intf *intf = file->private_data;
+	struct rt2x00debug_intf *intf = iocb->ki_filp->private_data;
+	size_t length = iov_iter_count(to);
 	struct sk_buff *skb;
 	size_t status;
 	int retval;
 
-	if (file->f_flags & O_NONBLOCK)
+	if (iocb->ki_filp->f_flags & O_NONBLOCK)
 		return -EAGAIN;
 
 	retval =
@@ -259,12 +258,12 @@ static ssize_t rt2x00debug_read_queue_dump(struct file *file,
 		return retval;
 
 	status = min_t(size_t, skb->len, length);
-	if (copy_to_user(buf, skb->data, status)) {
+	if (!copy_to_iter_full(skb->data, status, to)) {
 		status = -EFAULT;
 		goto exit;
 	}
 
-	*offset += status;
+	iocb->ki_pos += status;
 
 exit:
 	kfree_skb(skb);
@@ -287,27 +286,26 @@ static __poll_t rt2x00debug_poll_queue_dump(struct file *file,
 
 static const struct file_operations rt2x00debug_fop_queue_dump = {
 	.owner		= THIS_MODULE,
-	.read		= rt2x00debug_read_queue_dump,
+	.read_iter	= rt2x00debug_read_queue_dump,
 	.poll		= rt2x00debug_poll_queue_dump,
 	.open		= rt2x00debug_open_queue_dump,
 	.release	= rt2x00debug_release_queue_dump,
 	.llseek		= default_llseek,
 };
 
-static ssize_t rt2x00debug_read_queue_stats(struct file *file,
-					    char __user *buf,
-					    size_t length,
-					    loff_t *offset)
+static ssize_t rt2x00debug_read_queue_stats(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct rt2x00debug_intf *intf = file->private_data;
+	struct rt2x00debug_intf *intf = iocb->ki_filp->private_data;
 	struct data_queue *queue;
 	unsigned long irqflags;
 	unsigned int lines = 1 + intf->rt2x00dev->data_queues;
+	size_t length = iov_iter_count(to);
 	size_t size;
 	char *data;
 	char *temp;
 
-	if (*offset)
+	if (iocb->ki_pos)
 		return 0;
 
 	data = kcalloc(lines, MAX_LINE_LENGTH, GFP_KERNEL);
@@ -333,39 +331,38 @@ static ssize_t rt2x00debug_read_queue_stats(struct file *file,
 	size = strlen(data);
 	size = min(size, length);
 
-	if (copy_to_user(buf, data, size)) {
+	if (!copy_to_iter_full(data, size, to)) {
 		kfree(data);
 		return -EFAULT;
 	}
 
 	kfree(data);
 
-	*offset += size;
+	iocb->ki_pos += size;
 	return size;
 }
 
 static const struct file_operations rt2x00debug_fop_queue_stats = {
 	.owner		= THIS_MODULE,
-	.read		= rt2x00debug_read_queue_stats,
+	.read_iter	= rt2x00debug_read_queue_stats,
 	.open		= rt2x00debug_file_open,
 	.release	= rt2x00debug_file_release,
 	.llseek		= default_llseek,
 };
 
 #ifdef CONFIG_RT2X00_LIB_CRYPTO
-static ssize_t rt2x00debug_read_crypto_stats(struct file *file,
-					     char __user *buf,
-					     size_t length,
-					     loff_t *offset)
+static ssize_t rt2x00debug_read_crypto_stats(struct kiocb *iocb,
+					     struct iov_iter *to)
 {
-	struct rt2x00debug_intf *intf = file->private_data;
+	struct rt2x00debug_intf *intf = iocb->ki_filp->private_data;
 	static const char * const name[] = { "WEP64", "WEP128", "TKIP", "AES" };
+	size_t length = iov_iter_count(to);
 	char *data;
 	char *temp;
 	size_t size;
 	unsigned int i;
 
-	if (*offset)
+	if (iocb->ki_pos)
 		return 0;
 
 	data = kcalloc(1 + CIPHER_MAX, MAX_LINE_LENGTH, GFP_KERNEL);
@@ -386,20 +383,20 @@ static ssize_t rt2x00debug_read_crypto_stats(struct file *file,
 	size = strlen(data);
 	size = min(size, length);
 
-	if (copy_to_user(buf, data, size)) {
+	if (!copy_to_iter_full(data, size, to)) {
 		kfree(data);
 		return -EFAULT;
 	}
 
 	kfree(data);
 
-	*offset += size;
+	iocb->ki_pos += size;
 	return size;
 }
 
 static const struct file_operations rt2x00debug_fop_crypto_stats = {
 	.owner		= THIS_MODULE,
-	.read		= rt2x00debug_read_crypto_stats,
+	.read_iter	= rt2x00debug_read_crypto_stats,
 	.open		= rt2x00debug_file_open,
 	.release	= rt2x00debug_file_release,
 	.llseek		= default_llseek,
@@ -407,19 +404,17 @@ static const struct file_operations rt2x00debug_fop_crypto_stats = {
 #endif
 
 #define RT2X00DEBUGFS_OPS_READ(__name, __format, __type)	\
-static ssize_t rt2x00debug_read_##__name(struct file *file,	\
-					 char __user *buf,	\
-					 size_t length,		\
-					 loff_t *offset)	\
+static ssize_t rt2x00debug_read_##__name(struct kiocb *iocb,	\
+					 struct iov_iter *to)	\
 {								\
-	struct rt2x00debug_intf *intf = file->private_data;	\
+	struct rt2x00debug_intf *intf = iocb->ki_filp->private_data;	\
 	const struct rt2x00debug *debug = intf->debug;		\
 	char line[16];						\
 	size_t size;						\
 	unsigned int index = intf->offset_##__name;		\
 	__type value;						\
 								\
-	if (*offset)						\
+	if (iocb->ki_pos)					\
 		return 0;					\
 								\
 	if (index >= debug->__name.word_count)			\
@@ -435,23 +430,22 @@ static ssize_t rt2x00debug_read_##__name(struct file *file,	\
 								\
 	size = sprintf(line, __format, value);			\
 								\
-	return simple_read_from_buffer(buf, length, offset, line, size); \
+	return simple_copy_to_iter(line, &iocb->ki_pos, size, to); \
 }
 
 #define RT2X00DEBUGFS_OPS_WRITE(__name, __type)			\
-static ssize_t rt2x00debug_write_##__name(struct file *file,	\
-					  const char __user *buf,\
-					  size_t length,	\
-					  loff_t *offset)	\
+static ssize_t rt2x00debug_write_##__name(struct kiocb *iocb,	\
+					  struct iov_iter *from)\
 {								\
-	struct rt2x00debug_intf *intf = file->private_data;	\
+	struct rt2x00debug_intf *intf = iocb->ki_filp->private_data;	\
 	const struct rt2x00debug *debug = intf->debug;		\
+	size_t length = iov_iter_count(from);			\
 	char line[17];						\
 	size_t size;						\
 	unsigned int index = intf->offset_##__name;		\
 	__type value;						\
 								\
-	if (*offset)						\
+	if (iocb->ki_pos)					\
 		return 0;					\
 								\
 	if (index >= debug->__name.word_count)			\
@@ -460,7 +454,7 @@ static ssize_t rt2x00debug_write_##__name(struct file *file,	\
 	if (length > sizeof(line))				\
 		return -EINVAL;					\
 								\
-	if (copy_from_user(line, buf, length))			\
+	if (!copy_from_iter_full(line, length, from))		\
 		return -EFAULT;					\
 	line[16] = 0;						\
 						\
@@ -475,7 +469,7 @@ static ssize_t rt2x00debug_write_##__name(struct file *file,	\
 								\
 	debug->__name.write(intf->rt2x00dev, index, value);	\
 								\
-	*offset += size;					\
+	iocb->ki_pos += size;					\
 	return size;						\
 }
 
@@ -485,8 +479,8 @@ RT2X00DEBUGFS_OPS_WRITE(__name, __type);			\
 								\
 static const struct file_operations rt2x00debug_fop_##__name = {\
 	.owner		= THIS_MODULE,				\
-	.read		= rt2x00debug_read_##__name,		\
-	.write		= rt2x00debug_write_##__name,		\
+	.read_iter	= rt2x00debug_read_##__name,		\
+	.write_iter	= rt2x00debug_write_##__name,		\
 	.open		= rt2x00debug_file_open,		\
 	.release	= rt2x00debug_file_release,		\
 	.llseek		= generic_file_llseek,			\
@@ -498,62 +492,56 @@ RT2X00DEBUGFS_OPS(bbp, "0x%.2x\n", u8);
 RT2X00DEBUGFS_OPS(rf, "0x%.8x\n", u32);
 RT2X00DEBUGFS_OPS(rfcsr, "0x%.2x\n", u8);
 
-static ssize_t rt2x00debug_read_dev_flags(struct file *file,
-					  char __user *buf,
-					  size_t length,
-					  loff_t *offset)
+static ssize_t rt2x00debug_read_dev_flags(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct rt2x00debug_intf *intf =	file->private_data;
+	struct rt2x00debug_intf *intf =	iocb->ki_filp->private_data;
 	char line[16];
 	size_t size;
 
-	if (*offset)
+	if (iocb->ki_pos)
 		return 0;
 
 	size = sprintf(line, "0x%.8x\n", (unsigned int)intf->rt2x00dev->flags);
 
-	return simple_read_from_buffer(buf, length, offset, line, size);
+	return simple_copy_to_iter(line, &iocb->ki_pos, size, to);
 }
 
 static const struct file_operations rt2x00debug_fop_dev_flags = {
 	.owner		= THIS_MODULE,
-	.read		= rt2x00debug_read_dev_flags,
+	.read_iter	= rt2x00debug_read_dev_flags,
 	.open		= rt2x00debug_file_open,
 	.release	= rt2x00debug_file_release,
 	.llseek		= default_llseek,
 };
 
-static ssize_t rt2x00debug_read_cap_flags(struct file *file,
-					  char __user *buf,
-					  size_t length,
-					  loff_t *offset)
+static ssize_t rt2x00debug_read_cap_flags(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
-	struct rt2x00debug_intf *intf =	file->private_data;
+	struct rt2x00debug_intf *intf =	iocb->ki_filp->private_data;
 	char line[16];
 	size_t size;
 
-	if (*offset)
+	if (iocb->ki_pos)
 		return 0;
 
 	size = sprintf(line, "0x%.8x\n", (unsigned int)intf->rt2x00dev->cap_flags);
 
-	return simple_read_from_buffer(buf, length, offset, line, size);
+	return simple_copy_to_iter(line, &iocb->ki_pos, size, to);
 }
 
 static const struct file_operations rt2x00debug_fop_cap_flags = {
 	.owner		= THIS_MODULE,
-	.read		= rt2x00debug_read_cap_flags,
+	.read_iter	= rt2x00debug_read_cap_flags,
 	.open		= rt2x00debug_file_open,
 	.release	= rt2x00debug_file_release,
 	.llseek		= default_llseek,
 };
 
-static ssize_t rt2x00debug_write_restart_hw(struct file *file,
-					    const char __user *buf,
-					    size_t length,
-					    loff_t *offset)
+static ssize_t rt2x00debug_write_restart_hw(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct rt2x00debug_intf *intf =	file->private_data;
+	struct rt2x00debug_intf *intf =	iocb->ki_filp->private_data;
 	struct rt2x00_dev *rt2x00dev = intf->rt2x00dev;
 	static unsigned long last_reset = INITIAL_JIFFIES;
 
@@ -566,12 +554,12 @@ static ssize_t rt2x00debug_write_restart_hw(struct file *file,
 	last_reset = jiffies;
 
 	ieee80211_restart_hw(rt2x00dev->hw);
-	return length;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations rt2x00debug_restart_hw = {
 	.owner = THIS_MODULE,
-	.write = rt2x00debug_write_restart_hw,
+	.write_iter = rt2x00debug_write_restart_hw,
 	.open = simple_open,
 	.llseek = generic_file_llseek,
 };
Signature · 1 line
2.43.0
author maintainer
#314 lore raw

PATCH 308/437 wifi: rtlwifi: convert debugfs helpers to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/realtek/rtlwifi/debug.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtlwifi/debug.c +3 -2
index 9eb26dfe4ca9..11220484c4c6 100644
@@ -66,7 +66,7 @@ static int dl_debug_open_common(struct inode *inode, struct file *file)
 
 static const struct file_operations file_ops_common = {
 	.open = dl_debug_open_common,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
@@ -411,10 +411,11 @@ static ssize_t rtl_debugfs_common_write(struct file *filp,
 
 	return debugfs_priv->cb_write(filp, buffer, count, loff);
 }
+FOPS_WRITE_ITER_HELPER(rtl_debugfs_common_write);
 
 static const struct file_operations file_ops_common_write = {
 	.owner = THIS_MODULE,
-	.write = rtl_debugfs_common_write,
+	.write_iter = rtl_debugfs_common_write_iter,
 	.open = simple_open,
 	.release = rtl_debugfs_close,
 };
Signature · 1 line
2.43.0
author maintainer
#315 lore raw

PATCH 309/437 wifi: rtw88: convert debugfs helpers to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/realtek/rtw88/debug.c | 163 ++++++++++-----------
 1 file changed, 79 insertions(+), 84 deletions(-)
drivers/net/wireless/realtek/rtw88/debug.c +79 -84
index 5b2036798159..2a44bbc06a02 100644
@@ -19,8 +19,7 @@
 struct rtw_debugfs_priv {
 	struct rtw_dev *rtwdev;
 	int (*cb_read)(struct seq_file *m, void *v);
-	ssize_t (*cb_write)(struct file *filp, const char __user *buffer,
-			    size_t count, loff_t *loff);
+	ssize_t (*cb_write)(struct kiocb *, struct iov_iter *);
 	union {
 		u32 cb_data;
 		u8 *buf;
@@ -55,23 +54,21 @@ static int rtw_debugfs_single_show(struct seq_file *m, void *v)
 	return debugfs_priv->cb_read(m, v);
 }
 
-static ssize_t rtw_debugfs_common_write(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_common_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct rtw_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 
-	return debugfs_priv->cb_write(filp, buffer, count, loff);
+	return debugfs_priv->cb_write(iocb, from);
 }
 
-static ssize_t rtw_debugfs_single_write(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_single_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 
-	return debugfs_priv->cb_write(filp, buffer, count, loff);
+	return debugfs_priv->cb_write(iocb, from);
 }
 
 static int rtw_debugfs_single_open_rw(struct inode *inode, struct file *filp)
@@ -87,7 +84,7 @@ static int rtw_debugfs_close(struct inode *inode, struct file *filp)
 static const struct file_operations file_ops_single_r = {
 	.owner = THIS_MODULE,
 	.open = rtw_debugfs_single_open_rw,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
@@ -96,14 +93,14 @@ static const struct file_operations file_ops_single_rw = {
 	.owner = THIS_MODULE,
 	.open = rtw_debugfs_single_open_rw,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
-	.write = rtw_debugfs_single_write,
+	.write_iter = rtw_debugfs_single_write,
 };
 
 static const struct file_operations file_ops_common_write = {
 	.owner = THIS_MODULE,
-	.write = rtw_debugfs_common_write,
+	.write_iter = rtw_debugfs_common_write,
 	.open = simple_open,
 	.release = rtw_debugfs_close,
 };
@@ -171,9 +168,9 @@ static int rtw_debugfs_get_fix_rate(struct seq_file *m, void *v)
 }
 
 static int rtw_debugfs_copy_from_user(char tmp[], int size,
-				      const char __user *buffer, size_t count,
-				      int num)
+				      struct iov_iter *from, int num)
 {
+	size_t count = iov_iter_count(from);
 	int tmp_len;
 
 	memset(tmp, 0, size);
@@ -183,7 +180,7 @@ static int rtw_debugfs_copy_from_user(char tmp[], int size,
 
 	tmp_len = (count > size - 1 ? size - 1 : count);
 
-	if (copy_from_user(tmp, buffer, tmp_len))
+	if (!copy_from_iter_full(tmp, tmp_len, from))
 		return -EFAULT;
 
 	tmp[tmp_len] = '\0';
@@ -191,19 +188,19 @@ static int rtw_debugfs_copy_from_user(char tmp[], int size,
 	return 0;
 }
 
-static ssize_t rtw_debugfs_set_read_reg(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_read_reg(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char tmp[32 + 1];
 	u32 addr, len;
 	int num;
 	int ret;
 
-	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2);
+	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), from, 2);
 	if (ret)
 		return ret;
 
@@ -281,19 +278,19 @@ static int rtw_debugfs_get_rsvd_page(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw_debugfs_set_rsvd_page(struct file *filp,
-					 const char __user *buffer,
-					 size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_rsvd_page(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char tmp[32 + 1];
 	u32 offset, page_num;
 	int num;
 	int ret;
 
-	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 2);
+	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), from, 2);
 	if (ret)
 		return ret;
 
@@ -310,16 +307,16 @@ static ssize_t rtw_debugfs_set_rsvd_page(struct file *filp,
 	return count;
 }
 
-static ssize_t rtw_debugfs_set_single_input(struct file *filp,
-					    const char __user *buffer,
-					    size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_single_input(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
+	size_t count = iov_iter_count(from);
 	u32 input;
 	int ret;
 
-	ret = kstrtou32_from_user(buffer, count, 0, &input);
+	ret = kstrtou32_from_iter(from, count, 0, &input);
 	if (ret)
 		return ret;
 
@@ -328,18 +325,18 @@ static ssize_t rtw_debugfs_set_single_input(struct file *filp,
 	return count;
 }
 
-static ssize_t rtw_debugfs_set_write_reg(struct file *filp,
-					 const char __user *buffer,
-					 size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_write_reg(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct rtw_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char tmp[32 + 1];
 	u32 addr, val, len;
 	int num;
 	int ret;
 
-	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3);
+	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), from, 3);
 	if (ret)
 		return ret;
 
@@ -374,18 +371,17 @@ static ssize_t rtw_debugfs_set_write_reg(struct file *filp,
 	return count;
 }
 
-static ssize_t rtw_debugfs_set_h2c(struct file *filp,
-				   const char __user *buffer,
-				   size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_h2c(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct rtw_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char tmp[32 + 1];
 	u8 param[8];
 	int num;
 	int ret;
 
-	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3);
+	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), from, 3);
 	if (ret)
 		return ret;
 
@@ -404,18 +400,18 @@ static ssize_t rtw_debugfs_set_h2c(struct file *filp,
 	return count;
 }
 
-static ssize_t rtw_debugfs_set_rf_write(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_rf_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct rtw_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char tmp[32 + 1];
 	u32 path, addr, mask, val;
 	int num;
 	int ret;
 
-	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 4);
+	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), from, 4);
 	if (ret)
 		return ret;
 
@@ -436,19 +432,18 @@ static ssize_t rtw_debugfs_set_rf_write(struct file *filp,
 	return count;
 }
 
-static ssize_t rtw_debugfs_set_rf_read(struct file *filp,
-				       const char __user *buffer,
-				       size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_rf_read(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char tmp[32 + 1];
 	u32 path, addr, mask;
 	int num;
 	int ret;
 
-	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), buffer, count, 3);
+	ret = rtw_debugfs_copy_from_user(tmp, sizeof(tmp), from, 3);
 	if (ret)
 		return ret;
 
@@ -466,18 +461,18 @@ static ssize_t rtw_debugfs_set_rf_read(struct file *filp,
 	return count;
 }
 
-static ssize_t rtw_debugfs_set_fix_rate(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_fix_rate(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 	struct rtw_dm_info *dm_info = &rtwdev->dm_info;
+	size_t count = iov_iter_count(from);
 	u8 fix_rate;
 	int ret;
 
-	ret = kstrtou8_from_user(buffer, count, 0, &fix_rate);
+	ret = kstrtou8_from_iter(from, count, 0, &fix_rate);
 	if (ret)
 		return ret;
 
@@ -854,18 +849,18 @@ static int rtw_debugfs_get_coex_info(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw_debugfs_set_coex_enable(struct file *filp,
-					   const char __user *buffer,
-					   size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_coex_enable(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 	struct rtw_coex *coex = &rtwdev->coex;
+	size_t count = iov_iter_count(from);
 	bool enable;
 	int ret;
 
-	ret = kstrtobool_from_user(buffer, count, &enable);
+	ret = kstrtobool_from_iter(from, count, &enable);
 	if (ret)
 		return ret;
 
@@ -888,17 +883,17 @@ static int rtw_debugfs_get_coex_enable(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw_debugfs_set_edcca_enable(struct file *filp,
-					    const char __user *buffer,
-					    size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_edcca_enable(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	bool input;
 	int err;
 
-	err = kstrtobool_from_user(buffer, count, &input);
+	err = kstrtobool_from_iter(from, count, &input);
 	if (err)
 		return err;
 
@@ -920,17 +915,17 @@ static int rtw_debugfs_get_edcca_enable(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw_debugfs_set_fw_crash(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_fw_crash(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	bool input;
 	int ret;
 
-	ret = kstrtobool_from_user(buffer, count, &input);
+	ret = kstrtobool_from_iter(from, count, &input);
 	if (ret)
 		return ret;
 
@@ -960,17 +955,17 @@ static int rtw_debugfs_get_fw_crash(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw_debugfs_set_force_lowest_basic_rate(struct file *filp,
-						       const char __user *buffer,
-						       size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_force_lowest_basic_rate(struct kiocb *iocb,
+						       struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	bool input;
 	int err;
 
-	err = kstrtobool_from_user(buffer, count, &input);
+	err = kstrtobool_from_iter(from, count, &input);
 	if (err)
 		return err;
 
@@ -993,18 +988,18 @@ static int rtw_debugfs_get_force_lowest_basic_rate(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw_debugfs_set_dm_cap(struct file *filp,
-				      const char __user *buffer,
-				      size_t count, loff_t *loff)
+static ssize_t rtw_debugfs_set_dm_cap(struct kiocb *iocb,
+				      struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw_debugfs_priv *debugfs_priv = seqpriv->private;
 	struct rtw_dev *rtwdev = debugfs_priv->rtwdev;
 	struct rtw_dm_info *dm_info = &rtwdev->dm_info;
+	size_t count = iov_iter_count(from);
 	int ret, bit;
 	bool en;
 
-	ret = kstrtoint_from_user(buffer, count, 10, &bit);
+	ret = kstrtoint_from_iter(from, count, 10, &bit);
 	if (ret)
 		return ret;
 
Signature · 1 line
2.43.0
author maintainer
#316 lore raw

PATCH 310/437 wifi: rtw89: convert debugfs helpers to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/realtek/rtw89/debug.c | 155 ++++++++++-----------
 1 file changed, 74 insertions(+), 81 deletions(-)
drivers/net/wireless/realtek/rtw89/debug.c +74 -81
index affffc4092ba..20d8774f151a 100644
@@ -24,8 +24,7 @@ MODULE_PARM_DESC(debug_mask, "Debugging mask");
 struct rtw89_debugfs_priv {
 	struct rtw89_dev *rtwdev;
 	int (*cb_read)(struct seq_file *m, void *v);
-	ssize_t (*cb_write)(struct file *filp, const char __user *buffer,
-			    size_t count, loff_t *loff);
+	ssize_t (*cb_write)(struct kiocb *, struct iov_iter *);
 	union {
 		u32 cb_data;
 		struct {
@@ -75,23 +74,21 @@ static int rtw89_debugfs_single_show(struct seq_file *m, void *v)
 	return debugfs_priv->cb_read(m, v);
 }
 
-static ssize_t rtw89_debugfs_single_write(struct file *filp,
-					  const char __user *buffer,
-					  size_t count, loff_t *loff)
+static ssize_t rtw89_debugfs_single_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw89_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 
-	return debugfs_priv->cb_write(filp, buffer, count, loff);
+	return debugfs_priv->cb_write(iocb, from);
 }
 
-static ssize_t rtw89_debugfs_seq_file_write(struct file *filp,
-					    const char __user *buffer,
-					    size_t count, loff_t *loff)
+static ssize_t rtw89_debugfs_seq_file_write(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct seq_file *seqpriv = (struct seq_file *)filp->private_data;
+	struct seq_file *seqpriv = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = seqpriv->private;
 
-	return debugfs_priv->cb_write(filp, buffer, count, loff);
+	return debugfs_priv->cb_write(iocb, from);
 }
 
 static int rtw89_debugfs_single_open(struct inode *inode, struct file *filp)
@@ -107,7 +104,7 @@ static int rtw89_debugfs_close(struct inode *inode, struct file *filp)
 static const struct file_operations file_ops_single_r = {
 	.owner = THIS_MODULE,
 	.open = rtw89_debugfs_single_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
 };
@@ -116,33 +113,32 @@ static const struct file_operations file_ops_common_rw = {
 	.owner = THIS_MODULE,
 	.open = rtw89_debugfs_single_open,
 	.release = single_release,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
-	.write = rtw89_debugfs_seq_file_write,
+	.write_iter = rtw89_debugfs_seq_file_write,
 };
 
 static const struct file_operations file_ops_single_w = {
 	.owner = THIS_MODULE,
-	.write = rtw89_debugfs_single_write,
+	.write_iter = rtw89_debugfs_single_write,
 	.open = simple_open,
 	.release = rtw89_debugfs_close,
 };
 
 static ssize_t
-rtw89_debug_priv_read_reg_select(struct file *filp,
-				 const char __user *user_buf,
-				 size_t count, loff_t *loff)
+rtw89_debug_priv_read_reg_select(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t buf_size;
 	u32 addr, len;
 	int num;
 
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -207,19 +203,19 @@ static int rtw89_debug_priv_read_reg_get(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw89_debug_priv_write_reg_set(struct file *filp,
-					      const char __user *user_buf,
-					      size_t count, loff_t *loff)
+static ssize_t rtw89_debug_priv_write_reg_set(struct kiocb *iocb,
+					      struct iov_iter *from)
 {
-	struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw89_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t buf_size;
 	u32 addr, val, len;
 	int num;
 
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -251,13 +247,12 @@ static ssize_t rtw89_debug_priv_write_reg_set(struct file *filp,
 }
 
 static ssize_t
-rtw89_debug_priv_read_rf_select(struct file *filp,
-				const char __user *user_buf,
-				size_t count, loff_t *loff)
+rtw89_debug_priv_read_rf_select(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t buf_size;
 	u32 addr, mask;
@@ -265,7 +260,7 @@ rtw89_debug_priv_read_rf_select(struct file *filp,
 	int num;
 
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -306,12 +301,12 @@ static int rtw89_debug_priv_read_rf_get(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw89_debug_priv_write_rf_set(struct file *filp,
-					     const char __user *user_buf,
-					     size_t count, loff_t *loff)
+static ssize_t rtw89_debug_priv_write_rf_set(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw89_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t buf_size;
 	u32 addr, val, mask;
@@ -319,7 +314,7 @@ static ssize_t rtw89_debug_priv_write_rf_set(struct file *filp,
 	int num;
 
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -867,21 +862,20 @@ static int rtw89_debug_priv_txpwr_table_get(struct seq_file *m, void *v)
 }
 
 static ssize_t
-rtw89_debug_priv_mac_reg_dump_select(struct file *filp,
-				     const char __user *user_buf,
-				     size_t count, loff_t *loff)
+rtw89_debug_priv_mac_reg_dump_select(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
 	const struct rtw89_chip_info *chip = rtwdev->chip;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t buf_size;
 	int sel;
 	int ret;
 
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -984,20 +978,19 @@ static int rtw89_debug_priv_mac_reg_dump_get(struct seq_file *m, void *v)
 }
 
 static ssize_t
-rtw89_debug_priv_mac_mem_dump_select(struct file *filp,
-				     const char __user *user_buf,
-				     size_t count, loff_t *loff)
+rtw89_debug_priv_mac_mem_dump_select(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t buf_size;
 	u32 sel, start_addr, len;
 	int num;
 
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -1094,13 +1087,13 @@ rtw89_debug_priv_mac_mem_dump_get(struct seq_file *m, void *v)
 }
 
 static ssize_t
-rtw89_debug_priv_mac_dbg_port_dump_select(struct file *filp,
-					  const char __user *user_buf,
-					  size_t count, loff_t *loff)
+rtw89_debug_priv_mac_dbg_port_dump_select(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	size_t buf_size;
 	int sel, set;
@@ -1108,7 +1101,7 @@ rtw89_debug_priv_mac_dbg_port_dump_select(struct file *filp,
 	bool enable;
 
 	buf_size = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -3222,15 +3215,15 @@ rtw89_debug_priv_mac_dbg_port_dump_get(struct seq_file *m, void *v)
 	return 0;
 };
 
-static u8 *rtw89_hex2bin_user(struct rtw89_dev *rtwdev,
-			      const char __user *user_buf, size_t count)
+static u8 *rtw89_hex2bin_user(struct rtw89_dev *rtwdev, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char *buf;
 	u8 *bin;
 	int num;
 	int err = 0;
 
-	buf = memdup_user(user_buf, count);
+	buf = iterdup(from, count);
 	if (IS_ERR(buf))
 		return buf;
 
@@ -3253,17 +3246,17 @@ static u8 *rtw89_hex2bin_user(struct rtw89_dev *rtwdev,
 	return err ? ERR_PTR(err) : bin;
 }
 
-static ssize_t rtw89_debug_priv_send_h2c_set(struct file *filp,
-					     const char __user *user_buf,
-					     size_t count, loff_t *loff)
+static ssize_t rtw89_debug_priv_send_h2c_set(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw89_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	u8 *h2c;
 	int ret;
 	u16 h2c_len = count / 2;
 
-	h2c = rtw89_hex2bin_user(rtwdev, user_buf, count);
+	h2c = rtw89_hex2bin_user(rtwdev, from);
 	if (IS_ERR(h2c))
 		return -EFAULT;
 
@@ -3291,17 +3284,17 @@ rtw89_debug_priv_early_h2c_get(struct seq_file *m, void *v)
 }
 
 static ssize_t
-rtw89_debug_priv_early_h2c_set(struct file *filp, const char __user *user_buf,
-			       size_t count, loff_t *loff)
+rtw89_debug_priv_early_h2c_set(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
+	size_t count = iov_iter_count(from);
 	struct rtw89_early_h2c *early_h2c;
 	u8 *h2c;
 	u16 h2c_len = count / 2;
 
-	h2c = rtw89_hex2bin_user(rtwdev, user_buf, count);
+	h2c = rtw89_hex2bin_user(rtwdev, from);
 	if (IS_ERR(h2c))
 		return -EFAULT;
 
@@ -3372,17 +3365,17 @@ enum rtw89_dbg_crash_simulation_type {
 };
 
 static ssize_t
-rtw89_debug_priv_fw_crash_set(struct file *filp, const char __user *user_buf,
-			      size_t count, loff_t *loff)
+rtw89_debug_priv_fw_crash_set(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
 	int (*sim)(struct rtw89_dev *rtwdev);
+	size_t count = iov_iter_count(from);
 	u8 crash_type;
 	int ret;
 
-	ret = kstrtou8_from_user(user_buf, count, 0, &crash_type);
+	ret = kstrtou8_from_iter(from, count, 0, &crash_type);
 	if (ret)
 		return -EINVAL;
 
@@ -3420,17 +3413,17 @@ static int rtw89_debug_priv_btc_info_get(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t rtw89_debug_priv_btc_manual_set(struct file *filp,
-					       const char __user *user_buf,
-					       size_t count, loff_t *loff)
+static ssize_t rtw89_debug_priv_btc_manual_set(struct kiocb *iocb,
+					       struct iov_iter *from)
 {
-	struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw89_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
 	struct rtw89_btc *btc = &rtwdev->btc;
 	const struct rtw89_btc_ver *ver = btc->ver;
+	size_t count = iov_iter_count(from);
 	int ret;
 
-	ret = kstrtobool_from_user(user_buf, count, &btc->manual_ctrl);
+	ret = kstrtobool_from_iter(from, count, &btc->manual_ctrl);
 	if (ret)
 		return ret;
 
@@ -3442,16 +3435,16 @@ static ssize_t rtw89_debug_priv_btc_manual_set(struct file *filp,
 	return count;
 }
 
-static ssize_t rtw89_debug_fw_log_manual_set(struct file *filp,
-					     const char __user *user_buf,
-					     size_t count, loff_t *loff)
+static ssize_t rtw89_debug_fw_log_manual_set(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct rtw89_debugfs_priv *debugfs_priv = filp->private_data;
+	struct rtw89_debugfs_priv *debugfs_priv = iocb->ki_filp->private_data;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
 	struct rtw89_fw_log *log = &rtwdev->fw.log;
+	size_t count = iov_iter_count(from);
 	bool fw_log_manual;
 
-	if (kstrtobool_from_user(user_buf, count, &fw_log_manual))
+	if (kstrtobool_from_iter(from, count, &fw_log_manual))
 		goto out;
 
 	mutex_lock(&rtwdev->mutex);
@@ -3807,17 +3800,17 @@ rtw89_debug_priv_disable_dm_get(struct seq_file *m, void *v)
 }
 
 static ssize_t
-rtw89_debug_priv_disable_dm_set(struct file *filp, const char __user *user_buf,
-				size_t count, loff_t *loff)
+rtw89_debug_priv_disable_dm_set(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *m = (struct seq_file *)filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct rtw89_debugfs_priv *debugfs_priv = m->private;
 	struct rtw89_dev *rtwdev = debugfs_priv->rtwdev;
 	struct rtw89_hal *hal = &rtwdev->hal;
+	size_t count = iov_iter_count(from);
 	u32 conf;
 	int ret;
 
-	ret = kstrtou32_from_user(user_buf, count, 0, &conf);
+	ret = kstrtou32_from_iter(from, count, 0, &conf);
 	if (ret)
 		return -EINVAL;
 
Signature · 1 line
2.43.0
author maintainer
#317 lore raw

PATCH 311/437 wifi: rsi: rsi_91x_debugfs: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/rsi/rsi_91x_debugfs.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/net/wireless/rsi/rsi_91x_debugfs.c +8 -12
index c528e6ca2c8d..4a8e71ff7ba6 100644
@@ -222,25 +222,21 @@ static int rsi_debug_read(struct inode *inode,
 /**
  * rsi_debug_zone_write() - This function writes into hal queues as per user
  *			    requirement.
- * @filp: Pointer to the file structure.
- * @buff: Pointer to the character buffer.
- * @len: Length of the data to be written into buffer.
- * @data: Pointer to the data.
+ * @iocb: Metadata for IO.
+ * @from: iov_iter to copy data from.
  *
  * Return: len: Number of bytes read.
  */
-static ssize_t rsi_debug_zone_write(struct file *filp,
-				    const char __user *buff,
-				    size_t len,
-				    loff_t *data)
+static ssize_t rsi_debug_zone_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	unsigned long dbg_zone;
 	int ret;
 
 	if (!len)
 		return 0;
 
-	ret = kstrtoul_from_user(buff, len, 16, &dbg_zone);
+	ret = kstrtoul_from_iter(from, len, 16, &dbg_zone);
 
 	if (ret)
 		return ret;
@@ -252,16 +248,16 @@ static ssize_t rsi_debug_zone_write(struct file *filp,
 #define FOPS(fopen) { \
 	.owner = THIS_MODULE, \
 	.open = (fopen), \
-	.read = seq_read, \
+	.read_iter = seq_read_iter, \
 	.llseek = seq_lseek, \
 }
 
 #define FOPS_RW(fopen, fwrite) { \
 	.owner = THIS_MODULE, \
 	.open = (fopen), \
-	.read = seq_read, \
+	.read_iter = seq_read_iter, \
 	.llseek = seq_lseek, \
-	.write = (fwrite), \
+	.write_iter = (fwrite), \
 }
 
 static const struct rsi_dbg_files dev_debugfs_files[] = {
Signature · 1 line
2.43.0
author maintainer
#318 lore raw

PATCH 312/437 drivers/net/wireless/silabs: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/silabs/wfx/debug.c | 34 ++++++++++++-------------
 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/net/wireless/silabs/wfx/debug.c +17 -17
index e8265208f9a5..bd39be6a7f58 100644
@@ -202,21 +202,21 @@ static int wfx_tx_power_loop_show(struct seq_file *seq, void *v)
 }
 DEFINE_SHOW_ATTRIBUTE(wfx_tx_power_loop);
 
-static ssize_t wfx_send_pds_write(struct file *file, const char __user *user_buf,
-				  size_t count, loff_t *ppos)
+static ssize_t wfx_send_pds_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct wfx_dev *wdev = file->private_data;
+	struct wfx_dev *wdev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char *buf;
 	int ret;
 
-	if (*ppos != 0) {
+	if (iocb->ki_pos != 0) {
 		dev_dbg(wdev->dev, "PDS data must be written in one transaction");
 		return -EBUSY;
 	}
-	buf = memdup_user(user_buf, count);
+	buf = iterdup(from, count);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
-	*ppos = *ppos + count;
+	iocb->ki_pos += count;
 	ret = wfx_send_pds(wdev, buf, count);
 	kfree(buf);
 	if (ret < 0)
@@ -226,7 +226,7 @@ static ssize_t wfx_send_pds_write(struct file *file, const char __user *user_buf
 
 static const struct file_operations wfx_send_pds_fops = {
 	.open = simple_open,
-	.write = wfx_send_pds_write,
+	.write_iter = wfx_send_pds_write,
 };
 
 struct dbgfs_hif_msg {
@@ -236,10 +236,10 @@ struct dbgfs_hif_msg {
 	int ret;
 };
 
-static ssize_t wfx_send_hif_msg_write(struct file *file, const char __user *user_buf,
-				      size_t count, loff_t *ppos)
+static ssize_t wfx_send_hif_msg_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct dbgfs_hif_msg *context = file->private_data;
+	struct dbgfs_hif_msg *context = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct wfx_dev *wdev = context->wdev;
 	struct wfx_hif_msg *request;
 
@@ -255,7 +255,7 @@ static ssize_t wfx_send_hif_msg_write(struct file *file, const char __user *user
 	 * memory pattern may help user.
 	 */
 	memset(context->reply, 0xFF, sizeof(context->reply));
-	request = memdup_user(user_buf, count);
+	request = iterdup(from, count);
 	if (IS_ERR(request))
 		return PTR_ERR(request);
 	if (le16_to_cpu(request->len) != count) {
@@ -269,10 +269,10 @@ static ssize_t wfx_send_hif_msg_write(struct file *file, const char __user *user
 	return count;
 }
 
-static ssize_t wfx_send_hif_msg_read(struct file *file, char __user *user_buf,
-				     size_t count, loff_t *ppos)
+static ssize_t wfx_send_hif_msg_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dbgfs_hif_msg *context = file->private_data;
+	struct dbgfs_hif_msg *context = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	int ret;
 
 	if (count > sizeof(context->reply))
@@ -283,7 +283,7 @@ static ssize_t wfx_send_hif_msg_read(struct file *file, char __user *user_buf,
 	if (context->ret < 0)
 		return context->ret;
 	/* Be careful, write() is waiting for a full message while read() only returns a payload */
-	if (copy_to_user(user_buf, context->reply, count))
+	if (!copy_to_iter_full(context->reply, count, to))
 		return -EFAULT;
 
 	return count;
@@ -312,8 +312,8 @@ static int wfx_send_hif_msg_release(struct inode *inode, struct file *file)
 static const struct file_operations wfx_send_hif_msg_fops = {
 	.open = wfx_send_hif_msg_open,
 	.release = wfx_send_hif_msg_release,
-	.write = wfx_send_hif_msg_write,
-	.read = wfx_send_hif_msg_read,
+	.write_iter = wfx_send_hif_msg_write,
+	.read_iter = wfx_send_hif_msg_read,
 };
 
 int wfx_debug_init(struct wfx_dev *wdev)
Signature · 1 line
2.43.0
author maintainer
#319 lore raw

PATCH 313/437 drivers/net/wireless/st: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wireless/st/cw1200/debug.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/st/cw1200/debug.c +5 -5
index 8686929c70df..425fc06a9d38 100644
@@ -332,15 +332,15 @@ static int cw1200_counters_show(struct seq_file *seq, void *v)
 
 DEFINE_SHOW_ATTRIBUTE(cw1200_counters);
 
-static ssize_t cw1200_wsm_dumps(struct file *file,
-	const char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t cw1200_wsm_dumps(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct cw1200_common *priv = file->private_data;
+	struct cw1200_common *priv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	char buf[1];
 
 	if (!count)
 		return -EINVAL;
-	if (copy_from_user(buf, user_buf, 1))
+	if (!copy_from_iter_full(buf, 1, from))
 		return -EFAULT;
 
 	if (buf[0] == '1')
@@ -353,7 +353,7 @@ static ssize_t cw1200_wsm_dumps(struct file *file,
 
 static const struct file_operations fops_wsm_dumps = {
 	.open = simple_open,
-	.write = cw1200_wsm_dumps,
+	.write_iter = cw1200_wsm_dumps,
 	.llseek = default_llseek,
 };
 
Signature · 1 line
2.43.0
author maintainer
#320 lore raw

PATCH 314/437 drivers/net/ieee802154: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/ieee802154/ca8210.c | 29 ++++++++++++-----------------
 1 file changed, 12 insertions(+), 17 deletions(-)
drivers/net/ieee802154/ca8210.c +12 -17
index e685a7f946f0..af2bf8c24572 100644
@@ -2443,14 +2443,12 @@ static int ca8210_test_check_upstream(u8 *buf, void *device_ref)
  * Return: 0 or linux error code
  */
 static ssize_t ca8210_test_int_user_write(
-	struct file        *filp,
-	const char __user  *in_buf,
-	size_t              len,
-	loff_t             *off
-)
+	struct kiocb *iocb,
+	struct iov_iter *from)
 {
 	int ret;
-	struct ca8210_priv *priv = filp->private_data;
+	struct ca8210_priv *priv = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
 	u8 command[CA8210_SPI_BUF_SIZE];
 
 	memset(command, SPI_IDLE, 6);
@@ -2463,7 +2461,7 @@ static ssize_t ca8210_test_int_user_write(
 		return -EBADE;
 	}
 
-	ret = copy_from_user(command, in_buf, len);
+	ret = !copy_from_iter_full(command, len, from);
 	if (ret) {
 		dev_err(
 			&priv->spi->dev,
@@ -2518,18 +2516,15 @@ static ssize_t ca8210_test_int_user_write(
  * Return: number of bytes read
  */
 static ssize_t ca8210_test_int_user_read(
-	struct file  *filp,
-	char __user  *buf,
-	size_t        len,
-	loff_t       *offp
-)
+	struct kiocb *iocb,
+	struct iov_iter *to)
 {
 	int i, cmdlen;
-	struct ca8210_priv *priv = filp->private_data;
+	struct ca8210_priv *priv = iocb->ki_filp->private_data;
 	unsigned char *fifo_buffer;
 	unsigned long bytes_not_copied;
 
-	if (filp->f_flags & O_NONBLOCK) {
+	if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 		/* Non-blocking mode */
 		if (kfifo_is_empty(&priv->test.up_fifo))
 			return 0;
@@ -2551,7 +2546,7 @@ static ssize_t ca8210_test_int_user_read(
 	cmdlen = fifo_buffer[1];
 	bytes_not_copied = cmdlen + 2;
 
-	bytes_not_copied = copy_to_user(buf, fifo_buffer, bytes_not_copied);
+	bytes_not_copied = !copy_to_iter_full(fifo_buffer, bytes_not_copied, to);
 	if (bytes_not_copied > 0) {
 		dev_err(
 			&priv->spi->dev,
@@ -2626,8 +2621,8 @@ static __poll_t ca8210_test_int_poll(
 }
 
 static const struct file_operations test_int_fops = {
-	.read =           ca8210_test_int_user_read,
-	.write =          ca8210_test_int_user_write,
+	.read_iter =      ca8210_test_int_user_read,
+	.write_iter =     ca8210_test_int_user_write,
 	.open =           ca8210_test_int_open,
 	.release =        NULL,
 	.unlocked_ioctl = ca8210_test_int_ioctl,
Signature · 1 line
2.43.0
author maintainer
#321 lore raw

PATCH 315/437 drivers/net/netdevsim: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/netdevsim/dev.c         | 73 ++++++++++++++---------------
 drivers/net/netdevsim/fib.c         | 16 +++----
 drivers/net/netdevsim/health.c      | 12 ++---
 drivers/net/netdevsim/hwstats.c     | 13 +++--
 drivers/net/netdevsim/ipsec.c       | 10 ++--
 drivers/net/netdevsim/psample.c     | 12 ++---
 drivers/net/netdevsim/udp_tunnels.c |  9 ++--
 7 files changed, 69 insertions(+), 76 deletions(-)
drivers/net/netdevsim/dev.c +35 -38
index 92a7a36b93ac..41d49c53da39 100644
@@ -93,11 +93,10 @@ nsim_dev_take_snapshot(struct devlink *devlink,
 	return 0;
 }
 
-static ssize_t nsim_dev_take_snapshot_write(struct file *file,
-					    const char __user *data,
-					    size_t count, loff_t *ppos)
+static ssize_t nsim_dev_take_snapshot_write(struct kiocb *iocb,
+					    struct iov_iter *from)
 {
-	struct nsim_dev *nsim_dev = file->private_data;
+	struct nsim_dev *nsim_dev = iocb->ki_filp->private_data;
 	struct devlink *devlink;
 	u8 *dummy_data;
 	int err;
@@ -124,21 +123,20 @@ static ssize_t nsim_dev_take_snapshot_write(struct file *file,
 		return err;
 	}
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations nsim_dev_take_snapshot_fops = {
 	.open = simple_open,
-	.write = nsim_dev_take_snapshot_write,
+	.write_iter = nsim_dev_take_snapshot_write,
 	.llseek = generic_file_llseek,
 	.owner = THIS_MODULE,
 };
 
-static ssize_t nsim_dev_trap_fa_cookie_read(struct file *file,
-					    char __user *data,
-					    size_t count, loff_t *ppos)
+static ssize_t nsim_dev_trap_fa_cookie_read(struct kiocb *iocb,
+					    struct iov_iter *to)
 {
-	struct nsim_dev *nsim_dev = file->private_data;
+	struct nsim_dev *nsim_dev = iocb->ki_filp->private_data;
 	struct flow_action_cookie *fa_cookie;
 	unsigned int buf_len;
 	ssize_t ret;
@@ -159,7 +157,7 @@ static ssize_t nsim_dev_trap_fa_cookie_read(struct file *file,
 	bin2hex(buf, fa_cookie->cookie, fa_cookie->cookie_len);
 	spin_unlock(&nsim_dev->fa_cookie_lock);
 
-	ret = simple_read_from_buffer(data, count, ppos, buf, buf_len);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, buf_len, to);
 
 	kfree(buf);
 	return ret;
@@ -169,23 +167,23 @@ static ssize_t nsim_dev_trap_fa_cookie_read(struct file *file,
 	return ret;
 }
 
-static ssize_t nsim_dev_trap_fa_cookie_write(struct file *file,
-					     const char __user *data,
-					     size_t count, loff_t *ppos)
+static ssize_t nsim_dev_trap_fa_cookie_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct nsim_dev *nsim_dev = file->private_data;
+	struct nsim_dev *nsim_dev = iocb->ki_filp->private_data;
 	struct flow_action_cookie *fa_cookie;
+	size_t count = iov_iter_count(from);
 	size_t cookie_len;
 	ssize_t ret;
 	char *buf;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return -EINVAL;
 	cookie_len = (count - 1) / 2;
 	if ((count - 1) % 2)
 		return -EINVAL;
 
-	buf = memdup_user(data, count);
+	buf = iterdup(from, count);
 	if (IS_ERR(buf))
 		return PTR_ERR(buf);
 
@@ -218,42 +216,42 @@ static ssize_t nsim_dev_trap_fa_cookie_write(struct file *file,
 
 static const struct file_operations nsim_dev_trap_fa_cookie_fops = {
 	.open = simple_open,
-	.read = nsim_dev_trap_fa_cookie_read,
-	.write = nsim_dev_trap_fa_cookie_write,
+	.read_iter = nsim_dev_trap_fa_cookie_read,
+	.write_iter = nsim_dev_trap_fa_cookie_write,
 	.llseek = generic_file_llseek,
 	.owner = THIS_MODULE,
 };
 
-static ssize_t nsim_bus_dev_max_vfs_read(struct file *file, char __user *data,
-					 size_t count, loff_t *ppos)
+static ssize_t nsim_bus_dev_max_vfs_read(struct kiocb *iocb,
+					 struct iov_iter *to)
 {
-	struct nsim_dev *nsim_dev = file->private_data;
+	struct nsim_dev *nsim_dev = iocb->ki_filp->private_data;
 	char buf[11];
 	ssize_t len;
 
 	len = scnprintf(buf, sizeof(buf), "%u\n",
 			READ_ONCE(nsim_dev->nsim_bus_dev->max_vfs));
 
-	return simple_read_from_buffer(data, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t nsim_bus_dev_max_vfs_write(struct file *file,
-					  const char __user *data,
-					  size_t count, loff_t *ppos)
+static ssize_t nsim_bus_dev_max_vfs_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
 	struct nsim_vf_config *vfconfigs;
+	size_t count = iov_iter_count(from);
 	struct nsim_dev *nsim_dev;
 	char buf[10];
 	ssize_t ret;
 	u32 val;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	if (count >= sizeof(buf))
 		return -ENOSPC;
 
-	ret = copy_from_user(buf, data, count);
+	ret = !copy_from_iter_full(buf, count, from);
 	if (ret)
 		return -EFAULT;
 	buf[count] = '\0';
@@ -271,7 +269,7 @@ static ssize_t nsim_bus_dev_max_vfs_write(struct file *file,
 	if (!vfconfigs)
 		return -ENOMEM;
 
-	nsim_dev = file->private_data;
+	nsim_dev = iocb->ki_filp->private_data;
 	devl_lock(priv_to_devlink(nsim_dev));
 	/* Reject if VFs are configured */
 	if (nsim_dev_get_vfs(nsim_dev)) {
@@ -279,7 +277,7 @@ static ssize_t nsim_bus_dev_max_vfs_write(struct file *file,
 	} else {
 		swap(nsim_dev->vfconfigs, vfconfigs);
 		WRITE_ONCE(nsim_dev->nsim_bus_dev->max_vfs, val);
-		*ppos += count;
+		iocb->ki_pos += count;
 		ret = count;
 	}
 	devl_unlock(priv_to_devlink(nsim_dev));
@@ -290,8 +288,8 @@ static ssize_t nsim_bus_dev_max_vfs_write(struct file *file,
 
 static const struct file_operations nsim_dev_max_vfs_fops = {
 	.open = simple_open,
-	.read = nsim_bus_dev_max_vfs_read,
-	.write = nsim_bus_dev_max_vfs_write,
+	.read_iter = nsim_bus_dev_max_vfs_read,
+	.write_iter = nsim_bus_dev_max_vfs_write,
 	.llseek = generic_file_llseek,
 	.owner = THIS_MODULE,
 };
@@ -367,23 +365,22 @@ static void nsim_dev_debugfs_exit(struct nsim_dev *nsim_dev)
 	debugfs_remove_recursive(nsim_dev->ddir);
 }
 
-static ssize_t nsim_dev_rate_parent_read(struct file *file,
-					 char __user *data,
-					 size_t count, loff_t *ppos)
+static ssize_t nsim_dev_rate_parent_read(struct kiocb *iocb,
+					 struct iov_iter *to)
 {
-	char **name_ptr = file->private_data;
+	char **name_ptr = iocb->ki_filp->private_data;
 	size_t len;
 
 	if (!*name_ptr)
 		return 0;
 
 	len = strlen(*name_ptr);
-	return simple_read_from_buffer(data, count, ppos, *name_ptr, len);
+	return simple_copy_to_iter(*name_ptr, &iocb->ki_pos, len, to);
 }
 
 static const struct file_operations nsim_dev_rate_parent_fops = {
 	.open = simple_open,
-	.read = nsim_dev_rate_parent_read,
+	.read_iter = nsim_dev_rate_parent_read,
 	.llseek = generic_file_llseek,
 	.owner = THIS_MODULE,
 };
drivers/net/netdevsim/fib.c +8 -8
index a1f91ff8ec56..4ab1b7944f3e 100644
@@ -1361,15 +1361,15 @@ static void nsim_nexthop_free(void *ptr, void *arg)
 	nsim_nexthop_destroy(nexthop);
 }
 
-static ssize_t nsim_nexthop_bucket_activity_write(struct file *file,
-						  const char __user *user_buf,
-						  size_t size, loff_t *ppos)
+static ssize_t nsim_nexthop_bucket_activity_write(struct kiocb *iocb,
+						  struct iov_iter *from)
 {
-	struct nsim_fib_data *data = file->private_data;
+	struct nsim_fib_data *data = iocb->ki_filp->private_data;
 	struct net *net = devlink_net(data->devlink);
+	size_t size = iov_iter_count(from);
 	struct nsim_nexthop *nexthop;
 	unsigned long *activity;
-	loff_t pos = *ppos;
+	loff_t pos = iocb->ki_pos;
 	u16 bucket_index;
 	char buf[128];
 	int err = 0;
@@ -1379,7 +1379,7 @@ static ssize_t nsim_nexthop_bucket_activity_write(struct file *file,
 		return -EINVAL;
 	if (size > sizeof(buf))
 		return -EINVAL;
-	if (copy_from_user(buf, user_buf, size))
+	if (!copy_from_iter_full(buf, size, from))
 		return -EFAULT;
 	if (sscanf(buf, "%u %hu", &nhid, &bucket_index) != 2)
 		return -EINVAL;
@@ -1407,13 +1407,13 @@ static ssize_t nsim_nexthop_bucket_activity_write(struct file *file,
 out:
 	rtnl_unlock();
 
-	*ppos = size;
+	iocb->ki_pos = size;
 	return err ?: size;
 }
 
 static const struct file_operations nsim_nexthop_bucket_activity_fops = {
 	.open = simple_open,
-	.write = nsim_nexthop_bucket_activity_write,
+	.write_iter = nsim_nexthop_bucket_activity_write,
 	.llseek = no_llseek,
 	.owner = THIS_MODULE,
 };
drivers/net/netdevsim/health.c +6 -6
index 70e8bdf34be9..b1c23d23bee2 100644
@@ -140,16 +140,16 @@ struct devlink_health_reporter_ops nsim_dev_dummy_reporter_ops = {
 	.diagnose = nsim_dev_dummy_reporter_diagnose,
 };
 
-static ssize_t nsim_dev_health_break_write(struct file *file,
-					   const char __user *data,
-					   size_t count, loff_t *ppos)
+static ssize_t nsim_dev_health_break_write(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct nsim_dev_health *health = file->private_data;
+	struct nsim_dev_health *health = iocb->ki_filp->private_data;
 	struct nsim_dev_dummy_reporter_ctx ctx;
+	size_t count = iov_iter_count(from);
 	char *break_msg;
 	int err;
 
-	break_msg = memdup_user_nul(data, count);
+	break_msg = iterdup_nul(from, count);
 	if (IS_ERR(break_msg))
 		return PTR_ERR(break_msg);
 
@@ -168,7 +168,7 @@ static ssize_t nsim_dev_health_break_write(struct file *file,
 
 static const struct file_operations nsim_dev_health_break_fops = {
 	.open = simple_open,
-	.write = nsim_dev_health_break_write,
+	.write_iter = nsim_dev_health_break_write,
 	.llseek = generic_file_llseek,
 	.owner = THIS_MODULE,
 };
drivers/net/netdevsim/hwstats.c +6 -7
index 0e58aa7f0374..8e9b13c464a8 100644
@@ -337,20 +337,19 @@ struct nsim_dev_hwstats_fops {
 };
 
 static ssize_t
-nsim_dev_hwstats_do_write(struct file *file,
-			  const char __user *data,
-			  size_t count, loff_t *ppos)
+nsim_dev_hwstats_do_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct nsim_dev_hwstats *hwstats = file->private_data;
+	struct nsim_dev_hwstats *hwstats = iocb->ki_filp->private_data;
 	struct nsim_dev_hwstats_fops *hwsfops;
+	size_t count = iov_iter_count(from);
 	struct list_head *hwsdev_list;
 	int ifindex;
 	int err;
 
-	hwsfops = container_of(debugfs_real_fops(file),
+	hwsfops = container_of(debugfs_real_fops(iocb->ki_filp),
 			       struct nsim_dev_hwstats_fops, fops);
 
-	err = kstrtoint_from_user(data, count, 0, &ifindex);
+	err = kstrtoint_from_iter(from, count, 0, &ifindex);
 	if (err)
 		return err;
 
@@ -385,7 +384,7 @@ nsim_dev_hwstats_do_write(struct file *file,
 	{							\
 		.fops = {					\
 			.open = simple_open,			\
-			.write = nsim_dev_hwstats_do_write,	\
+			.write_iter = nsim_dev_hwstats_do_write,	\
 			.llseek = generic_file_llseek,		\
 			.owner = THIS_MODULE,			\
 		},						\
drivers/net/netdevsim/ipsec.c +4 -6
index f0d58092e7e9..16535c552d12 100644
@@ -9,11 +9,9 @@
 
 #define NSIM_IPSEC_AUTH_BITS	128
 
-static ssize_t nsim_dbg_netdev_ops_read(struct file *filp,
-					char __user *buffer,
-					size_t count, loff_t *ppos)
+static ssize_t nsim_dbg_netdev_ops_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct netdevsim *ns = filp->private_data;
+	struct netdevsim *ns = iocb->ki_filp->private_data;
 	struct nsim_ipsec *ipsec = &ns->ipsec;
 	size_t bufsize;
 	char *buf, *p;
@@ -53,7 +51,7 @@ static ssize_t nsim_dbg_netdev_ops_read(struct file *filp,
 			       sap->key[2], sap->key[3]);
 	}
 
-	len = simple_read_from_buffer(buffer, count, ppos, buf, p - buf);
+	len = simple_copy_to_iter(buf, &iocb->ki_pos, p - buf, to);
 
 	kfree(buf);
 	return len;
@@ -62,7 +60,7 @@ static ssize_t nsim_dbg_netdev_ops_read(struct file *filp,
 static const struct file_operations ipsec_dbg_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = nsim_dbg_netdev_ops_read,
+	.read_iter = nsim_dbg_netdev_ops_read,
 };
 
 static int nsim_ipsec_find_empty_idx(struct nsim_ipsec *ipsec)
drivers/net/netdevsim/psample.c +6 -6
index f0c6477dd0ae..21353aea4f4a 100644
@@ -168,15 +168,15 @@ static int nsim_dev_psample_disable(struct nsim_dev *nsim_dev)
 	return 0;
 }
 
-static ssize_t nsim_dev_psample_enable_write(struct file *file,
-					     const char __user *data,
-					     size_t count, loff_t *ppos)
+static ssize_t nsim_dev_psample_enable_write(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
-	struct nsim_dev *nsim_dev = file->private_data;
+	struct nsim_dev *nsim_dev = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	bool enable;
 	int err;
 
-	err = kstrtobool_from_user(data, count, &enable);
+	err = kstrtobool_from_iter(from, count, &enable);
 	if (err)
 		return err;
 
@@ -190,7 +190,7 @@ static ssize_t nsim_dev_psample_enable_write(struct file *file,
 
 static const struct file_operations nsim_psample_enable_fops = {
 	.open = simple_open,
-	.write = nsim_dev_psample_enable_write,
+	.write_iter = nsim_dev_psample_enable_write,
 	.llseek = generic_file_llseek,
 	.owner = THIS_MODULE,
 };
drivers/net/netdevsim/udp_tunnels.c +4 -5
index 02dc3123eb6c..efbd5af4562c 100644
@@ -106,10 +106,9 @@ static const struct udp_tunnel_nic_info nsim_udp_tunnel_info = {
 };
 
 static ssize_t
-nsim_udp_tunnels_info_reset_write(struct file *file, const char __user *data,
-				  size_t count, loff_t *ppos)
+nsim_udp_tunnels_info_reset_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct net_device *dev = file->private_data;
+	struct net_device *dev = iocb->ki_filp->private_data;
 	struct netdevsim *ns = netdev_priv(dev);
 
 	memset(ns->udp_ports.ports, 0, sizeof(ns->udp_ports.__ports));
@@ -117,12 +116,12 @@ nsim_udp_tunnels_info_reset_write(struct file *file, const char __user *data,
 	udp_tunnel_nic_reset_ntf(dev);
 	rtnl_unlock();
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations nsim_udp_tunnels_info_reset_fops = {
 	.open = simple_open,
-	.write = nsim_udp_tunnels_info_reset_write,
+	.write_iter = nsim_udp_tunnels_info_reset_write,
 	.llseek = generic_file_llseek,
 	.owner = THIS_MODULE,
 };
Signature · 1 line
2.43.0
author maintainer
#322 lore raw

PATCH 316/437 drivers/net/ppp: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/ppp/ppp_generic.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/ppp/ppp_generic.c +7 -6
index fe380fe196e7..6601b6c3e2b2 100644
@@ -492,11 +492,12 @@ static ssize_t ppp_read(struct file *file, char __user *buf,
  out:
 	return ret;
 }
+FOPS_READ_ITER_HELPER(ppp_read);
 
-static ssize_t ppp_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t ppp_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct ppp_file *pf = file->private_data;
+	struct ppp_file *pf = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct sk_buff *skb;
 	ssize_t ret;
 
@@ -511,7 +512,7 @@ static ssize_t ppp_write(struct file *file, const char __user *buf,
 		goto out;
 	skb_reserve(skb, pf->hdrlen);
 	ret = -EFAULT;
-	if (copy_from_user(skb_put(skb, count), buf, count)) {
+	if (!copy_from_iter_full(skb_put(skb, count), count, from)) {
 		kfree_skb(skb);
 		goto out;
 	}
@@ -1092,8 +1093,8 @@ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf,
 
 static const struct file_operations ppp_device_fops = {
 	.owner		= THIS_MODULE,
-	.read		= ppp_read,
-	.write		= ppp_write,
+	.read_iter	= ppp_read_iter,
+	.write_iter	= ppp_write,
 	.poll		= ppp_poll,
 	.unlocked_ioctl	= ppp_ioctl,
 #ifdef CONFIG_COMPAT
Signature · 1 line
2.43.0
author maintainer
#323 lore raw

PATCH 317/437 drivers/net/wwan: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/wwan/iosm/iosm_ipc_trace.c | 21 ++++++-------
 drivers/net/wwan/wwan_core.c           | 26 ++++++++--------
 drivers/net/wwan/wwan_hwsim.c          | 42 ++++++++++++--------------
 3 files changed, 42 insertions(+), 47 deletions(-)
drivers/net/wwan/iosm/iosm_ipc_trace.c +10 -11
index eeecfa3d10c5..8374bd4826bc 100644
@@ -70,10 +70,9 @@ static struct rchan_callbacks relay_callbacks = {
 };
 
 /* Copy the trace control mode to user buffer */
-static ssize_t ipc_trace_ctrl_file_read(struct file *filp, char __user *buffer,
-					size_t count, loff_t *ppos)
+static ssize_t ipc_trace_ctrl_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct iosm_trace *ipc_trace = filp->private_data;
+	struct iosm_trace *ipc_trace = iocb->ki_filp->private_data;
 	char buf[16];
 	int len;
 
@@ -81,19 +80,19 @@ static ssize_t ipc_trace_ctrl_file_read(struct file *filp, char __user *buffer,
 	len = snprintf(buf, sizeof(buf), "%d\n", ipc_trace->mode);
 	mutex_unlock(&ipc_trace->trc_mutex);
 
-	return simple_read_from_buffer(buffer, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
 /* Open and close the trace channel depending on user input */
-static ssize_t ipc_trace_ctrl_file_write(struct file *filp,
-					 const char __user *buffer,
-					 size_t count, loff_t *ppos)
+static ssize_t ipc_trace_ctrl_file_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct iosm_trace *ipc_trace = filp->private_data;
+	struct iosm_trace *ipc_trace = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	unsigned long val;
 	int ret;
 
-	ret = kstrtoul_from_user(buffer, count, 10, &val);
+	ret = kstrtoul_from_iter(from, count, 10, &val);
 	if (ret)
 		return ret;
 
@@ -122,8 +121,8 @@ static ssize_t ipc_trace_ctrl_file_write(struct file *filp,
 
 static const struct file_operations ipc_trace_fops = {
 	.open = simple_open,
-	.write = ipc_trace_ctrl_file_write,
-	.read  = ipc_trace_ctrl_file_read,
+	.write_iter = ipc_trace_ctrl_file_write,
+	.read_iter  = ipc_trace_ctrl_file_read,
 };
 
 /**
drivers/net/wwan/wwan_core.c +13 -13
index 17431f1b1a0c..1007d0255427 100644
@@ -684,15 +684,15 @@ static int wwan_port_fops_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t wwan_port_fops_read(struct file *filp, char __user *buf,
-				   size_t count, loff_t *ppos)
+static ssize_t wwan_port_fops_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct wwan_port *port = filp->private_data;
+	struct wwan_port *port = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct sk_buff *skb;
 	size_t copied;
 	int ret;
 
-	ret = wwan_wait_rx(port, !!(filp->f_flags & O_NONBLOCK));
+	ret = wwan_wait_rx(port, !!(iocb->ki_filp->f_flags & O_NONBLOCK));
 	if (ret)
 		return ret;
 
@@ -701,7 +701,7 @@ static ssize_t wwan_port_fops_read(struct file *filp, char __user *buf,
 		return -EIO;
 
 	copied = min_t(size_t, count, skb->len);
-	if (copy_to_user(buf, skb->data, copied)) {
+	if (!copy_to_iter_full(skb->data, copied, to)) {
 		kfree_skb(skb);
 		return -EFAULT;
 	}
@@ -716,15 +716,15 @@ static ssize_t wwan_port_fops_read(struct file *filp, char __user *buf,
 	return copied;
 }
 
-static ssize_t wwan_port_fops_write(struct file *filp, const char __user *buf,
-				    size_t count, loff_t *offp)
+static ssize_t wwan_port_fops_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct sk_buff *skb, *head = NULL, *tail = NULL;
-	struct wwan_port *port = filp->private_data;
+	struct wwan_port *port = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	size_t frag_len, remain = count;
 	int ret;
 
-	ret = wwan_wait_tx(port, !!(filp->f_flags & O_NONBLOCK));
+	ret = wwan_wait_tx(port, !!(iocb->ki_filp->f_flags & O_NONBLOCK));
 	if (ret)
 		return ret;
 
@@ -747,7 +747,7 @@ static ssize_t wwan_port_fops_write(struct file *filp, const char __user *buf,
 			tail = skb;
 		}
 
-		if (copy_from_user(skb_put(skb, frag_len), buf + count - remain, frag_len)) {
+		if (!copy_from_iter_full(skb_put(skb, frag_len), frag_len, from)) {
 			ret = -EFAULT;
 			goto freeskb;
 		}
@@ -759,7 +759,7 @@ static ssize_t wwan_port_fops_write(struct file *filp, const char __user *buf,
 		}
 	} while (remain -= frag_len);
 
-	ret = wwan_port_op_tx(port, head, !!(filp->f_flags & O_NONBLOCK));
+	ret = wwan_port_op_tx(port, head, !!(iocb->ki_filp->f_flags & O_NONBLOCK));
 	if (!ret)
 		return count;
 
@@ -897,8 +897,8 @@ static const struct file_operations wwan_port_fops = {
 	.owner = THIS_MODULE,
 	.open = wwan_port_fops_open,
 	.release = wwan_port_fops_release,
-	.read = wwan_port_fops_read,
-	.write = wwan_port_fops_write,
+	.read_iter = wwan_port_fops_read,
+	.write_iter = wwan_port_fops_write,
 	.poll = wwan_port_fops_poll,
 	.unlocked_ioctl = wwan_port_fops_ioctl,
 #ifdef CONFIG_COMPAT
drivers/net/wwan/wwan_hwsim.c +19 -23

99 lines not on this page · raw message

Signature · 1 line
2.43.0
author maintainer
#324 lore raw

PATCH 318/437 drivers/net/xen-netback: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/net/xen-netback/xenbus.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/net/xen-netback/xenbus.c +7 -12
index a78a25b87240..5f2ef4d6bb17 100644
@@ -102,26 +102,21 @@ static int xenvif_read_io_ring(struct seq_file *m, void *v)
 #define XENVIF_KICK_STR "kick"
 #define BUFFER_SIZE     32
 
-static ssize_t
-xenvif_write_io_ring(struct file *filp, const char __user *buf, size_t count,
-		     loff_t *ppos)
+static ssize_t xenvif_write_io_ring(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct xenvif_queue *queue =
-		((struct seq_file *)filp->private_data)->private;
+		((struct seq_file *)iocb->ki_filp->private_data)->private;
+	size_t count = iov_iter_count(from);
 	int len;
 	char write[BUFFER_SIZE];
 
 	/* don't allow partial writes and check the length */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 	if (count >= sizeof(write))
 		return -ENOSPC;
 
-	len = simple_write_to_buffer(write,
-				     sizeof(write) - 1,
-				     ppos,
-				     buf,
-				     count);
+	len = simple_copy_from_iter(write, &iocb->ki_pos, sizeof(write) - 1, from);
 	if (len < 0)
 		return len;
 
@@ -152,10 +147,10 @@ static int xenvif_io_ring_open(struct inode *inode, struct file *filp)
 static const struct file_operations xenvif_dbg_io_ring_ops_fops = {
 	.owner = THIS_MODULE,
 	.open = xenvif_io_ring_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = single_release,
-	.write = xenvif_write_io_ring,
+	.write_iter = xenvif_write_io_ring,
 };
 
 static int xenvif_ctrl_show(struct seq_file *m, void *v)
Signature · 1 line
2.43.0
author maintainer
#325 lore raw

PATCH 319/437 drivers/net/ethernet/broadcom-bnxt: convert to read/write iterators

In reply to Jens Axboe

From: Bui Quang Minh <[email protected]>

---
 drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_debugfs.c +6 -7
index 156c2404854f..777f2e892869 100644
@@ -17,15 +17,14 @@
 
 static struct dentry *bnxt_debug_mnt;
 
-static ssize_t debugfs_dim_read(struct file *filep,
-				char __user *buffer,
-				size_t count, loff_t *ppos)
+static ssize_t debugfs_dim_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct dim *dim = filep->private_data;
+	struct dim *dim = iocb->ki_filp->private_data;
 	int len;
 	char *buf;
+	size_t count = iov_iter_count(to);
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return 0;
 	if (!dim)
 		return -ENODEV;
@@ -50,7 +49,7 @@ static ssize_t debugfs_dim_read(struct file *filep,
 		kfree(buf);
 		return -ENOSPC;
 	}
-	len = simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
+	len = simple_copy_to_iter(buf, &iocb->ki_pos, strlen(buf), to);
 	kfree(buf);
 	return len;
 }
@@ -58,7 +57,7 @@ static ssize_t debugfs_dim_read(struct file *filep,
 static const struct file_operations debugfs_dim_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read = debugfs_dim_read,
+	.read_iter = debugfs_dim_read_iter,
 };
 
 static void debugfs_dim_ring_init(struct dim *dim, int ring_idx,
Signature · 1 line
2.43.0
author maintainer
#326 lore raw

PATCH 320/437 drivers/net/brocade-bnad: ensure the copied buf is NULL terminated

In reply to Jens Axboe

From: Bui Quang Minh <[email protected]>

Currently, we allocate a nbytes-sized kernel buffer and copy nbytes from userspace to that buffer. Later, we use scanf on this buffer but we don't ensure that the string is terminated inside the buffer, this can lead to OOB read when using scanf. Fix this issue by using memdup_user_nul instead of memdup_user.

Fixes 7afc5dbde091 ("bna: Add debugfs interface.")
---
 drivers/net/ethernet/brocade/bna/bnad_debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/brocade/bna/bnad_debugfs.c +2 -2
index 7246e13dd559..97291bfbeea5 100644
@@ -312,7 +312,7 @@ bnad_debugfs_write_regrd(struct file *file, const char __user *buf,
 	void *kern_buf;
 
 	/* Copy the user space buf */
-	kern_buf = memdup_user(buf, nbytes);
+	kern_buf = memdup_user_nul(buf, nbytes);
 	if (IS_ERR(kern_buf))
 		return PTR_ERR(kern_buf);
 
@@ -372,7 +372,7 @@ bnad_debugfs_write_regwr(struct file *file, const char __user *buf,
 	void *kern_buf;
 
 	/* Copy the user space buf */
-	kern_buf = memdup_user(buf, nbytes);
+	kern_buf = memdup_user_nul(buf, nbytes);
 	if (IS_ERR(kern_buf))
 		return PTR_ERR(kern_buf);
 
Signature · 1 line
2.43.0
author maintainer
#327 lore raw

PATCH 321/437 drivers/net/brocade-bnad: convert to read/write iterators

In reply to Jens Axboe

From: Bui Quang Minh <[email protected]>

---
 .../net/ethernet/brocade/bna/bnad_debugfs.c   | 47 +++++++++----------
 1 file changed, 23 insertions(+), 24 deletions(-)
drivers/net/ethernet/brocade/bna/bnad_debugfs.c +23 -24
index 97291bfbeea5..88451f739f1f 100644
@@ -229,16 +229,15 @@ bnad_debugfs_lseek(struct file *file, loff_t offset, int orig)
 }
 
 static ssize_t
-bnad_debugfs_read(struct file *file, char __user *buf,
-		  size_t nbytes, loff_t *pos)
+bnad_debugfs_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct bnad_debug_info *debug = file->private_data;
+	struct bnad_debug_info *debug = iocb->ki_filp->private_data;
 
 	if (!debug || !debug->debug_buffer)
 		return 0;
 
-	return simple_read_from_buffer(buf, nbytes, pos,
-				debug->debug_buffer, debug->buffer_len);
+	return simple_copy_to_iter(debug->debug_buffer, &iocb->ki_pos,
+				   debug->buffer_len, to);
 }
 
 #define BFA_REG_CT_ADDRSZ	(0x40000)
@@ -275,18 +274,18 @@ bna_reg_offset_check(struct bfa_ioc *ioc, u32 offset, u32 len)
 }
 
 static ssize_t
-bnad_debugfs_read_regrd(struct file *file, char __user *buf,
-			size_t nbytes, loff_t *pos)
+bnad_debugfs_read_regrd_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct bnad_debug_info *regrd_debug = file->private_data;
+	struct bnad_debug_info *regrd_debug = iocb->ki_filp->private_data;
 	struct bnad *bnad = (struct bnad *)regrd_debug->i_private;
 	ssize_t rc;
+	loff_t *pos = &iocb->ki_pos;
+	size_t nbytes = iov_iter_count(to);
 
 	if (!bnad->regdata)
 		return 0;
 
-	rc = simple_read_from_buffer(buf, nbytes, pos,
-			bnad->regdata, bnad->reglen);
+	rc = simple_copy_to_iter(bnad->regdata, pos, bnad->reglen, to);
 
 	if ((*pos + nbytes) >= bnad->reglen) {
 		kfree(bnad->regdata);
@@ -298,10 +297,9 @@ bnad_debugfs_read_regrd(struct file *file, char __user *buf,
 }
 
 static ssize_t
-bnad_debugfs_write_regrd(struct file *file, const char __user *buf,
-		size_t nbytes, loff_t *ppos)
+bnad_debugfs_write_regrd_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct bnad_debug_info *regrd_debug = file->private_data;
+	struct bnad_debug_info *regrd_debug = iocb->ki_filp->private_data;
 	struct bnad *bnad = (struct bnad *)regrd_debug->i_private;
 	struct bfa_ioc *ioc = &bnad->bna.ioceth.ioc;
 	int rc, i;
@@ -310,9 +308,10 @@ bnad_debugfs_write_regrd(struct file *file, const char __user *buf,
 	void __iomem *rb, *reg_addr;
 	unsigned long flags;
 	void *kern_buf;
+	size_t nbytes = iov_iter_count(from);
 
 	/* Copy the user space buf */
-	kern_buf = memdup_user_nul(buf, nbytes);
+	kern_buf = iterdup_nul(from, nbytes);
 	if (IS_ERR(kern_buf))
 		return PTR_ERR(kern_buf);
 
@@ -359,10 +358,9 @@ bnad_debugfs_write_regrd(struct file *file, const char __user *buf,
 }
 
 static ssize_t
-bnad_debugfs_write_regwr(struct file *file, const char __user *buf,
-		size_t nbytes, loff_t *ppos)
+bnad_debugfs_write_regwr_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct bnad_debug_info *debug = file->private_data;
+	struct bnad_debug_info *debug = iocb->ki_filp->private_data;
 	struct bnad *bnad = (struct bnad *)debug->i_private;
 	struct bfa_ioc *ioc = &bnad->bna.ioceth.ioc;
 	int rc;
@@ -370,9 +368,10 @@ bnad_debugfs_write_regwr(struct file *file, const char __user *buf,
 	void __iomem *reg_addr;
 	unsigned long flags;
 	void *kern_buf;
+	size_t nbytes = iov_iter_count(from);
 
 	/* Copy the user space buf */
-	kern_buf = memdup_user_nul(buf, nbytes);
+	kern_buf = iterdup_nul(from, nbytes);
 	if (IS_ERR(kern_buf))
 		return PTR_ERR(kern_buf);
 
@@ -434,7 +433,7 @@ static const struct file_operations bnad_debugfs_op_fwtrc = {
 	.owner		=	THIS_MODULE,
 	.open		=	bnad_debugfs_open_fwtrc,
 	.llseek		=	bnad_debugfs_lseek,
-	.read		=	bnad_debugfs_read,
+	.read_iter	=	bnad_debugfs_read_iter,
 	.release	=	bnad_debugfs_buffer_release,
 };
 
@@ -442,7 +441,7 @@ static const struct file_operations bnad_debugfs_op_fwsave = {
 	.owner		=	THIS_MODULE,
 	.open		=	bnad_debugfs_open_fwsave,
 	.llseek		=	bnad_debugfs_lseek,
-	.read		=	bnad_debugfs_read,
+	.read_iter	=	bnad_debugfs_read_iter,
 	.release	=	bnad_debugfs_buffer_release,
 };
 
@@ -450,8 +449,8 @@ static const struct file_operations bnad_debugfs_op_regrd = {
 	.owner		=       THIS_MODULE,
 	.open		=	bnad_debugfs_open_reg,
 	.llseek		=	bnad_debugfs_lseek,
-	.read		=	bnad_debugfs_read_regrd,
-	.write		=	bnad_debugfs_write_regrd,
+	.read_iter	=	bnad_debugfs_read_regrd_iter,
+	.write_iter	=	bnad_debugfs_write_regrd_iter,
 	.release	=	bnad_debugfs_release,
 };
 
@@ -459,7 +458,7 @@ static const struct file_operations bnad_debugfs_op_regwr = {
 	.owner		=	THIS_MODULE,
 	.open		=	bnad_debugfs_open_reg,
 	.llseek		=	bnad_debugfs_lseek,
-	.write		=	bnad_debugfs_write_regwr,
+	.write_iter	=	bnad_debugfs_write_regwr_iter,
 	.release	=	bnad_debugfs_release,
 };
 
@@ -467,7 +466,7 @@ static const struct file_operations bnad_debugfs_op_drvinfo = {
 	.owner		=	THIS_MODULE,
 	.open		=	bnad_debugfs_open_drvinfo,
 	.llseek		=	bnad_debugfs_lseek,
-	.read		=	bnad_debugfs_read,
+	.read_iter	=	bnad_debugfs_read_iter,
 	.release	=	bnad_debugfs_buffer_release,
 };
 
Signature · 1 line
2.43.0
author maintainer
#328 lore raw

PATCH 322/437 drivers/net/ethernet/intel-ice: ensure the copied buf is NULL terminated

In reply to Jens Axboe

From: Bui Quang Minh <[email protected]>

Currently, we allocate a count-sized kernel buffer and copy count bytes from userspace to that buffer. Later, we use sscanf on this buffer but we don't ensure that the string is terminated inside the buffer, this can lead to OOB read when using sscanf. Fix this issue by using memdup_user_nul instead of memdup_user.

Fixes 96a9a9341cda ("ice: configure FW logging")
Fixes 73671c3162c8 ("ice: enable FW logging")
---
 drivers/net/ethernet/intel/ice/ice_debugfs.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_debugfs.c +4 -4
index d252d98218d0..9fc0fd95a13d 100644
@@ -171,7 +171,7 @@ ice_debugfs_module_write(struct file *filp, const char __user *buf,
 	if (*ppos != 0 || count > 8)
 		return -EINVAL;
 
-	cmd_buf = memdup_user(buf, count);
+	cmd_buf = memdup_user_nul(buf, count);
 	if (IS_ERR(cmd_buf))
 		return PTR_ERR(cmd_buf);
 
@@ -257,7 +257,7 @@ ice_debugfs_nr_messages_write(struct file *filp, const char __user *buf,
 	if (*ppos != 0 || count > 4)
 		return -EINVAL;
 
-	cmd_buf = memdup_user(buf, count);
+	cmd_buf = memdup_user_nul(buf, count);
 	if (IS_ERR(cmd_buf))
 		return PTR_ERR(cmd_buf);
 
@@ -332,7 +332,7 @@ ice_debugfs_enable_write(struct file *filp, const char __user *buf,
 	if (*ppos != 0 || count > 2)
 		return -EINVAL;
 
-	cmd_buf = memdup_user(buf, count);
+	cmd_buf = memdup_user_nul(buf, count);
 	if (IS_ERR(cmd_buf))
 		return PTR_ERR(cmd_buf);
 
@@ -428,7 +428,7 @@ ice_debugfs_log_size_write(struct file *filp, const char __user *buf,
 	if (*ppos != 0 || count > 5)
 		return -EINVAL;
 
-	cmd_buf = memdup_user(buf, count);
+	cmd_buf = memdup_user_nul(buf, count);
 	if (IS_ERR(cmd_buf))
 		return PTR_ERR(cmd_buf);
 
Signature · 1 line
2.43.0
author maintainer
#329 lore raw

PATCH 323/437 drivers/net/ethernet/intel: convert to read/write iterators

In reply to Jens Axboe

From: Bui Quang Minh <[email protected]>

---
 .../net/ethernet/intel/fm10k/fm10k_debugfs.c  |  10 +-
 .../net/ethernet/intel/i40e/i40e_debugfs.c    | 103 +++++-----
 drivers/net/ethernet/intel/ice/ice_debugfs.c  | 181 ++++++++----------
 .../net/ethernet/intel/ixgbe/ixgbe_debugfs.c  |  99 ++++------
 4 files changed, 173 insertions(+), 220 deletions(-)
drivers/net/ethernet/intel/fm10k/fm10k_debugfs.c +5 -5
index 5c77054d67c6..7995883a2c27 100644
@@ -132,11 +132,11 @@ static int fm10k_dbg_desc_open(struct inode *inode, struct file *filep)
 }
 
 static const struct file_operations fm10k_dbg_desc_fops = {
-	.owner   = THIS_MODULE,
-	.open    = fm10k_dbg_desc_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release,
+	.owner     = THIS_MODULE,
+	.open      = fm10k_dbg_desc_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release,
 };
 
 /**
drivers/net/ethernet/intel/i40e/i40e_debugfs.c +46 -57

199 lines not on this page · raw message

drivers/net/ethernet/intel/ice/ice_debugfs.c +80 -101

340 lines not on this page · raw message

drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c +42 -57

168 lines not on this page · raw message

Signature · 1 line
2.43.0
author maintainer
#330 lore raw

PATCH 324/437 drivers/net/ethernet/chelsio: convert to read/write iterators

In reply to Jens Axboe

From: Bui Quang Minh <[email protected]>

---
 .../ethernet/chelsio/cxgb4/cxgb4_debugfs.c    | 321 +++++++++---------
 drivers/net/ethernet/chelsio/cxgb4/l2t.c      |   2 +-
 2 files changed, 164 insertions(+), 159 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +163 -158
index 14e0d989c3ba..a3b94ceea07d 100644
@@ -227,11 +227,11 @@ static int cim_la_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations cim_la_fops = {
-	.owner   = THIS_MODULE,
-	.open    = cim_la_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = cim_la_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 static int cim_pif_la_show(struct seq_file *seq, void *v, int idx)
@@ -270,11 +270,11 @@ static int cim_pif_la_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations cim_pif_la_fops = {
-	.owner   = THIS_MODULE,
-	.open    = cim_pif_la_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = cim_pif_la_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 static int cim_ma_la_show(struct seq_file *seq, void *v, int idx)
@@ -316,11 +316,11 @@ static int cim_ma_la_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations cim_ma_la_fops = {
-	.owner   = THIS_MODULE,
-	.open    = cim_ma_la_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = cim_ma_la_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 static int cim_qcfg_show(struct seq_file *seq, void *v)
@@ -409,11 +409,11 @@ static int cim_ibq_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations cim_ibq_fops = {
-	.owner   = THIS_MODULE,
-	.open    = cim_ibq_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = cim_ibq_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 static int cim_obq_open(struct inode *inode, struct file *file)
@@ -438,11 +438,11 @@ static int cim_obq_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations cim_obq_fops = {
-	.owner   = THIS_MODULE,
-	.open    = cim_obq_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = cim_obq_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 struct field_desc {
@@ -660,16 +660,16 @@ static int tp_la_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t tp_la_write(struct file *file, const char __user *buf,
-			   size_t count, loff_t *pos)
+static ssize_t tp_la_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	int err;
 	char s[32];
 	unsigned long val;
+	size_t count = iov_iter_count(from);
 	size_t size = min(sizeof(s) - 1, count);
-	struct adapter *adap = file_inode(file)->i_private;
+	struct adapter *adap = file_inode(iocb->ki_filp)->i_private;
 
-	if (copy_from_user(s, buf, size))
+	if (!copy_from_iter_full(s, size, from))
 		return -EFAULT;
 	s[size] = '\0';
 	err = kstrtoul(s, 0, &val);
@@ -684,12 +684,12 @@ static ssize_t tp_la_write(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations tp_la_fops = {
-	.owner   = THIS_MODULE,
-	.open    = tp_la_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private,
-	.write   = tp_la_write
+	.owner      = THIS_MODULE,
+	.open       = tp_la_open,
+	.read_iter  = seq_read_iter,
+	.llseek     = seq_lseek,
+	.release    = seq_release_private,
+	.write_iter = tp_la_write_iter
 };
 
 static int ulprx_la_show(struct seq_file *seq, void *v, int idx)
@@ -720,11 +720,11 @@ static int ulprx_la_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations ulprx_la_fops = {
-	.owner   = THIS_MODULE,
-	.open    = ulprx_la_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = ulprx_la_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 /* Show the PM memory stats.  These stats include:
@@ -799,23 +799,22 @@ static int pm_stats_open(struct inode *inode, struct file *file)
 	return single_open(file, pm_stats_show, inode->i_private);
 }
 
-static ssize_t pm_stats_clear(struct file *file, const char __user *buf,
-			      size_t count, loff_t *pos)
+static ssize_t pm_stats_clear(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct adapter *adap = file_inode(file)->i_private;
+	struct adapter *adap = file_inode(iocb->ki_filp)->i_private;
 
 	t4_write_reg(adap, PM_RX_STAT_CONFIG_A, 0);
 	t4_write_reg(adap, PM_TX_STAT_CONFIG_A, 0);
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations pm_stats_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = pm_stats_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = single_release,
-	.write   = pm_stats_clear
+	.owner      = THIS_MODULE,
+	.open       = pm_stats_open,
+	.read_iter  = seq_read_iter,
+	.llseek     = seq_lseek,
+	.release    = single_release,
+	.write_iter = pm_stats_clear
 };
 
 static int tx_rate_show(struct seq_file *seq, void *v)
@@ -1134,11 +1133,11 @@ static int devlog_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations devlog_fops = {
-	.owner   = THIS_MODULE,
-	.open    = devlog_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = devlog_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 /* Show Firmware Mailbox Command/Reply Log
@@ -1232,11 +1231,11 @@ static int mboxlog_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations mboxlog_fops = {
-	.owner   = THIS_MODULE,
-	.open    = mboxlog_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release,
+	.owner     = THIS_MODULE,
+	.open      = mboxlog_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release,
 };
 
 static int mbox_show(struct seq_file *seq, void *v)
@@ -1275,8 +1274,7 @@ static int mbox_open(struct inode *inode, struct file *file)
 	return single_open(file, mbox_show, inode->i_private);
 }
 
-static ssize_t mbox_write(struct file *file, const char __user *buf,
-			  size_t count, loff_t *pos)
+static ssize_t mbox_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	int i;
 	char c = '\n', s[256];
@@ -1286,10 +1284,11 @@ static ssize_t mbox_write(struct file *file, const char __user *buf,
 	struct adapter *adap;
 	void __iomem *addr;
 	void __iomem *ctrl;
+	size_t count = iov_iter_count(from);
 
 	if (count > sizeof(s) - 1 || !count)
 		return -EINVAL;
-	if (copy_from_user(s, buf, count))
+	if (!copy_from_iter_full(s, count, from))
 		return -EFAULT;
 	s[count] = '\0';
 
@@ -1298,7 +1297,7 @@ static ssize_t mbox_write(struct file *file, const char __user *buf,
 		   &data[7], &c) < 8 || c != '\n')
 		return -EINVAL;
 
-	ino = file_inode(file);
+	ino = file_inode(iocb->ki_filp);
 	mbox = (uintptr_t)ino->i_private & 7;
 	adap = ino->i_private - mbox;
 	addr = adap->regs + PF_REG(mbox, CIM_PF_MAILBOX_DATA_A);
@@ -1315,12 +1314,12 @@ static ssize_t mbox_write(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations mbox_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = mbox_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = single_release,
-	.write   = mbox_write
+	.owner      = THIS_MODULE,
+	.open       = mbox_open,
+	.read_iter  = seq_read_iter,
+	.llseek     = seq_lseek,
+	.release    = single_release,
+	.write_iter = mbox_write_iter
 };
 
 static int mps_trc_show(struct seq_file *seq, void *v)
@@ -1408,8 +1407,7 @@ static unsigned int xdigit2int(unsigned char c)
  * must be anchored at 0.  An omitted mask is taken as a mask of 1s, an omitted
  * anchor is taken as 0.
  */
-static ssize_t mps_trc_write(struct file *file, const char __user *buf,
-			     size_t count, loff_t *pos)
+static ssize_t mps_trc_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	int i, enable, ret;
 	u32 *data, *mask;
@@ -1419,8 +1417,9 @@ static ssize_t mps_trc_write(struct file *file, const char __user *buf,
 	char *s, *p, *word, *end;
 	struct adapter *adap;
 	u32 j;
+	size_t count = iov_iter_count(from);
 
-	ino = file_inode(file);
+	ino = file_inode(iocb->ki_filp);
 	trcidx = (uintptr_t)ino->i_private & 3;
 	adap = ino->i_private - trcidx;
 
@@ -1432,7 +1431,7 @@ static ssize_t mps_trc_write(struct file *file, const char __user *buf,
 	p = s = kzalloc(count + 1, GFP_USER);
 	if (!s)
 		return -ENOMEM;
-	if (copy_from_user(s, buf, count)) {
+	if (!copy_from_iter_full(s, count, from)) {
 		count = -EFAULT;
 		goto out;
 	}
@@ -1608,20 +1607,20 @@ inval:				count = -EINVAL;
 }
 
 static const struct file_operations mps_trc_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = mps_trc_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = single_release,
-	.write   = mps_trc_write
+	.owner      = THIS_MODULE,
+	.open       = mps_trc_open,
+	.read_iter  = seq_read_iter,
+	.llseek     = seq_lseek,
+	.release    = single_release,
+	.write_iter = mps_trc_write_iter
 };
 
-static ssize_t flash_read(struct file *file, char __user *buf, size_t count,
-			  loff_t *ppos)
+static ssize_t flash_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	loff_t pos = *ppos;
-	loff_t avail = file_inode(file)->i_size;
-	struct adapter *adap = file->private_data;
+	loff_t pos = iocb->ki_pos;
+	loff_t avail = file_inode(iocb->ki_filp)->i_size;
+	struct adapter *adap = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 
 	if (pos < 0)
 		return -EINVAL;
@@ -1643,23 +1642,22 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t count,
 			return ret;
 
 		len -= ofst;
-		if (copy_to_user(buf, data + ofst, len))
+		if (!copy_to_iter_full(data + ofst, len, to))
 			return -EFAULT;
 
-		buf += len;
 		pos += len;
 		count -= len;
 	}
-	count = pos - *ppos;
-	*ppos = pos;
+	count = pos - iocb->ki_pos;
+	iocb->ki_pos = pos;
 	return count;
 }
 
 static const struct file_operations flash_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = mem_open,
-	.read    = flash_read,
-	.llseek  = default_llseek,
+	.owner     = THIS_MODULE,
+	.open      = mem_open,
+	.read_iter = flash_read_iter,
+	.llseek    = default_llseek,
 };
 
 static inline void tcamxy2valmask(u64 x, u64 y, u8 *addr, u64 *mask)
@@ -1928,11 +1926,11 @@ static int mps_tcam_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations mps_tcam_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = mps_tcam_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release,
+	.owner     = THIS_MODULE,
+	.open      = mps_tcam_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release,
 };
 
 /* Display various sensor information.
@@ -2005,11 +2003,11 @@ static int rss_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations rss_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = rss_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = rss_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 /* RSS Configuration.
@@ -2194,17 +2192,17 @@ static int rss_key_open(struct inode *inode, struct file *file)
 	return single_open(file, rss_key_show, inode->i_private);
 }
 
-static ssize_t rss_key_write(struct file *file, const char __user *buf,
-			     size_t count, loff_t *pos)
+static ssize_t rss_key_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	int i, j;
 	u32 key[10];
 	char s[100], *p;
-	struct adapter *adap = file_inode(file)->i_private;
+	struct adapter *adap = file_inode(iocb->ki_filp)->i_private;
+	size_t count = iov_iter_count(from);
 
 	if (count > sizeof(s) - 1)
 		return -EINVAL;
-	if (copy_from_user(s, buf, count))
+	if (!copy_from_iter_full(s, count, from))
 		return -EFAULT;
 	for (i = count; i > 0 && isspace(s[i - 1]); i--)
 		;
@@ -2224,12 +2222,12 @@ static ssize_t rss_key_write(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations rss_key_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = rss_key_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = single_release,
-	.write   = rss_key_write
+	.owner      = THIS_MODULE,
+	.open       = rss_key_open,
+	.read_iter  = seq_read_iter,
+	.llseek     = seq_lseek,
+	.release    = single_release,
+	.write_iter = rss_key_write_iter
 };
 
 /* PF RSS Configuration.
@@ -2308,11 +2306,11 @@ static int rss_pf_config_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations rss_pf_config_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = rss_pf_config_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = rss_pf_config_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 /* VF RSS Configuration.
@@ -2371,11 +2369,11 @@ static int rss_vf_config_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations rss_vf_config_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = rss_vf_config_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release_private
+	.owner     = THIS_MODULE,
+	.open      = rss_vf_config_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release_private
 };
 
 #ifdef CONFIG_CHELSIO_T4_DCB
@@ -2559,11 +2557,11 @@ static int dcb_info_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations dcb_info_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = dcb_info_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release,
+	.owner     = THIS_MODULE,
+	.open      = dcb_info_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release,
 };
 #endif /* CONFIG_CHELSIO_T4_DCB */
 
@@ -3243,11 +3241,11 @@ static int sge_qinfo_open(struct inode *inode, struct file *file)
 }
 
 static const struct file_operations sge_qinfo_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = sge_qinfo_open,
-	.read    = seq_read,
-	.llseek  = seq_lseek,
-	.release = seq_release,
+	.owner     = THIS_MODULE,
+	.open      = sge_qinfo_open,
+	.read_iter = seq_read_iter,
+	.llseek    = seq_lseek,
+	.release   = seq_release,
 };
 
 int mem_open(struct inode *inode, struct file *file)
@@ -3265,15 +3263,15 @@ int mem_open(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
-			loff_t *ppos)
+static ssize_t mem_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	loff_t pos = *ppos;
-	loff_t avail = file_inode(file)->i_size;
-	unsigned int mem = (uintptr_t)file->private_data & 0x7;
-	struct adapter *adap = file->private_data - mem;
+	loff_t pos = iocb->ki_pos;
+	loff_t avail = file_inode(iocb->ki_filp)->i_size;
+	unsigned int mem = (uintptr_t)iocb->ki_filp->private_data & 0x7;
+	struct adapter *adap = iocb->ki_filp->private_data - mem;
 	__be32 *data;
 	int ret;
+	size_t count = iov_iter_count(to);
 
 	if (pos < 0)
 		return -EINVAL;
@@ -3293,20 +3291,20 @@ static ssize_t mem_read(struct file *file, char __user *buf, size_t count,
 		kvfree(data);
 		return ret;
 	}
-	ret = copy_to_user(buf, data, count);
+	ret = !copy_to_iter_full(data, count, to);
 
 	kvfree(data);
 	if (ret)
 		return -EFAULT;
 
-	*ppos = pos + count;
+	iocb->ki_pos = pos + count;
 	return count;
 }
 static const struct file_operations mem_debugfs_fops = {
-	.owner   = THIS_MODULE,
-	.open    = simple_open,
-	.read    = mem_read,
-	.llseek  = default_llseek,
+	.owner     = THIS_MODULE,
+	.open      = simple_open,
+	.read_iter = mem_read_iter,
+	.llseek    = default_llseek,
 };
 
 static int tid_info_show(struct seq_file *seq, void *v)
@@ -3401,11 +3399,10 @@ static void add_debugfs_mem(struct adapter *adap, const char *name,
 				 size_mb << 20);
 }
 
-static ssize_t blocked_fl_read(struct file *filp, char __user *ubuf,
-			       size_t count, loff_t *ppos)
+static ssize_t blocked_fl_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
 	int len;
-	const struct adapter *adap = filp->private_data;
+	const struct adapter *adap = iocb->ki_filp->private_data;
 	char *buf;
 	ssize_t size = (adap->sge.egr_sz + 3) / 4 +
 			adap->sge.egr_sz / 32 + 2; /* includes ,/\n/\0 */
@@ -3417,23 +3414,31 @@ static ssize_t blocked_fl_read(struct file *filp, char __user *ubuf,
 	len = snprintf(buf, size - 1, "%*pb\n",
 		       adap->sge.egr_sz, adap->sge.blocked_fl);
 	len += sprintf(buf + len, "\n");
-	size = simple_read_from_buffer(ubuf, count, ppos, buf, len);
+	size = simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 	kfree(buf);
 	return size;
 }
 
-static ssize_t blocked_fl_write(struct file *filp, const char __user *ubuf,
-				size_t count, loff_t *ppos)
+static ssize_t blocked_fl_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
 	int err;
 	unsigned long *t;
-	struct adapter *adap = filp->private_data;
+	struct adapter *adap = iocb->ki_filp->private_data;
+	void *kern_buf;
+	size_t count = iov_iter_count(from);
 
 	t = bitmap_zalloc(adap->sge.egr_sz, GFP_KERNEL);
 	if (!t)
 		return -ENOMEM;
 
-	err = bitmap_parse_user(ubuf, count, t, adap->sge.egr_sz);
+	kern_buf = kzalloc(count + 1, GFP_KERNEL);
+	if (!kern_buf)
+		return -ENOMEM;
+
+	if (!copy_from_iter_full(kern_buf, count, from))
+		return -EFAULT;
+
+	err = bitmap_parse(kern_buf, UINT_MAX, t, adap->sge.egr_sz);
 	if (err) {
 		bitmap_free(t);
 		return err;
@@ -3445,11 +3450,11 @@ static ssize_t blocked_fl_write(struct file *filp, const char __user *ubuf,
 }
 
 static const struct file_operations blocked_fl_fops = {
-	.owner   = THIS_MODULE,
-	.open    = simple_open,
-	.read    = blocked_fl_read,
-	.write   = blocked_fl_write,
-	.llseek  = generic_file_llseek,
+	.owner      = THIS_MODULE,
+	.open       = simple_open,
+	.read_iter  = blocked_fl_read_iter,
+	.write_iter = blocked_fl_write_iter,
+	.llseek     = generic_file_llseek,
 };
 
 static void mem_region_show(struct seq_file *seq, const char *name,
drivers/net/ethernet/chelsio/cxgb4/l2t.c +1 -1
index 1e5f5b1a22a6..c4564a14b6ee 100644
@@ -756,7 +756,7 @@ static int l2t_seq_open(struct inode *inode, struct file *file)
 const struct file_operations t4_l2t_fops = {
 	.owner = THIS_MODULE,
 	.open = l2t_seq_open,
-	.read = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek = seq_lseek,
 	.release = seq_release,
 };
Signature · 1 line
2.43.0
author maintainer
#331 lore raw

PATCH 325/437 drivers/net/ethernet/hisilicon: convert to read/write iterators

In reply to Jens Axboe

From: Bui Quang Minh <[email protected]>

---
 .../net/ethernet/hisilicon/hns3/hns3_debugfs.c    | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +7 -8
index 807eb3bbb11c..0ea141e12655 100644
@@ -1257,10 +1257,9 @@ static int hns3_dbg_read_cmd(struct hns3_dbg_data *dbg_data,
 	return ops->dbg_read_cmd(dbg_data->handle, cmd, buf, len);
 }
 
-static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,
-			     size_t count, loff_t *ppos)
+static ssize_t hns3_dbg_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct hns3_dbg_data *dbg_data = filp->private_data;
+	struct hns3_dbg_data *dbg_data = iocb->ki_filp->private_data;
 	struct hnae3_handle *handle = dbg_data->handle;
 	struct hns3_nic_priv *priv = handle->priv;
 	ssize_t size = 0;
@@ -1301,8 +1300,8 @@ static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,
 			goto out;
 	}
 
-	size = simple_read_from_buffer(buffer, count, ppos, read_buf,
-				       strlen(read_buf));
+	size = simple_copy_to_iter(read_buf, &iocb->ki_pos, strlen(read_buf),
+				   to);
 	if (size > 0) {
 		mutex_unlock(&handle->dbgfs_lock);
 		return size;
@@ -1320,9 +1319,9 @@ static ssize_t hns3_dbg_read(struct file *filp, char __user *buffer,
 }
 
 static const struct file_operations hns3_dbg_fops = {
-	.owner = THIS_MODULE,
-	.open  = simple_open,
-	.read  = hns3_dbg_read,
+	.owner     = THIS_MODULE,
+	.open      = simple_open,
+	.read_iter = hns3_dbg_read_iter,
 };
 
 static int hns3_dbg_bd_file_init(struct hnae3_handle *handle, u32 cmd)
Signature · 1 line
2.43.0
author maintainer
#332 lore raw

PATCH 326/437 drivers/net/ethernet/huawei: convert to read/write iterators

In reply to Jens Axboe

From: Bui Quang Minh <[email protected]>

---
 drivers/net/ethernet/huawei/hinic/hinic_debugfs.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/net/ethernet/huawei/hinic/hinic_debugfs.c +6 -7
index 061952c6c21a..411d005a4a95 100644
@@ -133,8 +133,7 @@ static int hinic_dbg_get_func_table(struct hinic_dev *nic_dev, int idx)
 	return ret;
 }
 
-static ssize_t hinic_dbg_cmd_read(struct file *filp, char __user *buffer, size_t count,
-				  loff_t *ppos)
+static ssize_t hinic_dbg_cmd_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct hinic_debug_priv *dbg;
 	char ret_buf[20];
@@ -142,7 +141,7 @@ static ssize_t hinic_dbg_cmd_read(struct file *filp, char __user *buffer, size_t
 	u64 out;
 	int ret;
 
-	desc = filp->private_data;
+	desc = iocb->ki_filp->private_data;
 	dbg = container_of(desc, struct hinic_debug_priv, field_id[*desc]);
 
 	switch (dbg->type) {
@@ -166,13 +165,13 @@ static ssize_t hinic_dbg_cmd_read(struct file *filp, char __user *buffer, size_t
 
 	ret = snprintf(ret_buf, sizeof(ret_buf), "0x%llx\n", out);
 
-	return simple_read_from_buffer(buffer, count, ppos, ret_buf, ret);
+	return simple_copy_to_iter(ret_buf, &iocb->ki_pos, ret, to);
 }
 
 static const struct file_operations hinic_dbg_cmd_fops = {
-	.owner = THIS_MODULE,
-	.open  = simple_open,
-	.read  = hinic_dbg_cmd_read,
+	.owner      = THIS_MODULE,
+	.open       = simple_open,
+	.read_iter  = hinic_dbg_cmd_read_iter,
 };
 
 static int create_dbg_files(struct hinic_dev *dev, enum hinic_dbg_type type, void *data,
Signature · 1 line
2.43.0
author maintainer
#333 lore raw

PATCH 327/437 drivers/net/ethernet/amd-xgbe: convert to read/write iterators

In reply to Jens Axboe

From: Bui Quang Minh <[email protected]>

[axboe: fix typo in xi2c_reg_value_read_iter]
---
 drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c | 233 +++++++++----------
 1 file changed, 112 insertions(+), 121 deletions(-)
drivers/net/ethernet/amd/xgbe/xgbe-debugfs.c +112 -121
index b0a6c96b6ef4..5dfd4fc8618e 100644
@@ -121,36 +121,30 @@
 #include "xgbe.h"
 #include "xgbe-common.h"
 
-static ssize_t xgbe_common_read(char __user *buffer, size_t count,
-				loff_t *ppos, unsigned int value)
+static ssize_t xgbe_common_read_iter(struct iov_iter *to, loff_t *ppos,
+				     unsigned int value)
 {
-	char *buf;
-	ssize_t len;
+	char buf[16];
+	int len;
+	size_t count = iov_iter_count(to);
 
 	if (*ppos != 0)
 		return 0;
 
-	buf = kasprintf(GFP_KERNEL, "0x%08x\n", value);
-	if (!buf)
-		return -ENOMEM;
-
-	if (count < strlen(buf)) {
-		kfree(buf);
+	len = sprintf(buf, "0x%08x\n", value);
+	if (count < len)
 		return -ENOSPC;
-	}
-
-	len = simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
-	kfree(buf);
 
-	return len;
+	return simple_copy_to_iter(buf, ppos, len, to);
 }
 
-static ssize_t xgbe_common_write(const char __user *buffer, size_t count,
-				 loff_t *ppos, unsigned int *value)
+static ssize_t xgbe_common_write_iter(struct iov_iter *from, loff_t *ppos,
+				      unsigned int *value)
 {
 	char workarea[32];
 	ssize_t len;
 	int ret;
+	size_t count = iov_iter_count(from);
 
 	if (*ppos != 0)
 		return -EINVAL;
@@ -158,8 +152,8 @@ static ssize_t xgbe_common_write(const char __user *buffer, size_t count,
 	if (count >= sizeof(workarea))
 		return -ENOSPC;
 
-	len = simple_write_to_buffer(workarea, sizeof(workarea) - 1, ppos,
-				     buffer, count);
+	len = simple_copy_from_iter(workarea, ppos, sizeof(workarea) - 1,
+				    from);
 	if (len < 0)
 		return len;
 
@@ -171,44 +165,43 @@ static ssize_t xgbe_common_write(const char __user *buffer, size_t count,
 	return len;
 }
 
-static ssize_t xgmac_reg_addr_read(struct file *filp, char __user *buffer,
-				   size_t count, loff_t *ppos)
+static ssize_t xgmac_reg_addr_read_iter(struct kiocb *iocb,
+					struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_read(buffer, count, ppos, pdata->debugfs_xgmac_reg);
+	return xgbe_common_read_iter(to, &iocb->ki_pos,
+				     pdata->debugfs_xgmac_reg);
 }
 
-static ssize_t xgmac_reg_addr_write(struct file *filp,
-				    const char __user *buffer,
-				    size_t count, loff_t *ppos)
+static ssize_t xgmac_reg_addr_write_iter(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_write(buffer, count, ppos,
-				 &pdata->debugfs_xgmac_reg);
+	return xgbe_common_write_iter(from, &iocb->ki_pos,
+				      &pdata->debugfs_xgmac_reg);
 }
 
-static ssize_t xgmac_reg_value_read(struct file *filp, char __user *buffer,
-				    size_t count, loff_t *ppos)
+static ssize_t xgmac_reg_value_read_iter(struct kiocb *iocb,
+					 struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 
 	value = XGMAC_IOREAD(pdata, pdata->debugfs_xgmac_reg);
 
-	return xgbe_common_read(buffer, count, ppos, value);
+	return xgbe_common_read_iter(to, &iocb->ki_pos, value);
 }
 
-static ssize_t xgmac_reg_value_write(struct file *filp,
-				     const char __user *buffer,
-				     size_t count, loff_t *ppos)
+static ssize_t xgmac_reg_value_write_iter(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 	ssize_t len;
 
-	len = xgbe_common_write(buffer, count, ppos, &value);
+	len = xgbe_common_write_iter(from, &iocb->ki_pos, &value);
 	if (len < 0)
 		return len;
 
@@ -220,72 +213,73 @@ static ssize_t xgmac_reg_value_write(struct file *filp,
 static const struct file_operations xgmac_reg_addr_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xgmac_reg_addr_read,
-	.write = xgmac_reg_addr_write,
+	.read_iter =  xgmac_reg_addr_read_iter,
+	.write_iter = xgmac_reg_addr_write_iter,
 };
 
 static const struct file_operations xgmac_reg_value_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xgmac_reg_value_read,
-	.write = xgmac_reg_value_write,
+	.read_iter =  xgmac_reg_value_read_iter,
+	.write_iter = xgmac_reg_value_write_iter,
 };
 
-static ssize_t xpcs_mmd_read(struct file *filp, char __user *buffer,
-			     size_t count, loff_t *ppos)
+static ssize_t xpcs_mmd_read_iter(struct kiocb *iocb,
+				  struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_read(buffer, count, ppos, pdata->debugfs_xpcs_mmd);
+	return xgbe_common_read_iter(to, &iocb->ki_pos,
+				     pdata->debugfs_xpcs_mmd);
 }
 
-static ssize_t xpcs_mmd_write(struct file *filp, const char __user *buffer,
-			      size_t count, loff_t *ppos)
+static ssize_t xpcs_mmd_write_iter(struct kiocb *iocb,
+				   struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_write(buffer, count, ppos,
-				 &pdata->debugfs_xpcs_mmd);
+	return xgbe_common_write_iter(from, &iocb->ki_pos,
+				      &pdata->debugfs_xpcs_mmd);
 }
 
-static ssize_t xpcs_reg_addr_read(struct file *filp, char __user *buffer,
-				  size_t count, loff_t *ppos)
+static ssize_t xpcs_reg_addr_read_iter(struct kiocb *iocb,
+				       struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_read(buffer, count, ppos, pdata->debugfs_xpcs_reg);
+	return xgbe_common_read_iter(to, &iocb->ki_pos,
+				     pdata->debugfs_xpcs_reg);
 }
 
-static ssize_t xpcs_reg_addr_write(struct file *filp, const char __user *buffer,
-				   size_t count, loff_t *ppos)
+static ssize_t xpcs_reg_addr_write_iter(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_write(buffer, count, ppos,
-				 &pdata->debugfs_xpcs_reg);
+	return xgbe_common_write_iter(from, &iocb->ki_pos,
+				      &pdata->debugfs_xpcs_reg);
 }
 
-static ssize_t xpcs_reg_value_read(struct file *filp, char __user *buffer,
-				   size_t count, loff_t *ppos)
+static ssize_t xpcs_reg_value_read_iter(struct kiocb *iocb,
+					struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 
 	value = XMDIO_READ(pdata, pdata->debugfs_xpcs_mmd,
 			   pdata->debugfs_xpcs_reg);
 
-	return xgbe_common_read(buffer, count, ppos, value);
+	return xgbe_common_read_iter(to, &iocb->ki_pos, value);
 }
 
-static ssize_t xpcs_reg_value_write(struct file *filp,
-				    const char __user *buffer,
-				    size_t count, loff_t *ppos)
+static ssize_t xpcs_reg_value_write_iter(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 	ssize_t len;
 
-	len = xgbe_common_write(buffer, count, ppos, &value);
+	len = xgbe_common_write_iter(from, &iocb->ki_pos, &value);
 	if (len < 0)
 		return len;
 
@@ -298,62 +292,61 @@ static ssize_t xpcs_reg_value_write(struct file *filp,
 static const struct file_operations xpcs_mmd_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xpcs_mmd_read,
-	.write = xpcs_mmd_write,
+	.read_iter =  xpcs_mmd_read_iter,
+	.write_iter = xpcs_mmd_write_iter,
 };
 
 static const struct file_operations xpcs_reg_addr_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xpcs_reg_addr_read,
-	.write = xpcs_reg_addr_write,
+	.read_iter =  xpcs_reg_addr_read_iter,
+	.write_iter = xpcs_reg_addr_write_iter,
 };
 
 static const struct file_operations xpcs_reg_value_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xpcs_reg_value_read,
-	.write = xpcs_reg_value_write,
+	.read_iter =  xpcs_reg_value_read_iter,
+	.write_iter = xpcs_reg_value_write_iter,
 };
 
-static ssize_t xprop_reg_addr_read(struct file *filp, char __user *buffer,
-				   size_t count, loff_t *ppos)
+static ssize_t xprop_reg_addr_read_iter(struct kiocb *iocb,
+					struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_read(buffer, count, ppos, pdata->debugfs_xprop_reg);
+	return xgbe_common_read_iter(to, &iocb->ki_pos,
+				     pdata->debugfs_xprop_reg);
 }
 
-static ssize_t xprop_reg_addr_write(struct file *filp,
-				    const char __user *buffer,
-				    size_t count, loff_t *ppos)
+static ssize_t xprop_reg_addr_write_iter(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_write(buffer, count, ppos,
-				 &pdata->debugfs_xprop_reg);
+	return xgbe_common_write_iter(from, &iocb->ki_pos,
+				      &pdata->debugfs_xprop_reg);
 }
 
-static ssize_t xprop_reg_value_read(struct file *filp, char __user *buffer,
-				    size_t count, loff_t *ppos)
+static ssize_t xprop_reg_value_read_iter(struct kiocb *iocb,
+					 struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 
 	value = XP_IOREAD(pdata, pdata->debugfs_xprop_reg);
 
-	return xgbe_common_read(buffer, count, ppos, value);
+	return xgbe_common_read_iter(to, &iocb->ki_pos, value);
 }
 
-static ssize_t xprop_reg_value_write(struct file *filp,
-				     const char __user *buffer,
-				     size_t count, loff_t *ppos)
+static ssize_t xprop_reg_value_write_iter(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 	ssize_t len;
 
-	len = xgbe_common_write(buffer, count, ppos, &value);
+	len = xgbe_common_write_iter(from, &iocb->ki_pos, &value);
 	if (len < 0)
 		return len;
 
@@ -365,55 +358,53 @@ static ssize_t xprop_reg_value_write(struct file *filp,
 static const struct file_operations xprop_reg_addr_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xprop_reg_addr_read,
-	.write = xprop_reg_addr_write,
+	.read_iter =  xprop_reg_addr_read_iter,
+	.write_iter = xprop_reg_addr_write_iter,
 };
 
 static const struct file_operations xprop_reg_value_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xprop_reg_value_read,
-	.write = xprop_reg_value_write,
+	.read_iter =  xprop_reg_value_read_iter,
+	.write_iter = xprop_reg_value_write_iter,
 };
 
-static ssize_t xi2c_reg_addr_read(struct file *filp, char __user *buffer,
-				  size_t count, loff_t *ppos)
+static ssize_t xi2c_reg_addr_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_read(buffer, count, ppos, pdata->debugfs_xi2c_reg);
+	return xgbe_common_read_iter(to, &iocb->ki_pos,
+				     pdata->debugfs_xi2c_reg);
 }
 
-static ssize_t xi2c_reg_addr_write(struct file *filp,
-				   const char __user *buffer,
-				   size_t count, loff_t *ppos)
+static ssize_t xi2c_reg_addr_write_iter(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 
-	return xgbe_common_write(buffer, count, ppos,
-				 &pdata->debugfs_xi2c_reg);
+	return xgbe_common_write_iter(from, &iocb->ki_pos,
+				      &pdata->debugfs_xi2c_reg);
 }
 
-static ssize_t xi2c_reg_value_read(struct file *filp, char __user *buffer,
-				   size_t count, loff_t *ppos)
+static ssize_t xi2c_reg_value_read_iter(struct kiocb *iocb,
+					struct iov_iter *to)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 
 	value = XI2C_IOREAD(pdata, pdata->debugfs_xi2c_reg);
 
-	return xgbe_common_read(buffer, count, ppos, value);
+	return xgbe_common_read_iter(to, &iocb->ki_pos, value);
 }
 
-static ssize_t xi2c_reg_value_write(struct file *filp,
-				    const char __user *buffer,
-				    size_t count, loff_t *ppos)
+static ssize_t xi2c_reg_value_write_iter(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
-	struct xgbe_prv_data *pdata = filp->private_data;
+	struct xgbe_prv_data *pdata = iocb->ki_filp->private_data;
 	unsigned int value;
 	ssize_t len;
 
-	len = xgbe_common_write(buffer, count, ppos, &value);
+	len = xgbe_common_write_iter(from, &iocb->ki_pos, &value);
 	if (len < 0)
 		return len;
 
@@ -425,15 +416,15 @@ static ssize_t xi2c_reg_value_write(struct file *filp,
 static const struct file_operations xi2c_reg_addr_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xi2c_reg_addr_read,
-	.write = xi2c_reg_addr_write,
+	.read_iter =  xi2c_reg_addr_read_iter,
+	.write_iter = xi2c_reg_addr_write_iter,
 };
 
 static const struct file_operations xi2c_reg_value_fops = {
 	.owner = THIS_MODULE,
 	.open = simple_open,
-	.read =  xi2c_reg_value_read,
-	.write = xi2c_reg_value_write,
+	.read_iter =  xi2c_reg_value_read_iter,
+	.write_iter = xi2c_reg_value_write_iter,
 };
 
 void xgbe_debugfs_init(struct xgbe_prv_data *pdata)
Signature · 1 line
2.43.0
author maintainer
#334 lore raw

PATCH 328/437 drivers/net/ethernet/marvell/octeontx2: convert to read/write iterators

In reply to Jens Axboe

From: Bui Quang Minh <[email protected]>

---
 .../marvell/octeontx2/af/rvu_debugfs.c        | 159 ++++++++----------
 1 file changed, 73 insertions(+), 86 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +73 -86
index 2500f5ba4f5a..be3b071743f5 100644
@@ -209,8 +209,8 @@ static int rvu_dbg_open_##name(struct inode *inode, struct file *file) \
 static const struct file_operations rvu_dbg_##name##_fops = { \
 	.owner		= THIS_MODULE, \
 	.open		= rvu_dbg_open_##name, \
-	.read		= seq_read, \
-	.write		= rvu_dbg_##write_op, \
+	.read_iter	= seq_read_iter, \
+	.write_iter	= rvu_dbg_##write_op, \
 	.llseek		= seq_lseek, \
 	.release	= single_release, \
 }
@@ -219,8 +219,8 @@ static const struct file_operations rvu_dbg_##name##_fops = { \
 static const struct file_operations rvu_dbg_##name##_fops = { \
 	.owner = THIS_MODULE, \
 	.open = simple_open, \
-	.read = rvu_dbg_##read_op, \
-	.write = rvu_dbg_##write_op \
+	.read_iter = rvu_dbg_##read_op, \
+	.write_iter = rvu_dbg_##write_op \
 }
 
 static void print_nix_qsize(struct seq_file *filp, struct rvu_pfvf *pfvf);
@@ -572,11 +572,10 @@ static void rvu_dbg_mcs_init(struct rvu *rvu)
 
 #define LMT_MAPTBL_ENTRY_SIZE 16
 /* Dump LMTST map table */
-static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,
-					       char __user *buffer,
-					       size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_lmtst_map_table_display(struct kiocb *iocb,
+					       struct iov_iter *to)
 {
-	struct rvu *rvu = filp->private_data;
+	struct rvu *rvu = iocb->ki_filp->private_data;
 	u64 lmt_addr, val, tbl_base;
 	int pf, vf, num_vfs, hw_vfs;
 	void __iomem *lmt_map_base;
@@ -585,9 +584,10 @@ static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,
 	int index = 0;
 	char *buf;
 	int ret;
+	size_t count = iov_iter_count(to);
 
 	/* don't allow partial reads */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	buf = kzalloc(buf_size, GFP_KERNEL);
@@ -649,15 +649,15 @@ static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,
 	off +=	scnprintf(&buf[off], buf_size - 1 - off, "\n");
 
 	ret = min(off, count);
-	if (copy_to_user(buffer, buf, ret))
-		ret = -EFAULT;
+	if (!copy_to_iter_full(buf, ret, to))
+		return -EFAULT;
 	kfree(buf);
 
 	iounmap(lmt_map_base);
 	if (ret < 0)
 		return ret;
 
-	*ppos = ret;
+	iocb->ki_pos = ret;
 	return ret;
 }
 
@@ -731,22 +731,21 @@ static int get_max_column_width(struct rvu *rvu)
 }
 
 /* Dumps current provisioning status of all RVU block LFs */
-static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
-					  char __user *buffer,
-					  size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_rsrc_attach_status(struct kiocb *iocb,
+					  struct iov_iter *to)
 {
 	int index, off = 0, flag = 0, len = 0, i = 0;
-	struct rvu *rvu = filp->private_data;
-	int bytes_not_copied = 0;
+	struct rvu *rvu = iocb->ki_filp->private_data;
 	struct rvu_block block;
 	int pf, vf, pcifunc;
 	int buf_size = 2048;
 	int lf_str_size;
 	char *lfs;
 	char *buf;
+	bool ret;
 
 	/* don't allow partial reads */
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return 0;
 
 	buf = kzalloc(buf_size, GFP_KERNEL);
@@ -771,12 +770,13 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
 		}
 
 	off += scnprintf(&buf[off], buf_size - 1 - off, "\n");
-	bytes_not_copied = copy_to_user(buffer + (i * off), buf, off);
-	if (bytes_not_copied)
+	iov_iter_advance(to, i * off);
+	ret = !copy_to_iter_full(buf, off, to);
+	if (ret)
 		goto out;
 
 	i++;
-	*ppos += off;
+	iocb->ki_pos += off;
 	for (pf = 0; pf < rvu->hw->total_pfs; pf++) {
 		for (vf = 0; vf <= rvu->hw->total_vfs; vf++) {
 			off = 0;
@@ -813,14 +813,13 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
 			if (flag) {
 				off +=	scnprintf(&buf[off],
 						  buf_size - 1 - off, "\n");
-				bytes_not_copied = copy_to_user(buffer +
-								(i * off),
-								buf, off);
-				if (bytes_not_copied)
+				iov_iter_advance(to, i * off);
+				ret = !copy_to_iter_full(buf, off, to);
+				if (ret)
 					goto out;
 
 				i++;
-				*ppos += off;
+				iocb->ki_pos += off;
 			}
 		}
 	}
@@ -828,10 +827,10 @@ static ssize_t rvu_dbg_rsrc_attach_status(struct file *filp,
 out:
 	kfree(lfs);
 	kfree(buf);
-	if (bytes_not_copied)
+	if (!ret)
 		return -EFAULT;
 
-	return *ppos;
+	return iocb->ki_pos;
 }
 
 RVU_DEBUG_FOPS(rsrc_status, rsrc_attach_status, NULL);
@@ -986,23 +985,26 @@ static int rvu_dbg_qsize_display(struct seq_file *filp, void *unsused,
 	return 0;
 }
 
-static ssize_t rvu_dbg_qsize_write(struct file *filp,
-				   const char __user *buffer, size_t count,
-				   loff_t *ppos, int blktype)
+static ssize_t rvu_dbg_qsize_write(struct kiocb *iocb, struct iov_iter *from,
+				   int blktype)
 {
 	char *blk_string = (blktype == BLKTYPE_NPA) ? "npa" : "nix";
-	struct seq_file *seqfile = filp->private_data;
+	struct seq_file *seqfile = iocb->ki_filp->private_data;
 	char *cmd_buf, *cmd_buf_tmp, *subtoken;
 	struct rvu *rvu = seqfile->private;
 	struct dentry *current_dir;
 	int blkaddr;
 	u16 pcifunc;
 	int ret, lf;
+	size_t count = iov_iter_count(from);
 
-	cmd_buf = memdup_user(buffer, count + 1);
-	if (IS_ERR(cmd_buf))
+	cmd_buf = kmalloc(count + 1, GFP_KERNEL);
+	if (!cmd_buf)
 		return -ENOMEM;
 
+	if (!copy_from_iter_full(cmd_buf, count, from))
+		return -EFAULT;
+
 	cmd_buf[count] = '\0';
 
 	cmd_buf_tmp = strchr(cmd_buf, '\n');
@@ -1025,7 +1027,7 @@ static ssize_t rvu_dbg_qsize_write(struct file *filp,
 	if (blktype == BLKTYPE_NPA) {
 		blkaddr = BLKADDR_NPA;
 	} else {
-		current_dir = filp->f_path.dentry->d_parent;
+		current_dir = iocb->ki_filp->f_path.dentry->d_parent;
 		blkaddr = (!strcmp(current_dir->d_name.name, "nix1") ?
 				   BLKADDR_NIX1 : BLKADDR_NIX0);
 	}
@@ -1044,12 +1046,10 @@ static ssize_t rvu_dbg_qsize_write(struct file *filp,
 	return ret ? ret : count;
 }
 
-static ssize_t rvu_dbg_npa_qsize_write(struct file *filp,
-				       const char __user *buffer,
-				       size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_npa_qsize_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	return rvu_dbg_qsize_write(filp, buffer, count, ppos,
-					    BLKTYPE_NPA);
+	return rvu_dbg_qsize_write(iocb, from, BLKTYPE_NPA);
 }
 
 static int rvu_dbg_npa_qsize_display(struct seq_file *filp, void *unused)
@@ -1292,16 +1292,14 @@ static int write_npa_ctx(struct rvu *rvu, bool all,
 }
 
 static int parse_cmd_buffer_ctx(char *cmd_buf, size_t *count,
-				const char __user *buffer, int *npalf,
+				struct iov_iter *from, int *npalf,
 				int *id, bool *all)
 {
-	int bytes_not_copied;
 	char *cmd_buf_tmp;
 	char *subtoken;
 	int ret;
 
-	bytes_not_copied = copy_from_user(cmd_buf, buffer, *count);
-	if (bytes_not_copied)
+	if (!copy_from_iter_full(cmd_buf, *count, from))
 		return -EFAULT;
 
 	cmd_buf[*count] = '\0';
@@ -1329,24 +1327,25 @@ static int parse_cmd_buffer_ctx(char *cmd_buf, size_t *count,
 	return ret;
 }
 
-static ssize_t rvu_dbg_npa_ctx_write(struct file *filp,
-				     const char __user *buffer,
-				     size_t count, loff_t *ppos, int ctype)
+static ssize_t rvu_dbg_npa_ctx_write(struct kiocb *iocb,
+				     struct iov_iter *from,
+				     int ctype)
 {
 	char *cmd_buf, *ctype_string = (ctype == NPA_AQ_CTYPE_AURA) ?
 					"aura" : "pool";
-	struct seq_file *seqfp = filp->private_data;
+	struct seq_file *seqfp = iocb->ki_filp->private_data;
 	struct rvu *rvu = seqfp->private;
 	int npalf, id = 0, ret;
 	bool all = false;
+	size_t count = iov_iter_count(from);
 
-	if ((*ppos != 0) || !count)
+	if (iocb->ki_pos != 0 || !count)
 		return -EINVAL;
 
 	cmd_buf = kzalloc(count + 1, GFP_KERNEL);
 	if (!cmd_buf)
 		return count;
-	ret = parse_cmd_buffer_ctx(cmd_buf, &count, buffer,
+	ret = parse_cmd_buffer_ctx(cmd_buf, &count, from,
 				   &npalf, &id, &all);
 	if (ret < 0) {
 		dev_info(rvu->dev,
@@ -1361,12 +1360,10 @@ static ssize_t rvu_dbg_npa_ctx_write(struct file *filp,
 	return ret ? ret : count;
 }
 
-static ssize_t rvu_dbg_npa_aura_ctx_write(struct file *filp,
-					  const char __user *buffer,
-					  size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_npa_aura_ctx_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	return rvu_dbg_npa_ctx_write(filp, buffer, count, ppos,
-				     NPA_AQ_CTYPE_AURA);
+	return rvu_dbg_npa_ctx_write(iocb, from, NPA_AQ_CTYPE_AURA);
 }
 
 static int rvu_dbg_npa_aura_ctx_display(struct seq_file *filp, void *unused)
@@ -1376,12 +1373,10 @@ static int rvu_dbg_npa_aura_ctx_display(struct seq_file *filp, void *unused)
 
 RVU_DEBUG_SEQ_FOPS(npa_aura_ctx, npa_aura_ctx_display, npa_aura_ctx_write);
 
-static ssize_t rvu_dbg_npa_pool_ctx_write(struct file *filp,
-					  const char __user *buffer,
-					  size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_npa_pool_ctx_write(struct kiocb *iocb,
+					  struct iov_iter *from)
 {
-	return rvu_dbg_npa_ctx_write(filp, buffer, count, ppos,
-				     NPA_AQ_CTYPE_POOL);
+	return rvu_dbg_npa_ctx_write(iocb, from, NPA_AQ_CTYPE_POOL);
 }
 
 static int rvu_dbg_npa_pool_ctx_display(struct seq_file *filp, void *unused)
@@ -2021,19 +2016,19 @@ static int write_nix_queue_ctx(struct rvu *rvu, bool all, int nixlf,
 	return 0;
 }
 
-static ssize_t rvu_dbg_nix_queue_ctx_write(struct file *filp,
-					   const char __user *buffer,
-					   size_t count, loff_t *ppos,
+static ssize_t rvu_dbg_nix_queue_ctx_write(struct kiocb *iocb,
+					   struct iov_iter *from,
 					   int ctype)
 {
-	struct seq_file *m = filp->private_data;
+	struct seq_file *m = iocb->ki_filp->private_data;
 	struct nix_hw *nix_hw = m->private;
 	struct rvu *rvu = nix_hw->rvu;
 	char *cmd_buf, *ctype_string;
 	int nixlf, id = 0, ret;
 	bool all = false;
+	size_t count = iov_iter_count(from);
 
-	if ((*ppos != 0) || !count)
+	if (iocb->ki_pos != 0 || !count)
 		return -EINVAL;
 
 	switch (ctype) {
@@ -2055,7 +2050,7 @@ static ssize_t rvu_dbg_nix_queue_ctx_write(struct file *filp,
 	if (!cmd_buf)
 		return count;
 
-	ret = parse_cmd_buffer_ctx(cmd_buf, &count, buffer,
+	ret = parse_cmd_buffer_ctx(cmd_buf, &count, from,
 				   &nixlf, &id, &all);
 	if (ret < 0) {
 		dev_info(rvu->dev,
@@ -2071,12 +2066,10 @@ static ssize_t rvu_dbg_nix_queue_ctx_write(struct file *filp,
 	return ret ? ret : count;
 }
 
-static ssize_t rvu_dbg_nix_sq_ctx_write(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_nix_sq_ctx_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	return rvu_dbg_nix_queue_ctx_write(filp, buffer, count, ppos,
-					    NIX_AQ_CTYPE_SQ);
+	return rvu_dbg_nix_queue_ctx_write(iocb, from, NIX_AQ_CTYPE_SQ);
 }
 
 static int rvu_dbg_nix_sq_ctx_display(struct seq_file *filp, void *unused)
@@ -2086,12 +2079,10 @@ static int rvu_dbg_nix_sq_ctx_display(struct seq_file *filp, void *unused)
 
 RVU_DEBUG_SEQ_FOPS(nix_sq_ctx, nix_sq_ctx_display, nix_sq_ctx_write);
 
-static ssize_t rvu_dbg_nix_rq_ctx_write(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_nix_rq_ctx_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	return rvu_dbg_nix_queue_ctx_write(filp, buffer, count, ppos,
-					    NIX_AQ_CTYPE_RQ);
+	return rvu_dbg_nix_queue_ctx_write(iocb, from, NIX_AQ_CTYPE_RQ);
 }
 
 static int rvu_dbg_nix_rq_ctx_display(struct seq_file *filp, void  *unused)
@@ -2101,12 +2092,10 @@ static int rvu_dbg_nix_rq_ctx_display(struct seq_file *filp, void  *unused)
 
 RVU_DEBUG_SEQ_FOPS(nix_rq_ctx, nix_rq_ctx_display, nix_rq_ctx_write);
 
-static ssize_t rvu_dbg_nix_cq_ctx_write(struct file *filp,
-					const char __user *buffer,
-					size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_nix_cq_ctx_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
-	return rvu_dbg_nix_queue_ctx_write(filp, buffer, count, ppos,
-					    NIX_AQ_CTYPE_CQ);
+	return rvu_dbg_nix_queue_ctx_write(iocb, from, NIX_AQ_CTYPE_CQ);
 }
 
 static int rvu_dbg_nix_cq_ctx_display(struct seq_file *filp, void *unused)
@@ -2153,12 +2142,10 @@ static void print_nix_qsize(struct seq_file *filp, struct rvu_pfvf *pfvf)
 				     "sq");
 }
 
-static ssize_t rvu_dbg_nix_qsize_write(struct file *filp,
-				       const char __user *buffer,
-				       size_t count, loff_t *ppos)
+static ssize_t rvu_dbg_nix_qsize_write(struct kiocb *iocb,
+				       struct iov_iter *from)
 {
-	return rvu_dbg_qsize_write(filp, buffer, count, ppos,
-				   BLKTYPE_NIX);
+	return rvu_dbg_qsize_write(iocb, from, BLKTYPE_NIX);
 }
 
 static int rvu_dbg_nix_qsize_display(struct seq_file *filp, void *unused)
Signature · 1 line
2.43.0
author maintainer
#335 lore raw

PATCH 329/437 drivers/net/ethernet/mellanox/mlx5/core: convert to read/write iterators

In reply to Jens Axboe

From: Bui Quang Minh <[email protected]>

---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 78 ++++++++++---------
 .../net/ethernet/mellanox/mlx5/core/debugfs.c | 49 ++++++------
 .../net/ethernet/mellanox/mlx5/core/lib/sd.c  | 13 ++--
 3 files changed, 69 insertions(+), 71 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +40 -38
index 4957412ff1f6..fecd1553fac5 100644
@@ -1246,13 +1246,13 @@ static int mlx5_cmd_invoke(struct mlx5_core_dev *dev, struct mlx5_cmd_msg *in,
 	return err ? : status;
 }
 
-static ssize_t dbg_write(struct file *filp, const char __user *buf,
-			 size_t count, loff_t *pos)
+static ssize_t dbg_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mlx5_core_dev *dev = filp->private_data;
+	struct mlx5_core_dev *dev = iocb->ki_filp->private_data;
 	struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
 	char lbuf[3];
 	int err;
+	size_t count = iov_iter_count(from);
 
 	if (!dbg->in_msg || !dbg->out_msg)
 		return -ENOMEM;
@@ -1260,7 +1260,7 @@ static ssize_t dbg_write(struct file *filp, const char __user *buf,
 	if (count < sizeof(lbuf) - 1)
 		return -EINVAL;
 
-	if (copy_from_user(lbuf, buf, sizeof(lbuf) - 1))
+	if (!copy_from_iter_full(lbuf, sizeof(lbuf) - 1, from))
 		return -EFAULT;
 
 	lbuf[sizeof(lbuf) - 1] = 0;
@@ -1274,9 +1274,9 @@ static ssize_t dbg_write(struct file *filp, const char __user *buf,
 }
 
 static const struct file_operations fops = {
-	.owner	= THIS_MODULE,
-	.open	= simple_open,
-	.write	= dbg_write,
+	.owner		= THIS_MODULE,
+	.open		= simple_open,
+	.write_iter	= dbg_write_iter,
 };
 
 static int mlx5_copy_to_msg(struct mlx5_cmd_msg *to, void *from, int size,
@@ -1435,54 +1435,56 @@ static void mlx5_free_cmd_msg(struct mlx5_core_dev *dev,
 	kfree(msg);
 }
 
-static ssize_t data_write(struct file *filp, const char __user *buf,
-			  size_t count, loff_t *pos)
+static ssize_t data_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mlx5_core_dev *dev = filp->private_data;
+	struct mlx5_core_dev *dev = iocb->ki_filp->private_data;
 	struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
 	void *ptr;
+	size_t count = iov_iter_count(from);
 
-	if (*pos != 0)
+	if (iocb->ki_pos != 0)
 		return -EINVAL;
 
 	kfree(dbg->in_msg);
 	dbg->in_msg = NULL;
 	dbg->inlen = 0;
-	ptr = memdup_user(buf, count);
-	if (IS_ERR(ptr))
-		return PTR_ERR(ptr);
+	ptr = kmalloc(count, GFP_KERNEL);
+	if (!ptr)
+		return -ENOMEM;
+
+	if (!copy_from_iter_full(ptr, count, from))
+		return -EFAULT;
+
 	dbg->in_msg = ptr;
 	dbg->inlen = count;
 
-	*pos = count;
+	iocb->ki_pos = count;
 
 	return count;
 }
 
-static ssize_t data_read(struct file *filp, char __user *buf, size_t count,
-			 loff_t *pos)
+static ssize_t data_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mlx5_core_dev *dev = filp->private_data;
+	struct mlx5_core_dev *dev = iocb->ki_filp->private_data;
 	struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
 
 	if (!dbg->out_msg)
 		return -ENOMEM;
 
-	return simple_read_from_buffer(buf, count, pos, dbg->out_msg,
-				       dbg->outlen);
+	return simple_copy_to_iter(dbg->out_msg, &iocb->ki_pos,
+				   dbg->outlen, to);
 }
 
 static const struct file_operations dfops = {
-	.owner	= THIS_MODULE,
-	.open	= simple_open,
-	.write	= data_write,
-	.read	= data_read,
+	.owner		= THIS_MODULE,
+	.open		= simple_open,
+	.write_iter	= data_write_iter,
+	.read_iter	= data_read_iter,
 };
 
-static ssize_t outlen_read(struct file *filp, char __user *buf, size_t count,
-			   loff_t *pos)
+static ssize_t outlen_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mlx5_core_dev *dev = filp->private_data;
+	struct mlx5_core_dev *dev = iocb->ki_filp->private_data;
 	struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
 	char outlen[8];
 	int err;
@@ -1491,27 +1493,27 @@ static ssize_t outlen_read(struct file *filp, char __user *buf, size_t count,
 	if (err < 0)
 		return err;
 
-	return simple_read_from_buffer(buf, count, pos, outlen, err);
+	return simple_copy_to_iter(outlen, &iocb->ki_pos, err, to);
 }
 
-static ssize_t outlen_write(struct file *filp, const char __user *buf,
-			    size_t count, loff_t *pos)
+static ssize_t outlen_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mlx5_core_dev *dev = filp->private_data;
+	struct mlx5_core_dev *dev = iocb->ki_filp->private_data;
 	struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
 	char outlen_str[8] = {0};
 	int outlen;
 	void *ptr;
 	int err;
+	size_t count = iov_iter_count(from);
 
-	if (*pos != 0 || count > 6)
+	if (iocb->ki_pos != 0 || count > 6)
 		return -EINVAL;
 
 	kfree(dbg->out_msg);
 	dbg->out_msg = NULL;
 	dbg->outlen = 0;
 
-	if (copy_from_user(outlen_str, buf, count))
+	if (!copy_from_iter_full(outlen_str, count, from))
 		return -EFAULT;
 
 	err = sscanf(outlen_str, "%d", &outlen);
@@ -1525,16 +1527,16 @@ static ssize_t outlen_write(struct file *filp, const char __user *buf,
 	dbg->out_msg = ptr;
 	dbg->outlen = outlen;
 
-	*pos = count;
+	iocb->ki_pos = count;
 
 	return count;
 }
 
 static const struct file_operations olfops = {
-	.owner	= THIS_MODULE,
-	.open	= simple_open,
-	.write	= outlen_write,
-	.read	= outlen_read,
+	.owner		= THIS_MODULE,
+	.open		= simple_open,
+	.write_iter	= outlen_write_iter,
+	.read_iter	= outlen_read_iter,
 };
 
 static void set_wqname(struct mlx5_core_dev *dev)
drivers/net/ethernet/mellanox/mlx5/core/debugfs.c +23 -26

116 lines not on this page · raw message

drivers/net/ethernet/mellanox/mlx5/core/lib/sd.c +6 -7
index 5b28084e8a03..09429b069c20 100644
@@ -393,24 +393,23 @@ static void sd_print_group(struct mlx5_core_dev *primary)
 			MLX5_CAP_GEN(pos, vhca_id));
 }
 
-static ssize_t dev_read(struct file *filp, char __user *buf, size_t count,
-			loff_t *pos)
+static ssize_t dev_read_iter(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct mlx5_core_dev *dev;
 	char tbuf[32];
 	int ret;
 
-	dev = filp->private_data;
+	dev = iocb->ki_filp->private_data;
 	ret = snprintf(tbuf, sizeof(tbuf), "%s vhca %#x\n", pci_name(dev->pdev),
 		       MLX5_CAP_GEN(dev, vhca_id));
 
-	return simple_read_from_buffer(buf, count, pos, tbuf, ret);
+	return simple_copy_to_iter(tbuf, &iocb->ki_pos, ret, to);
 }
 
 static const struct file_operations dev_fops = {
-	.owner	= THIS_MODULE,
-	.open	= simple_open,
-	.read	= dev_read,
+	.owner		= THIS_MODULE,
+	.open		= simple_open,
+	.read_iter	= dev_read_iter,
 };
 
 int mlx5_sd_init(struct mlx5_core_dev *dev)
Signature · 1 line
2.43.0
author maintainer
#336 lore raw

PATCH 330/437 x86/kernel: convert to read/write iterators

In reply to Jens Axboe
---
 arch/x86/kernel/apm_32.c                  | 10 +++---
 arch/x86/kernel/callthunks.c              |  2 +-
 arch/x86/kernel/cpu/debugfs.c             |  4 +--
 arch/x86/kernel/cpu/mce/dev-mcelog.c      | 38 +++++++++++------------
 arch/x86/kernel/cpu/mce/inject.c          | 27 +++++++---------
 arch/x86/kernel/cpu/mce/severity.c        | 11 +++----
 arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 18 +++++------
 arch/x86/kernel/cpuid.c                   | 16 +++++-----
 arch/x86/kernel/kdebugfs.c                | 14 ++++-----
 arch/x86/kernel/msr.c                     | 28 +++++++----------
 arch/x86/kernel/tboot.c                   | 17 +++++-----
 11 files changed, 86 insertions(+), 99 deletions(-)
arch/x86/kernel/apm_32.c +5 -5
index b37ab1095707..bc4c8db6b52f 100644
@@ -1431,13 +1431,14 @@ static int check_apm_user(struct apm_user *as, const char *func)
 	return 0;
 }
 
-static ssize_t do_read(struct file *fp, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t do_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	struct apm_user *as;
 	int i;
 	apm_event_t event;
 
-	as = fp->private_data;
+	as = iocb->ki_filp->private_data;
 	if (check_apm_user(as, "read"))
 		return -EIO;
 	if ((int)count < sizeof(apm_event_t))
@@ -1448,7 +1449,7 @@ static ssize_t do_read(struct file *fp, char __user *buf, size_t count, loff_t *
 	i = count;
 	while ((i >= sizeof(event)) && !queue_empty(as)) {
 		event = get_queued_event(as);
-		if (copy_to_user(buf, &event, sizeof(event))) {
+		if (!copy_to_iter_full(&event, sizeof(event), to)) {
 			if (i < count)
 				break;
 			return -EFAULT;
@@ -1464,7 +1465,6 @@ static ssize_t do_read(struct file *fp, char __user *buf, size_t count, loff_t *
 			as->standbys_read++;
 			break;
 		}
-		buf += sizeof(event);
 		i -= sizeof(event);
 	}
 	if (i < count)
@@ -1876,7 +1876,7 @@ __setup("apm=", apm_setup);
 
 static const struct file_operations apm_bios_fops = {
 	.owner		= THIS_MODULE,
-	.read		= do_read,
+	.read_iter	= do_read,
 	.poll		= do_poll,
 	.unlocked_ioctl	= do_ioctl,
 	.open		= do_open,
arch/x86/kernel/callthunks.c +1 -1
index e92ff0c11db8..bec11795ff8e 100644
@@ -375,7 +375,7 @@ static int callthunks_debug_open(struct inode *inode, struct file *file)
 
 static const struct file_operations dfs_ops = {
 	.open		= callthunks_debug_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
arch/x86/kernel/cpu/debugfs.c +2 -2
index 3baf3e435834..1f29b224c8c0 100644
@@ -42,7 +42,7 @@ static int cpu_debug_open(struct inode *inode, struct file *file)
 
 static const struct file_operations dfs_cpu_ops = {
 	.open		= cpu_debug_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -76,7 +76,7 @@ static int dom_debug_open(struct inode *inode, struct file *file)
 
 static const struct file_operations dfs_dom_ops = {
 	.open		= dom_debug_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
arch/x86/kernel/cpu/mce/dev-mcelog.c +18 -20
index a05ac0716ecf..1d5d1b26b85b 100644
@@ -159,7 +159,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
 static int mce_apei_read_done;
 
 /* Collect MCE record of previous boot in persistent storage via APEI ERST. */
-static int __mce_read_apei(char __user **ubuf, size_t usize)
+static int __mce_read_apei(struct iov_iter *to, size_t usize)
 {
 	int rc;
 	u64 record_id;
@@ -181,7 +181,7 @@ static int __mce_read_apei(char __user **ubuf, size_t usize)
 		return rc;
 	}
 	rc = -EFAULT;
-	if (copy_to_user(*ubuf, &m, sizeof(struct mce)))
+	if (!copy_to_iter_full(&m, sizeof(struct mce), to))
 		return rc;
 	/*
 	 * In fact, we should have cleared the record after that has
@@ -194,51 +194,49 @@ static int __mce_read_apei(char __user **ubuf, size_t usize)
 		mce_apei_read_done = 1;
 		return rc;
 	}
-	*ubuf += sizeof(struct mce);
 
 	return 0;
 }
 
-static ssize_t mce_chrdev_read(struct file *filp, char __user *ubuf,
-				size_t usize, loff_t *off)
+static ssize_t mce_chrdev_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	char __user *buf = ubuf;
+	size_t copied, usize = iov_iter_count(to);
 	unsigned next;
 	int i, err;
 
 	mutex_lock(&mce_chrdev_read_mutex);
 
 	if (!mce_apei_read_done) {
-		err = __mce_read_apei(&buf, usize);
-		if (err || buf != ubuf)
+		err = __mce_read_apei(to, usize);
+		if (err)
 			goto out;
 	}
 
 	/* Only supports full reads right now */
 	err = -EINVAL;
-	if (*off != 0 || usize < mcelog->len * sizeof(struct mce))
+	if (iocb->ki_pos != 0 || usize < mcelog->len * sizeof(struct mce))
 		goto out;
 
 	next = mcelog->next;
 	err = 0;
+	copied = 0;
 
 	for (i = 0; i < next; i++) {
 		struct mce *m = &mcelog->entry[i];
 
-		err |= copy_to_user(buf, m, sizeof(*m));
-		buf += sizeof(*m);
+		if (copy_to_iter_full(m, sizeof(*m), to))
+			copied += sizeof(*m);
+		else
+			err = -EFAULT;
 	}
 
 	memset(mcelog->entry, 0, next * sizeof(struct mce));
 	mcelog->next = 0;
 
-	if (err)
-		err = -EFAULT;
-
 out:
 	mutex_unlock(&mce_chrdev_read_mutex);
 
-	return err ? err : buf - ubuf;
+	return err ? err : copied;
 }
 
 static __poll_t mce_chrdev_poll(struct file *file, poll_table *wait)
@@ -290,9 +288,9 @@ void mce_unregister_injector_chain(struct notifier_block *nb)
 }
 EXPORT_SYMBOL_GPL(mce_unregister_injector_chain);
 
-static ssize_t mce_chrdev_write(struct file *filp, const char __user *ubuf,
-				size_t usize, loff_t *off)
+static ssize_t mce_chrdev_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t usize = iov_iter_count(from);
 	struct mce m;
 
 	if (!capable(CAP_SYS_ADMIN))
@@ -306,7 +304,7 @@ static ssize_t mce_chrdev_write(struct file *filp, const char __user *ubuf,
 
 	if ((unsigned long)usize > sizeof(struct mce))
 		usize = sizeof(struct mce);
-	if (copy_from_user(&m, ubuf, usize))
+	if (!copy_from_iter_full(&m, usize, from))
 		return -EFAULT;
 
 	if (m.extcpu >= num_possible_cpus() || !cpu_online(m.extcpu))
@@ -326,8 +324,8 @@ static ssize_t mce_chrdev_write(struct file *filp, const char __user *ubuf,
 static const struct file_operations mce_chrdev_ops = {
 	.open			= mce_chrdev_open,
 	.release		= mce_chrdev_release,
-	.read			= mce_chrdev_read,
-	.write			= mce_chrdev_write,
+	.read_iter		= mce_chrdev_read,
+	.write_iter		= mce_chrdev_write,
 	.poll			= mce_chrdev_poll,
 	.unlocked_ioctl		= mce_chrdev_ioctl,
 	.compat_ioctl		= compat_ptr_ioctl,
arch/x86/kernel/cpu/mce/inject.c +12 -15
index 94953d749475..5d545f331d0d 100644
@@ -349,27 +349,26 @@ static int __set_inj(const char *buf)
 	return -EINVAL;
 }
 
-static ssize_t flags_read(struct file *filp, char __user *ubuf,
-			  size_t cnt, loff_t *ppos)
+static ssize_t flags_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[MAX_FLAG_OPT_SIZE];
 	int n;
 
 	n = sprintf(buf, "%s\n", flags_options[inj_type]);
 
-	return simple_read_from_buffer(ubuf, cnt, ppos, buf, n);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, n, to);
 }
 
-static ssize_t flags_write(struct file *filp, const char __user *ubuf,
-			   size_t cnt, loff_t *ppos)
+static ssize_t flags_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char buf[MAX_FLAG_OPT_SIZE], *__buf;
+	size_t cnt = iov_iter_count(from);
 	int err;
 
 	if (!cnt || cnt > MAX_FLAG_OPT_SIZE)
 		return -EINVAL;
 
-	if (copy_from_user(&buf, ubuf, cnt))
+	if (!copy_from_iter_full(&buf, cnt, from))
 		return -EFAULT;
 
 	buf[cnt - 1] = 0;
@@ -383,14 +382,14 @@ static ssize_t flags_write(struct file *filp, const char __user *ubuf,
 		return err;
 	}
 
-	*ppos += cnt;
+	iocb->ki_pos += cnt;
 
 	return cnt;
 }
 
 static const struct file_operations flags_fops = {
-	.read           = flags_read,
-	.write          = flags_write,
+	.read_iter      = flags_read,
+	.write_iter     = flags_write,
 	.llseek         = generic_file_llseek,
 };
 
@@ -679,16 +678,14 @@ static const char readme_msg[] =
 "ipid:\t IPID (AMD-specific)\n"
 "\n";
 
-static ssize_t
-inj_readme_read(struct file *filp, char __user *ubuf,
-		       size_t cnt, loff_t *ppos)
+static ssize_t inj_readme_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	return simple_read_from_buffer(ubuf, cnt, ppos,
-					readme_msg, strlen(readme_msg));
+	return simple_copy_to_iter(readme_msg, &iocb->ki_pos,
+					strlen(readme_msg), to);
 }
 
 static const struct file_operations readme_fops = {
-	.read		= inj_readme_read,
+	.read_iter	= inj_readme_read,
 };
 
 static struct dfs_node {
arch/x86/kernel/cpu/mce/severity.c +5 -6
index c4477162c07d..eb648f415d55 100644
@@ -447,21 +447,20 @@ static int severities_coverage_open(struct inode *inode, struct file *file)
 	return seq_open(file, &severities_seq_ops);
 }
 
-static ssize_t severities_coverage_write(struct file *file,
-					 const char __user *ubuf,
-					 size_t count, loff_t *ppos)
+static ssize_t severities_coverage_write(struct kiocb *iocb,
+					 struct iov_iter *from)
 {
 	int i;
 	for (i = 0; i < ARRAY_SIZE(severities); i++)
 		severities[i].covered = 0;
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations severities_coverage_fops = {
 	.open		= severities_coverage_open,
 	.release	= seq_release,
-	.read		= seq_read,
-	.write		= severities_coverage_write,
+	.read_iter	= seq_read_iter,
+	.write_iter	= severities_coverage_write,
 	.llseek		= seq_lseek,
 };
 
arch/x86/kernel/cpu/resctrl/pseudo_lock.c +8 -10
index 884b88e25141..e10f1e9513ec 100644
@@ -1244,18 +1244,18 @@ static int pseudo_lock_measure_cycles(struct rdtgroup *rdtgrp, int sel)
 	return ret;
 }
 
-static ssize_t pseudo_lock_measure_trigger(struct file *file,
-					   const char __user *user_buf,
-					   size_t count, loff_t *ppos)
+static ssize_t pseudo_lock_measure_trigger(struct kiocb *iocb,
+					   struct iov_iter *from)
 {
-	struct rdtgroup *rdtgrp = file->private_data;
+	struct rdtgroup *rdtgrp = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	size_t buf_size;
 	char buf[32];
 	int ret;
 	int sel;
 
 	buf_size = min(count, (sizeof(buf) - 1));
-	if (copy_from_user(buf, user_buf, buf_size))
+	if (!copy_from_iter_full(buf, buf_size, from))
 		return -EFAULT;
 
 	buf[buf_size] = '\0';
@@ -1263,20 +1263,20 @@ static ssize_t pseudo_lock_measure_trigger(struct file *file,
 	if (ret == 0) {
 		if (sel != 1 && sel != 2 && sel != 3)
 			return -EINVAL;
-		ret = debugfs_file_get(file->f_path.dentry);
+		ret = debugfs_file_get(iocb->ki_filp->f_path.dentry);
 		if (ret)
 			return ret;
 		ret = pseudo_lock_measure_cycles(rdtgrp, sel);
 		if (ret == 0)
 			ret = count;
-		debugfs_file_put(file->f_path.dentry);
+		debugfs_file_put(iocb->ki_filp->f_path.dentry);
 	}
 
 	return ret;
 }
 
 static const struct file_operations pseudo_measure_fops = {
-	.write = pseudo_lock_measure_trigger,
+	.write_iter = pseudo_lock_measure_trigger,
 	.open = simple_open,
 	.llseek = default_llseek,
 };
@@ -1570,8 +1570,6 @@ static int pseudo_lock_dev_mmap(struct file *filp, struct vm_area_struct *vma)
 static const struct file_operations pseudo_lock_dev_fops = {
 	.owner =	THIS_MODULE,
 	.llseek =	no_llseek,
-	.read =		NULL,
-	.write =	NULL,
 	.open =		pseudo_lock_dev_open,
 	.release =	pseudo_lock_dev_release,
 	.mmap =		pseudo_lock_dev_mmap,
arch/x86/kernel/cpuid.c +7 -9
index dae436253de4..f33fc680cc7d 100644
@@ -58,13 +58,12 @@ static void cpuid_smp_cpuid(void *cmd_block)
 	complete(&cmd->done);
 }
 
-static ssize_t cpuid_read(struct file *file, char __user *buf,
-			  size_t count, loff_t *ppos)
+static ssize_t cpuid_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	char __user *tmp = buf;
 	struct cpuid_regs_done cmd;
-	int cpu = iminor(file_inode(file));
-	u64 pos = *ppos;
+	int cpu = iminor(file_inode(iocb->ki_filp));
+	size_t count = iov_iter_count(to);
+	u64 pos = iocb->ki_pos;
 	ssize_t bytes = 0;
 	int err = 0;
 
@@ -84,13 +83,12 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
 		if (err)
 			break;
 		wait_for_completion(&cmd.done);
-		if (copy_to_user(tmp, &cmd.regs, 16)) {
+		if (!copy_to_iter_full(&cmd.regs, 16, to)) {
 			err = -EFAULT;
 			break;
 		}
-		tmp += 16;
 		bytes += 16;
-		*ppos = ++pos;
+		iocb->ki_pos = ++pos;
 		reinit_completion(&cmd.done);
 	}
 
@@ -119,7 +117,7 @@ static int cpuid_open(struct inode *inode, struct file *file)
 static const struct file_operations cpuid_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_seek_end_llseek,
-	.read = cpuid_read,
+	.read_iter = cpuid_read,
 	.open = cpuid_open,
 };
 
arch/x86/kernel/kdebugfs.c +7 -7
index e2e89bebcbc3..4b4db90ffab2 100644
@@ -26,12 +26,12 @@ struct setup_data_node {
 	u32 len;
 };
 
-static ssize_t setup_data_read(struct file *file, char __user *user_buf,
-			       size_t count, loff_t *ppos)
+static ssize_t setup_data_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct setup_data_node *node = file->private_data;
+	struct setup_data_node *node = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	unsigned long remain;
-	loff_t pos = *ppos;
+	loff_t pos = iocb->ki_pos;
 	void *p;
 	u64 pa;
 
@@ -54,20 +54,20 @@ static ssize_t setup_data_read(struct file *file, char __user *user_buf,
 	if (!p)
 		return -ENOMEM;
 
-	remain = copy_to_user(user_buf, p, count);
+	remain = !copy_to_iter_full(p, count, to);
 
 	memunmap(p);
 
 	if (remain)
 		return -EFAULT;
 
-	*ppos = pos + count;
+	iocb->ki_pos = pos + count;
 
 	return count;
 }
 
 static const struct file_operations fops_setup_data = {
-	.read		= setup_data_read,
+	.read_iter	= setup_data_read,
 	.open		= simple_open,
 	.llseek		= default_llseek,
 };
arch/x86/kernel/msr.c +12 -16
index e17c16c54a37..80cd3d83fb75 100644
@@ -49,13 +49,12 @@ enum allow_write_msrs {
 
 static enum allow_write_msrs allow_writes = MSR_WRITES_DEFAULT;
 
-static ssize_t msr_read(struct file *file, char __user *buf,
-			size_t count, loff_t *ppos)
+static ssize_t msr_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	u32 __user *tmp = (u32 __user *) buf;
 	u32 data[2];
-	u32 reg = *ppos;
-	int cpu = iminor(file_inode(file));
+	u32 reg = iocb->ki_pos;
+	int cpu = iminor(file_inode(iocb->ki_filp));
+	size_t count = iov_iter_count(to);
 	int err = 0;
 	ssize_t bytes = 0;
 
@@ -66,11 +65,10 @@ static ssize_t msr_read(struct file *file, char __user *buf,
 		err = rdmsr_safe_on_cpu(cpu, reg, &data[0], &data[1]);
 		if (err)
 			break;
-		if (copy_to_user(tmp, &data, 8)) {
+		if (!copy_to_iter_full(&data, 8, to)) {
 			err = -EFAULT;
 			break;
 		}
-		tmp += 2;
 		bytes += 8;
 	}
 
@@ -105,13 +103,12 @@ static int filter_write(u32 reg)
 	return 0;
 }
 
-static ssize_t msr_write(struct file *file, const char __user *buf,
-			 size_t count, loff_t *ppos)
+static ssize_t msr_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	const u32 __user *tmp = (const u32 __user *)buf;
+	size_t count = iov_iter_count(from);
 	u32 data[2];
-	u32 reg = *ppos;
-	int cpu = iminor(file_inode(file));
+	u32 reg = iocb->ki_pos;
+	int cpu = iminor(file_inode(iocb->ki_filp));
 	int err = 0;
 	ssize_t bytes = 0;
 
@@ -127,7 +124,7 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
 		return -EINVAL;	/* Invalid chunk size */
 
 	for (; count; count -= 8) {
-		if (copy_from_user(&data, tmp, 8)) {
+		if (!copy_from_iter_full(&data, 8, from)) {
 			err = -EFAULT;
 			break;
 		}
@@ -138,7 +135,6 @@ static ssize_t msr_write(struct file *file, const char __user *buf,
 		if (err)
 			break;
 
-		tmp += 2;
 		bytes += 8;
 	}
 
@@ -227,8 +223,8 @@ static int msr_open(struct inode *inode, struct file *file)
 static const struct file_operations msr_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_seek_end_llseek,
-	.read = msr_read,
-	.write = msr_write,
+	.read_iter = msr_read,
+	.write_iter = msr_write,
 	.open = msr_open,
 	.unlocked_ioctl = msr_ioctl,
 	.compat_ioctl = msr_ioctl,
arch/x86/kernel/tboot.c +9 -8
index 4c1bcb6053fc..59020897c7e6 100644
@@ -356,8 +356,9 @@ static int tboot_dying_cpu(unsigned int cpu)
 
 static uint8_t tboot_log_uuid[16] = TBOOT_LOG_UUID;
 
-static ssize_t tboot_log_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t tboot_log_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	void __iomem *log_base;
 	u8 log_uuid[16];
 	u32 max_size;
@@ -373,13 +374,13 @@ static ssize_t tboot_log_read(struct file *file, char __user *user_buf, size_t c
 		goto err_iounmap;
 
 	max_size = readl(log_base + LOG_MAX_SIZE_OFF);
-	if (*ppos >= max_size) {
+	if (iocb->ki_pos >= max_size) {
 		ret = 0;
 		goto err_iounmap;
 	}
 
-	if (*ppos + count > max_size)
-		count = max_size - *ppos;
+	if (iocb->ki_pos + count > max_size)
+		count = max_size - iocb->ki_pos;
 
 	kbuf = kmalloc(count, GFP_KERNEL);
 	if (!kbuf) {
@@ -387,11 +388,11 @@ static ssize_t tboot_log_read(struct file *file, char __user *user_buf, size_t c
 		goto err_iounmap;
 	}
 
-	memcpy_fromio(kbuf, log_base + LOG_BUF_OFF + *ppos, count);
-	if (copy_to_user(user_buf, kbuf, count))
+	memcpy_fromio(kbuf, log_base + LOG_BUF_OFF + iocb->ki_pos, count);
+	if (!copy_to_iter_full(kbuf, count, to))
 		goto err_kfree;
 
-	*ppos += count;
+	iocb->ki_pos += count;
 
 	ret = count;
 
@@ -405,7 +406,7 @@ static ssize_t tboot_log_read(struct file *file, char __user *user_buf, size_t c
 }
 
 static const struct file_operations tboot_log_fops = {
-	.read	= tboot_log_read,
+	.read_iter	= tboot_log_read,
 	.llseek	= default_llseek,
 };
 
Signature · 1 line
2.43.0
author maintainer
#337 lore raw

PATCH 331/437 x86/kvm: convert to read/write iterators

In reply to Jens Axboe
---
 arch/x86/kvm/debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/debugfs.c +1 -1
index 999227fc7c66..552db0812b02 100644
@@ -184,7 +184,7 @@ static int kvm_mmu_rmaps_stat_release(struct inode *inode, struct file *file)
 static const struct file_operations mmu_rmaps_stat_fops = {
 	.owner		= THIS_MODULE,
 	.open		= kvm_mmu_rmaps_stat_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= kvm_mmu_rmaps_stat_release,
 };
Signature · 1 line
2.43.0
author maintainer
#338 lore raw

PATCH 332/437 x86/mm: convert to read/write iterators

In reply to Jens Axboe
---
 arch/x86/mm/pat/memtype.c    |  2 +-
 arch/x86/mm/pat/set_memory.c |  2 +-
 arch/x86/mm/pkeys.c          | 15 +++++++--------
 arch/x86/mm/tlb.c            | 15 +++++++--------
 4 files changed, 16 insertions(+), 18 deletions(-)
arch/x86/mm/pat/memtype.c +1 -1
index 36b603d0cdde..46f1d1966f96 100644
@@ -1194,7 +1194,7 @@ static int memtype_seq_open(struct inode *inode, struct file *file)
 
 static const struct file_operations memtype_fops = {
 	.open    = memtype_seq_open,
-	.read    = seq_read,
+	.read_iter = seq_read_iter,
 	.llseek  = seq_lseek,
 	.release = seq_release,
 };
arch/x86/mm/pat/set_memory.c +1 -1
index 80c9037ffadf..ee1888fbd218 100644
@@ -186,7 +186,7 @@ static int cpastats_open(struct inode *inode, struct file *file)
 
 static const struct file_operations cpastats_fops = {
 	.open		= cpastats_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
arch/x86/mm/pkeys.c +7 -8
index 7418c367e328..7f084e4f6bd2 100644
@@ -127,25 +127,24 @@ u32 init_pkru_value = PKRU_AD_MASK( 1) | PKRU_AD_MASK( 2) |
 		      PKRU_AD_MASK(13) | PKRU_AD_MASK(14) |
 		      PKRU_AD_MASK(15);
 
-static ssize_t init_pkru_read_file(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t init_pkru_read_file(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[32];
 	unsigned int len;
 
 	len = sprintf(buf, "0x%x\n", init_pkru_value);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t init_pkru_write_file(struct file *file,
-		 const char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t init_pkru_write_file(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	ssize_t len;
 	u32 new_init_pkru;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	/* Make the buffer a valid string that we can not overrun */
@@ -166,8 +165,8 @@ static ssize_t init_pkru_write_file(struct file *file,
 }
 
 static const struct file_operations fops_init_pkru = {
-	.read = init_pkru_read_file,
-	.write = init_pkru_write_file,
+	.read_iter = init_pkru_read_file,
+	.write_iter = init_pkru_write_file,
 	.llseek = default_llseek,
 };
 
arch/x86/mm/tlb.c +7 -8
index 44ac64f3a047..97edf3026036 100644
@@ -1303,25 +1303,24 @@ bool nmi_uaccess_okay(void)
 	return true;
 }
 
-static ssize_t tlbflush_read_file(struct file *file, char __user *user_buf,
-			     size_t count, loff_t *ppos)
+static ssize_t tlbflush_read_file(struct kiocb *iocb, struct iov_iter *to)
 {
 	char buf[32];
 	unsigned int len;
 
 	len = sprintf(buf, "%ld\n", tlb_single_page_flush_ceiling);
-	return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, len, to);
 }
 
-static ssize_t tlbflush_write_file(struct file *file,
-		 const char __user *user_buf, size_t count, loff_t *ppos)
+static ssize_t tlbflush_write_file(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	char buf[32];
 	ssize_t len;
 	int ceiling;
 
 	len = min(count, sizeof(buf) - 1);
-	if (copy_from_user(buf, user_buf, len))
+	if (!copy_from_iter_full(buf, len, from))
 		return -EFAULT;
 
 	buf[len] = '\0';
@@ -1336,8 +1335,8 @@ static ssize_t tlbflush_write_file(struct file *file,
 }
 
 static const struct file_operations fops_tlbflush = {
-	.read = tlbflush_read_file,
-	.write = tlbflush_write_file,
+	.read_iter = tlbflush_read_file,
+	.write_iter = tlbflush_write_file,
 	.llseek = default_llseek,
 };
 
Signature · 1 line
2.43.0
author maintainer
#339 lore raw

PATCH 333/437 arch/arm: convert to read/write iterators

In reply to Jens Axboe
---
 arch/arm/common/bL_switcher_dummy_if.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/common/bL_switcher_dummy_if.c +4 -4
index cabc0659b329..f9794c4a6a40 100644
@@ -15,9 +15,9 @@
 #include <linux/uaccess.h>
 #include <asm/bL_switcher.h>
 
-static ssize_t bL_switcher_write(struct file *file, const char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t bL_switcher_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	unsigned char val[3];
 	unsigned int cpu, cluster;
 	int ret;
@@ -27,7 +27,7 @@ static ssize_t bL_switcher_write(struct file *file, const char __user *buf,
 	if (len < 3)
 		return -EINVAL;
 
-	if (copy_from_user(val, buf, 3))
+	if (!copy_from_iter_full(val, 3, fro))
 		return -EFAULT;
 
 	/* format: <cpu#>,<cluster#> */
@@ -44,7 +44,7 @@ static ssize_t bL_switcher_write(struct file *file, const char __user *buf,
 }
 
 static const struct file_operations bL_switcher_fops = {
-	.write		= bL_switcher_write,
+	.write_iter	= bL_switcher_write,
 	.owner	= THIS_MODULE,
 };
 
Signature · 1 line
2.43.0
author maintainer
#340 lore raw

PATCH 334/437 arch/mips: convert to read/write iterators

In reply to Jens Axboe
---
 arch/mips/kernel/rtlx.c   |  6 ++++--
 arch/mips/kernel/vpe.c    | 14 +++++++-------
 arch/mips/mm/sc-debugfs.c | 16 +++++++---------
 3 files changed, 18 insertions(+), 18 deletions(-)
arch/mips/kernel/rtlx.c +4 -2
index 18c509c59f33..6e3bf6d4c64b 100644
@@ -369,6 +369,7 @@ static ssize_t file_read(struct file *file, char __user *buffer, size_t count,
 
 	return rtlx_read(minor, buffer, count);
 }
+FOPS_READ_ITER_HELPER(file_read);
 
 static ssize_t file_write(struct file *file, const char __user *buffer,
 			  size_t count, loff_t *ppos)
@@ -390,13 +391,14 @@ static ssize_t file_write(struct file *file, const char __user *buffer,
 
 	return rtlx_write(minor, buffer, count);
 }
+FOPS_WRITE_ITER_HELPER(file_write);
 
 const struct file_operations rtlx_fops = {
 	.owner =   THIS_MODULE,
 	.open =    file_open,
 	.release = file_release,
-	.write =   file_write,
-	.read =    file_read,
+	.write_iter =   file_write_iter,
+	.read_iter = file_read_iter,
 	.poll =    file_poll,
 	.llseek =  noop_llseek,
 };
arch/mips/kernel/vpe.c +7 -7
index 737d0d4fdcd3..55db91fba7b0 100644
@@ -834,13 +834,13 @@ static int vpe_release(struct inode *inode, struct file *filp)
 #endif
 }
 
-static ssize_t vpe_write(struct file *file, const char __user *buffer,
-			 size_t count, loff_t *ppos)
+static ssize_t vpe_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	size_t ret = count;
 	struct vpe *v;
 
-	if (iminor(file_inode(file)) != VPE_MODULE_MINOR)
+	if (iminor(file_inode(iocb->ki_filp)) != VPE_MODULE_MINOR)
 		return -ENODEV;
 
 	v = get_vpe(aprp_cpu_index());
@@ -853,19 +853,19 @@ static ssize_t vpe_write(struct file *file, const char __user *buffer,
 		return -ENOMEM;
 	}
 
-	count -= copy_from_user(v->pbuffer + v->len, buffer, count);
-	if (!count)
+	ret !copy_from_iter_full(v->pbuffer + v->len, count, from);
+	if (!ret)
 		return -EFAULT;
 
 	v->len += count;
-	return ret;
+	return count;
 }
 
 const struct file_operations vpe_fops = {
 	.owner = THIS_MODULE,
 	.open = vpe_open,
 	.release = vpe_release,
-	.write = vpe_write,
+	.write_iter = vpe_write,
 	.llseek = noop_llseek,
 };
 
arch/mips/mm/sc-debugfs.c +7 -9
index 80ff3947157d..d85e8b95d9b5 100644
@@ -10,8 +10,7 @@
 #include <linux/debugfs.h>
 #include <linux/init.h>
 
-static ssize_t sc_prefetch_read(struct file *file, char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t sc_prefetch_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	bool enabled = bc_prefetch_is_enabled();
 	char buf[3];
@@ -20,17 +19,16 @@ static ssize_t sc_prefetch_read(struct file *file, char __user *user_buf,
 	buf[1] = '\n';
 	buf[2] = 0;
 
-	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+	return simple_copy_to_iter(buf, &iocb->ki_pos, 2, to);
 }
 
-static ssize_t sc_prefetch_write(struct file *file,
-				 const char __user *user_buf,
-				 size_t count, loff_t *ppos)
+static ssize_t sc_prefetch_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	bool enabled;
 	int err;
 
-	err = kstrtobool_from_user(user_buf, count, &enabled);
+	err = kstrtobool_from_iter(from, count, &enabled);
 	if (err)
 		return err;
 
@@ -45,8 +43,8 @@ static ssize_t sc_prefetch_write(struct file *file,
 static const struct file_operations sc_prefetch_fops = {
 	.open = simple_open,
 	.llseek = default_llseek,
-	.read = sc_prefetch_read,
-	.write = sc_prefetch_write,
+	.read_iter = sc_prefetch_read,
+	.write_iter = sc_prefetch_write,
 };
 
 static int __init sc_debugfs_init(void)
Signature · 1 line
2.43.0
author maintainer
#341 lore raw

PATCH 335/437 parisc: eisa_eeprom: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/parisc/eisa_eeprom.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/parisc/eisa_eeprom.c +6 -6
index 443b15422fc1..87066c0cfc1d 100644
@@ -22,23 +22,23 @@ static loff_t eisa_eeprom_llseek(struct file *file, loff_t offset, int origin)
 	return fixed_size_llseek(file, offset, origin, HPEE_MAX_LENGTH);
 }
 
-static ssize_t eisa_eeprom_read(struct file * file,
-			      char __user *buf, size_t count, loff_t *ppos )
+static ssize_t eisa_eeprom_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	unsigned char *tmp;
 	ssize_t ret;
 	int i;
 	
-	if (*ppos < 0 || *ppos >= HPEE_MAX_LENGTH)
+	if (iocb->ki_pos < 0 || iocb->ki_pos >= HPEE_MAX_LENGTH)
 		return 0;
 	
-	count = *ppos + count < HPEE_MAX_LENGTH ? count : HPEE_MAX_LENGTH - *ppos;
+	count = iocb->ki_pos + count < HPEE_MAX_LENGTH ? count : HPEE_MAX_LENGTH - iocb->ki_pos;
 	tmp = kmalloc(count, GFP_KERNEL);
 	if (tmp) {
 		for (i = 0; i < count; i++)
 			tmp[i] = readb(eisa_eeprom_addr+(*ppos)++);
 
-		if (copy_to_user (buf, tmp, count))
+		if (!copy_to_iter_full(tmp, count, to))
 			ret = -EFAULT;
 		else
 			ret = count;
@@ -68,7 +68,7 @@ static int eisa_eeprom_release(struct inode *inode, struct file *file)
 static const struct file_operations eisa_eeprom_fops = {
 	.owner =	THIS_MODULE,
 	.llseek =	eisa_eeprom_llseek,
-	.read =		eisa_eeprom_read,
+	.read_iter =	eisa_eeprom_read,
 	.open =		eisa_eeprom_open,
 	.release =	eisa_eeprom_release,
 };
Signature · 1 line
2.43.0
author maintainer
#342 lore raw

PATCH 336/437 arch/parisc: convert to read/write iterators

In reply to Jens Axboe
---
 arch/parisc/kernel/perf.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
arch/parisc/kernel/perf.c +7 -7
index b0f0816879df..a564c56ebb6f 100644
@@ -181,7 +181,7 @@ static const uint64_t *bitmask_array;   /* array of bitmasks to use */
 static int perf_config(uint32_t *image_ptr);
 static int perf_release(struct inode *inode, struct file *file);
 static int perf_open(struct inode *inode, struct file *file);
-static ssize_t perf_read(struct file *file, char __user *buf, size_t cnt, loff_t *ppos);
+static ssize_t perf_read(struct kiocb *iocb, struct iov_iter *to);
 static ssize_t perf_write(struct file *file, const char __user *buf,
 	size_t count, loff_t *ppos);
 static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
@@ -273,7 +273,7 @@ static int perf_release(struct inode *inode, struct file *file)
 /*
  * Read does nothing for this driver
  */
-static ssize_t perf_read(struct file *file, char __user *buf, size_t cnt, loff_t *ppos)
+static ssize_t perf_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return 0;
 }
@@ -285,9 +285,9 @@ static ssize_t perf_read(struct file *file, char __user *buf, size_t cnt, loff_t
  * called on the processor that the download should happen
  * on.
  */
-static ssize_t perf_write(struct file *file, const char __user *buf,
-	size_t count, loff_t *ppos)
+static ssize_t perf_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	size_t image_size __maybe_unused;
 	uint32_t image_type;
 	uint32_t interface_type;
@@ -306,7 +306,7 @@ static ssize_t perf_write(struct file *file, const char __user *buf,
 	if (count != sizeof(uint32_t))
 		return -EIO;
 
-	if (copy_from_user(&image_type, buf, sizeof(uint32_t)))
+	if (!copy_from_iter_full(&image_type, sizeof(uint32_t), from))
 		return -EFAULT;
 
 	/* Get the interface type and test type */
@@ -467,8 +467,8 @@ static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 static const struct file_operations perf_fops = {
 	.llseek = no_llseek,
-	.read = perf_read,
-	.write = perf_write,
+	.read_iter = perf_read,
+	.write_iter = perf_write,
 	.unlocked_ioctl = perf_ioctl,
 	.compat_ioctl = perf_ioctl,
 	.open = perf_open,
Signature · 1 line
2.43.0
author maintainer
#343 lore raw

PATCH 337/437 powerpc/kernel: convert to read/write iterators

In reply to Jens Axboe
---
 arch/powerpc/kernel/eeh.c | 58 ++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 34 deletions(-)
arch/powerpc/kernel/eeh.c +24 -34
index ab316e155ea9..35ea1c80e0de 100644
@@ -1588,9 +1588,8 @@ static int proc_eeh_show(struct seq_file *m, void *v)
 #ifdef CONFIG_DEBUG_FS
 
 
-static struct pci_dev *eeh_debug_lookup_pdev(struct file *filp,
-					     const char __user *user_buf,
-					     size_t count, loff_t *ppos)
+static struct pci_dev *eeh_debug_lookup_pdev(struct kiocb *iocb,
+					     struct iov_iter *from)
 {
 	uint32_t domain, bus, dev, fn;
 	struct pci_dev *pdev;
@@ -1598,7 +1597,7 @@ static struct pci_dev *eeh_debug_lookup_pdev(struct file *filp,
 	int ret;
 
 	memset(buf, 0, sizeof(buf));
-	ret = simple_write_to_buffer(buf, sizeof(buf)-1, ppos, user_buf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf)-1, from);
 	if (!ret)
 		return ERR_PTR(-EFAULT);
 
@@ -1637,17 +1636,16 @@ static int eeh_enable_dbgfs_get(void *data, u64 *val)
 DEFINE_DEBUGFS_ATTRIBUTE(eeh_enable_dbgfs_ops, eeh_enable_dbgfs_get,
 			 eeh_enable_dbgfs_set, "0x%llx\n");
 
-static ssize_t eeh_force_recover_write(struct file *filp,
-				const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t eeh_force_recover_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct pci_controller *hose;
 	uint32_t phbid, pe_no;
 	struct eeh_pe *pe;
 	char buf[20];
 	int ret;
 
-	ret = simple_write_to_buffer(buf, sizeof(buf), ppos, user_buf, count);
+	ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf), from);
 	if (!ret)
 		return -EFAULT;
 
@@ -1690,28 +1688,23 @@ static ssize_t eeh_force_recover_write(struct file *filp,
 static const struct file_operations eeh_force_recover_fops = {
 	.open	= simple_open,
 	.llseek	= no_llseek,
-	.write	= eeh_force_recover_write,
+	.write_iter = eeh_force_recover_write,
 };
 
-static ssize_t eeh_debugfs_dev_usage(struct file *filp,
-				char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t eeh_debugfs_dev_usage(struct kiocb *iocb, struct iov_iter *to)
 {
 	static const char usage[] = "input format: <domain>:<bus>:<dev>.<fn>\n";
 
-	return simple_read_from_buffer(user_buf, count, ppos,
-				       usage, sizeof(usage) - 1);
+	return simple_copy_to_iter(usage, &iocb->ki_pos, sizeof(usage) - 1, to);
 }
 
-static ssize_t eeh_dev_check_write(struct file *filp,
-				const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t eeh_dev_check_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct pci_dev *pdev;
 	struct eeh_dev *edev;
 	int ret;
 
-	pdev = eeh_debug_lookup_pdev(filp, user_buf, count, ppos);
+	pdev = eeh_debug_lookup_pdev(iocb, from);
 	if (IS_ERR(pdev))
 		return PTR_ERR(pdev);
 
@@ -1728,14 +1721,14 @@ static ssize_t eeh_dev_check_write(struct file *filp,
 
 	pci_dev_put(pdev);
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations eeh_dev_check_fops = {
 	.open	= simple_open,
 	.llseek	= no_llseek,
-	.write	= eeh_dev_check_write,
-	.read   = eeh_debugfs_dev_usage,
+	.write_iter = eeh_dev_check_write,
+	.read_iter = eeh_debugfs_dev_usage,
 };
 
 static int eeh_debugfs_break_device(struct pci_dev *pdev)
@@ -1831,14 +1824,12 @@ static int eeh_debugfs_break_device(struct pci_dev *pdev)
 	return 0;
 }
 
-static ssize_t eeh_dev_break_write(struct file *filp,
-				const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t eeh_dev_break_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	struct pci_dev *pdev;
 	int ret;
 
-	pdev = eeh_debug_lookup_pdev(filp, user_buf, count, ppos);
+	pdev = eeh_debug_lookup_pdev(iocb, from);
 	if (IS_ERR(pdev))
 		return PTR_ERR(pdev);
 
@@ -1848,25 +1839,24 @@ static ssize_t eeh_dev_break_write(struct file *filp,
 	if (ret < 0)
 		return ret;
 
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations eeh_dev_break_fops = {
 	.open	= simple_open,
 	.llseek	= no_llseek,
-	.write	= eeh_dev_break_write,
-	.read   = eeh_debugfs_dev_usage,
+	.write_iter = eeh_dev_break_write,
+	.read_iter = eeh_debugfs_dev_usage,
 };
 
-static ssize_t eeh_dev_can_recover(struct file *filp,
-				   const char __user *user_buf,
-				   size_t count, loff_t *ppos)
+static ssize_t eeh_dev_can_recover(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct pci_driver *drv;
 	struct pci_dev *pdev;
 	size_t ret;
 
-	pdev = eeh_debug_lookup_pdev(filp, user_buf, count, ppos);
+	pdev = eeh_debug_lookup_pdev(iocb, from);
 	if (IS_ERR(pdev))
 		return PTR_ERR(pdev);
 
@@ -1901,8 +1891,8 @@ static ssize_t eeh_dev_can_recover(struct file *filp,
 static const struct file_operations eeh_dev_can_recover_fops = {
 	.open	= simple_open,
 	.llseek	= no_llseek,
-	.write	= eeh_dev_can_recover,
-	.read   = eeh_debugfs_dev_usage,
+	.write_iter = eeh_dev_can_recover,
+	.read_iter = eeh_debugfs_dev_usage,
 };
 
 #endif
Signature · 1 line
2.43.0
author maintainer
#344 lore raw

PATCH 338/437 powerpc/kvm: convert to read/write iterators

In reply to Jens Axboe
---
 arch/powerpc/kvm/book3s_64_mmu_hv.c    | 25 ++++++++++++-------------
 arch/powerpc/kvm/book3s_64_mmu_radix.c | 19 ++++++++-----------
 arch/powerpc/kvm/book3s_hv.c           | 26 +++++++++++---------------
 arch/powerpc/kvm/timing.c              | 14 +++++++-------
 4 files changed, 38 insertions(+), 46 deletions(-)
arch/powerpc/kvm/book3s_64_mmu_hv.c +12 -13
index 2b1f0cdd8c18..254a267cac6f 100644
@@ -1820,6 +1820,7 @@ static ssize_t kvm_htab_read(struct file *file, char __user *buf,
 
 	return nb;
 }
+FOPS_READ_ITER_HELPER(kvm_htab_read);
 
 static ssize_t kvm_htab_write(struct file *file, const char __user *buf,
 			      size_t count, loff_t *ppos)
@@ -1943,6 +1944,7 @@ static ssize_t kvm_htab_write(struct file *file, const char __user *buf,
 		return err;
 	return nb;
 }
+FOPS_WRITE_ITER_HELPER(kvm_htab_write);
 
 static int kvm_htab_release(struct inode *inode, struct file *filp)
 {
@@ -1957,8 +1959,8 @@ static int kvm_htab_release(struct inode *inode, struct file *filp)
 }
 
 static const struct file_operations kvm_htab_fops = {
-	.read		= kvm_htab_read,
-	.write		= kvm_htab_write,
+	.read_iter	= kvm_htab_read_iter,
+	.write_iter	= kvm_htab_write_iter,
 	.llseek		= default_llseek,
 	.release	= kvm_htab_release,
 };
@@ -2035,10 +2037,10 @@ static int debugfs_htab_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t debugfs_htab_read(struct file *file, char __user *buf,
-				 size_t len, loff_t *ppos)
+static ssize_t debugfs_htab_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct debugfs_htab_state *p = file->private_data;
+	struct debugfs_htab_state *p = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t ret, r;
 	unsigned long i, n;
 	unsigned long v, hr, gr;
@@ -2057,11 +2059,10 @@ static ssize_t debugfs_htab_read(struct file *file, char __user *buf,
 		n = p->chars_left;
 		if (n > len)
 			n = len;
-		r = copy_to_user(buf, p->buf + p->buf_index, n);
+		r = copy_to_iter(p->buf + p->buf_index, n, to);
 		n -= r;
 		p->chars_left -= n;
 		p->buf_index += n;
-		buf += n;
 		len -= n;
 		ret = n;
 		if (r) {
@@ -2097,11 +2098,10 @@ static ssize_t debugfs_htab_read(struct file *file, char __user *buf,
 		p->chars_left = n;
 		if (n > len)
 			n = len;
-		r = copy_to_user(buf, p->buf, n);
+		r = copy_to_iter(p->buf, n, to);
 		n -= r;
 		p->chars_left -= n;
 		p->buf_index = n;
-		buf += n;
 		len -= n;
 		ret += n;
 		if (r) {
@@ -2117,8 +2117,7 @@ static ssize_t debugfs_htab_read(struct file *file, char __user *buf,
 	return ret;
 }
 
-static ssize_t debugfs_htab_write(struct file *file, const char __user *buf,
-			   size_t len, loff_t *ppos)
+static ssize_t debugfs_htab_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return -EACCES;
 }
@@ -2127,8 +2126,8 @@ static const struct file_operations debugfs_htab_fops = {
 	.owner	 = THIS_MODULE,
 	.open	 = debugfs_htab_open,
 	.release = debugfs_htab_release,
-	.read	 = debugfs_htab_read,
-	.write	 = debugfs_htab_write,
+	.read_iter  = debugfs_htab_read,
+	.write_iter = debugfs_htab_write,
 	.llseek	 = generic_file_llseek,
 };
 
arch/powerpc/kvm/book3s_64_mmu_radix.c +8 -11
index 408d98f8a514..d33c92bbe6f2 100644
@@ -1298,10 +1298,10 @@ static int debugfs_radix_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t debugfs_radix_read(struct file *file, char __user *buf,
-				 size_t len, loff_t *ppos)
+static ssize_t debugfs_radix_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct debugfs_radix_state *p = file->private_data;
+	struct debugfs_radix_state *p = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t ret, r;
 	unsigned long n;
 	struct kvm *kvm;
@@ -1328,11 +1328,10 @@ static ssize_t debugfs_radix_read(struct file *file, char __user *buf,
 		n = p->chars_left;
 		if (n > len)
 			n = len;
-		r = copy_to_user(buf, p->buf + p->buf_index, n);
+		r = copy_to_iter(p->buf + p->buf_index, n, to);
 		n -= r;
 		p->chars_left -= n;
 		p->buf_index += n;
-		buf += n;
 		len -= n;
 		ret = n;
 		if (r) {
@@ -1428,11 +1427,10 @@ static ssize_t debugfs_radix_read(struct file *file, char __user *buf,
 		p->chars_left = n;
 		if (n > len)
 			n = len;
-		r = copy_to_user(buf, p->buf, n);
+		r = copy_to_iter(p->buf, n, to);
 		n -= r;
 		p->chars_left -= n;
 		p->buf_index = n;
-		buf += n;
 		len -= n;
 		ret += n;
 		if (r) {
@@ -1450,8 +1448,7 @@ static ssize_t debugfs_radix_read(struct file *file, char __user *buf,
 	return ret;
 }
 
-static ssize_t debugfs_radix_write(struct file *file, const char __user *buf,
-			   size_t len, loff_t *ppos)
+static ssize_t debugfs_radix_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return -EACCES;
 }
@@ -1460,8 +1457,8 @@ static const struct file_operations debugfs_radix_fops = {
 	.owner	 = THIS_MODULE,
 	.open	 = debugfs_radix_open,
 	.release = debugfs_radix_release,
-	.read	 = debugfs_radix_read,
-	.write	 = debugfs_radix_write,
+	.read_iter  = debugfs_radix_read,
+	.write_iter = debugfs_radix_write,
 	.llseek	 = generic_file_llseek,
 };
 
arch/powerpc/kvm/book3s_hv.c +11 -15
index 8e86eb577eb8..33ccdf765395 100644
@@ -2860,10 +2860,10 @@ static int debugfs_timings_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t debugfs_timings_read(struct file *file, char __user *buf,
-				    size_t len, loff_t *ppos)
+static ssize_t debugfs_timings_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct debugfs_timings_state *p = file->private_data;
+	struct debugfs_timings_state *p = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	struct kvm_vcpu *vcpu = p->vcpu;
 	char *s, *buf_end;
 	struct kvmhv_tb_accumulator tb;
@@ -2910,23 +2910,19 @@ static ssize_t debugfs_timings_read(struct file *file, char __user *buf,
 		p->buflen = s - p->buf;
 	}
 
-	pos = *ppos;
+	pos = iocb->ki_pos;
 	if (pos >= p->buflen)
 		return 0;
 	if (len > p->buflen - pos)
 		len = p->buflen - pos;
-	n = copy_to_user(buf, p->buf + pos, len);
-	if (n) {
-		if (n == len)
-			return -EFAULT;
-		len -= n;
-	}
-	*ppos = pos + len;
+	n = !copy_to_iter_full(p->buf + pos, len, to);
+	if (n)
+		return -EFAULT;
+	iocb->ki_pos = pos + len;
 	return len;
 }
 
-static ssize_t debugfs_timings_write(struct file *file, const char __user *buf,
-				     size_t len, loff_t *ppos)
+static ssize_t debugfs_timings_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return -EACCES;
 }
@@ -2935,8 +2931,8 @@ static const struct file_operations debugfs_timings_ops = {
 	.owner	 = THIS_MODULE,
 	.open	 = debugfs_timings_open,
 	.release = debugfs_timings_release,
-	.read	 = debugfs_timings_read,
-	.write	 = debugfs_timings_write,
+	.read_iter = debugfs_timings_read,
+	.write_iter = debugfs_timings_write,
 	.llseek	 = generic_file_llseek,
 };
 
arch/powerpc/kvm/timing.c +7 -7
index 25071331f8c1..1281aaef2b44 100644
@@ -158,10 +158,10 @@ static int kvmppc_exit_timing_show(struct seq_file *m, void *private)
 }
 
 /* Write 'c' to clear the timing statistics. */
-static ssize_t kvmppc_exit_timing_write(struct file *file,
-				       const char __user *user_buf,
-				       size_t count, loff_t *ppos)
+static ssize_t kvmppc_exit_timing_write(struct kiocb *iocb,
+					struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	int err = -EINVAL;
 	char c;
 
@@ -169,13 +169,13 @@ static ssize_t kvmppc_exit_timing_write(struct file *file,
 		goto done;
 	}
 
-	if (get_user(c, user_buf)) {
+	if (get_iter(&c, from)) {
 		err = -EFAULT;
 		goto done;
 	}
 
 	if (c == 'c') {
-		struct seq_file *seqf = file->private_data;
+		struct seq_file *seqf = iocb->ki_filp->private_data;
 		struct kvm_vcpu *vcpu = seqf->private;
 		/* Write does not affect our buffers previously generated with
 		 * show. seq_file is locked here to prevent races of init with
@@ -198,8 +198,8 @@ static int kvmppc_exit_timing_open(struct inode *inode, struct file *file)
 static const struct file_operations kvmppc_exit_timing_fops = {
 	.owner   = THIS_MODULE,
 	.open    = kvmppc_exit_timing_open,
-	.read    = seq_read,
-	.write   = kvmppc_exit_timing_write,
+	.read_iter = seq_read_iter,
+	.write_iter = kvmppc_exit_timing_write,
 	.llseek  = seq_lseek,
 	.release = single_release,
 };
Signature · 1 line
2.43.0
author maintainer
#345 lore raw

PATCH 339/437 powerpc/spufs: convert to read/write iterators

In reply to Jens Axboe
---
 arch/powerpc/platforms/cell/spufs/file.c | 312 +++++++++++------------
 1 file changed, 147 insertions(+), 165 deletions(-)
arch/powerpc/platforms/cell/spufs/file.c +147 -165
index 02a8158c469d..025c9b0a0470 100644
@@ -67,14 +67,13 @@ static int spufs_attr_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t spufs_attr_read(struct file *file, char __user *buf,
-		size_t len, loff_t *ppos)
+static ssize_t spufs_attr_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct spufs_attr *attr;
 	size_t size;
 	ssize_t ret;
 
-	attr = file->private_data;
+	attr = iocb->ki_filp->private_data;
 	if (!attr->get)
 		return -EACCES;
 
@@ -82,7 +81,7 @@ static ssize_t spufs_attr_read(struct file *file, char __user *buf,
 	if (ret)
 		return ret;
 
-	if (*ppos) {		/* continued read */
+	if (iocb->ki_pos) {	/* continued read */
 		size = strlen(attr->get_buf);
 	} else {		/* first read */
 		u64 val;
@@ -94,21 +93,21 @@ static ssize_t spufs_attr_read(struct file *file, char __user *buf,
 				 attr->fmt, (unsigned long long)val);
 	}
 
-	ret = simple_read_from_buffer(buf, len, ppos, attr->get_buf, size);
+	ret = simple_copy_to_iter(attr->get_buf, &iocb->ki_pos, size, to);
 out:
 	mutex_unlock(&attr->mutex);
 	return ret;
 }
 
-static ssize_t spufs_attr_write(struct file *file, const char __user *buf,
-		size_t len, loff_t *ppos)
+static ssize_t spufs_attr_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t len = iov_iter_count(from);
 	struct spufs_attr *attr;
 	u64 val;
 	size_t size;
 	ssize_t ret;
 
-	attr = file->private_data;
+	attr = iocb->ki_filp->private_data;
 	if (!attr->set)
 		return -EACCES;
 
@@ -118,7 +117,7 @@ static ssize_t spufs_attr_write(struct file *file, const char __user *buf,
 
 	ret = -EFAULT;
 	size = min(sizeof(attr->set_buf) - 1, len);
-	if (copy_from_user(attr->set_buf, buf, size))
+	if (!copy_from_iter_full(attr->set_buf, size, from))
 		goto out;
 
 	ret = len; /* claim we got the whole input */
@@ -147,8 +146,8 @@ static int __fops ## _open(struct inode *inode, struct file *file)	\
 static const struct file_operations __fops = {				\
 	.open	 = __fops ## _open,					\
 	.release = spufs_attr_release,					\
-	.read	 = spufs_attr_read,					\
-	.write	 = spufs_attr_write,					\
+	.read_iter = spufs_attr_read,					\
+	.write_iter = spufs_attr_write,					\
 	.llseek  = generic_file_llseek,					\
 };
 
@@ -186,30 +185,27 @@ spufs_mem_dump(struct spu_context *ctx, struct coredump_params *cprm)
 	return spufs_dump_emit(cprm, ctx->ops->get_ls(ctx), LS_SIZE);
 }
 
-static ssize_t
-spufs_mem_read(struct file *file, char __user *buffer,
-				size_t size, loff_t *pos)
+static ssize_t spufs_mem_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	ssize_t ret;
 
 	ret = spu_acquire(ctx);
 	if (ret)
 		return ret;
-	ret = simple_read_from_buffer(buffer, size, pos, ctx->ops->get_ls(ctx),
-				      LS_SIZE);
+	ret = simple_copy_to_iter(ctx->ops->get_ls(ctx), &iocb->ki_pos, LS_SIZE,
+				  to);
 	spu_release(ctx);
 
 	return ret;
 }
 
-static ssize_t
-spufs_mem_write(struct file *file, const char __user *buffer,
-					size_t size, loff_t *ppos)
+static ssize_t spufs_mem_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	char *local_store;
-	loff_t pos = *ppos;
+	loff_t pos = iocb->ki_pos;
+	ssize_t size;
 	int ret;
 
 	if (pos > LS_SIZE)
@@ -220,7 +216,7 @@ spufs_mem_write(struct file *file, const char __user *buffer,
 		return ret;
 
 	local_store = ctx->ops->get_ls(ctx);
-	size = simple_write_to_buffer(local_store, LS_SIZE, ppos, buffer, size);
+	size = simple_copy_to_iter(local_store, &iocb->ki_pos, LS_SIZE, from);
 	spu_release(ctx);
 
 	return size;
@@ -301,8 +297,8 @@ static int spufs_mem_mmap(struct file *file, struct vm_area_struct *vma)
 static const struct file_operations spufs_mem_fops = {
 	.open			= spufs_mem_open,
 	.release		= spufs_mem_release,
-	.read			= spufs_mem_read,
-	.write			= spufs_mem_write,
+	.read_iter		= spufs_mem_read,
+	.write_iter		= spufs_mem_write,
 	.llseek			= generic_file_llseek,
 	.mmap			= spufs_mem_mmap,
 };
@@ -451,8 +447,8 @@ spufs_cntl_release(struct inode *inode, struct file *file)
 static const struct file_operations spufs_cntl_fops = {
 	.open = spufs_cntl_open,
 	.release = spufs_cntl_release,
-	.read = simple_attr_read,
-	.write = simple_attr_write,
+	.read_iter = simple_attr_read_iter,
+	.write_iter = simple_attr_write_iter,
 	.llseek	= no_llseek,
 	.mmap = spufs_cntl_mmap,
 };
@@ -472,44 +468,41 @@ spufs_regs_dump(struct spu_context *ctx, struct coredump_params *cprm)
 			       sizeof(ctx->csa.lscsa->gprs));
 }
 
-static ssize_t
-spufs_regs_read(struct file *file, char __user *buffer,
-		size_t size, loff_t *pos)
+static ssize_t spufs_regs_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int ret;
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 
 	/* pre-check for file position: if we'd return EOF, there's no point
 	 * causing a deschedule */
-	if (*pos >= sizeof(ctx->csa.lscsa->gprs))
+	if (iocb->ki_pos >= sizeof(ctx->csa.lscsa->gprs))
 		return 0;
 
 	ret = spu_acquire_saved(ctx);
 	if (ret)
 		return ret;
-	ret = simple_read_from_buffer(buffer, size, pos, ctx->csa.lscsa->gprs,
-				      sizeof(ctx->csa.lscsa->gprs));
+	ret = simple_copy_to_iter(ctx->csa.lscsa->gprs, &iocb->ki_pos,
+				      sizeof(ctx->csa.lscsa->gprs), to);
 	spu_release_saved(ctx);
 	return ret;
 }
 
-static ssize_t
-spufs_regs_write(struct file *file, const char __user *buffer,
-		 size_t size, loff_t *pos)
+static ssize_t spufs_regs_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	struct spu_lscsa *lscsa = ctx->csa.lscsa;
+	ssize_t size;
 	int ret;
 
-	if (*pos >= sizeof(lscsa->gprs))
+	if (iocb->ki_pos >= sizeof(lscsa->gprs))
 		return -EFBIG;
 
 	ret = spu_acquire_saved(ctx);
 	if (ret)
 		return ret;
 
-	size = simple_write_to_buffer(lscsa->gprs, sizeof(lscsa->gprs), pos,
-					buffer, size);
+	size = simple_copy_from_iter(lscsa->gprs, &iocb->ki_pos,
+					sizeof(lscsa->gprs), from);
 
 	spu_release_saved(ctx);
 	return size;
@@ -517,8 +510,8 @@ spufs_regs_write(struct file *file, const char __user *buffer,
 
 static const struct file_operations spufs_regs_fops = {
 	.open	 = spufs_regs_open,
-	.read    = spufs_regs_read,
-	.write   = spufs_regs_write,
+	.read_iter = spufs_regs_read,
+	.write_iter = spufs_regs_write,
 	.llseek  = generic_file_llseek,
 };
 
@@ -529,39 +522,36 @@ spufs_fpcr_dump(struct spu_context *ctx, struct coredump_params *cprm)
 			       sizeof(ctx->csa.lscsa->fpcr));
 }
 
-static ssize_t
-spufs_fpcr_read(struct file *file, char __user * buffer,
-		size_t size, loff_t * pos)
+static ssize_t spufs_fpcr_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	int ret;
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 
 	ret = spu_acquire_saved(ctx);
 	if (ret)
 		return ret;
-	ret = simple_read_from_buffer(buffer, size, pos, &ctx->csa.lscsa->fpcr,
-				      sizeof(ctx->csa.lscsa->fpcr));
+	ret = simple_copy_to_iter(&ctx->csa.lscsa->fpcr, &iocb->ki_pos,
+				      sizeof(ctx->csa.lscsa->fpcr), to);
 	spu_release_saved(ctx);
 	return ret;
 }
 
-static ssize_t
-spufs_fpcr_write(struct file *file, const char __user * buffer,
-		 size_t size, loff_t * pos)
+static ssize_t spufs_fpcr_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	struct spu_lscsa *lscsa = ctx->csa.lscsa;
+	ssize_t size;
 	int ret;
 
-	if (*pos >= sizeof(lscsa->fpcr))
+	if (iocb->ki_pos >= sizeof(lscsa->fpcr))
 		return -EFBIG;
 
 	ret = spu_acquire_saved(ctx);
 	if (ret)
 		return ret;
 
-	size = simple_write_to_buffer(&lscsa->fpcr, sizeof(lscsa->fpcr), pos,
-					buffer, size);
+	size = simple_copy_from_iter(&lscsa->fpcr, &iocb->ki_pos,
+					sizeof(lscsa->fpcr), from);
 
 	spu_release_saved(ctx);
 	return size;
@@ -569,8 +559,8 @@ spufs_fpcr_write(struct file *file, const char __user * buffer,
 
 static const struct file_operations spufs_fpcr_fops = {
 	.open = spufs_regs_open,
-	.read = spufs_fpcr_read,
-	.write = spufs_fpcr_write,
+	.read_iter = spufs_fpcr_read,
+	.write_iter = spufs_fpcr_write,
 	.llseek = generic_file_llseek,
 };
 
@@ -591,11 +581,11 @@ static int spufs_pipe_open(struct inode *inode, struct file *file)
  * - end of the user provided buffer
  * - end of the mapped area
  */
-static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t spufs_mbox_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
-	u32 mbox_data, __user *udata = (void __user *)buf;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
+	u32 mbox_data;
 	ssize_t count;
 
 	if (len < 4)
@@ -605,7 +595,7 @@ static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
 	if (count)
 		return count;
 
-	for (count = 0; (count + 4) <= len; count += 4, udata++) {
+	for (count = 0; (count + 4) <= len; count += 4) {
 		int ret;
 		ret = ctx->ops->mbox_read(ctx, &mbox_data);
 		if (ret == 0)
@@ -616,7 +606,7 @@ static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
 		 * but still need to return the data we have
 		 * read successfully so far.
 		 */
-		ret = put_user(mbox_data, udata);
+		ret = put_iter(mbox_data, to);
 		if (ret) {
 			if (!count)
 				count = -EFAULT;
@@ -633,14 +623,14 @@ static ssize_t spufs_mbox_read(struct file *file, char __user *buf,
 
 static const struct file_operations spufs_mbox_fops = {
 	.open	= spufs_pipe_open,
-	.read	= spufs_mbox_read,
+	.read_iter = spufs_mbox_read,
 	.llseek	= no_llseek,
 };
 
-static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t spufs_mbox_stat_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t ret;
 	u32 mbox_stat;
 
@@ -655,7 +645,7 @@ static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf,
 
 	spu_release(ctx);
 
-	if (copy_to_user(buf, &mbox_stat, sizeof mbox_stat))
+	if (!copy_to_iter_full(&mbox_stat, sizeof (mbox_stat), to))
 		return -EFAULT;
 
 	return 4;
@@ -663,7 +653,7 @@ static ssize_t spufs_mbox_stat_read(struct file *file, char __user *buf,
 
 static const struct file_operations spufs_mbox_stat_fops = {
 	.open	= spufs_pipe_open,
-	.read	= spufs_mbox_stat_read,
+	.read_iter = spufs_mbox_stat_read,
 	.llseek = no_llseek,
 };
 
@@ -694,11 +684,11 @@ void spufs_ibox_callback(struct spu *spu)
  * any data is available, but return when we have been able to
  * read something.
  */
-static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t spufs_ibox_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
-	u32 ibox_data, __user *udata = (void __user *)buf;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
+	u32 ibox_data;
 	ssize_t count;
 
 	if (len < 4)
@@ -710,7 +700,7 @@ static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
 
 	/* wait only for the first element */
 	count = 0;
-	if (file->f_flags & O_NONBLOCK) {
+	if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 		if (!spu_ibox_read(ctx, &ibox_data)) {
 			count = -EAGAIN;
 			goto out_unlock;
@@ -722,11 +712,11 @@ static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
 	}
 
 	/* if we can't write at all, return -EFAULT */
-	count = put_user(ibox_data, udata);
+	count = put_iter(ibox_data, to);
 	if (count)
 		goto out_unlock;
 
-	for (count = 4, udata++; (count + 4) <= len; count += 4, udata++) {
+	for (count = 4; (count + 4) <= len; count += 4) {
 		int ret;
 		ret = ctx->ops->ibox_read(ctx, &ibox_data);
 		if (ret == 0)
@@ -736,7 +726,7 @@ static ssize_t spufs_ibox_read(struct file *file, char __user *buf,
 		 * but still need to return the data we have
 		 * read successfully so far.
 		 */
-		ret = put_user(ibox_data, udata);
+		ret = put_iter(ibox_data, to);
 		if (ret)
 			break;
 	}
@@ -767,15 +757,15 @@ static __poll_t spufs_ibox_poll(struct file *file, poll_table *wait)
 
 static const struct file_operations spufs_ibox_fops = {
 	.open	= spufs_pipe_open,
-	.read	= spufs_ibox_read,
+	.read_iter = spufs_ibox_read,
 	.poll	= spufs_ibox_poll,
 	.llseek = no_llseek,
 };
 
-static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t spufs_ibox_stat_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t ret;
 	u32 ibox_stat;
 
@@ -788,7 +778,7 @@ static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf,
 	ibox_stat = (ctx->ops->mbox_stat_read(ctx) >> 16) & 0xff;
 	spu_release(ctx);
 
-	if (copy_to_user(buf, &ibox_stat, sizeof ibox_stat))
+	if (!copy_to_iter_full(&ibox_stat, sizeof ibox_stat, to))
 		return -EFAULT;
 
 	return 4;
@@ -796,7 +786,7 @@ static ssize_t spufs_ibox_stat_read(struct file *file, char __user *buf,
 
 static const struct file_operations spufs_ibox_stat_fops = {
 	.open	= spufs_pipe_open,
-	.read	= spufs_ibox_stat_read,
+	.read_iter = spufs_ibox_stat_read,
 	.llseek = no_llseek,
 };
 
@@ -827,17 +817,17 @@ void spufs_wbox_callback(struct spu *spu)
  * space is available, but return when we have been able to
  * write something.
  */
-static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t spufs_wbox_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct spu_context *ctx = file->private_data;
-	u32 wbox_data, __user *udata = (void __user *)buf;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(from);
+	u32 wbox_data;
 	ssize_t count;
 
 	if (len < 4)
 		return -EINVAL;
 
-	if (get_user(wbox_data, udata))
+	if (get_iter(wbox_data, from))
 		return -EFAULT;
 
 	count = spu_acquire(ctx);
@@ -849,7 +839,7 @@ static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
 	 * in case of !O_NONBLOCK
 	 */
 	count = 0;
-	if (file->f_flags & O_NONBLOCK) {
+	if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 		if (!spu_wbox_write(ctx, wbox_data)) {
 			count = -EAGAIN;
 			goto out_unlock;
@@ -862,9 +852,9 @@ static ssize_t spufs_wbox_write(struct file *file, const char __user *buf,
 
 
 	/* write as much as possible */
-	for (count = 4, udata++; (count + 4) <= len; count += 4, udata++) {
+	for (count = 4; (count + 4) <= len; count += 4) {
 		int ret;
-		ret = get_user(wbox_data, udata);
+		ret = get_iter(wbox_data, from);
 		if (ret)
 			break;
 
@@ -899,15 +889,15 @@ static __poll_t spufs_wbox_poll(struct file *file, poll_table *wait)
 
 static const struct file_operations spufs_wbox_fops = {
 	.open	= spufs_pipe_open,
-	.write	= spufs_wbox_write,
+	.write_iter = spufs_wbox_write,
 	.poll	= spufs_wbox_poll,
 	.llseek = no_llseek,
 };
 
-static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t spufs_wbox_stat_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	ssize_t ret;
 	u32 wbox_stat;
 
@@ -920,7 +910,7 @@ static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf,
 	wbox_stat = (ctx->ops->mbox_stat_read(ctx) >> 8) & 0xff;
 	spu_release(ctx);
 
-	if (copy_to_user(buf, &wbox_stat, sizeof wbox_stat))
+	if (!copy_to_iter_full(&wbox_stat, sizeof wbox_stat, to))
 		return -EFAULT;
 
 	return 4;
@@ -928,7 +918,7 @@ static ssize_t spufs_wbox_stat_read(struct file *file, char __user *buf,
 
 static const struct file_operations spufs_wbox_stat_fops = {
 	.open	= spufs_pipe_open,
-	.read	= spufs_wbox_stat_read,
+	.read_iter = spufs_wbox_stat_read,
 	.llseek = no_llseek,
 };
 
@@ -994,6 +984,7 @@ static ssize_t spufs_signal1_read(struct file *file, char __user *buf,
 
 	return ret;
 }
+FOPS_READ_ITER_HELPER(spufs_signal1_read);
 
 static ssize_t spufs_signal1_write(struct file *file, const char __user *buf,
 			size_t len, loff_t *pos)
@@ -1018,6 +1009,7 @@ static ssize_t spufs_signal1_write(struct file *file, const char __user *buf,
 
 	return 4;
 }
+FOPS_WRITE_ITER_HELPER(spufs_signal1_write);
 
 static vm_fault_t
 spufs_signal1_mmap_fault(struct vm_fault *vmf)
@@ -1053,8 +1045,8 @@ static int spufs_signal1_mmap(struct file *file, struct vm_area_struct *vma)
 static const struct file_operations spufs_signal1_fops = {
 	.open = spufs_signal1_open,
 	.release = spufs_signal1_release,
-	.read = spufs_signal1_read,
-	.write = spufs_signal1_write,
+	.read_iter = spufs_signal1_read_iter,
+	.write_iter = spufs_signal1_write_iter,
 	.mmap = spufs_signal1_mmap,
 	.llseek = no_llseek,
 };
@@ -1062,7 +1054,7 @@ static const struct file_operations spufs_signal1_fops = {
 static const struct file_operations spufs_signal1_nosched_fops = {
 	.open = spufs_signal1_open,
 	.release = spufs_signal1_release,
-	.write = spufs_signal1_write,
+	.write_iter = spufs_signal1_write_iter,
 	.mmap = spufs_signal1_mmap,
 	.llseek = no_llseek,
 };
@@ -1102,29 +1094,28 @@ static ssize_t spufs_signal2_dump(struct spu_context *ctx,
 			       sizeof(ctx->csa.spu_chnldata_RW[4]));
 }
 
-static ssize_t __spufs_signal2_read(struct spu_context *ctx, char __user *buf,
-			size_t len)
+static ssize_t __spufs_signal2_read(struct spu_context *ctx, struct iov_iter *to)
 {
+	size_t len = iov_iter_count(to);
 	if (len < sizeof(ctx->csa.spu_chnldata_RW[4]))
 		return -EINVAL;
 	if (!ctx->csa.spu_chnlcnt_RW[4])
 		return 0;
-	if (copy_to_user(buf, &ctx->csa.spu_chnldata_RW[4],
-			 sizeof(ctx->csa.spu_chnldata_RW[4])))
+	if (!copy_to_iter_full(&ctx->csa.spu_chnldata_RW[4],
+			 sizeof(ctx->csa.spu_chnldata_RW[4]), to))
 		return -EFAULT;
 	return sizeof(ctx->csa.spu_chnldata_RW[4]);
 }
 
-static ssize_t spufs_signal2_read(struct file *file, char __user *buf,
-			size_t len, loff_t *pos)
+static ssize_t spufs_signal2_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	int ret;
 
 	ret = spu_acquire_saved(ctx);
 	if (ret)
 		return ret;
-	ret = __spufs_signal2_read(ctx, buf, len);
+	ret = __spufs_signal2_read(ctx, to);
 	spu_release_saved(ctx);
 
 	return ret;
@@ -1153,6 +1144,7 @@ static ssize_t spufs_signal2_write(struct file *file, const char __user *buf,
 
 	return 4;
 }
+FOPS_WRITE_ITER_HELPER(spufs_signal2_write);
 
 #if SPUFS_MMAP_4K
 static vm_fault_t
@@ -1192,8 +1184,8 @@ static int spufs_signal2_mmap(struct file *file, struct vm_area_struct *vma)
 static const struct file_operations spufs_signal2_fops = {
 	.open = spufs_signal2_open,
 	.release = spufs_signal2_release,
-	.read = spufs_signal2_read,
-	.write = spufs_signal2_write,
+	.read_iter = spufs_signal2_read,
+	.write_iter = spufs_signal2_write_iter,
 	.mmap = spufs_signal2_mmap,
 	.llseek = no_llseek,
 };
@@ -1201,7 +1193,7 @@ static const struct file_operations spufs_signal2_fops = {
 static const struct file_operations spufs_signal2_nosched_fops = {
 	.open = spufs_signal2_open,
 	.release = spufs_signal2_release,
-	.write = spufs_signal2_write,
+	.write_iter = spufs_signal2_write_iter,
 	.mmap = spufs_signal2_mmap,
 	.llseek = no_llseek,
 };
@@ -1491,10 +1483,10 @@ static int spufs_read_mfc_tagstatus(struct spu_context *ctx, u32 *status)
 	return 0;
 }
 
-static ssize_t spufs_mfc_read(struct file *file, char __user *buffer,
-			size_t size, loff_t *pos)
+static ssize_t spufs_mfc_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(to);
 	int ret = -EINVAL;
 	u32 status;
 
@@ -1506,7 +1498,7 @@ static ssize_t spufs_mfc_read(struct file *file, char __user *buffer,
 		return ret;
 
 	ret = -EINVAL;
-	if (file->f_flags & O_NONBLOCK) {
+	if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 		status = ctx->ops->read_mfc_tagstatus(ctx);
 		if (!(status & ctx->tagwait))
 			ret = -EAGAIN;
@@ -1522,7 +1514,7 @@ static ssize_t spufs_mfc_read(struct file *file, char __user *buffer,
 	spu_release(ctx);
 
 	ret = 4;
-	if (copy_to_user(buffer, &status, 4))
+	if (!copy_to_iter_full(&status, 4, to))
 		ret = -EFAULT;
 
 out:
@@ -1617,10 +1609,10 @@ static int spu_send_mfc_command(struct spu_context *ctx,
 	return 1;
 }
 
-static ssize_t spufs_mfc_write(struct file *file, const char __user *buffer,
-			size_t size, loff_t *pos)
+static ssize_t spufs_mfc_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t size = iov_iter_count(from);
 	struct mfc_dma_command cmd;
 	int ret = -EINVAL;
 
@@ -1628,7 +1620,7 @@ static ssize_t spufs_mfc_write(struct file *file, const char __user *buffer,
 		goto out;
 
 	ret = -EFAULT;
-	if (copy_from_user(&cmd, buffer, sizeof cmd))
+	if (!copy_from_iter_full(&cmd, sizeof cmd, from))
 		goto out;
 
 	ret = spufs_check_valid_dma(&cmd);
@@ -1643,7 +1635,7 @@ static ssize_t spufs_mfc_write(struct file *file, const char __user *buffer,
 	if (ret)
 		goto out;
 
-	if (file->f_flags & O_NONBLOCK) {
+	if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 		ret = ctx->ops->send_mfc_command(ctx, &cmd);
 	} else {
 		int status;
@@ -1738,8 +1730,8 @@ static int spufs_mfc_fsync(struct file *file, loff_t start, loff_t end, int data
 static const struct file_operations spufs_mfc_fops = {
 	.open	 = spufs_mfc_open,
 	.release = spufs_mfc_release,
-	.read	 = spufs_mfc_read,
-	.write	 = spufs_mfc_write,
+	.read_iter = spufs_mfc_read,
+	.write_iter = spufs_mfc_write,
 	.poll	 = spufs_mfc_poll,
 	.flush	 = spufs_mfc_flush,
 	.fsync	 = spufs_mfc_fsync,
@@ -1943,7 +1935,7 @@ static int spufs_caps_open(struct inode *inode, struct file *file)
 
 static const struct file_operations spufs_caps_fops = {
 	.open		= spufs_caps_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -1957,10 +1949,9 @@ static ssize_t spufs_mbox_info_dump(struct spu_context *ctx,
 			       sizeof(ctx->csa.prob.pu_mb_R));
 }
 
-static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,
-				   size_t len, loff_t *pos)
+static ssize_t spufs_mbox_info_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	u32 stat, data;
 	int ret;
 
@@ -1977,12 +1968,12 @@ static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,
 	if (!(stat & 0x0000ff))
 		return 0;
 
-	return simple_read_from_buffer(buf, len, pos, &data, sizeof(data));
+	return simple_copy_to_iter(&data, &iocb->ki_pos, sizeof(data), to);
 }
 
 static const struct file_operations spufs_mbox_info_fops = {
 	.open = spufs_info_open,
-	.read = spufs_mbox_info_read,
+	.read_iter = spufs_mbox_info_read,
 	.llseek  = generic_file_llseek,
 };
 
@@ -1995,10 +1986,9 @@ static ssize_t spufs_ibox_info_dump(struct spu_context *ctx,
 			       sizeof(ctx->csa.priv2.puint_mb_R));
 }
 
-static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,
-				   size_t len, loff_t *pos)
+static ssize_t spufs_ibox_info_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	u32 stat, data;
 	int ret;
 
@@ -2015,12 +2005,12 @@ static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,
 	if (!(stat & 0xff0000))
 		return 0;
 
-	return simple_read_from_buffer(buf, len, pos, &data, sizeof(data));
+	return simple_copy_to_iter(&data, &iocb->ki_pos, sizeof(data), to);
 }
 
 static const struct file_operations spufs_ibox_info_fops = {
 	.open = spufs_info_open,
-	.read = spufs_ibox_info_read,
+	.read_iter = spufs_ibox_info_read,
 	.llseek  = generic_file_llseek,
 };
 
@@ -2036,10 +2026,9 @@ static ssize_t spufs_wbox_info_dump(struct spu_context *ctx,
 			spufs_wbox_info_cnt(ctx));
 }
 
-static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf,
-				   size_t len, loff_t *pos)
+static ssize_t spufs_wbox_info_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	u32 data[ARRAY_SIZE(ctx->csa.spu_mailbox_data)];
 	int ret, count;
 
@@ -2052,13 +2041,12 @@ static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf,
 	spin_unlock(&ctx->csa.register_lock);
 	spu_release_saved(ctx);
 
-	return simple_read_from_buffer(buf, len, pos, &data,
-				count * sizeof(u32));
+	return simple_copy_to_iter(&data, &iocb->ki_pos, count * sizeof(u32), to);
 }
 
 static const struct file_operations spufs_wbox_info_fops = {
 	.open = spufs_info_open,
-	.read = spufs_wbox_info_read,
+	.read_iter = spufs_wbox_info_read,
 	.llseek  = generic_file_llseek,
 };
 
@@ -2092,10 +2080,9 @@ static ssize_t spufs_dma_info_dump(struct spu_context *ctx,
 	return spufs_dump_emit(cprm, &info, sizeof(info));
 }
 
-static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,
-			      size_t len, loff_t *pos)
+static ssize_t spufs_dma_info_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
 	struct spu_dma_info info;
 	int ret;
 
@@ -2107,13 +2094,12 @@ static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,
 	spin_unlock(&ctx->csa.register_lock);
 	spu_release_saved(ctx);
 
-	return simple_read_from_buffer(buf, len, pos, &info,
-				sizeof(info));
+	return simple_copy_to_iter(&info, &iocb->ki_pos, sizeof(info), to);
 }
 
 static const struct file_operations spufs_dma_info_fops = {
 	.open = spufs_info_open,
-	.read = spufs_dma_info_read,
+	.read_iter = spufs_dma_info_read,
 	.llseek = no_llseek,
 };
 
@@ -2146,10 +2132,10 @@ static ssize_t spufs_proxydma_info_dump(struct spu_context *ctx,
 	return spufs_dump_emit(cprm, &info, sizeof(info));
 }
 
-static ssize_t spufs_proxydma_info_read(struct file *file, char __user *buf,
-				   size_t len, loff_t *pos)
+static ssize_t spufs_proxydma_info_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct spu_context *ctx = file->private_data;
+	struct spu_context *ctx = iocb->ki_filp->private_data;
+	size_t len = iov_iter_count(to);
 	struct spu_proxydma_info info;
 	int ret;
 
@@ -2164,13 +2150,12 @@ static ssize_t spufs_proxydma_info_read(struct file *file, char __user *buf,
 	spin_unlock(&ctx->csa.register_lock);
 	spu_release_saved(ctx);
 
-	return simple_read_from_buffer(buf, len, pos, &info,
-				sizeof(info));
+	return simple_copy_to_iter(&info, &iocb->ki_pos, sizeof(info), to);
 }
 
 static const struct file_operations spufs_proxydma_info_fops = {
 	.open = spufs_info_open,
-	.read = spufs_proxydma_info_read,
+	.read_iter = spufs_proxydma_info_read,
 	.llseek = no_llseek,
 };
 
@@ -2189,7 +2174,7 @@ static int spufs_tid_open(struct inode *inode, struct file *file)
 
 static const struct file_operations spufs_tid_fops = {
 	.open		= spufs_tid_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -2279,7 +2264,7 @@ static int spufs_stat_open(struct inode *inode, struct file *file)
 
 static const struct file_operations spufs_stat_fops = {
 	.open		= spufs_stat_open,
-	.read		= seq_read,
+	.read_iter	= seq_read_iter,
 	.llseek		= seq_lseek,
 	.release	= single_release,
 };
@@ -2357,16 +2342,13 @@ static int switch_log_sprint(struct spu_context *ctx, char *tbuf, int n)
 			(unsigned long long) p->timebase);
 }
 
-static ssize_t spufs_switch_log_read(struct file *file, char __user *buf,
-			     size_t len, loff_t *ppos)
+static ssize_t spufs_switch_log_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct inode *inode = file_inode(file);
+	struct inode *inode = file_inode(iocb->ki_filp);
 	struct spu_context *ctx = SPUFS_I(inode)->i_ctx;
+	size_t len = iov_iter_count(to);
 	int error = 0, cnt = 0;
 
-	if (!buf)
-		return -EINVAL;
-
 	error = spu_acquire(ctx);
 	if (error)
 		return error;
@@ -2381,7 +2363,7 @@ static ssize_t spufs_switch_log_read(struct file *file, char __user *buf,
 				 * just return straight away */
 				break;
 
-			} else if (file->f_flags & O_NONBLOCK) {
+			} else if (iocb->ki_filp->f_flags & O_NONBLOCK) {
 				error = -EAGAIN;
 				break;
 
@@ -2417,7 +2399,7 @@ static ssize_t spufs_switch_log_read(struct file *file, char __user *buf,
 			 * partial buffer (so far) */
 			break;
 
-		error = copy_to_user(buf + cnt, tbuf, width);
+		error = !copy_to_iter_full(tbuf, width, to);
 		if (error)
 			break;
 		cnt += width;
@@ -2451,7 +2433,7 @@ static __poll_t spufs_switch_log_poll(struct file *file, poll_table *wait)
 
 static const struct file_operations spufs_switch_log_fops = {
 	.open		= spufs_switch_log_open,
-	.read		= spufs_switch_log_read,
+	.read_iter	= spufs_switch_log_read,
 	.poll		= spufs_switch_log_poll,
 	.release	= spufs_switch_log_release,
 	.llseek		= no_llseek,
@@ -2532,7 +2514,7 @@ static int spufs_ctx_open(struct inode *inode, struct file *file)
 
 static const struct file_operations spufs_ctx_fops = {
 	.open           = spufs_ctx_open,
-	.read           = seq_read,
+	.read_iter      = seq_read_iter,
 	.llseek         = seq_lseek,
 	.release        = single_release,
 };
Signature · 1 line
2.43.0
author maintainer
#346 lore raw

PATCH 340/437 powerpc/platforms: convert to read/write iterators

In reply to Jens Axboe
---
 arch/powerpc/platforms/52xx/mpc52xx_gpt.c    |  7 ++---
 arch/powerpc/platforms/powernv/eeh-powernv.c | 11 ++++---
 arch/powerpc/platforms/powernv/memtrace.c    |  9 +++---
 arch/powerpc/platforms/powernv/opal-lpc.c    |  6 ++--
 arch/powerpc/platforms/powernv/opal-prd.c    | 22 +++++++-------
 arch/powerpc/platforms/powernv/opal-xscom.c  | 30 +++++++++-----------
 arch/powerpc/platforms/pseries/dtl.c         | 16 +++++------
 arch/powerpc/platforms/pseries/lpar.c        | 11 ++++---
 arch/powerpc/platforms/pseries/papr-vpd.c    |  8 +++---
 9 files changed, 57 insertions(+), 63 deletions(-)
arch/powerpc/platforms/52xx/mpc52xx_gpt.c +3 -4
index 581059527c36..d166f153ad12 100644
@@ -530,10 +530,9 @@ static inline void mpc52xx_gpt_wdt_ping(struct mpc52xx_gpt_priv *gpt_wdt)
 }
 
 /* wdt misc device api */
-static ssize_t mpc52xx_wdt_write(struct file *file, const char __user *data,
-				 size_t len, loff_t *ppos)
+static ssize_t mpc52xx_wdt_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mpc52xx_gpt_priv *gpt_wdt = file->private_data;
+	struct mpc52xx_gpt_priv *gpt_wdt = iocb->ki_filp->private_data;
 	mpc52xx_gpt_wdt_ping(gpt_wdt);
 	return 0;
 }
@@ -645,7 +644,7 @@ static int mpc52xx_wdt_release(struct inode *inode, struct file *file)
 static const struct file_operations mpc52xx_wdt_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= no_llseek,
-	.write		= mpc52xx_wdt_write,
+	.write_iter	= mpc52xx_wdt_write,
 	.unlocked_ioctl = mpc52xx_wdt_ioctl,
 	.compat_ioctl	= compat_ptr_ioctl,
 	.open		= mpc52xx_wdt_open,
arch/powerpc/platforms/powernv/eeh-powernv.c +5 -6
index af3a5d37a149..c2a6081fed1d 100644
@@ -62,11 +62,10 @@ static irqreturn_t pnv_eeh_event(int irq, void *data)
 }
 
 #ifdef CONFIG_DEBUG_FS
-static ssize_t pnv_eeh_ei_write(struct file *filp,
-				const char __user *user_buf,
-				size_t count, loff_t *ppos)
+static ssize_t pnv_eeh_ei_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct pci_controller *hose = filp->private_data;
+	struct pci_controller *hose = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	struct eeh_pe *pe;
 	int pe_no, type, func;
 	unsigned long addr, mask;
@@ -77,7 +76,7 @@ static ssize_t pnv_eeh_ei_write(struct file *filp,
 		return -ENXIO;
 
 	/* Copy over argument buffer */
-	ret = simple_write_to_buffer(buf, sizeof(buf), ppos, user_buf, count);
+	ret = simple_copy_to_iter(buf, &iocb->ki_pos, sizeof(buf), from);
 	if (!ret)
 		return -EFAULT;
 
@@ -100,7 +99,7 @@ static ssize_t pnv_eeh_ei_write(struct file *filp,
 static const struct file_operations pnv_eeh_ei_fops = {
 	.open	= simple_open,
 	.llseek	= no_llseek,
-	.write	= pnv_eeh_ei_write,
+	.write_iter	= pnv_eeh_ei_write,
 };
 
 static int pnv_eeh_dbgfs_set(void *data, int offset, u64 val)
arch/powerpc/platforms/powernv/memtrace.c +4 -5
index 877720c64515..366da300e605 100644
@@ -37,12 +37,11 @@ static struct memtrace_entry *memtrace_array;
 static unsigned int memtrace_array_nr;
 
 
-static ssize_t memtrace_read(struct file *filp, char __user *ubuf,
-			     size_t count, loff_t *ppos)
+static ssize_t memtrace_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct memtrace_entry *ent = filp->private_data;
+	struct memtrace_entry *ent = iocb->ki_filp->private_data;
 
-	return simple_read_from_buffer(ubuf, count, ppos, ent->mem, ent->size);
+	return simple_copy_to_iter(ent->mem, &iocb->ki_pos, ent->size, to);
 }
 
 static int memtrace_mmap(struct file *filp, struct vm_area_struct *vma)
@@ -62,7 +61,7 @@ static int memtrace_mmap(struct file *filp, struct vm_area_struct *vma)
 
 static const struct file_operations memtrace_fops = {
 	.llseek = default_llseek,
-	.read	= memtrace_read,
+	.read_iter = memtrace_read,
 	.open	= simple_open,
 	.mmap   = memtrace_mmap,
 };
arch/powerpc/platforms/powernv/opal-lpc.c +4 -2
index a16f07cdab26..e2f18ed6af17 100644
@@ -271,6 +271,7 @@ static ssize_t lpc_debug_read(struct file *filp, char __user *ubuf,
 
 	return count;
 }
+FOPS_READ_ITER_HELPER(lpc_debug_read);
 
 static ssize_t lpc_debug_write(struct file *filp, const char __user *ubuf,
 			       size_t count, loff_t *ppos)
@@ -342,10 +343,11 @@ static ssize_t lpc_debug_write(struct file *filp, const char __user *ubuf,
 
 	return count;
 }
+FOPS_WRITE_ITER_HELPER(lpc_debug_write);
 
 static const struct file_operations lpc_fops = {
-	.read =		lpc_debug_read,
-	.write =	lpc_debug_write,
+	.read_iter =	lpc_debug_read_iter,
+	.write_iter =	lpc_debug_write_iter,
 	.open =		simple_open,
 	.llseek =	default_llseek,
 };
arch/powerpc/platforms/powernv/opal-prd.c +11 -11
index 24f04f20d3e8..ac760ad1e46d 100644
@@ -156,10 +156,10 @@ static __poll_t opal_prd_poll(struct file *file,
 	return 0;
 }
 
-static ssize_t opal_prd_read(struct file *file, char __user *buf,
-		size_t count, loff_t *ppos)
+static ssize_t opal_prd_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	struct opal_prd_msg_queue_item *item;
+	size_t count = iov_iter_count(to);
 	unsigned long flags;
 	ssize_t size, err;
 	int rc;
@@ -168,7 +168,7 @@ static ssize_t opal_prd_read(struct file *file, char __user *buf,
 	if (count < sizeof(item->msg.header))
 		return -EINVAL;
 
-	if (*ppos)
+	if (iocb->ki_pos)
 		return -ESPIPE;
 
 	item = NULL;
@@ -186,7 +186,7 @@ static ssize_t opal_prd_read(struct file *file, char __user *buf,
 		if (item)
 			break;
 
-		if (file->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 
 		rc = wait_event_interruptible(opal_prd_msg_wait,
@@ -201,7 +201,7 @@ static ssize_t opal_prd_read(struct file *file, char __user *buf,
 		goto err_requeue;
 	}
 
-	rc = copy_to_user(buf, &item->msg, size);
+	rc = !copy_to_iter_full(&item->msg, size, to);
 	if (rc) {
 		err = -EFAULT;
 		goto err_requeue;
@@ -219,9 +219,9 @@ static ssize_t opal_prd_read(struct file *file, char __user *buf,
 	return err;
 }
 
-static ssize_t opal_prd_write(struct file *file, const char __user *buf,
-		size_t count, loff_t *ppos)
+static ssize_t opal_prd_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t count = iov_iter_count(from);
 	struct opal_prd_msg_header hdr;
 	struct opal_prd_msg *msg;
 	ssize_t size;
@@ -233,13 +233,13 @@ static ssize_t opal_prd_write(struct file *file, const char __user *buf,
 		return -EINVAL;
 
 	/* grab the header */
-	rc = copy_from_user(&hdr, buf, sizeof(hdr));
+	rc = !copy_from_iter_full(&hdr, sizeof(hdr), from);
 	if (rc)
 		return -EFAULT;
 
 	size = be16_to_cpu(hdr.size);
 
-	msg = memdup_user(buf, size);
+	msg = iterdup(from, size);
 	if (IS_ERR(msg))
 		return PTR_ERR(msg);
 
@@ -325,8 +325,8 @@ static const struct file_operations opal_prd_fops = {
 	.open		= opal_prd_open,
 	.mmap		= opal_prd_mmap,
 	.poll		= opal_prd_poll,
-	.read		= opal_prd_read,
-	.write		= opal_prd_write,
+	.read_iter	= opal_prd_read,
+	.write_iter	= opal_prd_write,
 	.unlocked_ioctl	= opal_prd_ioctl,
 	.release	= opal_prd_release,
 	.owner		= THIS_MODULE,
arch/powerpc/platforms/powernv/opal-xscom.c +13 -17
index 748c2b97fa53..344bc747f576 100644
@@ -84,12 +84,11 @@ struct scom_debug_entry {
 	char name[16];
 };
 
-static ssize_t scom_debug_read(struct file *filp, char __user *ubuf,
-			       size_t count, loff_t *ppos)
+static ssize_t scom_debug_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct scom_debug_entry *ent = filp->private_data;
-	u64 __user *ubuf64 = (u64 __user *)ubuf;
-	loff_t off = *ppos;
+	struct scom_debug_entry *ent = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
+	loff_t off = iocb->ki_pos;
 	ssize_t done = 0;
 	u64 reg, reg_base, reg_cnt, val;
 	int rc;
@@ -102,25 +101,23 @@ static ssize_t scom_debug_read(struct file *filp, char __user *ubuf,
 	for (reg = 0; reg < reg_cnt; reg++) {
 		rc = opal_scom_read(ent->chip, reg_base, reg, &val);
 		if (!rc)
-			rc = put_user(val, ubuf64);
+			rc = put_iter(val, to);
 		if (rc) {
 			if (!done)
 				done = rc;
 			break;
 		}
-		ubuf64++;
-		*ppos += 8;
+		iocb->ki_pos += 8;
 		done += 8;
 	}
 	return done;
 }
 
-static ssize_t scom_debug_write(struct file *filp, const char __user *ubuf,
-				size_t count, loff_t *ppos)
+static ssize_t scom_debug_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct scom_debug_entry *ent = filp->private_data;
-	u64 __user *ubuf64 = (u64 __user *)ubuf;
-	loff_t off = *ppos;
+	struct scom_debug_entry *ent = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
+	loff_t off = iocb->ki_pos;
 	ssize_t done = 0;
 	u64 reg, reg_base, reg_cnt, val;
 	int rc;
@@ -131,7 +128,7 @@ static ssize_t scom_debug_write(struct file *filp, const char __user *ubuf,
 	reg_cnt = count >> 3;
 
 	for (reg = 0; reg < reg_cnt; reg++) {
-		rc = get_user(val, ubuf64);
+		rc = get_iter(val, from);
 		if (!rc)
 			rc = opal_scom_write(ent->chip, reg_base, reg,  val);
 		if (rc) {
@@ -139,15 +136,14 @@ static ssize_t scom_debug_write(struct file *filp, const char __user *ubuf,
 				done = rc;
 			break;
 		}
-		ubuf64++;
 		done += 8;
 	}
 	return done;
 }
 
 static const struct file_operations scom_debug_fops = {
-	.read =		scom_debug_read,
-	.write =	scom_debug_write,
+	.read_iter =	scom_debug_read,
+	.write_iter =	scom_debug_write,
 	.open =		simple_open,
 	.llseek =	default_llseek,
 };
arch/powerpc/platforms/pseries/dtl.c +8 -8
index 3f1cdccebc9c..3efb00703b43 100644
@@ -257,17 +257,17 @@ static int dtl_file_release(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t dtl_file_read(struct file *filp, char __user *buf, size_t len,
-		loff_t *pos)
+static ssize_t dtl_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	long int rc, n_read, n_req, read_size;
+	size_t len = iov_iter_count(to);
 	struct dtl *dtl;
 	u64 cur_idx, last_idx, i;
 
 	if ((len % sizeof(struct dtl_entry)) != 0)
 		return -EINVAL;
 
-	dtl = filp->private_data;
+	dtl = iocb->ki_filp->private_data;
 
 	/* requested number of entries to read */
 	n_req = len / sizeof(struct dtl_entry);
@@ -300,19 +300,19 @@ static ssize_t dtl_file_read(struct file *filp, char __user *buf, size_t len,
 	if (i + n_req > dtl->buf_entries) {
 		read_size = dtl->buf_entries - i;
 
-		rc = copy_to_user(buf, &dtl->buf[i],
-				read_size * sizeof(struct dtl_entry));
+		rc = !copy_to_iter_full(&dtl->buf[i],
+				read_size * sizeof(struct dtl_entry), to);
 		if (rc)
 			return -EFAULT;
 
 		i = 0;
 		n_req -= read_size;
 		n_read += read_size;
-		buf += read_size * sizeof(struct dtl_entry);
 	}
 
 	/* .. and now the head */
-	rc = copy_to_user(buf, &dtl->buf[i], n_req * sizeof(struct dtl_entry));
+	rc = !copy_to_iter_full(&dtl->buf[i], n_req * sizeof(struct dtl_entry),
+				to);
 	if (rc)
 		return -EFAULT;
 
@@ -324,7 +324,7 @@ static ssize_t dtl_file_read(struct file *filp, char __user *buf, size_t len,
 static const struct file_operations dtl_fops = {
 	.open		= dtl_file_open,
 	.release	= dtl_file_release,
-	.read		= dtl_file_read,
+	.read_iter	= dtl_file_read,
 	.llseek		= no_llseek,
 };
 
arch/powerpc/platforms/pseries/lpar.c +5 -6
index 4e9916bb03d7..2ccbcf9f295a 100644
@@ -1991,19 +1991,18 @@ machine_device_initcall(pseries, reserve_vrma_context_id);
 
 #ifdef CONFIG_DEBUG_FS
 /* debugfs file interface for vpa data */
-static ssize_t vpa_file_read(struct file *filp, char __user *buf, size_t len,
-			      loff_t *pos)
+static ssize_t vpa_file_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	int cpu = (long)filp->private_data;
+	int cpu = (long)iocb->ki_filp->private_data;
 	struct lppaca *lppaca = &lppaca_of(cpu);
 
-	return simple_read_from_buffer(buf, len, pos, lppaca,
-				sizeof(struct lppaca));
+	return simple_copy_to_iter(lppaca, &iocb->ki_pos, sizeof(struct lppaca),
+					to);
 }
 
 static const struct file_operations vpa_fops = {
 	.open		= simple_open,
-	.read		= vpa_file_read,
+	.read_iter	= vpa_file_read,
 	.llseek		= default_llseek,
 };
 
arch/powerpc/platforms/pseries/papr-vpd.c +4 -4
index c29e85db5f35..bab048029ed5 100644
@@ -408,9 +408,9 @@ static const struct vpd_blob *papr_vpd_retrieve(const struct papr_location_code
 	return blob;
 }
 
-static ssize_t papr_vpd_handle_read(struct file *file, char __user *buf, size_t size, loff_t *off)
+static ssize_t papr_vpd_handle_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	const struct vpd_blob *blob = file->private_data;
+	const struct vpd_blob *blob = iocb->ki_filp->private_data;
 
 	/* bug: we should not instantiate a handle without any data attached. */
 	if (!vpd_blob_has_data(blob)) {
@@ -418,7 +418,7 @@ static ssize_t papr_vpd_handle_read(struct file *file, char __user *buf, size_t
 		return -EIO;
 	}
 
-	return simple_read_from_buffer(buf, size, off, blob->data, blob->len);
+	return simple_copy_to_iter(blob->data, &iocb->ki_pos, blob->len, to);
 }
 
 static int papr_vpd_handle_release(struct inode *inode, struct file *file)
@@ -439,7 +439,7 @@ static loff_t papr_vpd_handle_seek(struct file *file, loff_t off, int whence)
 
 
 static const struct file_operations papr_vpd_handle_ops = {
-	.read = papr_vpd_handle_read,
+	.read_iter = papr_vpd_handle_read,
 	.llseek = papr_vpd_handle_seek,
 	.release = papr_vpd_handle_release,
 };
Signature · 1 line
2.43.0
author maintainer
#347 lore raw

PATCH 341/437 s390: cio: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/s390/cio/cio_inject.c | 11 ++++++-----
 drivers/s390/cio/qdio_debug.c | 12 ++++++------
 2 files changed, 12 insertions(+), 11 deletions(-)
drivers/s390/cio/cio_inject.c +6 -5
index 8613fa937237..33ccd36098b3 100644
@@ -123,15 +123,16 @@ static ssize_t crw_inject_write(struct file *file, const char __user *buf,
 
 	return lbuf;
 }
+FOPS_WRITE_ITER_HELPER(crw_inject_write);
 
 /* Debugfs write handler for inject_enable node*/
-static ssize_t enable_inject_write(struct file *file, const char __user *buf,
-				   size_t lbuf, loff_t *ppos)
+static ssize_t enable_inject_write(struct kiocb *iocb, struct iov_iter *from)
 {
+	size_t lbuf = iov_iter_count(from);
 	unsigned long en = 0;
 	int rc;
 
-	rc = kstrtoul_from_user(buf, lbuf, 10, &en);
+	rc = kstrtoul_from_iter(from, lbuf, 10, &en);
 	if (rc)
 		return rc;
 
@@ -149,12 +150,12 @@ static ssize_t enable_inject_write(struct file *file, const char __user *buf,
 
 static const struct file_operations crw_fops = {
 	.owner = THIS_MODULE,
-	.write = crw_inject_write,
+	.write_iter = crw_inject_write_iter,
 };
 
 static const struct file_operations cio_en_fops = {
 	.owner = THIS_MODULE,
-	.write = enable_inject_write,
+	.write_iter = enable_inject_write,
 };
 
 static int __init cio_inject_init(void)
drivers/s390/cio/qdio_debug.c +6 -6
index 1a9714af51e4..0c9f84c5197f 100644
@@ -234,11 +234,11 @@ static int qperf_show(struct seq_file *m, void *v)
 	return 0;
 }
 
-static ssize_t qperf_seq_write(struct file *file, const char __user *ubuf,
-			       size_t count, loff_t *off)
+static ssize_t qperf_seq_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct seq_file *seq = file->private_data;
+	struct seq_file *seq = iocb->ki_filp->private_data;
 	struct qdio_irq *irq_ptr = seq->private;
+	size_t count = iov_iter_count(from);
 	struct qdio_q *q;
 	unsigned long val;
 	int ret, i;
@@ -246,7 +246,7 @@ static ssize_t qperf_seq_write(struct file *file, const char __user *ubuf,
 	if (!irq_ptr)
 		return 0;
 
-	ret = kstrtoul_from_user(ubuf, count, 10, &val);
+	ret = kstrtoul_from_iter(from, count, 10, &val);
 	if (ret)
 		return ret;
 
@@ -275,8 +275,8 @@ static int qperf_seq_open(struct inode *inode, struct file *filp)
 static const struct file_operations debugfs_perf_fops = {
 	.owner	 = THIS_MODULE,
 	.open	 = qperf_seq_open,
-	.read	 = seq_read,
-	.write	 = qperf_seq_write,
+	.read_iter = seq_read_iter,
+	.write_iter = qperf_seq_write,
 	.llseek  = seq_lseek,
 	.release = single_release,
 };
Signature · 1 line
2.43.0
author maintainer
#348 lore raw

PATCH 342/437 s390: fs3270: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/s390/char/fs3270.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/s390/char/fs3270.c +4 -2
index 4d824f86bbbb..c8c767342167 100644
@@ -276,6 +276,7 @@ static ssize_t fs3270_read(struct file *filp, char __user *data,
 	idal_buffer_free(ib);
 	return rc;
 }
+FOPS_READ_ITER_HELPER(fs3270_read);
 
 /*
  * Process writes to fullscreen 3270.
@@ -316,6 +317,7 @@ static ssize_t fs3270_write(struct file *filp, const char __user *data,
 	idal_buffer_free(ib);
 	return rc;
 }
+FOPS_WRITE_ITER_HELPER(fs3270_write);
 
 /*
  * process ioctl commands for the tube driver
@@ -509,8 +511,8 @@ static int fs3270_close(struct inode *inode, struct file *filp)
 
 static const struct file_operations fs3270_fops = {
 	.owner		 = THIS_MODULE,		/* owner */
-	.read		 = fs3270_read,		/* read */
-	.write		 = fs3270_write,	/* write */
+	.read_iter	 = fs3270_read_iter,	/* read */
+	.write_iter	 = fs3270_write_iter,	/* write */
 	.unlocked_ioctl	 = fs3270_ioctl,	/* ioctl */
 	.compat_ioctl	 = fs3270_ioctl,	/* ioctl */
 	.open		 = fs3270_open,		/* open */
Signature · 1 line
2.43.0
author maintainer
#349 lore raw

PATCH 343/437 s390: hmcdrv: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/s390/char/hmcdrv_dev.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/s390/char/hmcdrv_dev.c +6 -6
index 8d50c894711f..df793008a390 100644
@@ -56,10 +56,8 @@ struct hmcdrv_dev_node {
 static int hmcdrv_dev_open(struct inode *inode, struct file *fp);
 static int hmcdrv_dev_release(struct inode *inode, struct file *fp);
 static loff_t hmcdrv_dev_seek(struct file *fp, loff_t pos, int whence);
-static ssize_t hmcdrv_dev_read(struct file *fp, char __user *ubuf,
-			       size_t len, loff_t *pos);
-static ssize_t hmcdrv_dev_write(struct file *fp, const char __user *ubuf,
-				size_t len, loff_t *pos);
+static ssize_t hmcdrv_dev_read_iter(struct kiocb *iocb, struct iov_iter *to);
+static ssize_t hmcdrv_dev_write_iter(struct kiocb *iocb, struct iov_iter *from);
 static ssize_t hmcdrv_dev_transfer(char __kernel *cmd, loff_t offset,
 				   char __user *buf, size_t len);
 
@@ -70,8 +68,8 @@ static const struct file_operations hmcdrv_dev_fops = {
 	.open = hmcdrv_dev_open,
 	.llseek = hmcdrv_dev_seek,
 	.release = hmcdrv_dev_release,
-	.read = hmcdrv_dev_read,
-	.write = hmcdrv_dev_write,
+	.read_iter = hmcdrv_dev_read_iter,
+	.write_iter = hmcdrv_dev_write_iter,
 };
 
 static struct hmcdrv_dev_node hmcdrv_dev; /* HMC device struct (static) */
@@ -239,6 +237,7 @@ static ssize_t hmcdrv_dev_read(struct file *fp, char __user *ubuf,
 
 	return retlen;
 }
+FOPS_READ_ITER_HELPER(hmcdrv_dev_read);
 
 /*
  * write()
@@ -276,6 +275,7 @@ static ssize_t hmcdrv_dev_write(struct file *fp, const char __user *ubuf,
 
 	return retlen;
 }
+FOPS_WRITE_ITER_HELPER(hmcdrv_dev_write);
 
 /**
  * hmcdrv_dev_init() - creates a HMC drive CD/DVD device
Signature · 1 line
2.43.0
author maintainer
#350 lore raw

PATCH 344/437 s390: tape_char: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/s390/char/tape_char.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/s390/char/tape_char.c +6 -4
index cc8237afeffa..b6a8e99f0d31 100644
@@ -32,8 +32,8 @@
 /*
  * file operation structure for tape character frontend
  */
-static ssize_t tapechar_read(struct file *, char __user *, size_t, loff_t *);
-static ssize_t tapechar_write(struct file *, const char __user *, size_t, loff_t *);
+static ssize_t tapechar_read_iter(struct kiocb *iocb, struct iov_iter *to);
+static ssize_t tapechar_write_iter(struct kiocb *iocb, struct iov_iter *from);
 static int tapechar_open(struct inode *,struct file *);
 static int tapechar_release(struct inode *,struct file *);
 static long tapechar_ioctl(struct file *, unsigned int, unsigned long);
@@ -44,8 +44,8 @@ static long tapechar_compat_ioctl(struct file *, unsigned int, unsigned long);
 static const struct file_operations tape_fops =
 {
 	.owner = THIS_MODULE,
-	.read = tapechar_read,
-	.write = tapechar_write,
+	.read_iter = tapechar_read_iter,
+	.write_iter = tapechar_write_iter,
 	.unlocked_ioctl = tapechar_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl = tapechar_compat_ioctl,
@@ -179,6 +179,7 @@ tapechar_read(struct file *filp, char __user *data, size_t count, loff_t *ppos)
 	tape_free_request(request);
 	return rc;
 }
+FOPS_READ_ITER_HELPER(tapechar_read);
 
 /*
  * Tape device write function
@@ -263,6 +264,7 @@ tapechar_write(struct file *filp, const char __user *data, size_t count, loff_t
 
 	return rc ? rc : written;
 }
+FOPS_WRITE_ITER_HELPER(tapechar_write);
 
 /*
  * Character frontend tape device open function.
Signature · 1 line
2.43.0
author maintainer
#351 lore raw

PATCH 345/437 s390: vmcp: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/s390/char/vmcp.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)
drivers/s390/char/vmcp.c +10 -13
index eb0520a9d4af..348e528a386d 100644
@@ -128,14 +128,13 @@ static int vmcp_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static ssize_t
-vmcp_read(struct file *file, char __user *buff, size_t count, loff_t *ppos)
+static ssize_t vmcp_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	ssize_t ret;
 	size_t size;
 	struct vmcp_session *session;
 
-	session = file->private_data;
+	session = iocb->ki_filp->private_data;
 	if (mutex_lock_interruptible(&session->mutex))
 		return -ERESTARTSYS;
 	if (!session->response) {
@@ -143,27 +142,25 @@ vmcp_read(struct file *file, char __user *buff, size_t count, loff_t *ppos)
 		return 0;
 	}
 	size = min_t(size_t, session->resp_size, session->bufsize);
-	ret = simple_read_from_buffer(buff, count, ppos,
-					session->response, size);
+	ret = simple_copy_to_iter(session->response, &iocb->ki_pos, size, to);
 
 	mutex_unlock(&session->mutex);
 
 	return ret;
 }
 
-static ssize_t
-vmcp_write(struct file *file, const char __user *buff, size_t count,
-	   loff_t *ppos)
+static ssize_t vmcp_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char *cmd;
 	struct vmcp_session *session;
+	size_t count = iov_iter_count(from);
 
 	if (count > 240)
 		return -EINVAL;
-	cmd = memdup_user_nul(buff, count);
+	cmd = iterdup_nul(from, count);
 	if (IS_ERR(cmd))
 		return PTR_ERR(cmd);
-	session = file->private_data;
+	session = iocb->ki_filp->private_data;
 	if (mutex_lock_interruptible(&session->mutex)) {
 		kfree(cmd);
 		return -ERESTARTSYS;
@@ -180,7 +177,7 @@ vmcp_write(struct file *file, const char __user *buff, size_t count,
 				   &session->resp_code);
 	mutex_unlock(&session->mutex);
 	kfree(cmd);
-	*ppos = 0;		/* reset the file pointer after a command */
+	iocb->ki_pos = 0;	/* reset the file pointer after a command */
 	return count;
 }
 
@@ -238,8 +235,8 @@ static const struct file_operations vmcp_fops = {
 	.owner		= THIS_MODULE,
 	.open		= vmcp_open,
 	.release	= vmcp_release,
-	.read		= vmcp_read,
-	.write		= vmcp_write,
+	.read_iter	= vmcp_read,
+	.write_iter	= vmcp_write,
 	.unlocked_ioctl	= vmcp_ioctl,
 	.compat_ioctl	= vmcp_ioctl,
 	.llseek		= no_llseek,
Signature · 1 line
2.43.0
author maintainer
#352 lore raw

PATCH 346/437 s390: vmur: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/s390/char/vmur.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/s390/char/vmur.c +4 -2
index fe94dec427b6..187b0dde22e1 100644
@@ -461,6 +461,7 @@ static ssize_t ur_write(struct file *file, const char __user *udata,
 
 	return do_write(urf->urd, udata, count, urf->dev_reclen, ppos);
 }
+FOPS_WRITE_ITER_HELPER(ur_write);
 
 /*
  * diagnose code 0x14 subcode 0x0028 - position spool file to designated
@@ -580,6 +581,7 @@ static ssize_t ur_read(struct file *file, char __user *ubuf, size_t count,
 	mutex_unlock(&urd->io_mutex);
 	return rc;
 }
+FOPS_READ_ITER_HELPER(ur_read);
 
 /*
  * diagnose code 0x14 subcode 0x0fff - retrieve next file descriptor
@@ -799,8 +801,8 @@ static const struct file_operations ur_fops = {
 	.owner	 = THIS_MODULE,
 	.open	 = ur_open,
 	.release = ur_release,
-	.read	 = ur_read,
-	.write	 = ur_write,
+	.read_iter	 = ur_read_iter,
+	.write_iter	 = ur_write_iter,
 	.llseek  = ur_llseek,
 };
 
Signature · 1 line
2.43.0
author maintainer
#353 lore raw

PATCH 347/437 s390: zcore: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/s390/char/zcore.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
drivers/s390/char/zcore.c +11 -14
index 0969fa01df58..8f5c890605ce 100644
@@ -134,8 +134,7 @@ static void release_hsa(void)
 	hsa_available = 0;
 }
 
-static ssize_t zcore_reipl_write(struct file *filp, const char __user *buf,
-				 size_t count, loff_t *ppos)
+static ssize_t zcore_reipl_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	if (zcore_ipl_block) {
 		diag308(DIAG308_SET, zcore_ipl_block);
@@ -147,7 +146,7 @@ static ssize_t zcore_reipl_write(struct file *filp, const char __user *buf,
 		else
 			diag308(DIAG308_LOAD_NORMAL, NULL);
 	}
-	return count;
+	return iov_iter_count(from);
 }
 
 static int zcore_reipl_open(struct inode *inode, struct file *filp)
@@ -162,14 +161,13 @@ static int zcore_reipl_release(struct inode *inode, struct file *filp)
 
 static const struct file_operations zcore_reipl_fops = {
 	.owner		= THIS_MODULE,
-	.write		= zcore_reipl_write,
+	.write_iter	= zcore_reipl_write,
 	.open		= zcore_reipl_open,
 	.release	= zcore_reipl_release,
 	.llseek		= no_llseek,
 };
 
-static ssize_t zcore_hsa_read(struct file *filp, char __user *buf,
-			      size_t count, loff_t *ppos)
+static ssize_t zcore_hsa_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	static char str[18];
 
@@ -177,28 +175,27 @@ static ssize_t zcore_hsa_read(struct file *filp, char __user *buf,
 		snprintf(str, sizeof(str), "%lx\n", sclp.hsa_size);
 	else
 		snprintf(str, sizeof(str), "0\n");
-	return simple_read_from_buffer(buf, count, ppos, str, strlen(str));
+	return simple_copy_to_iter(str, &iocb->ki_pos, strlen(str), to);
 }
 
-static ssize_t zcore_hsa_write(struct file *filp, const char __user *buf,
-			       size_t count, loff_t *ppos)
+static ssize_t zcore_hsa_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	char value;
 
-	if (*ppos != 0)
+	if (iocb->ki_pos != 0)
 		return -EPIPE;
-	if (copy_from_user(&value, buf, 1))
+	if (!copy_from_iter_full(&value, 1, from))
 		return -EFAULT;
 	if (value != '0')
 		return -EINVAL;
 	release_hsa();
-	return count;
+	return iov_iter_count(from);
 }
 
 static const struct file_operations zcore_hsa_fops = {
 	.owner		= THIS_MODULE,
-	.write		= zcore_hsa_write,
-	.read		= zcore_hsa_read,
+	.write_iter	= zcore_hsa_write,
+	.read_iter	= zcore_hsa_read,
 	.open		= nonseekable_open,
 	.llseek		= no_llseek,
 };
Signature · 1 line
2.43.0
author maintainer
#354 lore raw

PATCH 348/437 s390: crypto: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/s390/crypto/zcrypt_api.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/s390/crypto/zcrypt_api.c +4 -6
index eba07f8ef308..bc2b385ea550 100644
@@ -475,8 +475,7 @@ static void zcdn_destroy_all(void)
  *
  * This function is not supported beyond zcrypt 1.3.1.
  */
-static ssize_t zcrypt_read(struct file *filp, char __user *buf,
-			   size_t count, loff_t *f_pos)
+static ssize_t zcrypt_read(struct kiocb *iocb, struct iov_iter *to)
 {
 	return -EPERM;
 }
@@ -486,8 +485,7 @@ static ssize_t zcrypt_read(struct file *filp, char __user *buf,
  *
  * Write is not allowed
  */
-static ssize_t zcrypt_write(struct file *filp, const char __user *buf,
-			    size_t count, loff_t *f_pos)
+static ssize_t zcrypt_write(struct kiocb *iocb, struct iov_iter *from)
 {
 	return -EPERM;
 }
@@ -1905,8 +1903,8 @@ static long zcrypt_compat_ioctl(struct file *filp, unsigned int cmd,
  */
 static const struct file_operations zcrypt_fops = {
 	.owner		= THIS_MODULE,
-	.read		= zcrypt_read,
-	.write		= zcrypt_write,
+	.read_iter	= zcrypt_read,
+	.write_iter	= zcrypt_write,
 	.unlocked_ioctl	= zcrypt_unlocked_ioctl,
 #ifdef CONFIG_COMPAT
 	.compat_ioctl	= zcrypt_compat_ioctl,
Signature · 1 line
2.43.0
author maintainer
#355 lore raw

PATCH 349/437 s390: monreader: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/s390/char/monreader.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/s390/char/monreader.c +8 -8
index 7207a7f5842a..151030779624 100644
@@ -358,10 +358,10 @@ static int mon_close(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t mon_read(struct file *filp, char __user *data,
-			size_t count, loff_t *ppos)
+static ssize_t mon_read(struct kiocb *iocb, struct iov_iter *to)
 {
-	struct mon_private *monpriv = filp->private_data;
+	struct mon_private *monpriv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(to);
 	struct mon_msg *monmsg;
 	int ret;
 	u32 mce_start;
@@ -371,7 +371,7 @@ static ssize_t mon_read(struct file *filp, char __user *data,
 		return PTR_ERR(monmsg);
 
 	if (!monmsg) {
-		if (filp->f_flags & O_NONBLOCK)
+		if (iocb->ki_filp->f_flags & O_NONBLOCK)
 			return -EAGAIN;
 		ret = wait_event_interruptible(mon_read_wait_queue,
 					atomic_read(&monpriv->read_ready) ||
@@ -392,7 +392,7 @@ static ssize_t mon_read(struct file *filp, char __user *data,
 	mce_start = mon_mca_start(monmsg) + monmsg->mca_offset;
 	if ((monmsg->pos >= mce_start) && (monmsg->pos < mce_start + 12)) {
 		count = min(count, (size_t) mce_start + 12 - monmsg->pos);
-		ret = copy_to_user(data, __va(monmsg->pos), count);
+		ret = !copy_to_iter_full(__va(monmsg->pos), count, to);
 		if (ret)
 			return -EFAULT;
 		monmsg->pos += count;
@@ -405,7 +405,7 @@ static ssize_t mon_read(struct file *filp, char __user *data,
 	if (monmsg->pos <= mon_rec_end(monmsg)) {
 		count = min(count, (size_t) mon_rec_end(monmsg) - monmsg->pos
 					    + 1);
-		ret = copy_to_user(data, __va(monmsg->pos), count);
+		ret = !copy_to_iter_full(__va(monmsg->pos), count, to);
 		if (ret)
 			return -EFAULT;
 		monmsg->pos += count;
@@ -418,7 +418,7 @@ static ssize_t mon_read(struct file *filp, char __user *data,
 	return ret;
 
 out_copy:
-	*ppos += count;
+	iocb->ki_pos += count;
 	return count;
 }
 
@@ -438,7 +438,7 @@ static const struct file_operations mon_fops = {
 	.owner   = THIS_MODULE,
 	.open    = &mon_open,
 	.release = &mon_close,
-	.read    = &mon_read,
+	.read_iter = &mon_read,
 	.poll    = &mon_poll,
 	.llseek  = noop_llseek,
 };
Signature · 1 line
2.43.0
author maintainer
#356 lore raw

PATCH 350/437 s390: monwriter: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/s390/char/monwriter.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/s390/char/monwriter.c +6 -6
index bc5193d81f9c..8baf04d05748 100644
@@ -216,10 +216,10 @@ static int monwrite_close(struct inode *inode, struct file *filp)
 	return 0;
 }
 
-static ssize_t monwrite_write(struct file *filp, const char __user *data,
-			      size_t count, loff_t *ppos)
+static ssize_t monwrite_write(struct kiocb *iocb, struct iov_iter *from)
 {
-	struct mon_private *monpriv = filp->private_data;
+	struct mon_private *monpriv = iocb->ki_filp->private_data;
+	size_t count = iov_iter_count(from);
 	size_t len, written;
 	void *to;
 	int rc;
@@ -230,7 +230,7 @@ static ssize_t monwrite_write(struct file *filp, const char __user *data,
 			len = min(count - written, monpriv->hdr_to_read);
 			to = (char *) &monpriv->hdr +
 				sizeof(monpriv->hdr) - monpriv->hdr_to_read;
-			if (copy_from_user(to, data + written, len)) {
+			if (!copy_from_iter_full(to, len, from)) {
 				rc = -EFAULT;
 				goto out_error;
 			}
@@ -249,7 +249,7 @@ static ssize_t monwrite_write(struct file *filp, const char __user *data,
 			len = min(count - written, monpriv->data_to_read);
 			to = monpriv->current_buf->data +
 				monpriv->hdr.datalen - monpriv->data_to_read;
-			if (copy_from_user(to, data + written, len)) {
+			if (!copy_from_iter_full(to, len, from)) {
 				rc = -EFAULT;
 				goto out_error;
 			}
@@ -277,7 +277,7 @@ static const struct file_operations monwrite_fops = {
 	.owner	 = THIS_MODULE,
 	.open	 = &monwrite_open,
 	.release = &monwrite_close,
-	.write	 = &monwrite_write,
+	.write_iter	 = &monwrite_write,
 	.llseek  = noop_llseek,
 };
 
Signature · 1 line
2.43.0
author maintainer
#357 lore raw

PATCH 351/437 s390: hw_random: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/char/hw_random/s390-trng.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/char/hw_random/s390-trng.c +4 -5
index d27e32e9bfee..b1e1b896907c 100644
@@ -53,9 +53,9 @@ static int trng_open(struct inode *inode, struct file *file)
 	return nonseekable_open(inode, file);
 }
 
-static ssize_t trng_read(struct file *file, char __user *ubuf,
-			 size_t nbytes, loff_t *ppos)
+static ssize_t trng_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t nbytes = iov_iter_count(to);
 	u8 buf[32];
 	u8 *p = buf;
 	unsigned int n;
@@ -85,12 +85,11 @@ static ssize_t trng_read(struct file *file, char __user *ubuf,
 		n = nbytes > PAGE_SIZE ? PAGE_SIZE : nbytes;
 		cpacf_trng(NULL, 0, p, n);
 		atomic64_add(n, &trng_dev_counter);
-		if (copy_to_user(ubuf, p, n)) {
+		if (!copy_to_iter_full(p, n, to)) {
 			ret = -EFAULT;
 			break;
 		}
 		nbytes -= n;
-		ubuf += n;
 		ret += n;
 	}
 
@@ -139,7 +138,7 @@ static const struct file_operations trng_fops = {
 	.owner		= THIS_MODULE,
 	.open		= &trng_open,
 	.release	= NULL,
-	.read		= &trng_read,
+	.read_iter	= trng_read,
 	.llseek		= noop_llseek,
 };
 
Signature · 1 line
2.43.0
author maintainer
#358 lore raw

PATCH 352/437 s390: vmlogrdr: convert to read/write iterators

In reply to Jens Axboe
---
 drivers/s390/char/vmlogrdr.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/s390/char/vmlogrdr.c +7 -8
index d7e408c8d0b8..52595690e43c 100644
@@ -88,14 +88,13 @@ struct vmlogrdr_priv_t {
  */
 static int vmlogrdr_open(struct inode *, struct file *);
 static int vmlogrdr_release(struct inode *, struct file *);
-static ssize_t vmlogrdr_read (struct file *filp, char __user *data,
-			      size_t count, loff_t * ppos);
+static ssize_t vmlogrdr_read(struct kiocb *iocb, struct iov_iter *to);
 
 static const struct file_operations vmlogrdr_fops = {
 	.owner   = THIS_MODULE,
 	.open    = vmlogrdr_open,
 	.release = vmlogrdr_release,
-	.read    = vmlogrdr_read,
+	.read_iter = vmlogrdr_read,
 	.llseek  = no_llseek,
 };
 
@@ -473,11 +472,11 @@ static int vmlogrdr_receive_data(struct vmlogrdr_priv_t *priv)
 }
 
 
-static ssize_t vmlogrdr_read(struct file *filp, char __user *data,
-			     size_t count, loff_t * ppos)
+static ssize_t vmlogrdr_read(struct kiocb *iocb, struct iov_iter *to)
 {
+	size_t count = iov_iter_count(to);
 	int rc;
-	struct vmlogrdr_priv_t * priv = filp->private_data;
+	struct vmlogrdr_priv_t * priv = iocb->ki_filp->private_data;
 
 	while (priv->buffer_free) {
 		rc = vmlogrdr_receive_data(priv);
@@ -492,10 +491,10 @@ static ssize_t vmlogrdr_read(struct file *filp, char __user *data,
 	if (count > priv->remaining)
 		count = priv->remaining;
 
-	if (copy_to_user(data, priv->current_position, count))
+	if (!copy_to_iter_full(priv->current_position, count, to))
 		return -EFAULT;
 
-	*ppos += count;
+	iocb->ki_pos += count;
 	priv->current_position += count;
 	priv->remaining -= count;
 
Signature · 1 line
2.43.0