Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2732417pxb; Tue, 9 Mar 2021 09:29:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJywcAdYAScxfc9ykJXuTw4RimiH2pzUQv0B/CbRucMvaoTLNXxjE/c+bEPEfvVLNpYk8SWY X-Received: by 2002:a5d:6602:: with SMTP id n2mr29910578wru.262.1615310972461; Tue, 09 Mar 2021 09:29:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615310972; cv=none; d=google.com; s=arc-20160816; b=gmp/3kC/zyx8hTHMyyPP0OPMwXoy/7/dI+p6okNOe0VHrr+GD5rDujwrue5Y6iYDNi jWsGW2Ai1eAvZWxEpvImo7cjAZswNBrIetWjsFmjIrpKvECogpvH8A81Adou+uwCHTNC dNQM1OLfoddjNLa3Pybpw8XlrA1WTnfoccPSXiOQ860xpMMp0E3lErD4FvL9Kw0XG7AT 65a6JqYYH+UCnuGpb+Rjnbu3PBwj3dQm1PsUcy46thOSx0/ag8aRXYr14GG5iDwZGM7n BclF1dE3OU7MNvS8fMPL+PjCPX/fTbMyRPkrtoxl+wD139aboZ+iUCsbyVtVQyAkqts4 4YVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=E0L24YzwE+RwXtp71i5Fz7XoP/XCEU0C3pgyRyLsjJE=; b=oFod5OtsmGE9Y1gTPAuCp8D6Wni+9wIoO1iXnxWCLIfTzZaGLRAO7On4eeGw/tRgWz 7f678qICYsx79SyqQrSz09LoZlohr+/2p/bd+EEfe859WEqkzRiIi1JG+sEsBKjGywYU fE2+mFrMNllw8X6dXuD3u/iELBqEIWk5R4LipKXrNcaC/fCTb1Y4QAfcMjiJnmebZ4zq MFIdOWdQenXotVVNQ2wfz86znw5uV4B1ztAEbnygcLa7DqVNsUBSVZX931Quo1RKuJv8 ZCJvut23PS/Ke6yQYnnXWS/ysaAc9aDIWpPUep6xXIaUJlgltVCcR23sLwloau2oAdvD B8yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tS2mj4X1; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si3626177ejr.694.2021.03.09.09.29.09; Tue, 09 Mar 2021 09:29:32 -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=@gmail.com header.s=20161025 header.b=tS2mj4X1; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231700AbhCIR2N (ORCPT + 99 others); Tue, 9 Mar 2021 12:28:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231639AbhCIR1o (ORCPT ); Tue, 9 Mar 2021 12:27:44 -0500 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 494DBC06174A; Tue, 9 Mar 2021 09:27:44 -0800 (PST) Received: by mail-lf1-x133.google.com with SMTP id k9so28337555lfo.12; Tue, 09 Mar 2021 09:27:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=E0L24YzwE+RwXtp71i5Fz7XoP/XCEU0C3pgyRyLsjJE=; b=tS2mj4X1C5n+8Mg4kcTRAsr1vZpnFfjT+mOLqUUPBoxeto0tLvrHSfqPlbjpe5YqOZ Gk7Cnlfh3h3ueQA5pntdcDXHvHEU/6Y2M7zwanh7FB9fVoGnW2J6/IzoLJK33hTbgz9L ZjCXvk/36ceJyirXGmduwixPo2uKV9hpSwNusiflQREJAgMxIcsDDqUYUUSyCbslFJ7m d8zWFw3Y+qM5EmAJdKJRdqr2mqlUud1joRNMC3igRS3V2nlGDizKIzRyR3rWjVnCi1SX Dcy3xrkOoGxrk1/4sd+NfF2GyNJHONZavEHDbaVcOBU3GP549qdVn/fPci1NQ7p7IwkG KZTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=E0L24YzwE+RwXtp71i5Fz7XoP/XCEU0C3pgyRyLsjJE=; b=ZXRsa9aNWKjnJ1iRsh98N7+Ifh1Juzf1IABcabItTIjq8unV9gkaGzoe5W7mIQl53D i9jr3JWvH6J3JckCBfs1fqTgm0Ud21qQ6WdK9HbdupQequFQkw88xVS322lBr/VGKiPu n+tUL60FxiKx9nn+PY9JexTANsG0++3RmImOrEgE030Ej9Rl88SH3B/uKymBos3uq2O7 L3or1+TetPpv2CAhEpRacva2aPUE4MAJzgC+rq43GDVgY/mkdQBLEgYjOdXLD3vfW3Py G6unZIRoZ/C7WZAG0fFKnxATbW5BIkmgIkebxzV5h7PBuHWw5dJYrEyPOvXq9DZnrIRI H0Ig== X-Gm-Message-State: AOAM533/4wP83i4OojGIkp6aHi1OkqSW33zoYjhffFb67Eu1z4LNYTft n3PPaRYeIIyDZuCJ1KNHFMsXHqdgD0LmOg== X-Received: by 2002:a05:6512:51c:: with SMTP id o28mr19019898lfb.237.1615310862860; Tue, 09 Mar 2021 09:27:42 -0800 (PST) Received: from [192.168.16.194] (h-4-68-234.A785.priv.bahnhof.se. [155.4.68.234]) by smtp.googlemail.com with ESMTPSA id m6sm2026164lfb.150.2021.03.09.09.27.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Mar 2021 09:27:42 -0800 (PST) Subject: Re: [RESEND v12] can: usb: etas_es58X: add support for ETAS ES58X CAN USB interfaces To: Vincent Mailhol Cc: Arunachalam Santhanam , linux-kernel@vger.kernel.org, Marc Kleine-Budde , linux-can@vger.kernel.org References: <20210309120946.1640-1-mailhol.vincent@wanadoo.fr> <20210309120946.1640-2-mailhol.vincent@wanadoo.fr> From: Jimmy Assarsson Message-ID: <45c0b0cc-bfd6-5180-7ad9-51eebc9de3c9@gmail.com> Date: Tue, 9 Mar 2021 18:27:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.3 MIME-Version: 1.0 In-Reply-To: <20210309120946.1640-2-mailhol.vincent@wanadoo.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Vincent, On 2021-03-09 13:09, Vincent Mailhol wrote: > This driver supports the ES581.4, ES582.1 and ES584.1 interfaces from > ETAS GmbH (https://www.etas.com/en/products/es58x.php). ... > diff --git a/drivers/net/can/usb/etas_es58x/es58x_core.c b/drivers/net/can/usb/etas_es58x/es58x_core.c > new file mode 100644 > index 000000000000..31f907a7b75f > --- /dev/null > +++ b/drivers/net/can/usb/etas_es58x/es58x_core.c ... > +/** > + * es58x_add_skb_idx() - Increment an index of the loopback FIFO. > + * @priv: ES58X private parameters related to the network device. > + * @idx: address of the index to be incremented. > + * @a: the increment. Must be positive and less or equal to > + * @priv->can.echo_skb_max. > + * > + * Do a modulus addition: set *@idx to (*@idx + @a) % > + * @priv->can.echo_skb_max. > + * > + * Rationale: the modulus operator % takes a decent amount of CPU > + * cycles (c.f. other division functions such as > + * include/linux/math64.h:iter_div_u64_rem()). > + */ > +static __always_inline void es58x_add_skb_idx(struct es58x_priv *priv, > + u16 *idx, u16 a) Never used? ... > +/** > + * es58x_get_product_info() - Get the product information and print them. > + * @es58x_dev: ES58X device. > + * > + * Do a synchronous call to get the product information. > + * > + * Return: zero on success, errno when any error occurs. > + */ > +static int es58x_get_product_info(struct es58x_device *es58x_dev) > +{ > + struct usb_device *udev = es58x_dev->udev; > + const int es58x_prod_info_idx = 6; > + /* Empirical tests show a prod_info length of maximum 83, > + * below should be more than enough. > + */ > + const size_t prod_info_len = 127; > + char *prod_info; > + int ret; > + > + prod_info = kmalloc(prod_info_len, GFP_KERNEL); > + if (!prod_info) > + return -ENOMEM; > + > + ret = usb_string(udev, es58x_prod_info_idx, prod_info, prod_info_len); > + if (ret < 0) { > + dev_err(es58x_dev->dev, > + "%s: Could not read the product info: %pe\n", > + __func__, ERR_PTR(ret)); Missing free > + return ret; > + } else if (ret >= prod_info_len - 1) { > + dev_warn(es58x_dev->dev, > + "%s: Buffer is too small, result might be truncated\n", > + __func__); > + } > + dev_info(es58x_dev->dev, "Product info: %s\n", prod_info); > + kfree(prod_info); > + > + return 0; > +} Regards, jimmy