From patchwork Sat Dec 4 16:35:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: philipp hortmann X-Patchwork-Id: 520756 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FB72C433EF for ; Sat, 4 Dec 2021 16:35:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355324AbhLDQil (ORCPT ); Sat, 4 Dec 2021 11:38:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355312AbhLDQil (ORCPT ); Sat, 4 Dec 2021 11:38:41 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7386BC0613F8; Sat, 4 Dec 2021 08:35:15 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id d24so12779601wra.0; Sat, 04 Dec 2021 08:35:15 -0800 (PST) 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=Gx0uXkDZfAezvx2UPITjgfJR6vkopVeUq+GbwzqBDgM=; b=DHII9CGr3LVdJWaYU5QSMAQ+pWXY/6v6xondHK2AywQF/qyRm82HZK4xsSEv6kDklM Lw9msnenQScFykTzmX/0N7zSRjEr136FVQwS//6SApdl7+hrNABVuqxaOPdnXPhfWwGM nSDX4a8D6zwimgPBYJ672g2P8Q+bDoNHuvma8Wt3LLP7xxbXBg3PMeC0TI7ZEcdIrss8 YW+RpWTDX/YQhwzwW+1gC3+EApXF6vCLcq56KD4eWs4VLH370FhP5QTeFQGiL5eMvHcR OX9I682skdtWc1XupJyIEucAFMqm2j6efgxKyKsuXAOQUjyKIF86CuAkZuLy3uLa+RdD qKfQ== 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=Gx0uXkDZfAezvx2UPITjgfJR6vkopVeUq+GbwzqBDgM=; b=5uJFKfnI3W5K2EWpN3NlMmsALpMcZ2HhejID5SjEniks+AQTXbyMknj/UmvvS5qZkH GBdB/gHuDeqv+dYDHJfTBpaupwS+89XljasiBSnrnmAtQN2xbLd2AFPCv8RDDWnu3euK 4b6NdPG+QCP6o+++C9UldvnNzjEhmrNuCoqW78LOXTz3FKm5LBharwetqjt7tuMxj93T H9dPODpXoNvkseciZIZuJJRZ+MsIMDZr9fbLuGBw9Soqa77MV8akcVwpyUc4ybREaN0T Jy6KGmG0QtqwuDwWNkYVcLg9nB/rNMk+GhpXRD43wylmLKGc4cQtKPZcG2f3kpSInJbB p5ng== X-Gm-Message-State: AOAM532RNrXs2GtRDpZ3wzUCByQl9r/EHTFlBkUBXPpHcoEXDCvZhj6L 7iHQEnl8+Yuo49jOZndPiElai3He9sRadg== X-Google-Smtp-Source: ABdhPJygaBhVFTZHWcRr9CPvNWh/1p+DMl8B8G3Xm0krV5okVkgk+eZJLPsQubzn6J4df0fo2pO3fg== X-Received: by 2002:adf:e848:: with SMTP id d8mr30602169wrn.3.1638635714091; Sat, 04 Dec 2021 08:35:14 -0800 (PST) Received: from matrix-ESPRIMO-P710 (p200300c78f4e0685b3447c22a42fc55e.dip0.t-ipconnect.de. [2003:c7:8f4e:685:b344:7c22:a42f:c55e]) by smtp.gmail.com with ESMTPSA id h17sm5702674wrp.34.2021.12.04.08.35.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Dec 2021 08:35:13 -0800 (PST) Date: Sat, 4 Dec 2021 17:35:11 +0100 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/4] Docs: usb: update usb_bulk_msg receiving example Message-ID: <0bd9336e18abad338b4967664a4667b96dae6be6.1638630342.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 Clarification that this example is not in the driver template anymore. Update code example so that it fits best to usb-skeleton.c Update format of function names Signed-off-by: Philipp Hortmann --- V1 -> V2: Added "Update format of function names" to patch description Corrected format of function names like the following example: "`usb_bulk_msg` function" to "usb_bulk_msg()" --- .../driver-api/usb/writing_usb_driver.rst | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Documentation/driver-api/usb/writing_usb_driver.rst b/Documentation/driver-api/usb/writing_usb_driver.rst index b43e1ce49f0e..ed11398837e5 100644 --- a/Documentation/driver-api/usb/writing_usb_driver.rst +++ b/Documentation/driver-api/usb/writing_usb_driver.rst @@ -218,36 +218,36 @@ do very much processing at that time. Our implementation of ``skel_write_bulk_callback`` merely reports if the urb was completed successfully or not and then returns. -The read function works a bit differently from the write function in +This read function works a bit differently from the write function in that we do not use an urb to transfer data from the device to the -driver. Instead we call the :c:func:`usb_bulk_msg` function, which can be used +driver. Instead we call usb_bulk_msg(), which can be used to send or receive data from a device without having to create urbs and -handle urb completion callback functions. We call the :c:func:`usb_bulk_msg` -function, giving it a buffer into which to place any data received from +handle urb completion callback functions. We call usb_bulk_msg(), +giving it a buffer into which to place any data received from the device and a timeout value. If the timeout period expires without receiving any data from the device, the function will fail and return an error message. This can be shown with the following code:: /* do an immediate bulk read to get data from the device */ - retval = usb_bulk_msg (skel->dev, - usb_rcvbulkpipe (skel->dev, - skel->bulk_in_endpointAddr), - skel->bulk_in_buffer, - skel->bulk_in_size, - &count, 5000); + rv = usb_bulk_msg(dev->udev, + usb_rcvbulkpipe (dev->udev, + dev->bulk_in_endpointAddr), + dev->bulk_in_buffer, + dev->bulk_in_size, + &len, 5000); /* if the read was successful, copy the data to user space */ - if (!retval) { - if (copy_to_user (buffer, skel->bulk_in_buffer, count)) - retval = -EFAULT; + if (!rv) { + if (copy_to_user (buffer, dev->bulk_in_buffer, len)) + rv = -EFAULT; else - retval = count; + rv = len; } -The :c:func:`usb_bulk_msg` function can be very useful for doing single reads +usb_bulk_msg() can be very useful for doing single reads or writes to a device; however, if you need to read or write constantly to a device, it is recommended to set up your own urbs and submit them to -the USB subsystem. +the USB subsystem. The template uses urbs for read and write. When the user program releases the file handle that it has been using to talk to the device, the release function in the driver is called. In From patchwork Sat Dec 4 16:35:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: philipp hortmann X-Patchwork-Id: 520951 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F05BFC433F5 for ; Sat, 4 Dec 2021 16:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355439AbhLDQit (ORCPT ); Sat, 4 Dec 2021 11:38:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355368AbhLDQir (ORCPT ); Sat, 4 Dec 2021 11:38:47 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5179C061751; Sat, 4 Dec 2021 08:35:21 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id p3-20020a05600c1d8300b003334fab53afso7223421wms.3; Sat, 04 Dec 2021 08:35:21 -0800 (PST) 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=u3KULnMm+NurqHrJGvU91cGjIx8E0SlKbgyOAzOc/P8=; b=o/q4NKNPWU+/+Q7uJ2QnVJNjV/l1DQgTt3tS0zxSf9jLrpPUikVG3f0xrC80TVbALT 7WuW6ZPUHvbU2fU714ZfFpFt5o/cJT0ASlF+blHSBVvDm5dkjumhV3OXLp/op7tQwMF8 rMqscaP9Q3QzBybWBbzhMQ88OKqSnpFgldYJGqfm+2BhUvIDeJd3xpyE1FdXF1GEzkZ7 8jhwoZsvV1ltqUpGonw8SwJbo3+zcFr87kpze3/QRGIAwALSg2cfUqHf2GalDkDBvWc8 Ff4Oxn578jCy0eTD2Q1mAmfV6nVC3X/0lkZ3RGZ5dE4scOO53TFVQh8L+w1ivnLNLAXV AEZQ== 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=u3KULnMm+NurqHrJGvU91cGjIx8E0SlKbgyOAzOc/P8=; b=66Q3xxvXzeGr6yBHMpVBZSLLhRwyzQ8Ze1E5ncSOqaQ8889aHqB/mk6gM107rjgXMR L0yP9+INxbfeSlPajiXHxuk4F1hyxT28axZdY7ENUKQ85gPelHLMEs3zn3ZkuRcX1+AG MXQC6pLxzBS9A0VXgqnKkxAj1X5FUQVmk7RfauvKg9inQ4ekTZbyZPf/tuW0Ao+xCgUO LCgkX++1ro3walhXbkYOr23gqTl2D8kZOUkZuOCKwKIJF1oxtEWWvSSoeXKR8qO2og5A Jnqcr/3t8SPvR1A4vogep6cy0v1RkvBEjo2pMa4b0JT7auueJj1/rL5BfBgFgr9eFMrH LGkw== X-Gm-Message-State: AOAM532fj31j587iQzSAu+Oh1qRSMyFZPKVVyHlTfT0aWQoW88mjW1fk 9jtSWx84E86UkmSGPP97KhwvmI+k2WtqCw== X-Google-Smtp-Source: ABdhPJx/F75BE2+08L0UH9gcthsmKQ303WAiJM2UNJLWXarJwnkDq+Y1nxiH1H9cxgtSSApIoqDVuw== X-Received: by 2002:a05:600c:b43:: with SMTP id k3mr24354880wmr.159.1638635720232; Sat, 04 Dec 2021 08:35:20 -0800 (PST) Received: from matrix-ESPRIMO-P710 (p200300c78f4e0685b3447c22a42fc55e.dip0.t-ipconnect.de. [2003:c7:8f4e:685:b344:7c22:a42f:c55e]) by smtp.gmail.com with ESMTPSA id az4sm8680185wmb.20.2021.12.04.08.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Dec 2021 08:35:19 -0800 (PST) Date: Sat, 4 Dec 2021 17:35:18 +0100 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/4] Docs: usb: update comment and code near decrement our usage count for the device Message-ID: <40aa115e18d1139a7642bf4034835cdfb9f5b066.1638630342.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 Put release function in the document typical form Update comment: decrement our usage count .. and code according to usb-skeleton.c Signed-off-by: Philipp Hortmann --- V1 -> V2: Corrected format of function name to skel_release() --- Documentation/driver-api/usb/writing_usb_driver.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/driver-api/usb/writing_usb_driver.rst b/Documentation/driver-api/usb/writing_usb_driver.rst index ed11398837e5..297b622f5438 100644 --- a/Documentation/driver-api/usb/writing_usb_driver.rst +++ b/Documentation/driver-api/usb/writing_usb_driver.rst @@ -250,12 +250,12 @@ a device, it is recommended to set up your own urbs and submit them to the USB subsystem. The template uses urbs for read and write. When the user program releases the file handle that it has been using to -talk to the device, the release function in the driver is called. In +talk to the device, skel_release() in the driver is called. In this function we decrement our private usage count and wait for possible pending writes:: - /* decrement our usage count for the device */ - --skel->open_count; + /* decrement the count on our device */ + kref_put(&dev->kref, skel_delete); One of the more difficult problems that USB drivers must be able to From patchwork Sat Dec 4 16:35:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: philipp hortmann X-Patchwork-Id: 520755 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9133C433F5 for ; Sat, 4 Dec 2021 16:35:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355461AbhLDQiz (ORCPT ); Sat, 4 Dec 2021 11:38:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355388AbhLDQiy (ORCPT ); Sat, 4 Dec 2021 11:38:54 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 203C2C061354; Sat, 4 Dec 2021 08:35:28 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id u1so12559922wru.13; Sat, 04 Dec 2021 08:35:28 -0800 (PST) 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=U5oa62j24xavZIhW1pQBwsS9AFzTZJdQ7fQ+VSov/gU=; b=QjujrxabGjUpNmt2NhBglQ8VAZ2txQBLtVcB/rzT2wSaX9OWozOLfKMb6CNyQTcV07 sG1VUu6P3i/MFJO5EMQyehuOBadwrxyW3ypLcLR885EaQy8F9T3GZO6YXDxc7UBIUMb7 eyh2s0R0ozfhA/fIqENgPzYmUyfX/jZg+vspyzQm9Ui5bO7uhHHiP8xzoW1EEF8VJ6yH mChbLelF2crp7dWgMk/bjvkk+/M9W1Wv3S98UzxRWOFnZHoeD1dZNPHQ7aAB6hnvW86M OjzmiCAqBIVnESAj0MAQqtzU43txdeDJoy+swGJyHbvy7pjNAH/iGIu4cd9DY2JAH7Oj ap6g== 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=U5oa62j24xavZIhW1pQBwsS9AFzTZJdQ7fQ+VSov/gU=; b=JmcX9m1nG0vhIluFXnZP4I61mgmEU6QcCU4356MDAJzP+t7kxChDTGDFFuRDVaO3bK k8dZ1VTDV98qoMWex9vV68ly/t8S17UbzAgZZoVWxjd3bQBZ5d0eEqTkNyhTmYB+A1qg mEgGQ7N5gk3x2PUbc6THz81opPKSX8+tRVrbfT6kgC+Nt8zQZk1mldMyVU0fJBEEWEcd w5MUQAhi4a7R0uqf8w64mPUSiGOUAQkfnKslJIeSkXAYs27ng0kOcTlwhxCdHq2jJgy1 CUjp8CvNar4rh2EY+4y0fR8YTKMq5gGTsRA9iTjV8VAHvcQ6PQam7KFzUniK1hqR2c+j mntg== X-Gm-Message-State: AOAM530oF0nn9+sto7ypEEAekiK7aWS2cOzWINz++GuU1lxKB4svtgvJ Nmd479zC8tFt4cx+t9hdX0s= X-Google-Smtp-Source: ABdhPJyIdX2n3WId2lMyChYLev51YRiEPslY7xT8mJ3MVirL5jdU0inRbWxNlxnNlUeCjkxuOIKEUQ== X-Received: by 2002:a5d:47c9:: with SMTP id o9mr8826548wrc.55.1638635726766; Sat, 04 Dec 2021 08:35:26 -0800 (PST) Received: from matrix-ESPRIMO-P710 (p200300c78f4e0685b3447c22a42fc55e.dip0.t-ipconnect.de. [2003:c7:8f4e:685:b344:7c22:a42f:c55e]) by smtp.gmail.com with ESMTPSA id n13sm6053915wrt.44.2021.12.04.08.35.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Dec 2021 08:35:26 -0800 (PST) Date: Sat, 4 Dec 2021 17:35:24 +0100 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/4] Docs: usb: update comment and code of function skel_delete Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Put skel_delete function in the document typical form Update code according to usb-skeleton.c Signed-off-by: Philipp Hortmann --- V1 -> V2: Corrected format of function name to skel_delete() --- .../driver-api/usb/writing_usb_driver.rst | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Documentation/driver-api/usb/writing_usb_driver.rst b/Documentation/driver-api/usb/writing_usb_driver.rst index 297b622f5438..b459f9e089e0 100644 --- a/Documentation/driver-api/usb/writing_usb_driver.rst +++ b/Documentation/driver-api/usb/writing_usb_driver.rst @@ -262,19 +262,18 @@ One of the more difficult problems that USB drivers must be able to handle smoothly is the fact that the USB device may be removed from the system at any point in time, even if a program is currently talking to it. It needs to be able to shut down any current reads and writes and -notify the user-space programs that the device is no longer there. The -following code (function ``skel_delete``) is an example of how to do -this:: +notify the user-space programs that the device is no longer there. +skel_delete() is an example of how to do this:: - static inline void skel_delete (struct usb_skel *dev) + static void skel_delete(struct kref *kref) { - kfree (dev->bulk_in_buffer); - if (dev->bulk_out_buffer != NULL) - usb_free_coherent (dev->udev, dev->bulk_out_size, - dev->bulk_out_buffer, - dev->write_urb->transfer_dma); - usb_free_urb (dev->write_urb); - kfree (dev); + struct usb_skel *dev = to_skel_dev(kref); + + usb_free_urb(dev->bulk_in_urb); + usb_put_intf(dev->interface); + usb_put_dev(dev->udev); + kfree(dev->bulk_in_buffer); + kfree(dev); } From patchwork Sat Dec 4 16:35:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: philipp hortmann X-Patchwork-Id: 520950 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A717C433EF for ; Sat, 4 Dec 2021 16:35:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355520AbhLDQjD (ORCPT ); Sat, 4 Dec 2021 11:39:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355531AbhLDQjC (ORCPT ); Sat, 4 Dec 2021 11:39:02 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BB5DC061A83; Sat, 4 Dec 2021 08:35:36 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id l16so12585749wrp.11; Sat, 04 Dec 2021 08:35:36 -0800 (PST) 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=DlUMJFNyNRj/XgYSHRvRQioo+7kkX6yRCyniuTQc4VM=; b=jZr2sPuj+uvl+MV3O56PzBkPpoH5fkRGRfzTs5PbxVeFuwsCDTP5cdKWhYWLZ9SIRX C39FECrQIlSwB8QcvVH45d2QrNw2bE4bjAmlLSBetZHiDsR7Df2nHk3q6WHG12ZsgRaB Q9LB7jnKcJae5Ov0Ysjn22hYTZqel2pjQZ/hH/dU0GHS1NHC6ddF0jvvGKJv0p3e2w6G Wrn+iyuGEYUTvrt4g1VgsY1L2nk6jqMW+WO30+t4P+qBmPQeRf4tUT0UCwnNh2b3+qgT TA+FQ6CEgTEK9yeo7iGl4UljZfcCT46PlR4PE3mS89/RopdFTttHb/9g9SGJlasEKcRI cNfQ== 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=DlUMJFNyNRj/XgYSHRvRQioo+7kkX6yRCyniuTQc4VM=; b=Lai526kqlWvUFpzVXGgEeepYuHNBSDz/9m9qp1Vk9CqCLs0kFfMEuLOOGJ4Un20Hlw ysC+hZ9vggZ9HXNV+oj0SG55YHcRPewTPlp0rsDpycSTd3M76pGhjac5P/XRitbXvJJO XKy1IGUSFhS32cmwD+yTXZQmEZkpvDsKN5tKniQNRVsmkkEcPOhfD3Oj9W8viaGOqs06 0d55D4DjVimhywAsEUfvOsruZzA1wRDVL7XzKWFkW1csfWKwo+9d/enQMhRHC/TqVQDZ kwXFjuznciAxxMmikrIb7f49Yq9xEGGBUd14eF08ShT1OkvMSIH7cXs+28Bjq9aVI9GW 3YSg== X-Gm-Message-State: AOAM530RZKfnUGESAr0zWI0hYOOfppJLXMLjyBZvE+mjTfat34PqUuXW oHRh03un26z/4RC7v1wG5gRvM7Bs+FJqCQ== X-Google-Smtp-Source: ABdhPJxLD784pITzSQYTE5Vbf4jwLGCG0AGUN3aGvj8DMKQz18NvHFEeh+AhUFEF/LNxrcrpnXcJpw== X-Received: by 2002:a5d:604b:: with SMTP id j11mr31016436wrt.22.1638635734714; Sat, 04 Dec 2021 08:35:34 -0800 (PST) Received: from matrix-ESPRIMO-P710 (p200300c78f4e0685b3447c22a42fc55e.dip0.t-ipconnect.de. [2003:c7:8f4e:685:b344:7c22:a42f:c55e]) by smtp.gmail.com with ESMTPSA id j17sm7229172wmq.41.2021.12.04.08.35.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Dec 2021 08:35:33 -0800 (PST) Date: Sat, 4 Dec 2021 17:35:32 +0100 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 4/4] Docs: usb: update explanation for device_present to disconnected Message-ID: <41cc6dbe6a97b7e5bff08a81a6e2fec3561cda76.1638630342.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 text for `device_present` flag to `disconnected` flag Signed-off-by: Philipp Hortmann --- V1 -> V2: Corrected format of function name to skel_disconnect() --- .../driver-api/usb/writing_usb_driver.rst | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Documentation/driver-api/usb/writing_usb_driver.rst b/Documentation/driver-api/usb/writing_usb_driver.rst index b459f9e089e0..fa795b8d7eac 100644 --- a/Documentation/driver-api/usb/writing_usb_driver.rst +++ b/Documentation/driver-api/usb/writing_usb_driver.rst @@ -277,15 +277,13 @@ skel_delete() is an example of how to do this:: } -If a program currently has an open handle to the device, we reset the -flag ``device_present``. For every read, write, release and other +If the driver probed the device successfully, the flag ``disconnected`` +is initialized and set to false. For every read, write and other functions that expect a device to be present, the driver first checks -this flag to see if the device is still present. If not, it releases -that the device has disappeared, and a ``-ENODEV`` error is returned to the -user-space program. When the release function is eventually called, it -determines if there is no device and if not, it does the cleanup that -the ``skel_disconnect`` function normally does if there are no open files -on the device (see Listing 5). +this flag to see if the device is still present. If not, a ``-ENODEV`` +error is returned to the user-space program. When the device is +disconnected, skel_disconnect() is called. It sets ``disconnected`` +to true and cleans up. Isochronous Data ================