Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1462762iog; Tue, 14 Jun 2022 06:37:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzd4dFiNsae0ZZ1ac3NpDV6NLs75TpmbkDczox7MGBQMvItDvQ8LQXr3Meuax+rq53INUj9 X-Received: by 2002:a17:902:f815:b0:163:c524:e475 with SMTP id ix21-20020a170902f81500b00163c524e475mr4583736plb.37.1655213869200; Tue, 14 Jun 2022 06:37:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655213869; cv=none; d=google.com; s=arc-20160816; b=pdEjZIZrfxSmAWWxm4/aQ6CzznbuKtp4JIv4FfIRW+0ZQfz0JCJLmBQoehQANU0m0x LW0RiBzXvyWxWZTESTpLFdYWNUZycOqbG8pOfc78702pIHMessqNh33npT8Zh68MdJFV 54MLeJwVQKkA2wmD7K5c4duy8YquMKvUk5+gbYxeHiZ17NKhXMT/6o6L89Ku3N5tG8Ls 9khOmUJHlLhbMEXcnXGT5U+7A107WOpq/JMV9CS0u+4ReZzDI004ViOKrKXXVBS1l3Jo KoOAURxdMAPsOrh05ZQyvDGmUMZx7V1v0O4Vv0kv3Tbq7XKm5LHcML2g2dkLNyP5gjgh VgjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=R7Zmyhhovdg7jA4sbkGr15373g5fZzWXwn/PzaeWDng=; b=VwjJ2EURVai2uOxceQD5fUQzIZW2Pe0POu0TvV74nLQ+ZWwZUaf5djhvb7OeVjPI9j ep+PtzxVQyBw0Iw02q7rwnF66QgwxBuGJId7RU07ER3oMWWPntsGqsh6ZLkEE05W1Vra XRBUZgm5R74jvh9D9EStm3LNC+BKvUaRbUPOJQq/JL26NcDGKNxdoAvauF0QU2NjLmk8 5LG//hFT52quq3DFzTQLSe5k6iBhTESiYwBIsSeEUcWcV1/2mhQzS2jwiURiWw1ddV0q hnBQXLQw6YTtRMYKC6TXsx8dqNFMKVAQZ/8o9TgF/Cxa2jZCu3EfcQn2uex4o8QyfprY x+Ig== 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 linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v22-20020a636116000000b00408b1d60fe3si1082705pgb.320.2022.06.14.06.37.35; Tue, 14 Jun 2022 06:37:49 -0700 (PDT) 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; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=oyKoCpe6; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356555AbiFNM3M (ORCPT + 99 others); Tue, 14 Jun 2022 08:29:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243537AbiFNM2i (ORCPT ); Tue, 14 Jun 2022 08:28:38 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49CF03E0F2 for ; Tue, 14 Jun 2022 05:28:33 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id eo8so3179777edb.0 for ; Tue, 14 Jun 2022 05:28:33 -0700 (PDT) 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:content-transfer-encoding; bh=R7Zmyhhovdg7jA4sbkGr15373g5fZzWXwn/PzaeWDng=; b=oyKoCpe6Et5htQdcXy2fQRoA8XFpBI1ozrSVuX76KcLzpkF/2kSXD3WdLcabVUE7eK wz/QavsFVQPt0Z6e7JZF7qAuYQsULzhq2vmd84BnIiU215InQijl3uzf/UOXyQu3Sxbd qq2G8TGd56pKCf91XdJ6RN+wQRHq+oxfb60To= 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:content-transfer-encoding; bh=R7Zmyhhovdg7jA4sbkGr15373g5fZzWXwn/PzaeWDng=; b=PUFZwpLgv/3HClv1jTZygfecQj70203b/UaRzYo0+jgL735C/qSZlhSa5KmfOFtZSn PJ+RxXo5xRa0v/WfebwfQLy6slnXmLtu9w7QjWrEJsEyjUUs80vw8wPph+296Dp6v2YV 6JgPi2fwuJQXcuvEdReTbb3/Huc9fORayC6gg2pA0zjwJPkDmpwjNQrZ/EOhquRvUO8c 7041sMhtAUqKFWKPZKbJlsYcw36DS3iJT/EVdYl52mSDHg8qVIeIMAJHOAf8DC9/7kAe mIVYNckShVfX1scZdvgZ5CMP+Y1BbOyyxWn4vEcRryhizwTb8CMotzCTsaZBd1j0BYXw JYcQ== X-Gm-Message-State: AJIora+/bdTOqWN5XaYPjZoVGQ7oLv6XYEwqbjRxVWnPdlSdGigxg4LB Hpoo25chUeDon1x0Up9aQ47GJ+iqqEK0Ag== 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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) -- 2.32.0