From patchwork Sat Oct 30 11:24:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Hortmann X-Patchwork-Id: 12594269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6E6EC433FE for ; Sat, 30 Oct 2021 11:25:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8180460F58 for ; Sat, 30 Oct 2021 11:25:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231929AbhJ3L13 (ORCPT ); Sat, 30 Oct 2021 07:27:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231911AbhJ3L12 (ORCPT ); Sat, 30 Oct 2021 07:27:28 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74AAFC061570; Sat, 30 Oct 2021 04:24:58 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id j128-20020a1c2386000000b003301a98dd62so5328889wmj.5; Sat, 30 Oct 2021 04:24:58 -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=3XYlB1/wp38jGvLFP8/69z9R6Lyv3a0CuAXL3ejVQQ0=; b=Ye+EOjkt1fESsP2qGh/PeGzkMQ5qV6nhSYys4pWRCVCemqfcnZdeOv7P3H4Pw/j5Uz UrJptIbFz7t3AKzbdz5fvECPcUGZSa1m1fbcBqzuWr59ojh6oXdR7hMQU25H1TZKqJCg rYGq4unfrz+MQ/p/WlULUVGY9+uaQULCMOjpIk0+bP+7rkoWln67y9wMf4pyt90CF8l4 0gogv4N3d482MrQZ1XPJgghDQ4NcoWIpfZunBD0eUf3EP2FqbwjtLEJ8w/iMwUUObvyV uAcXtreNCtWWp8tLdXiA6+TZoHi0IMD71mWydURKjnIKsEWl6u3cPuSOYSeb6sqAjnh/ /1Ag== 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=3XYlB1/wp38jGvLFP8/69z9R6Lyv3a0CuAXL3ejVQQ0=; b=gEWEobbtAVIJElhkQPKngCog3nT4ULE/qVnjH0NC1jO3vLaJuRQaoJe1G+mgYv+PrR VERIzyIcpGd7Espqza0IVW9sJ86J6i+J7XmzI9QKq9W0C4dtsb0FU6WsCxJW3a0T1i6R L+nRWYjArrUOyhQGy1rSH4VnvIRSr5x9DY7gt7s5GikkDpyyhi/vdjlkfaY+wXNBBCAE QbjsObokSG/3Vy0h2fzwBKBkRHdj2EitoqM84J6R3h3eic6sl9WGUNupXZd6pDJHJHdq ukMvNOzRdCvXHHt2SIv9s89wda3CJGouW3whHDMWBrDxJSqsDdCFQzMHgmW+huCHhJhz 5oBQ== X-Gm-Message-State: AOAM531obedHGozUyEJwkL9LPoK0/QFoCFkKpVdJKEyC3CKU63I9CRdQ XKG1qsfNWDMAWhT8wzfbFX0Ez/5ZRsI= X-Google-Smtp-Source: ABdhPJy9GmjzxibLOtPKLdggoift9Tt/CFaxSBuqZx4bliRw2aQO6p/PQbd8VnEvk7nQzNFjbGmT4g== X-Received: by 2002:a05:600c:4eca:: with SMTP id g10mr25616272wmq.171.1635593097061; Sat, 30 Oct 2021 04:24:57 -0700 (PDT) Received: from matrix-ESPRIMO-P710 (p200300c78f4e069113f7f01122185925.dip0.t-ipconnect.de. [2003:c7:8f4e:691:13f7:f011:2218:5925]) by smtp.gmail.com with ESMTPSA id p19sm10814673wmg.29.2021.10.30.04.24.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Oct 2021 04:24:56 -0700 (PDT) Date: Sat, 30 Oct 2021 13:24:55 +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 v2 1/3] Docs: usb: update err() to pr_err() and replace __FILE__ Message-ID: <2c477cb0cf5214ae9abf9a4a9de28fcb38f90070.1635591623.git.philipp.g.hortmann@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org update err() to pr_err() and replace __FILE__ Signed-off-by: Philipp Hortmann --- V1 -> V2: changed kernel message to be in one line added missing "n\" --- Documentation/driver-api/usb/writing_usb_driver.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/driver-api/usb/writing_usb_driver.rst b/Documentation/driver-api/usb/writing_usb_driver.rst index 2176297e5765..85e106f443e5 100644 --- a/Documentation/driver-api/usb/writing_usb_driver.rst +++ b/Documentation/driver-api/usb/writing_usb_driver.rst @@ -91,8 +91,8 @@ usually in the driver's init function, as shown here:: /* register this driver with the USB subsystem */ result = usb_register(&skel_driver); if (result < 0) { - err("usb_register failed for the "__FILE__ "driver." - "Error number %d", result); + pr_err("usb_register failed for the %s driver. Error number %d\n", + skel_driver.name, result); return -1; } From patchwork Sat Oct 30 11:25:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Hortmann X-Patchwork-Id: 12594271 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E01A7C433F5 for ; Sat, 30 Oct 2021 11:25:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C90BC60FC4 for ; Sat, 30 Oct 2021 11:25:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231934AbhJ3L1i (ORCPT ); Sat, 30 Oct 2021 07:27:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231912AbhJ3L1i (ORCPT ); Sat, 30 Oct 2021 07:27:38 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0334C061570; Sat, 30 Oct 2021 04:25:07 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id o4-20020a1c7504000000b0032cab7473caso7128069wmc.1; Sat, 30 Oct 2021 04:25:07 -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=/KDxxFThUMOPznUOZfbh3igj6eg/in2sKNhVqyAQPnU=; b=QFIX7mB6cox9Ay+tQRIGqE6HzTMdx1vjMz2XjlWbWaaUGE0/3XFaJiTlcWnPmd6LpV xL8y3+z9pPcURVFSPDmxstQiAcWmaRYq3rEsDN43C6D1Dkt5ZI1zTkbmFbvh5lJHDu/s 3LZWrQ+RfhpiaRvUm6SXoA7wxbhbfpA1L95wk1qX2CFKo9Uio8SZkjHW36Lx+G1inr/j WqseyxsAmysd/mU3bWj78eOd1GpD4GY+n0IhHZynuMSwojJjP/Y2BTz2GyB5zlUOuZB3 AAAFsUE+Ya4Nmexm6RtbYl7XvN5vGshv9cUe/YL5A6XSZL080oVumsw0dvwPJQl7XFHn jWVw== 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=/KDxxFThUMOPznUOZfbh3igj6eg/in2sKNhVqyAQPnU=; b=GqDXKXH7Kh6w5YRQVBW3q13Nd3AN6kzTTSq7qpCAejrLIoZ4dgSIz9GQ9yFBonrXO5 aH+FPzdgOPGMohZeGnuqXtsh/Nm2WMY7eTuOGG4dFaaxZwjwlLaY9VwvaldKuCE64Tkh 6UmvO4vONXaKAhTi6k2Q8R44m9Tl+VGzCzRmrlV2+x5A/6k9wAkpcEfQ0raO24as98DY 8kAvUoQBrqKplo/0Qadu7xik7T1TwAuBcAskc4WKygCcLO9ZODw+xUtsLAvRYtmK0a3s 8wdkPmRqqMMukPRMZ/pA3zwxdi8ziURtlaH8AiGmZyRli4tgMYGaFsinENUW4URMqGKx PSQQ== X-Gm-Message-State: AOAM53089ruxBrRrsfJwZMz0FxvDpSXO/yGmqPmhwi9LVJ2n1tA3rQyt wnFEjiKVu2ftrRpp2UpCRb0dw/jPiPw= X-Google-Smtp-Source: ABdhPJz1En9/CnyFCIhfyqzedEj4fmXgja7wLzbS8oiG6cT7bmRLnNDiwFwgTDy4RRFyhvps0TEy3A== X-Received: by 2002:a05:600c:4f81:: with SMTP id n1mr25888996wmq.63.1635593106645; Sat, 30 Oct 2021 04:25:06 -0700 (PDT) Received: from matrix-ESPRIMO-P710 (p200300c78f4e069113f7f01122185925.dip0.t-ipconnect.de. [2003:c7:8f4e:691:13f7:f011:2218:5925]) by smtp.gmail.com with ESMTPSA id q26sm5722558wrc.39.2021.10.30.04.25.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Oct 2021 04:25:06 -0700 (PDT) Date: Sat, 30 Oct 2021 13:25: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 v2 2/3] Docs: usb: update comment and code near increment usage count Message-ID: <38c6205d6b5c612902f9c187154c05e9cca51107.1635591623.git.philipp.g.hortmann@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org update comment: increment our usage count .. and code according to usb-skeleton.c Signed-off-by: Philipp Hortmann --- Documentation/driver-api/usb/writing_usb_driver.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/driver-api/usb/writing_usb_driver.rst b/Documentation/driver-api/usb/writing_usb_driver.rst index 85e106f443e5..24374cdb677b 100644 --- a/Documentation/driver-api/usb/writing_usb_driver.rst +++ b/Documentation/driver-api/usb/writing_usb_driver.rst @@ -167,8 +167,8 @@ structure. This is done so that future calls to file operations will enable the driver to determine which device the user is addressing. All of this is done with the following code:: - /* increment our usage count for the module */ - ++skel->open_count; + /* increment our usage count for the device */ + kref_get(&dev->kref); /* save our object in the file's private structure */ file->private_data = dev; From patchwork Sat Oct 30 11:25:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Hortmann X-Patchwork-Id: 12594273 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C984C433FE for ; Sat, 30 Oct 2021 11:25:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58D4860F58 for ; Sat, 30 Oct 2021 11:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231956AbhJ3L1q (ORCPT ); Sat, 30 Oct 2021 07:27:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231970AbhJ3L1p (ORCPT ); Sat, 30 Oct 2021 07:27:45 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABF9FC061570; Sat, 30 Oct 2021 04:25:13 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id v127so9980359wme.5; Sat, 30 Oct 2021 04:25:13 -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=LkR4Z3PEhPzZ6fXtkdmCLF9FtgcVowssMvoeMUKZdHg=; b=KRC/4GrDCneN9Ju8t5PH+uOrQPXYP0LoApSPT55/c4IXBtZ91PoLXtpwrz+L3u4XHL HrAkzG8gy8sN4EH0yVr+TPgIYFk5o1piUS6mOyDHEZqmRTzZyknmHs/6ptStjNBYvvNS QgMT+JbVFqe6kgl7rVHJh7bFIL6r0kzBHdQ++7Eu2m1L+Zyl/D8PXFEYet5SpoYJsFyq tX7H43EHOydeqwwgje//8mNDRtwB+2hnzdA1FVZ7BuF/eFwsZoG6udjq+DsgoNqbkS7F kcEyxZnzpe1I4Z/TY9b1Kr1ZnKPeOz9YMvVeX5JMHIPDvLLbrk1TEuwfbPOrNfXoHFdP sjqA== 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=LkR4Z3PEhPzZ6fXtkdmCLF9FtgcVowssMvoeMUKZdHg=; b=6zoSEfCg/61hPQ+mpDMXcQpRxFFFYBjMQ9A6ZyGEiOqG+D0oiPQUdTicU3vNX8/MQS zVkNU1ORCn+wAxyKV6VAGt4vJvMmBlI9Nfl4saJb9xh5dgSzJ7UhSkWw4AdFXRVAHhSU xc9XaJhweRqOkPlBP52Qvd/DU7/qX3zjPgttvEWuq4Nb+LrVTLCZh3xocK8+0QrUW8F8 233qThsNuokh13NRrOfpWpjxP+X/v8tLw14g4JcwRbpcqsz9tBI9O9DVy9dTyHW/wbfg Nd718Ig/Kns/zyOnOMnYJW2t/Enm2nI3zwW4W0aZCSmV5QoLp4F65ed/GcU2Q+32EVIa yMlQ== X-Gm-Message-State: AOAM533VxZG9vJ8fzdlDw7nUj6UrblxgneqTKfeGXPZ3z9c9xRFgv9fB UZYzLemIwDh3Uj1sPXZBpMg= X-Google-Smtp-Source: ABdhPJwlXO0mfvd0/CXUu9Sq/cBGiwX7nHA5X2uKEty2Qa2TkU4W+Qi6rMUzs4eDNykU9pvZjYkdCA== X-Received: by 2002:a05:600c:190a:: with SMTP id j10mr25739240wmq.149.1635593112313; Sat, 30 Oct 2021 04:25:12 -0700 (PDT) Received: from matrix-ESPRIMO-P710 (p200300c78f4e069113f7f01122185925.dip0.t-ipconnect.de. [2003:c7:8f4e:691:13f7:f011:2218:5925]) by smtp.gmail.com with ESMTPSA id u16sm7994689wrt.97.2021.10.30.04.25.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Oct 2021 04:25:12 -0700 (PDT) Date: Sat, 30 Oct 2021 13:25:10 +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 v2 3/3] Docs: usb: update writesize, copy_from_user, usb_fill_bulk_urb, usb_submit_urb Message-ID: <0c581a83dfc1a8c37e97dfa7279d333f367a9787.1635591623.git.philipp.g.hortmann@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-usb@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 24374cdb677b..9cdd9f923974 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); }