Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/netiucv: Make use of iucv_alloc_device()

Make use of iucv_alloc_device() to get rid of quite some code. In addition
this also removes a cast to an incompatible function (clang W=1):

drivers/s390/net/netiucv.c:1716:18: error: cast from 'void (*)(const void *)' to 'void (*)(struct device *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
1716 | dev->release = (void (*)(struct device *))kfree;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reported-by: Nathan Chancellor <nathan@kernel.org>
Closes: https://lore.kernel.org/r/20240417-s390-drivers-fix-cast-function-type-v1-3-fd048c9903b0@kernel.org
Acked-by: Alexandra Winter <wintera@linux.ibm.com>
Link: https://lore.kernel.org/r/20240506194454.1160315-4-hca@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>

authored by

Heiko Carstens and committed by
Alexander Gordeev
968bfb56 4ee55c95

+4 -16
+4 -16
drivers/s390/net/netiucv.c
··· 1696 1696 static int netiucv_register_device(struct net_device *ndev) 1697 1697 { 1698 1698 struct netiucv_priv *priv = netdev_priv(ndev); 1699 - struct device *dev = kzalloc(sizeof(struct device), GFP_KERNEL); 1699 + struct device *dev; 1700 1700 int ret; 1701 1701 1702 1702 IUCV_DBF_TEXT(trace, 3, __func__); 1703 1703 1704 - if (dev) { 1705 - dev_set_name(dev, "net%s", ndev->name); 1706 - dev->bus = &iucv_bus; 1707 - dev->parent = iucv_root; 1708 - dev->groups = netiucv_attr_groups; 1709 - /* 1710 - * The release function could be called after the 1711 - * module has been unloaded. It's _only_ task is to 1712 - * free the struct. Therefore, we specify kfree() 1713 - * directly here. (Probably a little bit obfuscating 1714 - * but legitime ...). 1715 - */ 1716 - dev->release = (void (*)(struct device *))kfree; 1717 - dev->driver = &netiucv_driver; 1718 - } else 1704 + dev = iucv_alloc_device(netiucv_attr_groups, &netiucv_driver, NULL, 1705 + "net%s", ndev->name); 1706 + if (!dev) 1719 1707 return -ENOMEM; 1720 1708 1721 1709 ret = device_register(dev);