Skip to content

Commit 968bfb5

Browse files
hcahcaAlexander Gordeev
authored andcommitted
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>
1 parent 4ee55c9 commit 968bfb5

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

drivers/s390/net/netiucv.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,26 +1696,14 @@ static const struct attribute_group *netiucv_attr_groups[] = {
16961696
static int netiucv_register_device(struct net_device *ndev)
16971697
{
16981698
struct netiucv_priv *priv = netdev_priv(ndev);
1699-
struct device *dev = kzalloc(sizeof(struct device), GFP_KERNEL);
1699+
struct device *dev;
17001700
int ret;
17011701

17021702
IUCV_DBF_TEXT(trace, 3, __func__);
17031703

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)
17191707
return -ENOMEM;
17201708

17211709
ret = device_register(dev);

0 commit comments

Comments
 (0)