From patchwork Mon Nov 29 20:21:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Hortmann X-Patchwork-Id: 12646013 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 DB8E5C4332F for ; Mon, 29 Nov 2021 22:51:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235697AbhK2WyU (ORCPT ); Mon, 29 Nov 2021 17:54:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233648AbhK2WxX (ORCPT ); Mon, 29 Nov 2021 17:53:23 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E6F2C08EB4F; Mon, 29 Nov 2021 12:21:45 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id a18so39489642wrn.6; Mon, 29 Nov 2021 12:21:45 -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=7gIeiPld9zLHugWa33z4cxIeDKg8lMMvyR8V+fYZSRU=; b=ozJ62MEtuU7hwSGRIjRdTImmV1wsksWSMmpW3R/9xrm6/FC6Bpo111l5Ez2bOWFEEO e2nJKH1iibcsLCU3PCBUhDy0sUjWKiqFfJ0T/wJUwvxZxlaxVmesQYxlPtVSBwtLFDKj t8Z4Z/uOg32QSLQMBBIsS/4hU8QUDuzsg5nwSWIpqnYVttWyyCO9aMxlSySLDbQ8FT5P mSOcY9b0fgJ+ldtXyCXE3f+t9JhUg8MOmw73zasTNhpvBZO0Efq+U6D82wxPCyGGFfb7 /4P2UcvFy9a9H56d9220BzmxKNI/iybT2lYf82KlPsCRrdGcSce0GDsVWts/2RkJBeFx tuEQ== 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=7gIeiPld9zLHugWa33z4cxIeDKg8lMMvyR8V+fYZSRU=; b=TEEddtjqMv0EZTU5Bd1GeaVOB19tEQ869hod3XHdHxnFqxuYyTFowSmEuc70wXluUF yg7OTDhgjKf2+oRTTlOTDslMFIdf7BXeqUdODKrZ2R7HO/nadRTiO3KH7SRBeDcAIHFY 5SNVod/SBs6uVoDtWjos22Vo65nL54QRLRTu9aA/w10ZWLx3iaDHMfoqksUM3/i3w9UU 8U/ZZL5ChTXzF86YqKW+7s7UrTFA6BueGC+Gbq6Scr1lZnAQYBoW2e/EHY9f6yrFYUUl pBcSvVmqH15W/JDISQOTFafxdzby2KX7mWSFWTcyYqsAzJGFvMcPt5ZGYdC9uAurFaIE bWQg== X-Gm-Message-State: AOAM533piJfhwS9LKkv7Ibp6yvOAc39COYKzk4rgV0+K04p6C8QS3tMV dyUk4CwkyqFFTdr/a4FAtn7acVeAcZU6DA== X-Google-Smtp-Source: ABdhPJwh67JHoWu8iWxdVopal7Q/Ny+oJcSNa8bO1ENTqBaL04B8qRvm7XXWsNg7uTaDZLsPDfL7Sg== X-Received: by 2002:a5d:4e0b:: with SMTP id p11mr35723785wrt.88.1638217303906; Mon, 29 Nov 2021 12:21:43 -0800 (PST) Received: from matrix-ESPRIMO-P710 (p200300c78f4e06460b103a790e4c64a8.dip0.t-ipconnect.de. [2003:c7:8f4e:646:b10:3a79:e4c:64a8]) by smtp.gmail.com with ESMTPSA id 9sm18599651wry.0.2021.11.29.12.21.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 12:21:43 -0800 (PST) Date: Mon, 29 Nov 2021 21:21:41 +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 1/4] Docs: usb: update usb_bulk_msg receiving example Message-ID: <28a76eedad7027277754cef84ca34810b0cfe6f4.1638152984.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 Signed-off-by: Philipp Hortmann --- .../driver-api/usb/writing_usb_driver.rst | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Documentation/driver-api/usb/writing_usb_driver.rst b/Documentation/driver-api/usb/writing_usb_driver.rst index b43e1ce49f0e..a9608ad18d77 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` function, 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` +handle urb completion callback functions. We call `usb_bulk_msg` function, 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 +Function `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 Mon Nov 29 20:21:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Hortmann X-Patchwork-Id: 12646017 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 78DB3C433FE for ; Mon, 29 Nov 2021 22:53:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235582AbhK2W4j (ORCPT ); Mon, 29 Nov 2021 17:56:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236171AbhK2W4M (ORCPT ); Mon, 29 Nov 2021 17:56:12 -0500 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 606B4C09CE47; Mon, 29 Nov 2021 12:21:50 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id az34-20020a05600c602200b0033bf8662572so13254817wmb.0; Mon, 29 Nov 2021 12:21:50 -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=fb86c64AAxfgKMIhtfj1EvABb44FROtjYen1/0oh/7E=; b=gDbo1dVJn1Pl7Vg552yy2coDXPNYenyEMsjHS0rQawHS1B2l3k0mtDIglMGgRwlA4/ H+k6yywj73T4bG0x7Nr/n0U4IhX6k48/oKy/T8t5l8kHU3F/UML3PS2Igq0W+NCy/SPR bwJ69n/C0Gc71wzQGgFSmHdFPPPzovkHX2cGzz/jGHrNZiN3mLOevE5ledsmAVgYkHCi tJjdZ12XvDZjsk5QSru3kuiu+rNW6wJin4zHg+botRjOZCCX8Rq2c/eAmEafJCdW+ntt BuTpSp49vW/lVlplrmHnXpoHROICJ7SBjiR09M6sYFu7fZEOQn+HvhuvsWG5IDPib1gp bYPA== 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=fb86c64AAxfgKMIhtfj1EvABb44FROtjYen1/0oh/7E=; b=THLr6ZZzytkHtiOXzD/HuxA8wfGjwGYeXL+C7E5JAVFis9SsiWu+IQv9MNN34GpJmL L62bcppsefSFiW9mCnRi2qUMgMN1jhHNPPS7r8vwRaexRo0fY8coAcDyVBlIAsc43F1n 3rS6hHvDSa3kvkAVHgcunEkxibDT8KWIxM510HYxvLoNun6DQL4miQzrhrCgEoRx8eFb 0v6p9AWR+8Hx6xYiStXTMstx7Wscoa0m2yoeihnOIlmyu+p3BOtUJM4ny/Sp/cCmn/SV 5pz16hcO7dqERHrg5s8bb51rDu5rOsifbhS7VULdxKUsAE8wKCYzs/tQihyR5N46Pzc/ snaw== X-Gm-Message-State: AOAM530z3m8KF/FkEVrqVKriQOLt0PLbw+pZbtonUwYiKGuwh1Azjs7U 9Ya6nvWnx4Wmsah+bxSNMkFoCZ+WcdcOfg== X-Google-Smtp-Source: ABdhPJyFDhJ0eC4nxYqZ0esW8KwbVh+54Ab+svmQe19/xmGfPC0ceJBssaQACJCxGZiy8zCfgr0Ymw== X-Received: by 2002:a7b:c94e:: with SMTP id i14mr249770wml.85.1638217309076; Mon, 29 Nov 2021 12:21:49 -0800 (PST) Received: from matrix-ESPRIMO-P710 (p200300c78f4e06460b103a790e4c64a8.dip0.t-ipconnect.de. [2003:c7:8f4e:646:b10:3a79:e4c:64a8]) by smtp.gmail.com with ESMTPSA id h2sm14315553wrz.23.2021.11.29.12.21.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 12:21:48 -0800 (PST) Date: Mon, 29 Nov 2021 21:21:47 +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 2/4] Docs: usb: update comment and code near decrement our usage count for the device Message-ID: <75317b591c0da0d32be77b819680733a44f6f70b.1638152984.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 --- 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 a9608ad18d77..b16e4e76d472 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, the `skel_release` function 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 Mon Nov 29 20:21:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Hortmann X-Patchwork-Id: 12645997 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 8C69BC433F5 for ; Mon, 29 Nov 2021 22:43:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235213AbhK2Wqm (ORCPT ); Mon, 29 Nov 2021 17:46:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235307AbhK2WqQ (ORCPT ); Mon, 29 Nov 2021 17:46:16 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8779C09CE48; Mon, 29 Nov 2021 12:21:55 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id d9so18570827wrw.4; Mon, 29 Nov 2021 12:21:55 -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=Yr7Pm1zMDL+waiXGnmgDPUcvU9J11jTasCepYE2XOcI=; b=LiiAhDbYWHpCwYtAa2MJumN97/cy1tI6b39nZ5sEpep8M7bmVXwMNhhnacI1jZh779 dglz9rJF/4h4heP1VBuF9fpEVK/B1WFEGD1SjlivBXiRrVLtsk6Lfcracj0nHg9w3F/k fyuxa3wFU8MW5BuOzJTpZG5IKQpGXktpS1VAskhKFnbjbtAmX0aIAvh3KQ/S4Co6+8pO +4sBr1SGcX0/rASd4P22u64snuSmRDGbM1QXs1qmf+SYhfMg+c1k3PcWbOtdiXNSmZaz SY2rpLmC3ODQDruPCIMSqUTR01Rj5V+g3JiYpkDFBuXRFjKuJrICF5HDFCh5mpuFHgQC CCBw== 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=Yr7Pm1zMDL+waiXGnmgDPUcvU9J11jTasCepYE2XOcI=; b=047kRsTFYwCtvH07KvmbACY0msd3Zhh2Mq9IafPZtlx+4E49/VtzuUN7IlZ2YITJBx m4+Qp6zZvr+5pmflsei0YGKktQ7fFvf5Y6GoHKvnkiUnUC9etLk8/ppO50lcLRv3Oj0+ Zl9vVyEQZFcZYlN+SiwNh+JLE8tgJkwkXbkwBOSY5jYjYPA5oTz25gMyMHwp0h0vnFCn dLVEjzdiwvJNujSIxAIsiU2ZyM0wA+pGTGMTpqhF1oyt+Hz6+jS9kkkvYgOe2xy8EuOC U6j/sk5BfZBFQxVHXgCqeDJ0OgMy7dTTnUJgE981ZEe9HXSTXxVChOGt5t7a2zA9CgUN 56oA== X-Gm-Message-State: AOAM532IOX2Ph31LBjUAgnjbwgfxuogGw0KnzQTv34CRCKa1AzDx5QgW 7wZtRSP7NcrTVn7wn8AB8R8= X-Google-Smtp-Source: ABdhPJx07ZTKQZSdjG2iCwY0lEujg0Naxur5L4l+SvNUdnLbUrbaNbWRNTlTwHTqXyH4JnDkNq/mcw== X-Received: by 2002:a05:6000:1acd:: with SMTP id i13mr36406501wry.398.1638217314493; Mon, 29 Nov 2021 12:21:54 -0800 (PST) Received: from matrix-ESPRIMO-P710 (p200300c78f4e06460b103a790e4c64a8.dip0.t-ipconnect.de. [2003:c7:8f4e:646:b10:3a79:e4c:64a8]) by smtp.gmail.com with ESMTPSA id o9sm14710006wrs.4.2021.11.29.12.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 12:21:54 -0800 (PST) Date: Mon, 29 Nov 2021 21:21:52 +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 3/4] Docs: usb: update comment and code of function skel_delete Message-ID: <76757c4fc1f5001c3285a9a071055e8715985604.1638152984.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 skel_delete function in the document typical form Update code according to usb-skeleton.c Signed-off-by: Philipp Hortmann --- .../driver-api/usb/writing_usb_driver.rst | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/Documentation/driver-api/usb/writing_usb_driver.rst b/Documentation/driver-api/usb/writing_usb_driver.rst index b16e4e76d472..74bb72a2f0ac 100644 --- a/Documentation/driver-api/usb/writing_usb_driver.rst +++ b/Documentation/driver-api/usb/writing_usb_driver.rst @@ -263,18 +263,17 @@ 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:: +`skel_delete` function 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 Mon Nov 29 20:21:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philipp Hortmann X-Patchwork-Id: 12646015 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 C08C8C433F5 for ; Mon, 29 Nov 2021 22:51:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234938AbhK2WyW (ORCPT ); Mon, 29 Nov 2021 17:54:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235599AbhK2Wx0 (ORCPT ); Mon, 29 Nov 2021 17:53:26 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C5FCC09CE49; Mon, 29 Nov 2021 12:22:01 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id o13so39331853wrs.12; Mon, 29 Nov 2021 12:22:01 -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=bd8os49boluMWjCPlqHxyzhvgDaCkV5iDG3ksc4Oiew=; b=JfGF2y22b1w2YpnDbGsNpUaD0qGZ5PtvI69SCPcLUOrJiY1sl8NMyFVmYVCH9WoDwp VwVv/AsBWBPipZCXyxs6dP2FeWa+AIZD+d62HU4aR/UigN0beszIVRwejJgSZ2XfBctn uk3kXYwUX3NXYU9BAESYsp68b+gotQykh/uzEl1o8OZQ4G+yA4k0GlQohXazTPqedsaw UKdJdu6G1gDMsXmiEQxWPImvPL1VXmaekdmnXN/FDIhAPphwXWLgmz6/1L42Kr4I60hY rYHs02yWDOAhNaBo2iKsmWELs/D4271YksdgLAM95dsLotCbXCqTrKBR9YTXJWeidqFV LaHA== 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=bd8os49boluMWjCPlqHxyzhvgDaCkV5iDG3ksc4Oiew=; b=y7WMWWcUtaMG0UGc/CdzmsxZlV0tTEDOz56X4tXYLYPy5e/wymhzcVSJVthkLcLmAU X/3fLATTUa2Rv27JQRxw+jMeZW05nRdxg2WVfy7aWJkS8/g32JnxDB+av+637jzPx7R8 TM4q9W6vhaCIe5kH7Qu1H9sqPYW5QC9Dg8JI5bEz4/8+0lUvl+b/zF1/59dPFE9z/zrG LUJV0WmecERe2qcx3F7n8sjLo8kOU+UczhTtlF/NXkJ2Q3kWpHR7u2LLrsWUiAieMYok x4HF/aeCSS+W6YOvXY8czKRpjllhb2tWBZbW+4r/fhNf/lR3dK13oYQgIt7SWcmiBfxA G5Lg== X-Gm-Message-State: AOAM530sOJihpjtC+aL7TSNG2p1BdeoYp7sX/pTRMX5ZbF9HjXLtiEhO PPVcEyhPfLQBcoTPTq93m3apbxTKHmDR+Q== X-Google-Smtp-Source: ABdhPJyHGI56MgmqOPpRT2GOWXCw4Uc+KNVhzS0Mzfto+/7wpT2FwsYAABpFPq7f5ZW3aQ0yApfpEw== X-Received: by 2002:adf:fbc5:: with SMTP id d5mr39029256wrs.291.1638217319837; Mon, 29 Nov 2021 12:21:59 -0800 (PST) Received: from matrix-ESPRIMO-P710 (p200300c78f4e06460b103a790e4c64a8.dip0.t-ipconnect.de. [2003:c7:8f4e:646:b10:3a79:e4c:64a8]) by smtp.gmail.com with ESMTPSA id n7sm14395121wro.68.2021.11.29.12.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 12:21:59 -0800 (PST) Date: Mon, 29 Nov 2021 21:21:57 +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 4/4] Docs: usb: update explanation for device_present to disconnected 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 Update text for `device_present` flag to `disconnected` flag Signed-off-by: Philipp Hortmann --- .../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 74bb72a2f0ac..d398d2155cd3 100644 --- a/Documentation/driver-api/usb/writing_usb_driver.rst +++ b/Documentation/driver-api/usb/writing_usb_driver.rst @@ -277,15 +277,13 @@ notify the user-space programs that the device is no longer there. The } -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_disconnected` function is called. It sets ``disconnected`` +to true and cleans up. Isochronous Data ================