can: peak_usb: report bus recovery as well
[ Upstream commit 128a1b87d3ceb2ba449d5aadb222fe22395adeb0 ] While the state changes are reported when the error counters increase and decrease, there is no event when the bus recovers and the error counters decrease again. So add those as well. Change the state going downward to be ERROR_PASSIVE -> ERROR_WARNING -> ERROR_ACTIVE instead of directly to ERROR_ACTIVE again. Signed-off-by: Jeroen Hofstee <jhofstee@victronenergy.com> Cc: Stephane Grosjean <s.grosjean@peak-system.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
a389194e8e
commit
ef6546a200
1 changed files with 10 additions and 5 deletions
|
@ -441,8 +441,8 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
|
||||||
}
|
}
|
||||||
if ((n & PCAN_USB_ERROR_BUS_LIGHT) == 0) {
|
if ((n & PCAN_USB_ERROR_BUS_LIGHT) == 0) {
|
||||||
/* no error (back to active state) */
|
/* no error (back to active state) */
|
||||||
mc->pdev->dev.can.state = CAN_STATE_ERROR_ACTIVE;
|
new_state = CAN_STATE_ERROR_ACTIVE;
|
||||||
return 0;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -465,9 +465,9 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((n & PCAN_USB_ERROR_BUS_HEAVY) == 0) {
|
if ((n & PCAN_USB_ERROR_BUS_HEAVY) == 0) {
|
||||||
/* no error (back to active state) */
|
/* no error (back to warning state) */
|
||||||
mc->pdev->dev.can.state = CAN_STATE_ERROR_ACTIVE;
|
new_state = CAN_STATE_ERROR_WARNING;
|
||||||
return 0;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -506,6 +506,11 @@ static int pcan_usb_decode_error(struct pcan_usb_msg_context *mc, u8 n,
|
||||||
mc->pdev->dev.can.can_stats.error_warning++;
|
mc->pdev->dev.can.can_stats.error_warning++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CAN_STATE_ERROR_ACTIVE:
|
||||||
|
cf->can_id |= CAN_ERR_CRTL;
|
||||||
|
cf->data[1] = CAN_ERR_CRTL_ACTIVE;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* CAN_STATE_MAX (trick to handle other errors) */
|
/* CAN_STATE_MAX (trick to handle other errors) */
|
||||||
cf->can_id |= CAN_ERR_CRTL;
|
cf->can_id |= CAN_ERR_CRTL;
|
||||||
|
|
Loading…
Add table
Reference in a new issue