| Message ID | 20241029084525.2858224-4-dario.binacchi@amarulasolutions.com |
|---|---|
| State | New |
| Headers |
Return-Path:
<linux-amarula+bncBCQ4XFG47UFRBAWCQK4QMGQESBYDCQY@amarulasolutions.com>
X-Original-To: linux-amarula@patchwork.amarulasolutions.com
Delivered-To: linux-amarula@patchwork.amarulasolutions.com
Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com
[209.85.208.72])
by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 779883F360
for <linux-amarula@patchwork.amarulasolutions.com>;
Tue, 29 Oct 2024 09:46:59 +0100 (CET)
Received: by mail-ed1-f72.google.com with SMTP id
4fb4d7f45d1cf-5c938ae4152sf6584098a12.1
for <linux-amarula@patchwork.amarulasolutions.com>;
Tue, 29 Oct 2024 01:46:59 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1730191619; cv=pass;
d=google.com; s=arc-20240605;
b=lk3fVPtaHQz4jLSitkf08inwxrjbbPIl2r2wf3J2860RAw3lZZVM3QF/AZ+lfBVHtG
I68zqBuoF24BWl4upYrlcfWrReR/mNwxol9aoyWdzF8mn75I3Al6x9x4AdGmQwgLSlOB
z9tTY7O2EXR/wRpyI1lvwzz8CivdsGnlKiHbNXlaLEDHYk9Hjte/8tk+xOWV1/F/OIPc
B64Bk/dI/urE5oRu8/pxYJ9cEnaUDjQxswZ58DzyUy2zIsk8RoCRUZZ3WQqSqPBd79kA
EOzpygLIO6+vGC3/afiQCSEpx8zp/g8nglp3tjxxSFGb7YEiS/k2jbi68vmcdqqlUuZ+
Gkxg==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20240605;
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=C/TJUlXOJbY6IHwLqAROP3mVTyTGnaN79qm3nxTj4A0=;
fh=DHJWMnaJsuT7R+ifGUr+75DT5GO90G4xQvcSj0TMb+E=;
b=HGxX0fgvnEll0gxLotF1PA/kRU7rRaw4mA0pe7Lk/lu+S/lRQzHZ75RESbO4sUaY9d
BodSZlqasSBDXb1AaENTJN1NYanZDtN9m7F/8E/qTerCjBJoTyCAXAfG8Vg4H7X1ekij
hvSkDJCeryRRrv+Y71msznkFtrnbw2+0vCU3QWAa7PprvA0kr8Mr7rUQzp/fpCQ863DK
llV0IO5qVDmzzVS1RIYD5v5bKNhQZRvtJzIsQGETdlMcui6X+6d6xXEd+Y6Uz8K2d0dV
ZKA2ux/pPEAPrAb2cJUUe9tz9x9/dwhoFTAHyG539phMdx20xPQKEHrCwKG0Kr4XsQ7s
/siQ==;
darn=patchwork.amarulasolutions.com
ARC-Authentication-Results: i=2; mx.google.com;
dkim=pass header.i=@amarulasolutions.com header.s=google
header.b=JnV+Q3yh;
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;
dara=pass header.i=@amarulasolutions.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=amarulasolutions.com; s=google; t=1730191619; x=1730796419;
darn=patchwork.amarulasolutions.com;
h=list-unsubscribe:list-archive:list-help:list-post:list-id
:mailing-list:precedence:x-original-authentication-results
:x-original-sender:mime-version:references:in-reply-to:message-id
:date:subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to;
bh=C/TJUlXOJbY6IHwLqAROP3mVTyTGnaN79qm3nxTj4A0=;
b=UuU1z8CjEpBxl2q8vUuSXAs4/s/K46iQNfmKtuV74iS+wA+JE/kWBqv2vPKBHeE9j8
8WR7rjZJExFw5SD+rU7DeHIKgJAui3z3K7Yvo80HlXmbKfGyB3oxXPv4HiNP61HwpALG
SxhHDNUn8HyBqKbc7UUIItO8e6vm3N/zVe8fk=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1730191619; x=1730796419;
h=list-unsubscribe:list-archive:list-help:list-post
:x-spam-checked-in-group:list-id:mailing-list:precedence
:x-original-authentication-results:x-original-sender:mime-version
:references:in-reply-to:message-id:date:subject:cc:to:from
:x-beenthere:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to;
bh=C/TJUlXOJbY6IHwLqAROP3mVTyTGnaN79qm3nxTj4A0=;
b=Zm48ZyIhHVBHDn/Pf4L5GBJq8cXVSptwVZiCd4AY3u1HExM4nF5Dq6ywjSLbP/qJ6G
ZDkfp/xF1TGFqMfrks+vVCqLI2Ja5anVa8XfBhnKpYjzn18VJoWimOe5IuRHDVoqBT+3
NEin20v0joJdmR6yLqddzBst9Hf2YTRnMAT/NcwgX8zA5GWS8aS2+FkQe6r+hJ9pWHxJ
6EK1jkxql2X0BUITvmtStZIJNkdCPTRJ2scYb9ljDupAqJIiIDUOxRQkNxnzlS6vH802
MKTt1irZqvfybtKKN3w8nuBe0Iqg6nrxmU5yBG46nqYoo+KRvCaEvmsM6iBgO7syqRmu
bTGA==
X-Forwarded-Encrypted: i=2;
AJvYcCV5pfn8MvhmJXrwmBCnCGzQPq4QCzUoUuIo8xT5cLslr6eellZVieNqec75DMaDdvpkR0JY9AJ/7I9FjGEw@patchwork.amarulasolutions.com
X-Gm-Message-State: AOJu0Yy+od9ge775CKhlWqgVPLPg5qWy210ZWIQrElpwer54uF4BF69d
cNjOE7OFLeyazuKoAodML2VDXFvbTpCLcU31p2HXMSIQKwxcyo2bomZe7Yz/WByInw==
X-Google-Smtp-Source:
AGHT+IGW2L1GyMwwrL5/Fd1IcGqy9EjiFsTM86KwE2qqZS9C9we3pvS9Q10xpVAKwnGgSZDmoNbYCQ==
X-Received: by 2002:a05:6402:520f:b0:5c8:a2b8:cab3 with SMTP id
4fb4d7f45d1cf-5cd28fffc2dmr1168287a12.4.1730191619062;
Tue, 29 Oct 2024 01:46:59 -0700 (PDT)
X-BeenThere: linux-amarula@amarulasolutions.com
Received: by 2002:a05:6402:549:b0:5cb:b66f:8fd with SMTP id
4fb4d7f45d1cf-5cbb66f0b48ls75263a12.1.-pod-prod-00-eu; Tue, 29 Oct 2024
01:46:57 -0700 (PDT)
X-Received: by 2002:a17:907:2dab:b0:a9a:7b3d:705 with SMTP id
a640c23a62f3a-a9e2b01618bmr111167166b.30.1730191617616;
Tue, 29 Oct 2024 01:46:57 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1730191617; cv=none;
d=google.com; s=arc-20240605;
b=Qoi9XARc6dsK6I5fDmBftqeLoeFDx36M6mVrU285BdZEtZEch/ciY+UWH+R2lBevHq
XDIK3ZbCDyM1zkbxmrPxEjCG9Kom5Prnd5OxrmC2HSCQlXKMJGW5DbZ9S4ZuRZ2yWh9z
Nq/dW3PVDGCF5SsDty01FO/Sl1NptJPFXzVlLoEtbrbbI1y+YWGGLK30U3GDuhLcQktq
4g/XjhLfqRK+UR5WrilI+xtfG7e6ueKapqYnOdflVVkCFoZ5roC5YT4o+bBCmTgNGeZF
CqFJbxJaKUSsGR+kHc7X3W/IPxxWXViyKxTTcJXDEX9ictiacvCKdvnhDB7utrsNlgZ6
I2yg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;
s=arc-20240605;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:dkim-signature;
bh=qZlCPcUtK7nW0/9iHLjxsFqERMJTARHO2kYU3JNPHEY=;
fh=ljoFiwPup6gC9YG4NMWOEWNdgUd1CKjWIIwpUvYy39c=;
b=gSuIatyBiRZZuu41E896TgNl0L6QZlcpYbIotdCIMOyMCQIyA7QJkwTHqOqtKePqT6
DQ+b1nMT1WsQj1ojZEnMaF+ULj6JRKzPzh/HMbFh+v/4Oi4bf41TswqG1lDFCUGhMSVw
7bfJBbjS4wzPCoqJ8mJr3DOOk2fJ62xr1yX7SY/6Te0iB8JkL4dQtknI6M3tUK8PWgdi
a6geCAbzULEkweeoV7mApZepGgqlqbzdDsoZdHKterrZWC5CIGnmuxFvschsteSn9ebJ
LO1CnsZn/EhwC46mBQfj5BQPXZ9XKZ05gSDsrV2OfFQPlomdPedl4rBS9/5Ogf/pjjAV
TzVA==;
dara=google.com
ARC-Authentication-Results: i=1; mx.google.com;
dkim=pass header.i=@amarulasolutions.com header.s=google
header.b=JnV+Q3yh;
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;
dara=pass header.i=@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
a640c23a62f3a-a9afaa7a791sor406366966b.9.2024.10.29.01.46.57
for <linux-amarula@amarulasolutions.com>
(Google Transport Security);
Tue, 29 Oct 2024 01:46: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:907:9814:b0:a9a:ca:4436 with SMTP id
a640c23a62f3a-a9e2ad15f3fmr140074766b.13.1730191617226;
Tue, 29 Oct 2024 01:46:57 -0700 (PDT)
Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it
(host-79-40-68-117.business.telecomitalia.it. [79.40.68.117])
by smtp.gmail.com with ESMTPSA id
a640c23a62f3a-a9b1dec7dacsm450134166b.9.2024.10.29.01.46.45
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Tue, 29 Oct 2024 01:46:56 -0700 (PDT)
From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
To: linux-kernel@vger.kernel.org
Cc: linux-amarula@amarulasolutions.com,
Dario Binacchi <dario.binacchi@amarulasolutions.com>,
Marc Kleine-Budde <mkl@pengutronix.de>,
Vincent Mailhol <mailhol.vincent@wanadoo.fr>,
linux-can@vger.kernel.org
Subject: [RFC PATCH v2 3/6] can: dev: add helpers to setup an error frame
Date: Tue, 29 Oct 2024 09:44:47 +0100
Message-ID: <20241029084525.2858224-4-dario.binacchi@amarulasolutions.com>
X-Mailer: git-send-email 2.43.0
In-Reply-To: <20241029084525.2858224-1-dario.binacchi@amarulasolutions.com>
References: <20241029084525.2858224-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=JnV+Q3yh;
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;
dara=pass header.i=@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: <linux-amarula.amarulasolutions.com>
X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com
X-Google-Group-Id: 476853432473
List-Post:
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/post>,
<mailto:linux-amarula@amarulasolutions.com>
List-Help:
<https://support.google.com/a/amarulasolutions.com/bin/topic.py?topic=25838>,
<mailto:linux-amarula+help@amarulasolutions.com>
List-Archive:
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/>
List-Unsubscribe:
<mailto:googlegroups-manage+476853432473+unsubscribe@googlegroups.com>,
<https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/subscribe>
|
| Series |
can: dev: add generic function can_update_bus_error_stats()
|
|
Commit Message
Dario Binacchi
Oct. 29, 2024, 8:44 a.m. UTC
These helpers can prevent errors and code duplication when setting up a
CAN error frame.
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---
Changes in v2:
- Replace macros with static inline functions
- Update the commit message
include/linux/can/dev.h | 46 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
Comments
On 29.10.2024 09:44:47, Dario Binacchi wrote: > These helpers can prevent errors and code duplication when setting up a > CAN error frame. > > Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> AFAICS in the flexcan driver we don't need the "if (cf)" checks, do we? Having repeated NULL pointer checks don't feel right. Marc > > --- > > Changes in v2: > - Replace macros with static inline functions > - Update the commit message > > include/linux/can/dev.h | 46 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 46 insertions(+) > > diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h > index 0977656b366d..1b09d30dae32 100644 > --- a/include/linux/can/dev.h > +++ b/include/linux/can/dev.h > @@ -168,6 +168,52 @@ static inline bool can_dev_dropped_skb(struct net_device *dev, struct sk_buff *s > return can_dropped_invalid_skb(dev, skb); > } > > +static inline void can_frame_error_init(struct can_frame *cf) > +{ > + if (cf) > + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; > +} > + > +static inline void can_frame_set_err_bit0(struct can_frame *cf) > +{ > + if (cf) > + cf->data[2] |= CAN_ERR_PROT_BIT0; > +} > + > +static inline void can_frame_set_err_bit1(struct can_frame *cf) > +{ > + if (cf) > + cf->data[2] |= CAN_ERR_PROT_BIT1; > +} > + > +static inline void can_frame_set_err_ack(struct can_frame *cf) > +{ > + if (cf) { > + cf->can_id |= CAN_ERR_ACK; > + cf->data[3] = CAN_ERR_PROT_LOC_ACK; > + } > +} > + > +static inline void can_frame_set_err_crc(struct can_frame *cf) > +{ > + if (cf) { > + cf->data[2] |= CAN_ERR_PROT_BIT; > + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; > + } > +} > + > +static inline void can_frame_set_err_form(struct can_frame *cf) > +{ > + if (cf) > + cf->data[2] |= CAN_ERR_PROT_FORM; > +} > + > +static inline void can_frame_set_err_stuff(struct can_frame *cf) > +{ > + if (cf) > + cf->data[2] |= CAN_ERR_PROT_STUFF; > +} > + > void can_setup(struct net_device *dev); > > struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max, > -- > 2.43.0 > >
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index 0977656b366d..1b09d30dae32 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h @@ -168,6 +168,52 @@ static inline bool can_dev_dropped_skb(struct net_device *dev, struct sk_buff *s return can_dropped_invalid_skb(dev, skb); } +static inline void can_frame_error_init(struct can_frame *cf) +{ + if (cf) + cf->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR; +} + +static inline void can_frame_set_err_bit0(struct can_frame *cf) +{ + if (cf) + cf->data[2] |= CAN_ERR_PROT_BIT0; +} + +static inline void can_frame_set_err_bit1(struct can_frame *cf) +{ + if (cf) + cf->data[2] |= CAN_ERR_PROT_BIT1; +} + +static inline void can_frame_set_err_ack(struct can_frame *cf) +{ + if (cf) { + cf->can_id |= CAN_ERR_ACK; + cf->data[3] = CAN_ERR_PROT_LOC_ACK; + } +} + +static inline void can_frame_set_err_crc(struct can_frame *cf) +{ + if (cf) { + cf->data[2] |= CAN_ERR_PROT_BIT; + cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ; + } +} + +static inline void can_frame_set_err_form(struct can_frame *cf) +{ + if (cf) + cf->data[2] |= CAN_ERR_PROT_FORM; +} + +static inline void can_frame_set_err_stuff(struct can_frame *cf) +{ + if (cf) + cf->data[2] |= CAN_ERR_PROT_STUFF; +} + void can_setup(struct net_device *dev); struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max,