Skip to content

Commit 7c7da8a

Browse files
vincent-mailholmarckleinebudde
authored andcommitted
can: dev: turn can_set_static_ctrlmode() into a non-inline function
can_set_static_ctrlmode() is declared as a static inline. But it is only called in the probe function of the devices and so does not really benefit from any kind of optimization. Transform it into a "normal" function by moving it to drivers/net/can/dev/dev.c Signed-off-by: Vincent Mailhol <mailhol@kernel.org> Link: https://patch.msgid.link/20250923-can-fix-mtu-v3-2-581bde113f52@kernel.org Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent c67732d commit 7c7da8a

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

drivers/net/can/dev/dev.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,27 @@ int can_change_mtu(struct net_device *dev, int new_mtu)
347347
}
348348
EXPORT_SYMBOL_GPL(can_change_mtu);
349349

350+
/* helper to define static CAN controller features at device creation time */
351+
int can_set_static_ctrlmode(struct net_device *dev, u32 static_mode)
352+
{
353+
struct can_priv *priv = netdev_priv(dev);
354+
355+
/* alloc_candev() succeeded => netdev_priv() is valid at this point */
356+
if (priv->ctrlmode_supported & static_mode) {
357+
netdev_warn(dev,
358+
"Controller features can not be supported and static at the same time\n");
359+
return -EINVAL;
360+
}
361+
priv->ctrlmode = static_mode;
362+
363+
/* override MTU which was set by default in can_setup()? */
364+
if (static_mode & CAN_CTRLMODE_FD)
365+
dev->mtu = CANFD_MTU;
366+
367+
return 0;
368+
}
369+
EXPORT_SYMBOL_GPL(can_set_static_ctrlmode);
370+
350371
/* generic implementation of netdev_ops::ndo_eth_ioctl for CAN devices
351372
* supporting hardware timestamps
352373
*/

include/linux/can/dev.h

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -125,27 +125,6 @@ static inline s32 can_get_relative_tdco(const struct can_priv *priv)
125125
return (s32)priv->fd.tdc.tdco - sample_point_in_tc;
126126
}
127127

128-
/* helper to define static CAN controller features at device creation time */
129-
static inline int __must_check can_set_static_ctrlmode(struct net_device *dev,
130-
u32 static_mode)
131-
{
132-
struct can_priv *priv = netdev_priv(dev);
133-
134-
/* alloc_candev() succeeded => netdev_priv() is valid at this point */
135-
if (priv->ctrlmode_supported & static_mode) {
136-
netdev_warn(dev,
137-
"Controller features can not be supported and static at the same time\n");
138-
return -EINVAL;
139-
}
140-
priv->ctrlmode = static_mode;
141-
142-
/* override MTU which was set by default in can_setup()? */
143-
if (static_mode & CAN_CTRLMODE_FD)
144-
dev->mtu = CANFD_MTU;
145-
146-
return 0;
147-
}
148-
149128
static inline u32 can_get_static_ctrlmode(struct can_priv *priv)
150129
{
151130
return priv->ctrlmode & ~priv->ctrlmode_supported;
@@ -188,6 +167,8 @@ struct can_priv *safe_candev_priv(struct net_device *dev);
188167
int open_candev(struct net_device *dev);
189168
void close_candev(struct net_device *dev);
190169
int can_change_mtu(struct net_device *dev, int new_mtu);
170+
int __must_check can_set_static_ctrlmode(struct net_device *dev,
171+
u32 static_mode);
191172
int can_eth_ioctl_hwts(struct net_device *netdev, struct ifreq *ifr, int cmd);
192173
int can_ethtool_op_get_ts_info_hwts(struct net_device *dev,
193174
struct kernel_ethtool_ts_info *info);

0 commit comments

Comments
 (0)