Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2898698pxu; Sun, 29 Nov 2020 08:19:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhJed7oFlmNUNrekMC4EXtRp7cBVcqYJafpUcI2roJ4gat0NDeh36WCM4rehVI6Fv/+fw7 X-Received: by 2002:a17:906:ecad:: with SMTP id qh13mr11612910ejb.443.1606666798171; Sun, 29 Nov 2020 08:19:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606666798; cv=none; d=google.com; s=arc-20160816; b=qjOQ+Jg0Mzw9zZDrRxG7Tr3+9go75MV3KpOCiJ0dFQD7lqMZcrAo0ubZ5XFWse8sYQ 2RbNi8lb4YPSUnCU4WoeaNHwfGN7zI4Cl+x1muVhnyqmPQrfD4+9zqCrs4FQtExQdZ0t kWS860dCFMJjIRItlccEbgQzWNLcqRmViYwU5dn1sq9nIxt6N8/cLkmGFvbhRxlZ/Ryz YHQbF9068VcLH7R8KsSiF80IT9GSE8NZzugXmjFCQr+Yw5Y1o8SusoCNID9dSYHgS8wS qJOMQrJFBmTd4wrRNIvH9Ow+KAkkvB5wV7p2ojNhvpCLtI0KN/rFM3pVtxtMoYNt4cMw o1Ew== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qbYEvVAr5fkSoiW+aOD66ahEe9BP1FJ89VIYtWi9eqI=; b=eNPXYwxfMJmnP2CkieWkVOPlRl9Q/mca2Qalx4mekI694kqGFjD5FxjMVEwHGYnudW 7iMYDgFSgkrM03XuSl1+bHxirWnn87P/Nk2oVY1b7hO6E3xNS0Ywsxr7WBY3HHUNebz+ nqk9EJQ+TzVhAj2M4N77vqPgeDP7BwpvQxvFDc+O28S+p12ZE2CU2Fd2cl6wvpCwz3rU CvpE2DfKw0zFXu+b74wXkxvDu4B9GfV4WoLarrJ6jEjlAFbTEMDDBcM3I36P3R9jwfGM cA5lXgqEARwrGvFAJNr7/8xS9xgWcJ8h4y4eUkF/KEDzVqqPOpLFqtf6Z95JutnMwBhm HAuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xNrqMzko; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si3218809ejc.599.2020.11.29.08.19.33; Sun, 29 Nov 2020 08:19:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xNrqMzko; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727117AbgK2QQy (ORCPT + 99 others); Sun, 29 Nov 2020 11:16:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:59764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbgK2QQy (ORCPT ); Sun, 29 Nov 2020 11:16:54 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A618F2080C; Sun, 29 Nov 2020 16:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606666567; bh=iuhl6jqcqemEjueLeX9RtQtS5Hlomxs0uN0YI18a/qU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xNrqMzkok3fomfue06G87svG+7XNZu+9H5o29JzHXDZ4ONw6uwPp7MukHSivZZdwx mu/rttiqKzrft1tu5KwQuh86tv/e7R7hQ8ybf/nLWUnEXr4No3mII6GXw+jVyJ5LMQ yfw8ENRAoAxyAkIcYP830FlYNzNg2vJvs1+P9RO0= Date: Sun, 29 Nov 2020 17:16:03 +0100 From: Greg Kroah-Hartman To: Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 03/15] usb: misc: cytherm: update to use usb_control_msg_recv() Message-ID: References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> <20201129160612.1908074-4-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20201129160612.1908074-4-anant.thazhemadam@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 29, 2020 at 09:36:00PM +0530, Anant Thazhemadam wrote: > The newer usb_control_msg_{send|recv}() API are an improvement on the > existing usb_control_msg() as it ensures that a short read/write is treated > as an error, data can be used off the stack, and raw usb pipes need not be > created in the calling functions. > For this reason, the instance of usb_control_msg() has been replaced with > usb_control_msg_recv(). > > The return value checking enforced by callers of the updated function have > also been appropriately updated. > > Signed-off-by: Anant Thazhemadam > --- > drivers/usb/misc/cytherm.c | 42 +++++++++++++++++++------------------- > 1 file changed, 21 insertions(+), 21 deletions(-) > > diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c > index 3e3802aaefa3..75fa4d806a77 100644 > --- a/drivers/usb/misc/cytherm.c > +++ b/drivers/usb/misc/cytherm.c > @@ -51,12 +51,12 @@ static int vendor_command(struct usb_device *dev, unsigned char request, > unsigned char value, unsigned char index, > void *buf, int size) > { > - return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), > - request, > - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER, > - value, > - index, buf, size, > - USB_CTRL_GET_TIMEOUT); > + return usb_control_msg_recv(dev, 0, > + request, > + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER, > + value, > + index, buf, size, > + USB_CTRL_GET_TIMEOUT, GFP_KERNEL); > } > > > @@ -95,14 +95,14 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *att > /* Set brightness */ > retval = vendor_command(cytherm->udev, WRITE_RAM, BRIGHTNESS, > cytherm->brightness, buffer, 8); > - if (retval) > - dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); > + if (!retval) > + dev_dbg(&cytherm->udev->dev, "brightness set correctly\n"); > /* Inform ?C that we have changed the brightness setting */ > retval = vendor_command(cytherm->udev, WRITE_RAM, BRIGHTNESS_SEM, > 0x01, buffer, 8); > - if (retval) > - dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); > - > + if (!retval) > + dev_dbg(&cytherm->udev->dev, "?C informed of change in brightness setting\n"); > + > kfree(buffer); > > return count; There's no more need to dynamically allocate the buffer variable here now, right? It can be on the stack as the change you made above allows that to work properly, no need to allocate the buffer twice in a row (once here and once in the USB core). That would make these functions less complex, always a good thing. You should check this on the other patches in this series as well. thanks, greg k-h