[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a45ed205-7c1b-a298-50c0-fc8b80a846c5@sigmadesigns.com>
Date: Wed, 11 Jan 2017 13:31:47 +0100
From: Marc Gonzalez <marc_gonzalez@...madesigns.com>
To: Guenter Roeck <linux@...ck-us.net>
CC: Wim Van Sebroeck <wim@...ana.be>, <linux-watchdog@...r.kernel.org>,
<linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
Mans Rullgard <mans@...sr.com>,
Thibaud Cornic <thibaud_cornic@...madesigns.com>,
Mark Rutland <mark.rutland@....com>,
Uwe Kleine-Konig <u.kleine-koenig@...gutronix.de>,
Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH 56/62] watchdog: tangox_wdt: Convert to use device managed
functions
On 11/01/2017 11:52, Guenter Roeck wrote:
> On 01/11/2017 01:07 AM, Marc Gonzalez wrote:
>
>>> @@ -134,12 +134,15 @@ static int tangox_wdt_probe(struct platform_device *pdev)
>>> err = clk_prepare_enable(dev->clk);
>>> if (err)
>>> return err;
>>> + err = devm_add_action_or_reset(&pdev->dev,
>>> + (void(*)(void *))clk_disable_unprepare,
>>> + dev->clk);
>>> + if (err)
>>> + return err;
>>
>> Hello Guenter,
>>
>> I would rather avoid the function pointer cast.
>> How about defining an auxiliary function for the cleanup action?
>>
>> clk_disable_unprepare() is static inline, so gcc will have to
>> define an auxiliary function either way. What do you think?
>
> Not really. It would just make it more complicated to replace the
> call with devm_clk_prepare_enable(), should it ever find its way
> into the light of day.
More complicated, because the cleanup function will have to be deleted later?
The compiler will warn if someone forgets to do that.
In my opinion, it's not a good idea to rely on the fact that casting
void(*)(struct clk *clk) to void(*)(void *) is likely to work as expected
on most platforms. (It has undefined behavior, strictly speaking.)
Do you really dislike the portable solution I suggested? :-(
Regards.
Powered by blists - more mailing lists