Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3564520rwb; Sat, 12 Nov 2022 08:03:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf6pbgWIkX7hNcunu/DwyQbzXTn3IgKTT1oByVh1UgCKPmj79aEyRSzhRFaJ+5y0MPUDdWjR X-Received: by 2002:a17:902:d381:b0:186:5de3:8f10 with SMTP id e1-20020a170902d38100b001865de38f10mr7105298pld.92.1668269019503; Sat, 12 Nov 2022 08:03:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668269019; cv=none; d=google.com; s=arc-20160816; b=02r14lJaCRj5edwZ06ZcEdSOcK4UMBj616HlfHBewW8MYVM0LKU+YTm9VZ1qprjx6J skVrJwlBF808NGOcOUm6ag9gCKSkZB/d28mWnvq8sqtMB9Xgrn2ROEBTJ64pqCdAPg1u zeZK0W6KKMzyt5qH1zhv7OFq4sJyXQGIG0lllyfgdAZz8s3ts+8bBcLNSh1oxztv8aWs yUFJyRS26cOB7vuvF2vERWqi6vhwztqIsyYc36sTmB/TaCIlsAVfGuNhyrQ6ToQhn6DQ MpB89oxQNbUTINaCOCte06dOaCwpgfBwHJJ48QHKHKZ7+4mVoJtK3BOcU89mA8YZj/D9 RpWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=eAXS4IU63Nkqenx5sPfnXZobdCoP4hjdtZAOQDOa3yk=; b=GepXk6j+ktIp+O+REU2w1+4M4B60Mdnps+4nraudmCJLKc/zaUMrkCHL9lVKb6lGUa KQdt+kyChW9AuurqB+wSJGl04AUjjyaW4ykrmcnyUz7lZD16Wv+jxlhuNZZ1NT+rtn0C dDM/XOZ5IL+qYWSXIHga+VB+6JRYJSz7nnKycdbOKxYAWMUgLBXRjOMEvxI/19Zo0Zai QyE+UhLTQWZZIIZD8D8Zgr91gDWHOTlZUrs+wCOGrs6RTNqrg7apgaNYTxOfm3q2fBL7 wgGtPonMcEoboFnM+fMFmHyC+jdWb8pVcHyCzMPFdlLB/t4jtPzxWfXzVY3bCl0ZJ+/o /KGQ== 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 21-20020a631355000000b0046fabcda4easi5219403pgt.555.2022.11.12.08.03.26; Sat, 12 Nov 2022 08:03:39 -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 S235056AbiKLPkq convert rfc822-to-8bit (ORCPT + 90 others); Sat, 12 Nov 2022 10:40:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231404AbiKLPkp (ORCPT ); Sat, 12 Nov 2022 10:40:45 -0500 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E65B1ADAC; Sat, 12 Nov 2022 07:40:44 -0800 (PST) Received: by mail-pg1-f172.google.com with SMTP id 136so6687276pga.1; Sat, 12 Nov 2022 07:40:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JFmEovQuih3sC0ACkx1NqUHQ6cWP4h8cIyeW3MWuhGY=; b=GziSfrdP4WDbfkR4yrd9a3/FbqVd11+6faQmdncSQvQsGWMoa+Gehd2LJTPNbpF6/d KqC/qR1ELHj06ue5Vgd2i3z1siVAwAX0gWwWOFP2CkccpvpzwnnW76vyW9A0o/TDKJi5 Dvun6PfBq9lN66ePWLM64NsZnXVKevEmGNb8DynGs4BqfnWrIoA/Jhjam6k35GbqdN79 gSwp2nncIzbQggLsPgzj2CixrWUiRyi8pPblkU8GhEtVK9rae8H25MtgmlMyznrcvuaf Do6dD/T7BNUXtsaMwKHQVDxXc10lHLwljWQQBlDkOU6bAsUzexCV+fAFFW8QRqR9Pd7T 5Z7g== X-Gm-Message-State: ANoB5pmTRQHPaZYueJxtKJJ/AyoDpe7C9yDyqkcW1rmQyrZr5ATcVZDA THSWn0yzo1v2c60llBxU+5orbLwkZYtxZ3b79W0fKt9VqLA= X-Received: by 2002:a63:4e53:0:b0:473:f7fb:d2c7 with SMTP id o19-20020a634e53000000b00473f7fbd2c7mr5730598pgl.535.1668267643484; Sat, 12 Nov 2022 07:40:43 -0800 (PST) MIME-Version: 1.0 References: <20221104171604.24052-4-mailhol.vincent@wanadoo.fr> In-Reply-To: From: Vincent MAILHOL Date: Sun, 13 Nov 2022 00:40:31 +0900 Message-ID: Subject: Re: [PATCH v2 3/3] can: etas_es58x: report the firmware version through ethtool To: Greg Kroah-Hartman Cc: Alan Stern , linux-can@vger.kernel.org, Marc Kleine-Budde , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,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 Mon. 7 nov. 2022 at 01:18, Greg Kroah-Hartman wrote: > On Sun, Nov 06, 2022 at 11:44:52PM +0900, Vincent MAILHOL wrote: > > On Sun. 6 Nov. 2022 à 23:22, Greg Kroah-Hartman wrote: > > > On Sun, Nov 06, 2022 at 09:47:05PM +0900, Vincent MAILHOL wrote: > > > > On Sun. 6 Nov. 2022 at 20:25, Greg Kroah-Hartman wrote: > > > > 1/ Can I still export and use usb_cache_string()? In other terms, does > > > > the first patch of this series still apply? This looks like the most > > > > convenient function to retrieve that custom string to me. > > > > > > Everyone seems to just use the usb_string() function, will that not work > > > for you? > > > > It is just that I would have to write two or three lines of code less. > > Odd, should it be used instead where others are calling usb_string()? > > > But if you prefer I can use usb_string(), no problem on that. > > Try it both ways. If it's easier with usb_cache_string(), then we can > export it. It's just odd that it hasn't been exported yet. I tried both. Not counting the line breaks, the empty lines and the comments, the usb_string() version needs 6 more lines. Not a huge difference but the usb_cache_string() remains easier (at least in my eyes). For reference, here is the diff before and after using usb_cache_string(): diff --git a/drivers/net/can/usb/etas_es58x/es58x_sysfs.c b/drivers/net/can/usb/etas_es58x/es58x_sysfs.c index 4ff0332f6f50..c1d220d0d35f 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_sysfs.c +++ b/drivers/net/can/usb/etas_es58x/es58x_sysfs.c @@ -178,17 +178,10 @@ void es58x_create_file(struct device *dev) { struct es58x_device *es58x_dev = dev_get_drvdata(dev); char *prod_info; - int ret; - prod_info = kmalloc(ES58X_PROD_INFO_SIZE, GFP_KERNEL); - if (!prod_info) - return; - - ret = usb_string(es58x_dev->udev, ES58X_PROD_INFO_IDX, - prod_info, ES58X_PROD_INFO_SIZE); - if (ret < 0) { + prod_info = usb_cache_string(es58x_dev->udev, ES58X_PROD_INFO_IDX); + if (!prod_info) { dev_warn(dev, "could not retrieve the product info string\n"); - kfree(prod_info); return; } diff --git a/drivers/net/can/usb/etas_es58x/es58x_sysfs.h b/drivers/net/can/usb/etas_es58x/es58x_sysfs.h index 62347ffa0214..a204aa5344a8 100644 --- a/drivers/net/can/usb/etas_es58x/es58x_sysfs.h +++ b/drivers/net/can/usb/etas_es58x/es58x_sysfs.h @@ -14,13 +14,6 @@ /* USB descriptor index containing the product information string. */ #define ES58X_PROD_INFO_IDX 6 -/* Maximum size for the USB information custom string. USB strings are - * at most 127 characters and es58x devices only use ASCII (i.e. one - * byte). Also, empirical observations show a maximum length of 83 - * bytes for the product information. - */ -#define ES58X_PROD_INFO_SIZE (127 + 1) - void es58x_create_file(struct device *dev); void es58x_remove_file(struct device *dev);