]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - include/linux/can/dev.h
Merge branch 'karo-tx6-mainline' into stable
[karo-tx-linux.git] / include / linux / can / dev.h
index 735f9f8c4e43e5350f36bc4b39e9f8634778fd40..5261751f6bd4dec116516691cbc40a6763a6d12b 100644 (file)
@@ -40,8 +40,11 @@ struct can_priv {
        struct can_clock clock;
 
        enum can_state state;
-       u32 ctrlmode;
-       u32 ctrlmode_supported;
+
+       /* CAN controller features - see include/uapi/linux/can/netlink.h */
+       u32 ctrlmode;           /* current options setting */
+       u32 ctrlmode_supported; /* options that can be modified by netlink */
+       u32 ctrlmode_static;    /* static enabled options for driver/hardware */
 
        int restart_ms;
        struct timer_list restart_timer;
@@ -108,6 +111,21 @@ static inline bool can_is_canfd_skb(const struct sk_buff *skb)
        return skb->len == CANFD_MTU;
 }
 
+/* helper to define static CAN controller features at device creation time */
+static inline void can_set_static_ctrlmode(struct net_device *dev,
+                                          u32 static_mode)
+{
+       struct can_priv *priv = netdev_priv(dev);
+
+       /* alloc_candev() succeeded => netdev_priv() is valid at this point */
+       priv->ctrlmode = static_mode;
+       priv->ctrlmode_static = static_mode;
+
+       /* override MTU which was set by default in can_setup()? */
+       if (static_mode & CAN_CTRLMODE_FD)
+               dev->mtu = CANFD_MTU;
+}
+
 /* get data length from can_dlc with sanitized can_dlc */
 u8 can_dlc2len(u8 can_dlc);