Skip to content

Commit 4ee55c9

Browse files
hcahcaAlexander Gordeev
authored andcommitted
s390/vmlogrdr: 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/char/vmlogrdr.c:746:18: error: cast from 'void (*)(const void *)' to 'void (*)(struct device *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict] 746 | 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-1-fd048c9903b0@kernel.org Acked-by: Alexandra Winter <wintera@linux.ibm.com> Link: https://lore.kernel.org/r/20240506194454.1160315-3-hca@linux.ibm.com Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent 4452e8e commit 4ee55c9

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

drivers/s390/char/vmlogrdr.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -728,23 +728,9 @@ static int vmlogrdr_register_device(struct vmlogrdr_priv_t *priv)
728728
struct device *dev;
729729
int ret;
730730

731-
dev = kzalloc(sizeof(struct device), GFP_KERNEL);
732-
if (dev) {
733-
dev_set_name(dev, "%s", priv->internal_name);
734-
dev->bus = &iucv_bus;
735-
dev->parent = iucv_root;
736-
dev->driver = &vmlogrdr_driver;
737-
dev->groups = vmlogrdr_attr_groups;
738-
dev_set_drvdata(dev, priv);
739-
/*
740-
* The release function could be called after the
741-
* module has been unloaded. It's _only_ task is to
742-
* free the struct. Therefore, we specify kfree()
743-
* directly here. (Probably a little bit obfuscating
744-
* but legitime ...).
745-
*/
746-
dev->release = (void (*)(struct device *))kfree;
747-
} else
731+
dev = iucv_alloc_device(vmlogrdr_attr_groups, &vmlogrdr_driver,
732+
priv, priv->internal_name);
733+
if (!dev)
748734
return -ENOMEM;
749735
ret = device_register(dev);
750736
if (ret) {

0 commit comments

Comments
 (0)