Received: by 2002:ab2:7988:0:b0:1f4:b336:87c4 with SMTP id g8csp80351lqj; Thu, 11 Apr 2024 10:18:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWf9vaDxXWdAz+f2HpUpEt9Lf/KeA+qdDC7EGD/07H70DxiShQTuVQhq+TQOeNtMfnGhMcxFIbYaWpsvGkveucInhyK5Es/yf9L14Vk9A== X-Google-Smtp-Source: AGHT+IE/TzqUarktjHj6mI7jsmdWh1OjOVkWBcMnJ/q5QS8YsGjWc1NbHjg8qFgI/dDB/tRiGnG7 X-Received: by 2002:a05:6a20:9499:b0:1a3:ae18:f1e4 with SMTP id hs25-20020a056a20949900b001a3ae18f1e4mr472467pzb.34.1712855920366; Thu, 11 Apr 2024 10:18:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712855920; cv=pass; d=google.com; s=arc-20160816; b=weP+MFjkro/VjxFVqzZw1JDzSeeZ0x2wa0uvlkgR/QYbkImJopRpeV8rntczHyNzbm CrSC2D0flVDZfyafuFdhr3KY4fDURd8Rj82DdpO5JYB3SHOtfVTTZ6AL3kHkkKhgTdGt VxhKByNE4lJrLrJ/RntQkzfTzC2dg0PPnthLxTEjobLaJ2QnvnvpGuOgRq9jNT06qYQo niel7B8FXbesVx3f2BVUFUnBc9cE6XCzUr1EaUgqlGCsfYGVaCUxQlvXpxmogmzXTwMl jhx0ttHO2Vv6tFdz+WmfZdbjhqVeb4vQZO52il3wuSqpedtL67pP0ScKSk4J5MHU1ipw 7uwQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4PmE6cYLOEpbXxSqhgYXqA34/7Mp6dcqScCNpKzg50k=; fh=2FInBIgEh7xt9W7JS1z2wQ7fUhvLHtwfAfkXluU3JoI=; b=rxp96AkTM5IhyahslcqdpVU6yZXEWzh9JsPa3pFzCn6kvOFvnLTPjRYpxoBQEoZWmq userfs+Ia9E/tub5xX7vn3MilVMtvlqvyV9bFYkNBB8OTLtO+e2cc6y6pIyeSB0A1UiX 7CZZpuBHw9HB1pV2dt9QbU7jyP1IZakjOBpeIKWdsVrbONUgA5fcLBlfnr1fbTiBKhud y6YhSc8Ddin3ivo3rlARLn634GcVvdygiXMjBTxhi2GpGXl1x81tfcV2TTDaPSXJB26z r1jaF4k2hkBR+NhHKdJ3oGCw0DHHV4yK/aE6I9Wcw5KTfQ8EJN0VpV+0CWDwqKcj9qva CJkQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=2LGusfou; arc=pass (i=1 spf=pass spfdomain=kernel.dk dkim=pass dkdomain=kernel-dk.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-141197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141197-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a19-20020a634d13000000b005e840af2241si1552464pgb.711.2024.04.11.10.18.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 10:18:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=2LGusfou; arc=pass (i=1 spf=pass spfdomain=kernel.dk dkim=pass dkdomain=kernel-dk.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-141197-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141197-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A277B287B89 for ; Thu, 11 Apr 2024 17:14:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D03211FD5C5; Thu, 11 Apr 2024 15:43:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="2LGusfou" Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7926A1FCA1D for ; Thu, 11 Apr 2024 15:43:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712850194; cv=none; b=Rxw2EQlwgCwua2PYd+LsGPXAS81lXFBJWyCjujj1fwj8i5bknViMTxEJPNW4zvHQyOhFQp1s4cUadyGI578mU75R0gq7NBmKaWFSNQTP3elcuBV0v8DSoNIZpkqr6jpli6quzg4vwU0fAOVpeSFHzuOfI0rid1W43hhsxR8Iyi8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712850194; c=relaxed/simple; bh=OqeRYAGBYnww6bnv0uYDdepyddZOIaBxQ+BPwM3ZmN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G221zA0YaYRTH+I7Ej+s0jU80RW+B3LUbKnDdewD3lAPh9OfzMB3jEdRuFYxw/26SQ1dPv9bKaGzqTqDD6UmdBZnIip5hFVpVLbV2pDS4pySG/pAhMNLbeqmMPAI/qmWVcm1ZAD9QWcjg3BuLo89oXzyCf2t3KFFWw3NE4596sQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=2LGusfou; arc=none smtp.client-ip=209.85.166.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-7c8e4c0412dso69698039f.1 for ; Thu, 11 Apr 2024 08:43:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1712850192; x=1713454992; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4PmE6cYLOEpbXxSqhgYXqA34/7Mp6dcqScCNpKzg50k=; b=2LGusfoul9IPelnBvAjNLNlISAzib5IaT7iLOQERwsJKdbqnNnji43x5PQpzgBnBwe QZ3Xh9XnVoIjhr2lq7kslktwXgIRJiUj9V4d2WMosTxQ5AKIloIMaX9Si03BPF9Jf5L9 A+Blv59MTb64/b3uRPdsWuD0DQF+nokYf9ymmVZ1O2lbnwk9UEzW6ImLHKU72aRFGHeh NBd2dzZO5dKFfHpo0uKDkglSOMdnzjyZqnPcCCRoQ9SCQDqjtEP0q8WhT2Xs5irg37wu 1Xwnz9p7+ZDaIvdNqom7vjnIpZncxL8rP4lQGLiPHJglvl5okEvo8UOGDltQJ+ETgdQL +tDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712850192; x=1713454992; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4PmE6cYLOEpbXxSqhgYXqA34/7Mp6dcqScCNpKzg50k=; b=vSVVKcOU1TyIvKyZiHcBpVCPoyhh2Iu31Ye/PYKQWlsiuKVXThO4UH6YMVzY/MfmtU t1232Fgl8pHommPDj1VFmeQ7S9QlQ0fqAYi69ewTX+nNCSfZva3kYHD9nvdVL/ccWER3 FukC2VZOgnSEORZ5pWGy8RKkZH9szzGuiLEOkiDQZ0FwZRLNYP3NxMi6PSY1hv++YbFO /Y7FLNmQzxJM7ech8nShKZzbywqEvM3M8JG3ihUM5g0/w0h4Cx4HGIFz4wUWJGhDHhC0 l3k1Z2e2BdX0pO/X/CIb0DJzsc40d6nJfridlIKVFaboYiazl7NV/Hxi8jRDz3lG10si hKMA== X-Gm-Message-State: AOJu0YwFTOGAqUxrlV+8vl+8yIjZ4+UwbX3uqmoX63N4NKq0iQzd9693 NiwxWW+hY1vnKrxIsSdOYiamUfV9n9unLa+IFwtwl1UdIQcrphtTzX9ZIQxLmsl1UOFDjXCNztU 6 X-Received: by 2002:a05:6602:84:b0:7d6:9d75:6de2 with SMTP id h4-20020a056602008400b007d69d756de2mr56943iob.2.1712850191909; Thu, 11 Apr 2024 08:43:11 -0700 (PDT) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id jc25-20020a056638891900b0047f14b7f6c0sm457056jab.5.2024.04.11.08.43.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 08:43:10 -0700 (PDT) From: Jens Axboe To: linux-kernel@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 413/437] media/rc: convert to read/write iterators Date: Thu, 11 Apr 2024 09:19:13 -0600 Message-ID: <20240411153126.16201-414-axboe@kernel.dk> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411153126.16201-1-axboe@kernel.dk> References: <20240411153126.16201-1-axboe@kernel.dk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Signed-off-by: Jens Axboe --- drivers/media/rc/imon.c | 26 ++++++++++++-------------- drivers/media/rc/lirc_dev.c | 15 ++++++++------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index 5719dda6e0f0..cfcf8101164a 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -65,12 +65,10 @@ static int display_open(struct inode *inode, struct file *file); static int display_close(struct inode *inode, struct file *file); /* VFD write operation */ -static ssize_t vfd_write(struct file *file, const char __user *buf, - size_t n_bytes, loff_t *pos); +static ssize_t vfd_write(struct kiocb *iocb, struct iov_iter *from); /* LCD file_operations override function prototypes */ -static ssize_t lcd_write(struct file *file, const char __user *buf, - size_t n_bytes, loff_t *pos); +static ssize_t lcd_write(struct kiocb *iocb, struct iov_iter *from); /*** G L O B A L S ***/ @@ -179,7 +177,7 @@ struct imon_context { static const struct file_operations vfd_fops = { .owner = THIS_MODULE, .open = display_open, - .write = vfd_write, + .write_iter = vfd_write, .release = display_close, .llseek = noop_llseek, }; @@ -188,7 +186,7 @@ static const struct file_operations vfd_fops = { static const struct file_operations lcd_fops = { .owner = THIS_MODULE, .open = display_open, - .write = lcd_write, + .write_iter = lcd_write, .release = display_close, .llseek = noop_llseek, }; @@ -938,16 +936,16 @@ static const struct attribute_group imon_rf_attr_group = { * than 32 bytes are provided spaces will be appended to * generate a full screen. */ -static ssize_t vfd_write(struct file *file, const char __user *buf, - size_t n_bytes, loff_t *pos) +static ssize_t vfd_write(struct kiocb *iocb, struct iov_iter *from) { int i; int offset; int seq; int retval = 0; - struct imon_context *ictx = file->private_data; + struct imon_context *ictx = iocb->ki_filp->private_data; static const unsigned char vfd_packet6[] = { 0x01, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF }; + size_t n_bytes = iov_iter_count(from); if (ictx->disconnected) return -ENODEV; @@ -967,7 +965,7 @@ static ssize_t vfd_write(struct file *file, const char __user *buf, goto exit; } - if (copy_from_user(ictx->tx.data_buf, buf, n_bytes)) { + if (!copy_from_iter_full(ictx->tx.data_buf, n_bytes, from)) { retval = -EFAULT; goto exit; } @@ -1023,11 +1021,11 @@ static ssize_t vfd_write(struct file *file, const char __user *buf, * display whatever diacritics you need, and so on), but it's also * a lot more complicated than most LCDs... */ -static ssize_t lcd_write(struct file *file, const char __user *buf, - size_t n_bytes, loff_t *pos) +static ssize_t lcd_write(struct kiocb *iocb, struct iov_iter *from) { int retval = 0; - struct imon_context *ictx = file->private_data; + struct imon_context *ictx = iocb->ki_filp->private_data; + size_t n_bytes = iov_iter_count(from); if (ictx->disconnected) return -ENODEV; @@ -1047,7 +1045,7 @@ static ssize_t lcd_write(struct file *file, const char __user *buf, goto exit; } - if (copy_from_user(ictx->usb_tx_buf, buf, 8)) { + if (!copy_from_iter_full(ictx->usb_tx_buf, 8, from)) { retval = -EFAULT; goto exit; } diff --git a/drivers/media/rc/lirc_dev.c b/drivers/media/rc/lirc_dev.c index caad59f76793..e88ba11192ea 100644 --- a/drivers/media/rc/lirc_dev.c +++ b/drivers/media/rc/lirc_dev.c @@ -211,10 +211,10 @@ static int lirc_close(struct inode *inode, struct file *file) return 0; } -static ssize_t lirc_transmit(struct file *file, const char __user *buf, - size_t n, loff_t *ppos) +static ssize_t lirc_transmit(struct kiocb *iocb, struct iov_iter *from) { - struct lirc_fh *fh = file->private_data; + struct lirc_fh *fh = iocb->ki_filp->private_data; + size_t n = iov_iter_count(from); struct rc_dev *dev = fh->rc; unsigned int *txbuf; struct ir_raw_event *raw = NULL; @@ -247,7 +247,7 @@ static ssize_t lirc_transmit(struct file *file, const char __user *buf, goto out_unlock; } - if (copy_from_user(&scan, buf, sizeof(scan))) { + if (!copy_from_iter_full(&scan, sizeof(scan), from)) { ret = -EFAULT; goto out_unlock; } @@ -309,7 +309,7 @@ static ssize_t lirc_transmit(struct file *file, const char __user *buf, goto out_unlock; } - txbuf = memdup_user(buf, n); + txbuf = iterdup(from, n); if (IS_ERR(txbuf)) { ret = PTR_ERR(txbuf); goto out_unlock; @@ -694,13 +694,14 @@ static ssize_t lirc_read(struct file *file, char __user *buffer, size_t length, else /* LIRC_MODE_SCANCODE */ return lirc_read_scancode(file, buffer, length); } +FOPS_READ_ITER_HELPER(lirc_read); static const struct file_operations lirc_fops = { .owner = THIS_MODULE, - .write = lirc_transmit, + .write_iter = lirc_transmit, .unlocked_ioctl = lirc_ioctl, .compat_ioctl = compat_ptr_ioctl, - .read = lirc_read, + .read_iter = lirc_read_iter, .poll = lirc_poll, .open = lirc_open, .release = lirc_close, -- 2.43.0