From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36CAC847E for ; Fri, 10 Mar 2023 13:46:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B33FCC433D2; Fri, 10 Mar 2023 13:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678456008; bh=okvNbCqdqw6+HV+m9K1jD8aNUPH7VSFb5Y15lhHHhcs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eo3+nfMktz8VPtKVL2ZjZtVrT7iAiyEr/ORDssqcgxAEMjdC6NmpDRGpukJdHtnec +XfJyJeb5RUgOvqoM4oXuJSETSL4fpyp3wm6XEdGkbq/Rdxy/4gN5X5I8NOIdnge8l aRg06Fw5ykmuRPBrfSAxpx7DSoGDuEO8cjN9OprQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Frank Jungclaus , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 4.14 050/193] can: esd_usb: Move mislocated storage of SJA1000_ECC_SEG bits in case of a bus error Date: Fri, 10 Mar 2023 14:37:12 +0100 Message-Id: <20230310133712.664588796@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310133710.926811681@linuxfoundation.org> References: <20230310133710.926811681@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Frank Jungclaus [ Upstream commit 118469f88180438ef43dee93d71f77c00e7b425d ] Move the supply for cf->data[3] (bit stream position of CAN error), in case of a bus- or protocol-error, outside of the "switch (ecc & SJA1000_ECC_MASK){}"-statement, because this bit stream position is independent of the error type. Fixes: 96d8e90382dc ("can: Add driver for esd CAN-USB/2 device") Signed-off-by: Frank Jungclaus Link: https://lore.kernel.org/all/20230216190450.3901254-2-frank.jungclaus@esd.eu Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- drivers/net/can/usb/esd_usb2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/usb/esd_usb2.c b/drivers/net/can/usb/esd_usb2.c index fbe1173b2651f..b15154a6c53eb 100644 --- a/drivers/net/can/usb/esd_usb2.c +++ b/drivers/net/can/usb/esd_usb2.c @@ -284,7 +284,6 @@ static void esd_usb2_rx_event(struct esd_usb2_net_priv *priv, cf->data[2] |= CAN_ERR_PROT_STUFF; break; default: - cf->data[3] = ecc & SJA1000_ECC_SEG; break; } @@ -292,6 +291,9 @@ static void esd_usb2_rx_event(struct esd_usb2_net_priv *priv, if (!(ecc & SJA1000_ECC_DIR)) cf->data[2] |= CAN_ERR_PROT_TX; + /* Bit stream position in CAN frame as the error was detected */ + cf->data[3] = ecc & SJA1000_ECC_SEG; + if (priv->can.state == CAN_STATE_ERROR_WARNING || priv->can.state == CAN_STATE_ERROR_PASSIVE) { cf->data[1] = (txerr > rxerr) ? -- 2.39.2