Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp436205pxb; Fri, 29 Oct 2021 12:43:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/6LsaPu8wdxe/a2/1tNkOBR1VIAi3+t084yHvZdZbNpR1yrGS8InTnqBvW0VTu/hMT2ap X-Received: by 2002:a05:6602:2bfa:: with SMTP id d26mr4941707ioy.131.1635536638983; Fri, 29 Oct 2021 12:43:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635536638; cv=none; d=google.com; s=arc-20160816; b=WXfYc2NgteMr2851AErs6LGogUkPUycGzHU2KDIZ4Z5eWPIynxl7M7z5A7srzWukV2 nPgGac7zSUKR15KNbdUVtDLRlcDMXajC8Lm9NYdmsONzWcB9oZbPc6jPn9+QlZEky+iJ GLtM+G3p2f7n1kqBjFcJ7OG0pWqk0M1NhW0RGFLiLOz78uyrCKYDkttGQs7bAtQf0gDJ iuhqUGFHbdmaKTKp3yZ9DUSUVse2q6nc/nWJMhIngtWqK28txHmgsuZ11Sa72YTyX7xd 5ar5d2ltiAMbgz9YdDwxb0/igs9ELw4OIPRdbNF3F/CjF7Sg6pCDtMJB21E6AgIQHwCX PD0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Iz1/9itNHKzffmv7IN5WPf90NYweKtO8I55T4DTR9D0=; b=F2Fhxih0AKWzkGxb5paCOjjRhSxEToZWZ1v0rQAkmYJdQOMdxUb37FjNWhUvC7h7GK 5dMtzZ8xlATXRv7PggjMeVNcYTkCMW5LKyAnJhUw0nfeOa7tjJFYPT9kub88POO7nJhu 5DnHxbkrpzG2E40OawZ6RjfF55b8L345NZXw4r2JoBb8yi9qckJhaQ8K+srhiv4/vLdt KsqOhHPyp4N7Ra2ghUsa7l7InGxp74aiV1B8r4yS3YqNBED3iJctt/keke6LpN7hofFQ rSTUpVkCjG/DGGJMzqiXdeTL6kuFx6erq/UieT5MDBi/OF05HK7QH8XWjpFTmEpq6b8F +9Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GknvBqos; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u9si9576718jad.39.2021.10.29.12.43.48; Fri, 29 Oct 2021 12:43:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=GknvBqos; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230521AbhJ2Tmk (ORCPT + 99 others); Fri, 29 Oct 2021 15:42:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230525AbhJ2Tmh (ORCPT ); Fri, 29 Oct 2021 15:42:37 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45461C061570; Fri, 29 Oct 2021 12:40:08 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id r8so5333989wra.7; Fri, 29 Oct 2021 12:40:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Iz1/9itNHKzffmv7IN5WPf90NYweKtO8I55T4DTR9D0=; b=GknvBqosrvVRhdZWoPFA+3S31LbF1oV4x9HxyljybQQ23m+RoG2gKywxQ0HZ6fED3J BcVwHgxs8cioVJtb228bhJ324CHDurEOpI8ATUl9jnB+oSQwDudn31MUlXM2KgAwMnpz rjacikS1rfXpddPdo6fUNln/VZTsfNjaLZ2v94BlBR3yOlKnahcC+E7kR/SIYuxuboey uOIlk2kIAyxxC95nWyXy4ouNkqh67Hv7/AKObkGXv0Qn7q1jBbCWPfOPzFGj8urwhaIk iM7NLeXR6v249tMoF6oyZMdLCooLY8fxlYBm1XzAU/tMFml4TDLOsXc/VZKNDbVKKIkp Qm1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Iz1/9itNHKzffmv7IN5WPf90NYweKtO8I55T4DTR9D0=; b=12HHBV32o6M24GAg7K9Q2AaJuWPe7ICOLFA3Bio4q9KGY6amlibf6iNqTskL+mIL1Z 0mMyvK7Yra5EEbW1iv+YrLX36dCppwzXIW1umtQRbm4poBvY5AcA1hcQGOY4tsTlGZuA DFy+fNDjlwy9r0U/f++PrTWR5rbpAnu5/ENKYsCmW0yN7PksHipL/9I4YWBi1Cy2/DoP Gc4SOYuPuqyJFRC8JrQmfMYPCzvsj68H7WZB3LPURPsloZrr8lJYW9j3+SwangM/Uh1l TuQ1u254ikDpT7y6LN/ci9kFMyVYqyI4jfWIb0NLfM8ICb+ucf4bgj+yRNJi87012jKG 5yig== X-Gm-Message-State: AOAM53082k2+3GMqy3J+fORCReQu1RHkqN9UNWAySxRmFGoV40wadC1q o26Lype86+Ndo1QrmecjF1c= X-Received: by 2002:a1c:2397:: with SMTP id j145mr4339558wmj.113.1635536406942; Fri, 29 Oct 2021 12:40:06 -0700 (PDT) Received: from matrix-ESPRIMO-P710 (p200300c78f4e06341d0f9ebdf4bbe019.dip0.t-ipconnect.de. [2003:c7:8f4e:634:1d0f:9ebd:f4bb:e019]) by smtp.gmail.com with ESMTPSA id f10sm7126673wri.84.2021.10.29.12.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 12:40:06 -0700 (PDT) Date: Fri, 29 Oct 2021 21:40:04 +0200 From: Philipp Hortmann To: corbet@lwn.net, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-usb@vger.kernel.org Subject: [PATCH 3/3] Docs: usb: update writesize, copy_from_user, usb_fill_bulk_urb, usb_submit_urb Message-ID: <939d9e91d1ac12003a08d7694b6d6bd29ba2a57d.1635533924.git.philipp.g.hortmann@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org update code examples writesize, copy_from_user, usb_fill_bulk_urb, usb_submit_urb in skel_write() according to usb-skeleton.c Signed-off-by: Philipp Hortmann --- .../driver-api/usb/writing_usb_driver.rst | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Documentation/driver-api/usb/writing_usb_driver.rst b/Documentation/driver-api/usb/writing_usb_driver.rst index 14eda0342649..02c28ee10b91 100644 --- a/Documentation/driver-api/usb/writing_usb_driver.rst +++ b/Documentation/driver-api/usb/writing_usb_driver.rst @@ -185,24 +185,26 @@ space, points the urb to the data and submits the urb to the USB subsystem. This can be seen in the following code:: /* we can only write as much as 1 urb will hold */ - bytes_written = (count > skel->bulk_out_size) ? skel->bulk_out_size : count; + size_t writesize = min_t(size_t, count, MAX_TRANSFER); /* copy the data from user space into our urb */ - copy_from_user(skel->write_urb->transfer_buffer, buffer, bytes_written); + copy_from_user(buf, user_buffer, writesize); /* set up our urb */ - usb_fill_bulk_urb(skel->write_urb, - skel->dev, - usb_sndbulkpipe(skel->dev, skel->bulk_out_endpointAddr), - skel->write_urb->transfer_buffer, - bytes_written, + usb_fill_bulk_urb(urb, + dev->udev, + usb_sndbulkpipe(dev->udev, dev->bulk_out_endpointAddr), + buf, + writesize, skel_write_bulk_callback, - skel); + dev); /* send the data out the bulk port */ - result = usb_submit_urb(skel->write_urb); - if (result) { - err("Failed submitting write urb, error %d", result); + retval = usb_submit_urb(urb, GFP_KERNEL); + if (retval) { + dev_err(&dev->interface->dev, + "%s - failed submitting write urb, error %d\n", + __func__, retval); } -- 2.25.1