Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

can: mcp251x: add LED trigger support

Add support for canbus activity led indicators on mcp251x devices by
calling appropriate can_led functions.

These are only enabled when CONFIG_CAN_LEDS is Y, becomes no-op
otherwise.

Cc: Christian Pellegrin <chripell@fsfe.org>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Fabio Baltieri and committed by
Marc Kleine-Budde
eb072a9b 5090f805

+19 -4
+19 -4
drivers/net/can/mcp251x.c
··· 60 60 61 61 #include <linux/can/core.h> 62 62 #include <linux/can/dev.h> 63 + #include <linux/can/led.h> 63 64 #include <linux/can/platform/mcp251x.h> 64 65 #include <linux/completion.h> 65 66 #include <linux/delay.h> ··· 495 494 496 495 priv->net->stats.rx_packets++; 497 496 priv->net->stats.rx_bytes += frame->can_dlc; 497 + 498 + can_led_event(priv->net, CAN_LED_EVENT_RX); 499 + 498 500 netif_rx_ni(skb); 499 501 } 500 502 ··· 711 707 712 708 mutex_unlock(&priv->mcp_lock); 713 709 710 + can_led_event(net, CAN_LED_EVENT_STOP); 711 + 714 712 return 0; 715 713 } 716 714 ··· 911 905 if (intf & CANINTF_TX) { 912 906 net->stats.tx_packets++; 913 907 net->stats.tx_bytes += priv->tx_len - 1; 908 + can_led_event(net, CAN_LED_EVENT_TX); 914 909 if (priv->tx_len) { 915 910 can_get_echo_skb(net, 0); 916 911 priv->tx_len = 0; ··· 975 968 mcp251x_open_clean(net); 976 969 goto open_unlock; 977 970 } 971 + 972 + can_led_event(net, CAN_LED_EVENT_OPEN); 973 + 978 974 netif_wake_queue(net); 979 975 980 976 open_unlock: ··· 1087 1077 pdata->transceiver_enable(0); 1088 1078 1089 1079 ret = register_candev(net); 1090 - if (!ret) { 1091 - dev_info(&spi->dev, "probed\n"); 1092 - return ret; 1093 - } 1080 + if (ret) 1081 + goto error_probe; 1082 + 1083 + devm_can_led_init(net); 1084 + 1085 + dev_info(&spi->dev, "probed\n"); 1086 + 1087 + return ret; 1088 + 1094 1089 error_probe: 1095 1090 if (!mcp251x_enable_dma) 1096 1091 kfree(priv->spi_rx_buf);