Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4396974ioa; Wed, 27 Apr 2022 02:59:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1uBWIeGrBBWIl27ik05N0sS1tsUCE8v7dTVJHoPl4G98ZLK9NniZSSi1e4FA7AJM/K5Dt X-Received: by 2002:a17:902:e94e:b0:158:91e6:501 with SMTP id b14-20020a170902e94e00b0015891e60501mr27779934pll.29.1651053585632; Wed, 27 Apr 2022 02:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651053585; cv=none; d=google.com; s=arc-20160816; b=Gzv2Vy2VlrbKmpH6xlWGcqfz6WRIuJToD+snlRVPXePPCSgF8z5XSm5BYRv4V2T+u+ 1wVhSqBKCtnm/8gCJjmeN7q09UXHzL3QbengnYM3SNDRJXt4r4UhLufJ4YX9T4xeHhGl xEYe9rg3vFxWByQBF/DXQRTLIq9E7hiuOvbuRXt3ZFhpOuH6+k/2nqzkHq0hbsb/WT5F 0OFhqf9yZdH/nIKnzAiBDiARzmgH1QdZUCOJZMdPFtTGwN8lircaFOzkt9tvMMC+jB1A 1o19rqnfCe0YJ31eTZDrAbAnyFBDBAFJfKd3J2IGmbm9rpgrosYi3Mt5B0rbJ85dYCpA ECeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=JljXmszvBnZw0s22Exxpej2VdJNcr+pA7qi5ksTCt2Y=; b=zTiO7CV9TvArjDVCS10Svfph4HQ0SmvqMwFJ0lRX2dfMTvtrTBNeMcbxPihjVSq8ff 9/xV61qVNL/p+wrJJ6dxiM5L7pIWKO3xdYekHZ+DwGXJSfPAuaQjjvTJCgZzpzWuuHem lkXHdlrLxvuKDsnsy9ydtHtGhi+GWutZyk5GJpxQG5Dr25EbRQQiR/bIY0LJuRLHWyR3 RlH6qZR8wdlz2IzLfyvNfN84UKw1UpfW9rZqCIJmjAQ9fj/xKcFYolBlBw2NNAYC0Qtc Y2BOTyJ7q22Dvezb4H/HXl6LREt9oiqH9tsLqyledorclz69PDRG/giexlBzLlaAgjwY wjnw== 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:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 31-20020a630c5f000000b003aa45e32c20si995761pgm.860.2022.04.27.02.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 02:59:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0DD7D2CF1C0; Wed, 27 Apr 2022 02:27:43 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357893AbiD0FmC (ORCPT + 99 others); Wed, 27 Apr 2022 01:42:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232148AbiD0FmB (ORCPT ); Wed, 27 Apr 2022 01:42:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 080F514DE8F; Tue, 26 Apr 2022 22:38:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BE456B824E6; Wed, 27 Apr 2022 05:38:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39A00C385A9; Wed, 27 Apr 2022 05:38:47 +0000 (UTC) Message-ID: <8cab70e2-cd3f-da75-9e6a-1d63e33e6e24@xs4all.nl> Date: Wed, 27 Apr 2022 07:38:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] media: stkwebcam: move stk_camera_read_reg() scratch buffer to struct stk_camera Content-Language: en-US To: trix@redhat.com, mchehab@kernel.org, cai.huoqing@linux.dev, paskripkin@gmail.com, xose.vazquez@gmail.com Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220312173049.1410977-1-trix@redhat.com> From: Hans Verkuil In-Reply-To: <20220312173049.1410977-1-trix@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 Hi Tom, On 12/03/2022 18:30, trix@redhat.com wrote: > From: Tom Rix > > In stk_camera_read_reg() a single byte buffer is alloc-ed and > freed on every function call. Since the size is known, > move the buffer to the struct stk_camera where it will be alloc-ed > and freed once. I read the replies to this patch, but I am not certain if you still want this patch to be merged, or will make a v2. I have no problem applying this patch as-is, but I just want to have confirmation that there won't be a v2. Regards, Hans > > Signed-off-by: Tom Rix > --- > drivers/media/usb/stkwebcam/stk-webcam.c | 11 ++--------- > drivers/media/usb/stkwebcam/stk-webcam.h | 2 ++ > 2 files changed, 4 insertions(+), 9 deletions(-) > > diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c > index 5b822214ccc5c..787edb3d47c23 100644 > --- a/drivers/media/usb/stkwebcam/stk-webcam.c > +++ b/drivers/media/usb/stkwebcam/stk-webcam.c > @@ -150,25 +150,18 @@ int stk_camera_write_reg(struct stk_camera *dev, u16 index, u8 value) > int stk_camera_read_reg(struct stk_camera *dev, u16 index, u8 *value) > { > struct usb_device *udev = dev->udev; > - unsigned char *buf; > int ret; > > - buf = kmalloc(sizeof(u8), GFP_KERNEL); > - if (!buf) > - return -ENOMEM; > - > ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), > 0x00, > USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, > 0x00, > index, > - buf, > + &dev->read_reg_scratch, > sizeof(u8), > 500); > if (ret >= 0) > - *value = *buf; > - > - kfree(buf); > + *value = dev->read_reg_scratch; > > if (ret < 0) > return ret; > diff --git a/drivers/media/usb/stkwebcam/stk-webcam.h b/drivers/media/usb/stkwebcam/stk-webcam.h > index 14519e5308b18..136decffe9ced 100644 > --- a/drivers/media/usb/stkwebcam/stk-webcam.h > +++ b/drivers/media/usb/stkwebcam/stk-webcam.h > @@ -105,6 +105,8 @@ struct stk_camera { > struct list_head sio_avail; > struct list_head sio_full; > unsigned sequence; > + > + u8 read_reg_scratch; > }; > > #define vdev_to_camera(d) container_of(d, struct stk_camera, vdev)