s390/smsgiucv_app: Make use of iucv_alloc_device()
authorHeiko Carstens <hca@linux.ibm.com>
Mon, 6 May 2024 19:44:52 +0000 (21:44 +0200)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Tue, 14 May 2024 18:21:03 +0000 (20:21 +0200)
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/smsgiucv_app.c:176:26: error: cast from 'void (*)(const void *)' to 'void (*)(struct device *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict]
    176 |         smsg_app_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-2-fd048c9903b0@kernel.org
Acked-by: Alexandra Winter <wintera@linux.ibm.com>
Link: https://lore.kernel.org/r/20240506194454.1160315-5-hca@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
drivers/s390/net/smsgiucv_app.c

index 0a263999f7ae44b181ac7dc786908698c42a9974..cc44cbb0028b20f67020b55155a6aba3ba941c5d 100644 (file)
@@ -156,25 +156,14 @@ static int __init smsgiucv_app_init(void)
        if (!MACHINE_IS_VM)
                return -ENODEV;
 
-       smsg_app_dev = kzalloc(sizeof(*smsg_app_dev), GFP_KERNEL);
-       if (!smsg_app_dev)
-               return -ENOMEM;
-
        smsgiucv_drv = driver_find(SMSGIUCV_DRV_NAME, &iucv_bus);
-       if (!smsgiucv_drv) {
-               kfree(smsg_app_dev);
+       if (!smsgiucv_drv)
                return -ENODEV;
-       }
 
-       rc = dev_set_name(smsg_app_dev, KMSG_COMPONENT);
-       if (rc) {
-               kfree(smsg_app_dev);
-               goto fail;
-       }
-       smsg_app_dev->bus = &iucv_bus;
-       smsg_app_dev->parent = iucv_root;
-       smsg_app_dev->release = (void (*)(struct device *)) kfree;
-       smsg_app_dev->driver = smsgiucv_drv;
+       smsg_app_dev = iucv_alloc_device(NULL, smsgiucv_drv, NULL, KMSG_COMPONENT);
+       if (!smsg_app_dev)
+               return -ENOMEM;
+
        rc = device_register(smsg_app_dev);
        if (rc) {
                put_device(smsg_app_dev);