Re: [PATCH] powermac: Call of_node_put(bk_node) only once in pmac_has_backlight_type()

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

 



Christophe Leroy <christophe.leroy@xxxxxxxxxx> writes:
> Le 02/10/2024 à 22:02, Markus Elfring a écrit :
>> From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
>> Date: Wed, 2 Oct 2024 21:50:27 +0200
>> 
>> An of_node_put(bk_node) call was immediately used after a pointer check
>> for an of_get_property() call in this function implementation.
>> Thus call such a function only once instead directly before the check.
>
> It seems pointless to perform a put immediately after a get. Shouldn't 
> of_find_property() be used instead ? And then of_property_read_string() 
> would probably be better.
>
> Maybe you can even use of_property_match_string().

Yes that would clean it up nicely I think, eg:

int pmac_has_backlight_type(const char *type)
{
        struct device_node* bk_node = of_find_node_by_name(NULL, "backlight");
        int i;

        i = of_property_match_string(bk_node, "backlight-control", type);
        of_node_put(bk_node);

        return i >= 0;
}

cheers





[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux