From patchwork Tue Aug 7 07:14:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 10558279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8947013AC for ; Tue, 7 Aug 2018 07:13:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66A0529660 for ; Tue, 7 Aug 2018 07:13:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AD2C29A39; Tue, 7 Aug 2018 07:13:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB13C29660 for ; Tue, 7 Aug 2018 07:13:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732805AbeHGJ0W (ORCPT ); Tue, 7 Aug 2018 05:26:22 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:37250 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728125AbeHGJ0W (ORCPT ); Tue, 7 Aug 2018 05:26:22 -0400 Received: by mail-pf1-f194.google.com with SMTP id a26-v6so8117168pfo.4 for ; Tue, 07 Aug 2018 00:13:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=xltT5TAoujnPv7v6tjWXB8ywHjR+DA+W/BmUvJoRLG8=; b=XcMpjytswNVhZH34hRITmXk6+jgo1crh8uXcwaqNwl9RGVkVC/jsKHkmZR384VTbRb ljaMc4lwc+bq6AgkHoV2uLENWYwC+7RfJqfSntEVKo0Mq98Yn09324EzEGCHewdJ3ipa Fm9s5LfVQEzGE5FXu3CPJ0xAITCOkPhG5a8Cg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xltT5TAoujnPv7v6tjWXB8ywHjR+DA+W/BmUvJoRLG8=; b=A8uMZAmqSToggZN0hCMdzdLgjwXjj34EafEu96xXrxbMJLJ3rrV+qAAKKMLkAj97dc gRMeQ3tegXutzsmU3K5xvSwx3Rh9jL9v822FASonpc1/0uzEet6NQW/2+MGGwh6dI98+ eHKuoZBPkxUz2ugidgTzZmXDgqB/xluAAOvTIe5TrSk/I7LaUDAFcajGVxeZSOSdG9rN KCk/H+O0m3lQDpdpV7PJopeTFRQmP2ujgk+HJKpf5kTHfQrtJT/ELE2Q0LWmj2tzL8ZY RAeDiT/oPvQYgPnqdDKk0rVIewhAzPj9BOhgDH8IOTgNE8AiWlZPaSExFyTL4o4+zFOw NS9A== X-Gm-Message-State: AOUpUlFbO+CUMA6Ftw+0ZFGvnCDVfVoOCwqvPUAwQc4JQidm2DEsz0RD JpI0y2x+Ro7SpdkkNqTpCZhzFA== X-Google-Smtp-Source: AAOMgpfHDrYCyRem7deEupIrm1QUOd5NNkSUOwRWq2Nfypl+4JphC+DQK6gWZeOTBYvTOWnSc0gLug== X-Received: by 2002:a62:51c6:: with SMTP id f189-v6mr10435412pfb.7.1533626004766; Tue, 07 Aug 2018 00:13:24 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id q25-v6sm1735898pfk.96.2018.08.07.00.13.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Aug 2018 00:13:24 -0700 (PDT) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rpmsg: char: Migrate to iter versions of read and write Date: Tue, 7 Aug 2018 00:14:24 -0700 Message-Id: <20180807071424.3236-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In order to be able to use the aio interface for writing to a rpmsg_char the write_iter function must be implemented, so migrate to iter version for read and write functions. Regular read and write uses the iter methods if present and is as such unaffected. Signed-off-by: Bjorn Andersson --- drivers/rpmsg/rpmsg_char.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index a76b963a7e50..eea5ebbb5119 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -167,9 +167,9 @@ static int rpmsg_eptdev_release(struct inode *inode, struct file *filp) return 0; } -static ssize_t rpmsg_eptdev_read(struct file *filp, char __user *buf, - size_t len, loff_t *f_pos) +static ssize_t rpmsg_eptdev_read_iter(struct kiocb *iocb, struct iov_iter *to) { + struct file *filp = iocb->ki_filp; struct rpmsg_eptdev *eptdev = filp->private_data; unsigned long flags; struct sk_buff *skb; @@ -205,8 +205,8 @@ static ssize_t rpmsg_eptdev_read(struct file *filp, char __user *buf, if (!skb) return -EFAULT; - use = min_t(size_t, len, skb->len); - if (copy_to_user(buf, skb->data, use)) + use = min_t(size_t, iov_iter_count(to), skb->len); + if (copy_to_iter(skb->data, use, to) != use) use = -EFAULT; kfree_skb(skb); @@ -214,16 +214,21 @@ static ssize_t rpmsg_eptdev_read(struct file *filp, char __user *buf, return use; } -static ssize_t rpmsg_eptdev_write(struct file *filp, const char __user *buf, - size_t len, loff_t *f_pos) +static ssize_t rpmsg_eptdev_write_iter(struct kiocb *iocb, + struct iov_iter *from) { + struct file *filp = iocb->ki_filp; struct rpmsg_eptdev *eptdev = filp->private_data; + size_t len = iov_iter_count(from); void *kbuf; int ret; - kbuf = memdup_user(buf, len); - if (IS_ERR(kbuf)) - return PTR_ERR(kbuf); + kbuf = kzalloc(len, GFP_KERNEL); + if (!kbuf) + return -ENOMEM; + + if (!copy_from_iter_full(kbuf, len, from)) + return -EFAULT; if (mutex_lock_interruptible(&eptdev->ept_lock)) { ret = -ERESTARTSYS; @@ -281,8 +286,8 @@ static const struct file_operations rpmsg_eptdev_fops = { .owner = THIS_MODULE, .open = rpmsg_eptdev_open, .release = rpmsg_eptdev_release, - .read = rpmsg_eptdev_read, - .write = rpmsg_eptdev_write, + .read_iter = rpmsg_eptdev_read_iter, + .write_iter = rpmsg_eptdev_write_iter, .poll = rpmsg_eptdev_poll, .unlocked_ioctl = rpmsg_eptdev_ioctl, .compat_ioctl = rpmsg_eptdev_ioctl,