From: Vivek Pernamitta Rename the MHI network interface to include the device name, improving clarity when multiple MHI controllers are connected. Currently, MHI NET device interfaces are created as mhi_swip/ mhi_hwip for each channel, making it difficult to distinguish between channels when multiple EP/MHI controllers are connected. Rename the MHI interface to include the device name, for example: - Channel IP_SW0 for the 1st MHI controller will be named mhi0_IP_SW0. - Channel IP_SW0 for the 2nd MHI controller will be named mhi1_IP_SW0. - Channel IP_HW0 for the 1st MHI controller will be named mhi0_IP_HW0. Signed-off-by: Vivek Pernamitta --- drivers/net/mhi_net.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/net/mhi_net.c b/drivers/net/mhi_net.c index ae169929a9d8e449b5a427993abf68e8d032fae2..08ab67f9a769ec64e1007853e47743003a197ec4 100644 --- a/drivers/net/mhi_net.c +++ b/drivers/net/mhi_net.c @@ -351,11 +351,20 @@ static void mhi_net_dellink(struct mhi_device *mhi_dev, struct net_device *ndev) static int mhi_net_probe(struct mhi_device *mhi_dev, const struct mhi_device_id *id) { - const struct mhi_device_info *info = (struct mhi_device_info *)id->driver_data; + const struct mhi_device_info *info; + struct device *dev = &mhi_dev->dev; + char netname[IFNAMSIZ] = {0}; struct net_device *ndev; int err; - ndev = alloc_netdev(sizeof(struct mhi_net_dev), info->netname, + info = (struct mhi_device_info *)id->driver_data; + + if (snprintf(netname, sizeof(netname), "%s", dev_name(dev)) >= IFNAMSIZ) { + dev_err(dev, "Invalid interface name: '%s'\n", netname); + return -EINVAL; + } + + ndev = alloc_netdev(sizeof(struct mhi_net_dev), netname, NET_NAME_PREDICTABLE, mhi_net_setup); if (!ndev) return -ENOMEM; -- 2.34.1