diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/can/dev.c | 5 | ||||
-rw-r--r-- | drivers/net/can/led.c | 38 |
2 files changed, 43 insertions, 0 deletions
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c index 13e738098fbe..6abc6e59778e 100644 --- a/drivers/net/can/dev.c +++ b/drivers/net/can/dev.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/can.h> | 25 | #include <linux/can.h> |
26 | #include <linux/can/dev.h> | 26 | #include <linux/can/dev.h> |
27 | #include <linux/can/netlink.h> | 27 | #include <linux/can/netlink.h> |
28 | #include <linux/can/led.h> | ||
28 | #include <net/rtnetlink.h> | 29 | #include <net/rtnetlink.h> |
29 | 30 | ||
30 | #define MOD_DESC "CAN device driver interface" | 31 | #define MOD_DESC "CAN device driver interface" |
@@ -811,6 +812,8 @@ static __init int can_dev_init(void) | |||
811 | { | 812 | { |
812 | int err; | 813 | int err; |
813 | 814 | ||
815 | can_led_notifier_init(); | ||
816 | |||
814 | err = rtnl_link_register(&can_link_ops); | 817 | err = rtnl_link_register(&can_link_ops); |
815 | if (!err) | 818 | if (!err) |
816 | printk(KERN_INFO MOD_DESC "\n"); | 819 | printk(KERN_INFO MOD_DESC "\n"); |
@@ -822,6 +825,8 @@ module_init(can_dev_init); | |||
822 | static __exit void can_dev_exit(void) | 825 | static __exit void can_dev_exit(void) |
823 | { | 826 | { |
824 | rtnl_link_unregister(&can_link_ops); | 827 | rtnl_link_unregister(&can_link_ops); |
828 | |||
829 | can_led_notifier_exit(); | ||
825 | } | 830 | } |
826 | module_exit(can_dev_exit); | 831 | module_exit(can_dev_exit); |
827 | 832 | ||
diff --git a/drivers/net/can/led.c b/drivers/net/can/led.c index c50a0d741c57..f27fca65dc4a 100644 --- a/drivers/net/can/led.c +++ b/drivers/net/can/led.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright 2012, Fabio Baltieri <fabio.baltieri@gmail.com> | 2 | * Copyright 2012, Fabio Baltieri <fabio.baltieri@gmail.com> |
3 | * Copyright 2012, Kurt Van Dijck <kurt.van.dijck@eia.be> | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License version 2 as | 6 | * it under the terms of the GNU General Public License version 2 as |
@@ -84,3 +85,40 @@ void devm_can_led_init(struct net_device *netdev) | |||
84 | devres_add(&netdev->dev, res); | 85 | devres_add(&netdev->dev, res); |
85 | } | 86 | } |
86 | EXPORT_SYMBOL_GPL(devm_can_led_init); | 87 | EXPORT_SYMBOL_GPL(devm_can_led_init); |
88 | |||
89 | /* NETDEV rename notifier to rename the associated led triggers too */ | ||
90 | static int can_led_notifier(struct notifier_block *nb, unsigned long msg, | ||
91 | void *data) | ||
92 | { | ||
93 | struct net_device *netdev = data; | ||
94 | struct can_priv *priv = safe_candev_priv(netdev); | ||
95 | char name[CAN_LED_NAME_SZ]; | ||
96 | |||
97 | if (!priv) | ||
98 | return NOTIFY_DONE; | ||
99 | |||
100 | if (msg == NETDEV_CHANGENAME) { | ||
101 | snprintf(name, sizeof(name), "%s-tx", netdev->name); | ||
102 | led_trigger_rename_static(name, priv->tx_led_trig); | ||
103 | |||
104 | snprintf(name, sizeof(name), "%s-rx", netdev->name); | ||
105 | led_trigger_rename_static(name, priv->rx_led_trig); | ||
106 | } | ||
107 | |||
108 | return NOTIFY_DONE; | ||
109 | } | ||
110 | |||
111 | /* notifier block for netdevice event */ | ||
112 | static struct notifier_block can_netdev_notifier __read_mostly = { | ||
113 | .notifier_call = can_led_notifier, | ||
114 | }; | ||
115 | |||
116 | int __init can_led_notifier_init(void) | ||
117 | { | ||
118 | return register_netdevice_notifier(&can_netdev_notifier); | ||
119 | } | ||
120 | |||
121 | void __exit can_led_notifier_exit(void) | ||
122 | { | ||
123 | unregister_netdevice_notifier(&can_netdev_notifier); | ||
124 | } | ||