]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
serdev: Simplify devm_serdev_device_open() function
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 24 Oct 2023 12:41:14 +0000 (15:41 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Oct 2023 11:04:11 +0000 (13:04 +0200)
Use devm_add_action_or_reset() instead of devres_alloc() and
devres_add(), which works the same. This will simplify the
code. There is no functional changes.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20231024124115.3598090-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serdev/core.c

index e46448efc48d305ed6db15a8587d4dbc7715fa5c..6a1e75f98f16654faef65f0a3b4b66c377f06ba7 100644 (file)
@@ -187,30 +187,20 @@ void serdev_device_close(struct serdev_device *serdev)
 }
 EXPORT_SYMBOL_GPL(serdev_device_close);
 
-static void devm_serdev_device_release(struct device *dev, void *dr)
+static void devm_serdev_device_close(void *serdev)
 {
-       serdev_device_close(*(struct serdev_device **)dr);
+       serdev_device_close(serdev);
 }
 
 int devm_serdev_device_open(struct device *dev, struct serdev_device *serdev)
 {
-       struct serdev_device **dr;
        int ret;
 
-       dr = devres_alloc(devm_serdev_device_release, sizeof(*dr), GFP_KERNEL);
-       if (!dr)
-               return -ENOMEM;
-
        ret = serdev_device_open(serdev);
-       if (ret) {
-               devres_free(dr);
+       if (ret)
                return ret;
-       }
 
-       *dr = serdev;
-       devres_add(dev, dr);
-
-       return 0;
+       return devm_add_action_or_reset(dev, devm_serdev_device_close, serdev);
 }
 EXPORT_SYMBOL_GPL(devm_serdev_device_open);