eeprom: at24: Use pm_runtime_resume_and_get to simplify the code
authorHeiner Kallweit <hkallweit1@gmail.com>
Wed, 20 Dec 2023 15:11:14 +0000 (16:11 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Jan 2024 16:01:14 +0000 (17:01 +0100)
Use helper pm_runtime_resume_and_get() to simplify the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Link: https://lore.kernel.org/r/c3045427-da42-4f7c-8a96-3c4756646cd0@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/eeprom/at24.c

index 3327c8a512ad7b224fd191ff9de48f99676d3f03..a5dcd7a134682e6154f2fe8bc7aec5629ebf45c3 100644 (file)
@@ -439,12 +439,9 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count)
        if (off + count > at24->byte_len)
                return -EINVAL;
 
-       ret = pm_runtime_get_sync(dev);
-       if (ret < 0) {
-               pm_runtime_put_noidle(dev);
+       ret = pm_runtime_resume_and_get(dev);
+       if (ret)
                return ret;
-       }
-
        /*
         * Read data from chip, protecting against concurrent updates
         * from this host, but not from other I2C masters.
@@ -486,12 +483,9 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)
        if (off + count > at24->byte_len)
                return -EINVAL;
 
-       ret = pm_runtime_get_sync(dev);
-       if (ret < 0) {
-               pm_runtime_put_noidle(dev);
+       ret = pm_runtime_resume_and_get(dev);
+       if (ret)
                return ret;
-       }
-
        /*
         * Write data to chip, protecting against concurrent updates
         * from this host, but not from other I2C masters.