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); }