Re: [BUG FIX] PM / cpu_domains: Check for NULL callbacks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 18, 2016 at 6:29 PM, Lina Iyer <lina.iyer@xxxxxxxxxx> wrote:
> Check for NULL platform callback before calling.
>
> Signed-off-by: Lina Iyer <lina.iyer@xxxxxxxxxx>
> ---
>  drivers/base/power/cpu_domains.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/power/cpu_domains.c b/drivers/base/power/cpu_domains.c
> index 7069411..bcaa474 100644
> --- a/drivers/base/power/cpu_domains.c
> +++ b/drivers/base/power/cpu_domains.c
> @@ -157,16 +157,22 @@ static int cpu_pd_power_on(struct generic_pm_domain *genpd)
>  {
>         struct cpu_pm_domain *pd = to_cpu_pd(genpd);
>
> -       return pd->ops.power_on();
> +       if (pd->ops.power_on)
> +               return pd->ops.power_on();
> +
> +       return 0;
>  }

I usually write things like that as

return pd->ops.power_on ? pd->ops.power_on() : 0;

That gets the job done in just one line of code instead of 4 and in
one statement instead of 3.

Thanks,
Rafael
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux