From patchwork Mon Oct 14 15:24:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 3578 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id D530C3FA1A for ; Mon, 14 Oct 2024 17:24:48 +0200 (CEST) Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-37d589138a9sf1418301f8f.1 for ; Mon, 14 Oct 2024 08:24:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1728919488; cv=pass; d=google.com; s=arc-20240605; b=BbBsSx8E+KWA5nAaixTMA/HxSU7u7auHsCCLDD6Cp/0CPBoPsPZBtit/06bXbIRbpU gBQ5a+32v7xDNsF+9XRVXF0/ZLgo1ZXyqnYonJCGqaZAt+d/XOMdkiOpcH+E2dzavSdq cV/rJkEeZ5g1PaXr27kjIiTtKZENov4kjQVyzZeTvDqu6aaknIl/c9h5cPuiAOGIw+S2 cZKixGk3u4goPdhTw1HVc0vlHPqzuEmISL74CrgIrYNOaxAiAVF3cwnM/iLbDma+Y8dN gHSZf1H00lRNHGV0psaN8XBtVcbCywZ4SFqvULQPo3Qnq9u6EUE/21LY9GprKttq/im8 3TkA== 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=d+gbzA0ax/pm1CuK6L/4+sFBzEGWQVfaY0H708xq5/I=; fh=OsYFHN2pZi9POtE5Rac9t0RnB8iW80G9jxQHB4Vx7wc=; b=SgC9QB6gBdF1ezI8JRtm4F+7pckTPBwQEwVmenPaLHkaFGpjxivxKDxHFTrGi0glv5 E+ciLxfW9aYeDFnnY3E00uk0wiHyxDV0GHzGtEJwv45dcFa/Fq6ABlRjqiVQxc0Al1S5 Ir88G4RWILdOAFFH/mdVVJEXXaFcGHbUF6+6fdgdW1qtVFJS2W4cz9Xu+H/m2ikJqUfs BIL3g1Kd+6XI/yTh6mHXsXqMPBBQe1egdrArbX+zxGKMtOY4C5hF7mpkuB2L0SZyHA0n pPCWyjIDAP1W0FdptNl1oWzJ5Bj0iFlHdEj7B+xZQDS6pJ4RvdUJD9aE9cRPDzufxIOf diZw==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=TRP6rrcz; 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=1728919488; x=1729524288; 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=d+gbzA0ax/pm1CuK6L/4+sFBzEGWQVfaY0H708xq5/I=; b=GcNmZ6fdYL6RCh/0ipujVkaszrdrzzzX4N65ehOn7XWMOuPM6Mg5KbemrbdvVa00aP 2gbHKeGUQ/M79YcejNXhi4IrSy6nUSWCpnflN0uVKVO/hT0kzIrFFDX5dTHZJSLnEimL HYxeWCfHtWpg8VrC3v3vmUrsfbh4+HFT10Bzg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728919488; x=1729524288; 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=d+gbzA0ax/pm1CuK6L/4+sFBzEGWQVfaY0H708xq5/I=; b=Uvwep1Iq9lCeJiWmB80tJQFa8JPvG041xNmt2T2lEcp4DZVuhfradl7JkHT7yq+BBt G5iNsvmkDJTGeHM1vbWZrLcvPOOLl8AE4xpWabu5q5NKF0Hm7vHofEC5aV/CYmyh4VOk D/yKf0yZpqiPrc2R97vAopH83MHU4O7aLqO9nbwnpxNNCP0bSp0pMv69nk/IWS05/SLD eZ5vktTuPvdCpw7+MEEJJ9VkYiyxK02iPGzRHfTY9MrYp4nHByves9Mdewtr7hG9lH7G 2PTr/KSJMxN1QCfYovPLVjEQDfN7qQ/01EWHUq4uxtwNGsbte/KbQGDIXQSRZQ++hgPc gy1w== X-Forwarded-Encrypted: i=2; AJvYcCXs/k9xqT79ZYlIAikv+S8wjovtTeIjFWhSmHk0ji5ybc7hM87itSM8flqe1SXP8eUxjGYLooc4jspauF1S@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0YxcvEM9ooTZsm/pHQCEcDTFUEP/QUD/QfFxZi/ysNdGnbir/+b5 gz32q7r0UG5IyRWpTad2BgRKOCz0zlikJvB0xZ+ccLYzCZIFATHMdaMs4FPqQhjucQ== X-Google-Smtp-Source: AGHT+IGKUBzVy6o/2Qp8cMNB5SrCbDX+0A6SVsQqaKLitCcJrr04H8DKRSH1FRkDlPlcqZ9HKGYXLg== X-Received: by 2002:adf:e78d:0:b0:37d:4894:6895 with SMTP id ffacd0b85a97d-37d551e432cmr8977581f8f.15.1728919488422; Mon, 14 Oct 2024 08:24:48 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a05:600c:3b8a:b0:42c:af5b:facc with SMTP id 5b1f17b1804b1-43115ff98eals7255085e9.1.-pod-prod-07-eu; Mon, 14 Oct 2024 08:24:47 -0700 (PDT) X-Received: by 2002:a05:600c:1c9e:b0:42c:c28c:e477 with SMTP id 5b1f17b1804b1-4311df1e5camr104444665e9.23.1728919486893; Mon, 14 Oct 2024 08:24:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728919486; cv=none; d=google.com; s=arc-20240605; b=b5p2K1l7l1mFegx2pSPJfIPOofdB3Za2x+ua7TzbBtTKCVK1FnvN1SyTtJrGZPKcPp feQQW9ZevMtETlMjXcm3Wch8GTkKxcrkqnA4baPNfl7jmPtcfBpV7I7X8LvsuGG0wTUn 75VGXxotHR2UvNgviJM4f93ZQhR5YwU9feJzsgL6xQ5j37olx9kP8KmTnveymJYUhMkq t+aalxwGKFlnhMZ3aDI9b98kIR6F5Q4SkOSMSCMcXOVuuin3tKhtXI2zE/ex/lfKEwyQ H77Qff2Qe94WRO4727c6dhtL6eU+11nhrivk02+ItqrlE63rgHQ7hNLaiXG7cZoYR4nb YPFg== 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=rl0FvaCWPNne/T/X4eNpX+jzq6AP7zoJV76Sz9wGAY8=; fh=dGLZOKN9V8tcsawm1ur1mnwhvDoTVzbByAl3wpaYkgg=; b=kvg/NLaTsCm4sQKrydvf5pWfMjp+5SFeCMYRMAxWm1kR9s/xKgIHyc05vyXlD2NOi2 Da2w7Pyqf+VcxicOCcBNJ4A1tH9v0wHHybCcptqJIkbdBUyEZ21sJoqPmVvWj5LrQzla em4Wb64H+hor8Gi68J399g249gzVGXJUZ1B2Nav+OZ0+uTJGnGy99SN8OezccOC99ruw BsocI7x5W1c4Vf8MdOxCNzvuZN4JlW8lfnMYZOhTQRXIXZlWYbMaB4El5Gti6Pgqbpfw Tu1uUb6BVSc3zWQDGN/N5eQ+QlYP/9cI4ILredzakvaemp7kYIhvseISXijIXE3gIq4o GwBA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=TRP6rrcz; 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 5b1f17b1804b1-431184d17c7sor28395515e9.7.2024.10.14.08.24.46 for (Google Transport Security); Mon, 14 Oct 2024 08:24:46 -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:a5d:684b:0:b0:37d:52d0:a59d with SMTP id ffacd0b85a97d-37d551ab465mr9434826f8f.10.1728919486433; Mon, 14 Oct 2024 08:24:46 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.amarulasolutions.com ([2.196.40.133]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d4b6bd1b7sm11629911f8f.37.2024.10.14.08.24.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Oct 2024 08:24:46 -0700 (PDT) From: Dario Binacchi To: linux-kernel@vger.kernel.org Cc: linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, Dario Binacchi , Marc Kleine-Budde , Vincent Mailhol , linux-can@vger.kernel.org Subject: [RFC PATCH 3/6] can: dev: add helper macros to setup an error frame Date: Mon, 14 Oct 2024 17:24:18 +0200 Message-ID: <20241014152431.2045377-4-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014152431.2045377-1-dario.binacchi@amarulasolutions.com> References: <20241014152431.2045377-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=TRP6rrcz; 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: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , These helpers can prevent errors and code duplication when setting up a CAN error frame. Signed-off-by: Dario Binacchi --- include/linux/can/dev.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index 0977656b366d..0202526be6b0 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h @@ -23,6 +23,33 @@ #include #include +#define CAN_FRAME_ERROR_INIT(cf) \ + ((cf)->can_id |= CAN_ERR_PROT | CAN_ERR_BUSERROR) + +#define CAN_FRAME_SET_ERR_BIT0(cf) \ + ((cf)->data[2] |= CAN_ERR_PROT_BIT0) + +#define CAN_FRAME_SET_ERR_BIT1(cf) \ + ((cf)->data[2] |= CAN_ERR_PROT_BIT1) + +#define CAN_FRAME_SET_ERR_ACK(cf) \ + do { \ + ((cf)->can_id |= CAN_ERR_ACK); \ + ((cf)->data[3] = CAN_ERR_PROT_LOC_ACK); \ + } while (0) + +#define CAN_FRAME_SET_ERR_CRC(cf) \ + do { \ + ((cf)->data[2] |= CAN_ERR_PROT_BIT); \ + ((cf)->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ); \ + } while (0) + +#define CAN_FRAME_SET_ERR_FORM(cf) \ + ((cf)->data[2] |= CAN_ERR_PROT_FORM) + +#define CAN_FRAME_SET_ERR_STUFF(cf) \ + ((cf)->data[2] |= CAN_ERR_PROT_STUFF) + /* * CAN mode */