Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1233183rwb; Thu, 15 Dec 2022 07:52:28 -0800 (PST) X-Google-Smtp-Source: AA0mqf4NuJ6TA4CCMw6kZGlXd71UexxchG/vIw6v6JDUKrPLXircHzu2oQpXFESW5kVNZZgpFXff X-Received: by 2002:a05:6a20:6918:b0:9d:efc0:62 with SMTP id q24-20020a056a20691800b0009defc00062mr49151784pzj.10.1671119548275; Thu, 15 Dec 2022 07:52:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671119548; cv=none; d=google.com; s=arc-20160816; b=tQhF2y2hFEWu9WzZUD7OGOOI1BpW2sLZXdtOmw5uwa+0mim+6/a0LZ+WnbCtT5iNcZ ZSQ0IObvk/N+9m/iwP5p43dd3uCdfTn1jElE+cyU4C2swFRBemMXqPwZlbB1JMOk4e4v vsTxjfB2w6NWiBr+vJPX1K2m/TK/CBWmWAGma0li00lbFritfWCIktTKmaZKUlpPFkLG 3i5IgzWULmWUiG8Bg/vh3RO6fVQXDfI3Tba0PN3mWW0rUkTzM6qG+MBimysWLbGhHjSy Yz9xrnaSD4wACl+PqJuFgQh1iikZuB9eAwCDXylH6sBHIzJOq5Rnjs+EGOKrdcNAx82c ynLw== 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; bh=uGWd7gmg9yyvtIp7QsL+m9n7wnVunjkCRfrYU0Qu3PY=; b=V2FEdj3EkrZPsCHWjKys/Kz9EigIYPjj/AgEWdCCYpIHiS8nNmAuxXdsQRoPZyI8Ia uDfIHEdf5WARYBhM19tVyPtpIJiHRcndGklBFL7+qlsGlaO8KtXldAzLguupHx+7UwkS w4xrRhJQidZGxwYyl8Bhu4g2EPXZKD1tdfrnqHUjNCL2FOHCnrFIKzHjfgzEE4wc8+iz luOnWB+r3KsJ29nIL1iSb+g6cjAMHkH86pGZ3d6XkF88KNK72itt0BbVqma0ImpGNn9d po68zR7g0cjZtMmNIiMz78LgpMTJNOa6aEsMJI6YehJb3JKXxmuIXKR/cxAHDX2CqaRg tjqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bc22-20020a656d96000000b00478ec716e29si3024658pgb.451.2022.12.15.07.52.18; Thu, 15 Dec 2022 07:52:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230177AbiLOPez (ORCPT + 68 others); Thu, 15 Dec 2022 10:34:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230202AbiLOPeu (ORCPT ); Thu, 15 Dec 2022 10:34:50 -0500 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 687A428E3F for ; Thu, 15 Dec 2022 07:34:43 -0800 (PST) Received: (qmail 963481 invoked by uid 1000); 15 Dec 2022 10:34:42 -0500 Date: Thu, 15 Dec 2022 10:34:42 -0500 From: Alan Stern To: Ricardo Ribalda Cc: Max Staudt , Jonathan Cameron , Sergey Senozhatsky , Ming Lei , Mauro Carvalho Chehab , Laurent Pinchart , Yunke Cao , Christoph Hellwig , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: Re: [PATCH v3 0/2] media: uvcvideo: Code cleanup for dev->status Message-ID: References: <20221214-uvc-status-alloc-v3-0-9a67616cc549@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221214-uvc-status-alloc-v3-0-9a67616cc549@chromium.org> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 15, 2022 at 11:57:17AM +0100, Ricardo Ribalda wrote: > There is no need to make a kzalloc just for 16 bytes. Let's embed the data > into the main data structure. > > Now that we are at it, lets remove all the castings and open coding of > offsets for it. > > [Christoph, do you think dma wise we are violating any non written rules? :) thanks] There _is_ a rule, and it is not exactly unwritten. The kerneldoc for the transfer_buffer member of struct urb says: This buffer must be suitable for DMA; allocate it with kmalloc() or equivalent. Which in general means that the buffer must not be part of a larger structure -- not unless the driver can guarantee that the structure will _never_ be accessed while a USB transfer to/from the buffer is taking place. There are examples all over the USB subsystem where buffers as small as one or two bytes get kmalloc'ed in order to obey this rule. 16 bytes is certainly big enough that you shouldn't worry about it being allocated separately. Alan Stern