lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJZ5v0jHYQHKsg=5OLCUuv=x2F0YN1D_VF984VKDKa7t-1rHJg@mail.gmail.com>
Date:   Fri, 13 Jan 2023 21:01:17 +0100
From:   "Rafael J. Wysocki" <rafael@...nel.org>
To:     Bjorn Helgaas <helgaas@...nel.org>
Cc:     "Rafael J . Wysocki" <rafael@...nel.org>,
        Len Brown <len.brown@...el.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
        Bjorn Helgaas <bhelgaas@...gle.com>
Subject: Re: [PATCH] PM: runtime: Simplify __rpm_get_callback()

On Thu, Dec 15, 2022 at 7:19 PM Bjorn Helgaas <helgaas@...nel.org> wrote:
>
> From: Bjorn Helgaas <bhelgaas@...gle.com>
>
> Simplify __rpm_get_callback() slightly by returning as soon as the return
> value is known.  No functional change intended.
>
> Signed-off-by: Bjorn Helgaas <bhelgaas@...gle.com>
> ---
>  drivers/base/power/runtime.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> index 50e726b6c2cf..7171ed0668f3 100644
> --- a/drivers/base/power/runtime.c
> +++ b/drivers/base/power/runtime.c
> @@ -20,8 +20,7 @@ typedef int (*pm_callback_t)(struct device *);
>
>  static pm_callback_t __rpm_get_callback(struct device *dev, size_t cb_offset)
>  {
> -       pm_callback_t cb;
> -       const struct dev_pm_ops *ops;
> +       const struct dev_pm_ops *ops = NULL;
>
>         if (dev->pm_domain)
>                 ops = &dev->pm_domain->ops;
> @@ -31,18 +30,14 @@ static pm_callback_t __rpm_get_callback(struct device *dev, size_t cb_offset)
>                 ops = dev->class->pm;
>         else if (dev->bus && dev->bus->pm)
>                 ops = dev->bus->pm;
> -       else
> -               ops = NULL;
>
>         if (ops)
> -               cb = *(pm_callback_t *)((void *)ops + cb_offset);
> -       else
> -               cb = NULL;
> +               return *(pm_callback_t *)((void *)ops + cb_offset);
>
> -       if (!cb && dev->driver && dev->driver->pm)
> -               cb = *(pm_callback_t *)((void *)dev->driver->pm + cb_offset);
> +       if (dev->driver && dev->driver->pm)
> +               return *(pm_callback_t *)((void *)dev->driver->pm + cb_offset);
>
> -       return cb;
> +       return NULL;
>  }
>
>  #define RPM_GET_CALLBACK(dev, callback) \
> --

Applied as 6.3 material, thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ