From patchwork Sun Jun 12 21:39:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2052 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 114753F1DD for ; Sun, 12 Jun 2022 23:39:59 +0200 (CEST) Received: by mail-ed1-f69.google.com with SMTP id y13-20020a056402358d00b0042dfb820070sf2958430edc.6 for ; Sun, 12 Jun 2022 14:39:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1655069999; cv=pass; d=google.com; s=arc-20160816; b=e1xWXhEZAxdaiyBl/i/b+aqPi+bvrXYGb/p4MMqruz+nqnQWl+T+9OgvIQfai3lXLu OxAUlUfUi4cd96tBvZKQ/kG01vrkU26YyDF7JjFEmh3gt8/6GUs5CE6FWWC8XSz3UfYS wWZOur+AQSG7JnsLQ1WFa+Xr7+7/VlG5YHX10hXP7ym2w9XY/Ji0jszD/HbqYBqblz2L PgGDqEtoxS0ZXhgHwW+/awq9zsPmMJCT4OQurdXF9go7Lhrx3f2UWvzhiHSlBj9cxe/0 zNBJl2oimsqh8vol8IhQoNMJvCCt0XRK7Cg6hgI25I4KNA6z+hx4oBMum/bYhVL7Hl1+ CkAQ== 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=4pFUQVeSzv4I39s6qZHjrQ2J1fyJgKsC98s6f7ej8R8=; b=N0XfR3XqfOiTIDdiRE4PKviirsOxRVvske2K8r8pp9xQ7qNPVKSmy1/bWoveFoVfN5 mAXMNCl9xab0mR34h7hwKj5mk30seyyUQ637E/oXy263OwMwH41Uw0ylLw1s4EwpTpE1 YaL/76+EE1Rn4NySAjZyncRz5TS7td8iFGhaPwG9iZOEXMJ0wbBLHXqeeFQif0ik5Eg2 kWAUpM2EWZbM4lAyyh2iOgemGqpXmT+0be8A2TQC8/7zLEc3BwQ1j+W9ZTV7uSZk7Jry FuGDwPCmWUv94r/THFHM2Z9TZXm1d3DiOBj1MZONWBW+o8VvZabWNc2TtD7ymtTFtbd1 Xudw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=d9VwXs1I; 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=4pFUQVeSzv4I39s6qZHjrQ2J1fyJgKsC98s6f7ej8R8=; b=HGEK7X80d8ygqi8xa1m/rMCPlE9Xfw6cTWIF2lkggIV+4/TX2jQyVDKn56MIj4S9kO UWnHVi5FLMu0rRZAnVHH9rp5dpYsocheXijOB8XtuaJL1+UwkJRv1u++je2Lf6bdHzT+ nJ9At1wbsmW0ICRkLNtL14lzKoZ8jw15KOOxs= 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=4pFUQVeSzv4I39s6qZHjrQ2J1fyJgKsC98s6f7ej8R8=; b=CfakY+zS26XnR+7SOswRMp+Yv9IlW+76ZgDFyMssabvpy+2aikRSO+LF/f74YOitEw DbB8uw+oI40pKQVPdp31hfpC6tdXIsTxyxAOHxPLoJ7YbauTq0/0gcrGZpM0F3QoC2KF sKSOAMiHRmO31nbFsj78Y2JN4yR5cVimR5sMLjteRNz/583PRWTGygLk9Jsmm0TakTGs J2EcRCnCAhdwYKcJ+xJwu2gjTMNyZtjbAloVg4iJvFpm1gZr/FTw6xemcuV4d05SH1rK svYPHFMEBoCJ1SZw08zOphwvXnMUr3W3vioz0CA/eppurOwmfrfgqFV47Ce65Gs1LpYF JyLw== X-Gm-Message-State: AOAM531IbjePaf4+eBwMKFb45kTKfkVqHnLgN9iMbsDspl39cLJ8ZWk5 zs3JCCnNCPQwGO4TBoqf9OUdhYvq X-Google-Smtp-Source: ABdhPJw/n6yLTl+hB3OOI7cWllnKW1CpD5xXjNw7h7OQHsJZp3WqVdMj9FhuRccCSKLbhgvccR9K3Q== X-Received: by 2002:a05:6402:4408:b0:42d:dc8d:a081 with SMTP id y8-20020a056402440800b0042ddc8da081mr62399883eda.69.1655069998954; Sun, 12 Jun 2022 14:39:58 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:6402:424b:b0:433:426d:7e15 with SMTP id g11-20020a056402424b00b00433426d7e15ls1835703edb.0.gmail; Sun, 12 Jun 2022 14:39:58 -0700 (PDT) X-Received: by 2002:a05:6402:c8b:b0:42f:ac38:9c07 with SMTP id cm11-20020a0564020c8b00b0042fac389c07mr53802572edb.292.1655069997901; Sun, 12 Jun 2022 14:39:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655069997; cv=none; d=google.com; s=arc-20160816; b=eWPSlv1D3OjlG7zhEps1tX+gz3M1wSCBsODeOFCHq0+Q/6oA97Bwyl2FVZbQ8tJcSP ttbqT2UxzkRQSPa1kSImfc8uU7wy5m+zLjxEVoNElyAP+5Z3Ume6wIxzr3hpWUSSC4Sv ajsak2BmX97G6bxHCOS/gjwlxH4m8BJRpNVHVO44RJY4FiAmn/dFY4owmouqCISAlE8q DV7hxEEpO1sN1GXpl5fJm3lxSNw6VIhH8H7p5aknyY8/x1pEe0Vjv0RPLlyI2FxLUL2+ 7FOzmFN98hiTTuVVhRDz9axY3LglIFEJ90L57UEPE5exe9Jk5k/vzlqQudkQbRwzPdU1 7Tjw== 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=Hx0NO2HP0dNrW23jq3KzvYzEwbT+EuqW3kfxDZENRj0=; b=mBUJtyg43roMgRKRTjc2fVFomjKo/EjWVQOTZ4bkpWHLF5ZIIg4D74VJs8+xwePfR1 yvlBjIbPVfm542SrShR+QNSxVAAuPQDMANtQ0oIUKROlBUcDBXjmI9Mi7dzhRCYsQCIl bSN7nwavoGTulkrlrLGEvOW8onOOVUi3CX25nQy8wna9LZ3H/tVXRiWfx4fPrU+JhEIL IBuN4HcFyHFRTTQQJ4nAFvFRJcBFlqJLoUVW1OhMBsIQN6KVyoCdppMpLr5mevD2o6DD jY2TKQZgX6scuI3wdRLtwn34a1zAInv54RzvaVXtgM4AsPeGLPBVe3wba31nPRCyHtCA 1Qwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=d9VwXs1I; 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 g17-20020a1709064e5100b0070b273756c3sor1273955ejw.127.2022.06.12.14.39.57 for (Google Transport Security); Sun, 12 Jun 2022 14:39:57 -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:a17:906:7a57:b0:711:faf1:587d with SMTP id i23-20020a1709067a5700b00711faf1587dmr20191424ejo.581.1655069997739; Sun, 12 Jun 2022 14:39:57 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id u10-20020a1709061daa00b00711d546f8a8sm2909398ejh.139.2022.06.12.14.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jun 2022 14:39:57 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: michael@amarulasolutions.com, Amarula patchwork , Oliver Hartkopp , 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 v3 05/13] can: netlink: dump bitrate 0 if can_priv::bittiming.bitrate is -1U Date: Sun, 12 Jun 2022 23:39:19 +0200 Message-Id: <20220612213927.3004444-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220612213927.3004444-1-dario.binacchi@amarulasolutions.com> References: <20220612213927.3004444-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=d9VwXs1I; 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: , Adding Netlink support to the slcan driver made it necessary to set the bitrate to a fake value (-1U) to prevent open_candev() from failing. 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 --- (no changes since v1) drivers/net/can/dev/netlink.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/dev/netlink.c b/drivers/net/can/dev/netlink.c index 7633d98e3912..788a6752fcc7 100644 --- a/drivers/net/can/dev/netlink.c +++ b/drivers/net/can/dev/netlink.c @@ -505,11 +505,16 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev) struct can_ctrlmode cm = {.flags = priv->ctrlmode}; struct can_berr_counter bec = { }; enum can_state state = priv->state; + __u32 bitrate = priv->bittiming.bitrate; + int ret = 0; if (priv->do_get_state) priv->do_get_state(dev, &state); - if ((priv->bittiming.bitrate && + if (bitrate == -1U) + priv->bittiming.bitrate = 0; + + if ((bitrate && nla_put(skb, IFLA_CAN_BITTIMING, sizeof(priv->bittiming), &priv->bittiming)) || @@ -563,9 +568,10 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev) can_ctrlmode_ext_fill_info(skb, priv) ) - return -EMSGSIZE; + ret = -EMSGSIZE; - return 0; + priv->bittiming.bitrate = bitrate; + return ret; } static size_t can_get_xstats_size(const struct net_device *dev)