diff options
Diffstat (limited to 'include/linux/can')
-rw-r--r-- | include/linux/can/dev.h | 11 | ||||
-rw-r--r-- | include/linux/can/led.h | 51 | ||||
-rw-r--r-- | include/linux/can/skb.h | 45 |
3 files changed, 107 insertions, 0 deletions
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h index 2b2fc345afca..fb0ab651a041 100644 --- a/include/linux/can/dev.h +++ b/include/linux/can/dev.h | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/can.h> | 16 | #include <linux/can.h> |
17 | #include <linux/can/netlink.h> | 17 | #include <linux/can/netlink.h> |
18 | #include <linux/can/error.h> | 18 | #include <linux/can/error.h> |
19 | #include <linux/can/led.h> | ||
19 | 20 | ||
20 | /* | 21 | /* |
21 | * CAN mode | 22 | * CAN mode |
@@ -52,6 +53,13 @@ struct can_priv { | |||
52 | 53 | ||
53 | unsigned int echo_skb_max; | 54 | unsigned int echo_skb_max; |
54 | struct sk_buff **echo_skb; | 55 | struct sk_buff **echo_skb; |
56 | |||
57 | #ifdef CONFIG_CAN_LEDS | ||
58 | struct led_trigger *tx_led_trig; | ||
59 | char tx_led_trig_name[CAN_LED_NAME_SZ]; | ||
60 | struct led_trigger *rx_led_trig; | ||
61 | char rx_led_trig_name[CAN_LED_NAME_SZ]; | ||
62 | #endif | ||
55 | }; | 63 | }; |
56 | 64 | ||
57 | /* | 65 | /* |
@@ -98,6 +106,9 @@ u8 can_len2dlc(u8 len); | |||
98 | struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max); | 106 | struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max); |
99 | void free_candev(struct net_device *dev); | 107 | void free_candev(struct net_device *dev); |
100 | 108 | ||
109 | /* a candev safe wrapper around netdev_priv */ | ||
110 | struct can_priv *safe_candev_priv(struct net_device *dev); | ||
111 | |||
101 | int open_candev(struct net_device *dev); | 112 | int open_candev(struct net_device *dev); |
102 | void close_candev(struct net_device *dev); | 113 | void close_candev(struct net_device *dev); |
103 | 114 | ||
diff --git a/include/linux/can/led.h b/include/linux/can/led.h new file mode 100644 index 000000000000..9c1167baf273 --- /dev/null +++ b/include/linux/can/led.h | |||
@@ -0,0 +1,51 @@ | |||
1 | /* | ||
2 | * Copyright 2012, Fabio Baltieri <fabio.baltieri@gmail.com> | ||
3 | * | ||
4 | * 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 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #ifndef CAN_LED_H | ||
10 | #define CAN_LED_H | ||
11 | |||
12 | #include <linux/if.h> | ||
13 | #include <linux/leds.h> | ||
14 | |||
15 | enum can_led_event { | ||
16 | CAN_LED_EVENT_OPEN, | ||
17 | CAN_LED_EVENT_STOP, | ||
18 | CAN_LED_EVENT_TX, | ||
19 | CAN_LED_EVENT_RX, | ||
20 | }; | ||
21 | |||
22 | #ifdef CONFIG_CAN_LEDS | ||
23 | |||
24 | /* keep space for interface name + "-tx"/"-rx" suffix and null terminator */ | ||
25 | #define CAN_LED_NAME_SZ (IFNAMSIZ + 4) | ||
26 | |||
27 | void can_led_event(struct net_device *netdev, enum can_led_event event); | ||
28 | void devm_can_led_init(struct net_device *netdev); | ||
29 | int __init can_led_notifier_init(void); | ||
30 | void __exit can_led_notifier_exit(void); | ||
31 | |||
32 | #else | ||
33 | |||
34 | static inline void can_led_event(struct net_device *netdev, | ||
35 | enum can_led_event event) | ||
36 | { | ||
37 | } | ||
38 | static inline void devm_can_led_init(struct net_device *netdev) | ||
39 | { | ||
40 | } | ||
41 | static inline int can_led_notifier_init(void) | ||
42 | { | ||
43 | return 0; | ||
44 | } | ||
45 | static inline void can_led_notifier_exit(void) | ||
46 | { | ||
47 | } | ||
48 | |||
49 | #endif | ||
50 | |||
51 | #endif | ||
diff --git a/include/linux/can/skb.h b/include/linux/can/skb.h new file mode 100644 index 000000000000..2f0543f7510c --- /dev/null +++ b/include/linux/can/skb.h | |||
@@ -0,0 +1,45 @@ | |||
1 | /* | ||
2 | * linux/can/skb.h | ||
3 | * | ||
4 | * Definitions for the CAN network socket buffer | ||
5 | * | ||
6 | * Copyright (C) 2012 Oliver Hartkopp <socketcan@hartkopp.net> | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | #ifndef CAN_SKB_H | ||
11 | #define CAN_SKB_H | ||
12 | |||
13 | #include <linux/types.h> | ||
14 | #include <linux/can.h> | ||
15 | |||
16 | /* | ||
17 | * The struct can_skb_priv is used to transport additional information along | ||
18 | * with the stored struct can(fd)_frame that can not be contained in existing | ||
19 | * struct sk_buff elements. | ||
20 | * N.B. that this information must not be modified in cloned CAN sk_buffs. | ||
21 | * To modify the CAN frame content or the struct can_skb_priv content | ||
22 | * skb_copy() needs to be used instead of skb_clone(). | ||
23 | */ | ||
24 | |||
25 | /** | ||
26 | * struct can_skb_priv - private additional data inside CAN sk_buffs | ||
27 | * @ifindex: ifindex of the first interface the CAN frame appeared on | ||
28 | * @cf: align to the following CAN frame at skb->data | ||
29 | */ | ||
30 | struct can_skb_priv { | ||
31 | int ifindex; | ||
32 | struct can_frame cf[0]; | ||
33 | }; | ||
34 | |||
35 | static inline struct can_skb_priv *can_skb_prv(struct sk_buff *skb) | ||
36 | { | ||
37 | return (struct can_skb_priv *)(skb->head); | ||
38 | } | ||
39 | |||
40 | static inline void can_skb_reserve(struct sk_buff *skb) | ||
41 | { | ||
42 | skb_reserve(skb, sizeof(struct can_skb_priv)); | ||
43 | } | ||
44 | |||
45 | #endif /* CAN_SKB_H */ | ||