From patchwork Tue Jun 14 12:28:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2069 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 4F67A3F03E for ; Tue, 14 Jun 2022 14:28:33 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id m5-20020a056402430500b004319d8ba8afsf6105227edc.5 for ; Tue, 14 Jun 2022 05:28:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1655209713; cv=pass; d=google.com; s=arc-20160816; b=zPX9VD/qSIFCys5bbYK1Rcczu4rnd9Jdsb2fCZ3I/UtGXSIIfDBQtVger3Xnu5ZLZ8 QQEu1xz6gVy9OFf9Z9jlVm7HrU8KllVtKLPfflatKZzyDb5py5X00WOvuhb69oiiacDT napvRB9AuwtfiTwwzp7WXZ8GsWZ2Zenpy2jTlEE6ifIxcbI4lto5t7IE7cpdtxBQsmZY FCUaXukf/i5AWYeCZGvTtzv4c9vvqySYM5fkjJZe2a3mXOW0EDtifvpt8krLTbv/gQgh bcH618VA92pFQBuWQ4Me+gbaH9rXSpiLW+XeD/U8pG9cImN/cNcxsk1TY8S6s6Kek9Sk SuMg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=zltaCgYn0pFDvvKg9qXSKa2p0qb7ICqlNMJT5AC9b+k=; b=Atrm6YyjhQwgvmnWPYUCxP/1mDq4QV38uUCc/nkys4fxVc9LW7wU5oUzW0sdLBI82F QtpePwEU9MgWTfdM5LT07cuA46ccytEMwRQzBI3jTkWEnamIxb2fSUeDCBpWbVs05tTn CIteZ/IqksQa+iUbDuQ5CXLerZ4jDra9rkNPX0k5Sx0VIcKRx5oV2jDZjKBdKqi8Q1kN Y1C9VPkGB883xQYfsmBPzPfw2hXpOwhlJBw4Wh0vJD0fPtEkCp7v70m4RArKwAKyC/95 onZMg/Nvyn/REQxhawYN2lSy9nSeelCIo8ezgnXVJwcbEOgiX1wzMTS3OQV8ShUz16uz WmVA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=oyKoCpe6; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=zltaCgYn0pFDvvKg9qXSKa2p0qb7ICqlNMJT5AC9b+k=; b=n7fmRuGGPciv+z9pl6e5Eni3UXvNRkAnyHgPYSLjPzJ/RpviI0zevd7W+KMSKj18ZR E+DSDxIXjk666xDLbT/ZItiW2rd/BMva7Q3iY8BvyDFvtHEPt1EWoqNcw3g+WL1RJGCq mY3JDCHuNtDSp6C140z7BryUrtsTHwOiRkHIY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=zltaCgYn0pFDvvKg9qXSKa2p0qb7ICqlNMJT5AC9b+k=; b=Y8KDIUPjCpnOl19IxBQx0COQEDroMFXiS7w11PR92sSw20tdzuAXbhFDcQyO8SBZKr qcZWQbWvEFMQHi90IlcUcMaG2Apd+XfQzqnCUlaAT74NTCr13W9/YhcHJp1QeCipkYo5 XwTTnyV12BXQOFRII4GCc5d/r+YqSJKMF4o6fxEPiSduO+hseqjn/zBiCcGhyv94Xm5t UNTzL/plM71G59Q8XvjIJgQuvHrzdzkil4SjJRUTG6rUpzp4XZvq3U37p7EtKEKSZMw4 1/rxQr2K7IUQggZ0hblvzHzmjPk8Tteaah+4qffcTGgMEY0rD9ucgncFGiHtXYsSJIHz t1hQ== X-Gm-Message-State: AOAM532j8SOKj/f88V6/LYrx+Ubwl382qsn+Typ2WGnE0GR8HmEb587G KVjpB1hpbZiaEgEZiyk4CzF3uIJP X-Google-Smtp-Source: AGRyM1tJqixu9UrN+h7tWjzqNLr9xudLKmO7Dr/dO+IcShtLnVcUFa2euV3XoFeaOvDvsEQUpSwMZw== X-Received: by 2002:a17:907:6287:b0:6e1:6ac:c769 with SMTP id nd7-20020a170907628700b006e106acc769mr4091059ejc.388.1655209712988; Tue, 14 Jun 2022 05:28:32 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:5ac1:b0:6ff:ab8:e8f with SMTP id x1-20020a1709065ac100b006ff0ab80e8fls991810ejs.6.gmail; Tue, 14 Jun 2022 05:28:32 -0700 (PDT) X-Received: by 2002:a17:907:7da2:b0:711:f36e:b855 with SMTP id oz34-20020a1709077da200b00711f36eb855mr4216190ejc.308.1655209711815; Tue, 14 Jun 2022 05:28:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655209711; cv=none; d=google.com; s=arc-20160816; b=G1m5yMyvlrz1Vw1ipoMJyFM0aGhDbh8pSFhwkVphNW53qNmVUdCxI3M0AkWQ0dIt69 S+3GnUs4Brfbt6iiO5ERsHQP095WbvJDwcg8O6G/3FbNXia9plCA2tymWYDECCVXWCMJ 65kr4gCOR7mZ0OIx/tE07EBt6FlVBoHQdNqzJwqMvqROphYndrZyx1sO6oDnT84frgtl 7NNcedrHN3qLz/B2wr80TPUq+H831Z/XqhqruOplmmwm+ah6q2zXaHW2+QlS3oPyBw6R HjSck09jH7H34X4zNAJq3xvdEv+WTiZkmdbPRRiNG4U/7LqZ6ScO1EGgdIFAM/er+dph oUHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=R7Zmyhhovdg7jA4sbkGr15373g5fZzWXwn/PzaeWDng=; b=W4SuqiqwxADmyFLaL9ubj2QBclmC21O2W2EI0fLDBTLI4AWFq5SCd4Wg/8CyPW2f8f d3HHsXDRA1j/b7jR2y6BKM2YgPi/WjseUPEKocUX35ZBmcYC2SvZuZcY18JHBM83z+OX 1O9mHCl51s3GV7eJXptk1cBp4raIeR9ujJxHvFEvFNLI4iKRQf3yyMu3v9u8QzuWy0CN K8D8JmCZK+pyyhG5WHvkMbyPKjLATQMSML3cK+0Q4BRMuUCiCpZpjv4b/2wZCeuvHQ6H q79VnUqD0llElrzIgpaVXUMcKV6abctV631Wk3fY5HdToZXinV8Rgk/Teb8ShEO5PGiB opoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=oyKoCpe6; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id w12-20020a056402128c00b0042e0057500esor4109829edv.48.2022.06.14.05.28.31 for (Google Transport Security); Tue, 14 Jun 2022 05:28:31 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:25c3:b0:434:dfbd:913e with SMTP id x3-20020a05640225c300b00434dfbd913emr5808884edb.27.1655209711597; Tue, 14 Jun 2022 05:28:31 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id z22-20020a17090655d600b006f3ef214e2csm5087043ejp.146.2022.06.14.05.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 05:28:31 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: Amarula patchwork , Oliver Hartkopp , michael@amarulasolutions.com, Dario Binacchi , Marc Kleine-Budde , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Vincent Mailhol , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH v4 04/12] can: netlink: dump bitrate 0 if can_priv::bittiming.bitrate is -1U Date: Tue, 14 Jun 2022 14:28:13 +0200 Message-Id: <20220614122821.3646071-5-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220614122821.3646071-1-dario.binacchi@amarulasolutions.com> References: <20220614122821.3646071-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=oyKoCpe6; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Upcoming changes on slcan driver will require you to specify a bitrate of value -1 to prevent the open_candev() from failing but at the same time highlighting that it is a fake value. In this case the command `ip --details -s -s link show' would print 4294967295 as the bitrate value. The patch change this value in 0. Suggested-by: Marc Kleine-Budde Signed-off-by: Dario Binacchi --- Changes in v4: - Move the patch in front of the patch "[v3,04/13] can: slcan: use CAN network device driver API". - Add the CAN_BITRATE_UNSET (0) and CAN_BITRATE_UNKNOWN (-1U) macros. - Simplify the bitrate check to dump it. - Update the commit description. drivers/net/can/dev/netlink.c | 3 ++- include/linux/can/bittiming.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c index 7633d98e3912..5427712fcf80 100644 --- a/drivers/net/can/dev/netlink.c +++ b/drivers/net/can/dev/netlink.c @@ -509,7 +509,8 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev) if (priv->do_get_state) priv->do_get_state(dev, &state); - if ((priv->bittiming.bitrate && + if ((priv->bittiming.bitrate != CAN_BITRATE_UNSET && + priv->bittiming.bitrate != CAN_BITRATE_UNKNOWN && nla_put(skb, IFLA_CAN_BITTIMING, sizeof(priv->bittiming), &priv->bittiming)) || diff --git a/include/linux/can/bittiming.h b/include/linux/can/bittiming.h index 7ae21c0f7f23..ef0a77173e3c 100644 --- a/include/linux/can/bittiming.h +++ b/include/linux/can/bittiming.h @@ -11,6 +11,8 @@ #define CAN_SYNC_SEG 1 +#define CAN_BITRATE_UNSET 0 +#define CAN_BITRATE_UNKNOWN (-1U) #define CAN_CTRLMODE_TDC_MASK \ (CAN_CTRLMODE_TDC_AUTO | CAN_CTRLMODE_TDC_MANUAL)