All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Hans de Goede <hdegoede@redhat.com>,
	Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
	mazziesaccount@gmail.com
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	MyungJoo Ham <myungjoo.ham@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Andy Gross <agross@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Jean Delvare <jdelvare@suse.com>,
	Mark Gross <mgross@linux.intel.com>,
	Sebastian Reichel <sre@kernel.org>, Chen-Yu Tsai <wens@csie.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Wim Van Sebroeck <wim@linux-watchdog.org>,
	Saravana Kannan <saravanak@google.com>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Joerg Roedel <jroedel@suse.de>,
	Dan Williams <dan.j.williams@intel.com>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-hwmon@vger.kernel.org, platform-driver-x86@vger.kernel.org,
	linux-pm@vger.kernel.org, linux-watchdog@vger.kernel.org
Subject: Re: [RFC PATCH 1/7] drivers: base: Add resource managed version of delayed work init
Date: Sat, 13 Feb 2021 10:17:29 -0800	[thread overview]
Message-ID: <7fc66c14-5dc5-d7b4-60ec-060bcf2d78cf@roeck-us.net> (raw)
In-Reply-To: <16140f5b-c504-1c07-9f0c-3813d686d157@redhat.com>

On 2/13/21 7:59 AM, Hans de Goede wrote:
> Hi,
> 
> On 2/13/21 4:27 PM, Guenter Roeck wrote:
>> On 2/13/21 7:03 AM, Hans de Goede wrote:
>> [ ... ]
>>>
>>> I think something like this should work:
>>>
>>> static int devm_delayed_work_autocancel(struct device *dev, struct delayed_work *w,
>>> 					void (*worker)(struct work_struct *work)) {
>>> 	INIT_DELAYED_WORK(w, worker);
>>> 	return devm_add_action(dev, (void (*action)(void *))cancel_delayed_work_sync, w);
>>> }
>>>
>>> I'm not sure about the cast, that may need something like this instead:
>>>
>>> typedef void (*devm_action_func)(void *);
>>>
>>> static int devm_delayed_work_autocancel(struct device *dev, struct delayed_work *w,
>>> 					void (*worker)(struct work_struct *work)) {
>>> 	INIT_DELAYED_WORK(w, worker);
>>> 	return devm_add_action(dev, (devm_action_func)cancel_delayed_work_sync, w);
>>
>> Unfortunately, you can not type cast function pointers in C. It is against the C ABI.
>> I am sure it is done in a few places in the kernel anyway, but those are wrong.
> 
> I see, bummer.
> 
>> This is the reason why many calls to devm_add_action() point to functions such as
>>
>> static void visconti_clk_disable_unprepare(void *data)
>> {
>>         clk_disable_unprepare(data);
>> }
>>
>> which could otherwise be handled using typecasts.
> 
> Hmm, wouldn't something like this be a candidate for adding a:
> 
> devm_clk_prepare_enable() helper?
> 
> This seems better then having the driver(s) make + error check separate
> clk_prepare_enable() + devm_add_action_or_reset() calls ?
> 

I don't really want to go there anymore. The maintainer rejected it several times.

Guenter

  reply	other threads:[~2021-02-13 18:18 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-13 11:58 [RFC PATCH 0/7] Add managed version of delayed work init Matti Vaittinen
2021-02-13 11:58 ` [RFC PATCH 1/7] drivers: base: Add resource " Matti Vaittinen
2021-02-13 12:16   ` Greg Kroah-Hartman
2021-02-13 12:26     ` Vaittinen, Matti
2021-02-13 12:38       ` gregkh
2021-02-13 13:18     ` Hans de Goede
2021-02-13 13:33       ` Greg Kroah-Hartman
2021-02-13 14:38         ` Hans de Goede
2021-02-13 14:52           ` Hans de Goede
2021-02-15  6:58       ` Matti Vaittinen
2021-02-13 15:03   ` Hans de Goede
2021-02-13 15:27     ` Guenter Roeck
2021-02-13 15:59       ` Hans de Goede
2021-02-13 18:17         ` Guenter Roeck [this message]
2021-02-15  7:22         ` Vaittinen, Matti
2021-02-15 10:37           ` Hans de Goede
2021-02-15 11:31             ` gregkh
2021-02-15 11:43               ` Hans de Goede
2021-02-15 13:12                 ` Vaittinen, Matti
2021-02-13 12:03 ` [RFC PATCH 2/7] extconn: Clean-up few drivers by using managed " Matti Vaittinen
2021-02-13 12:07 ` [RFC PATCH 3/7] hwmon: raspberry-pi: " Matti Vaittinen
2021-02-13 12:16   ` Greg Kroah-Hartman
2021-02-13 12:09 ` [RFC PATCH 4/7] platform/x86: gpd pocket fan: Clean-up " Matti Vaittinen
2021-02-13 12:12 ` [RFC PATCH 5/7] power: supply: Clean-up few drivers " Matti Vaittinen
2021-02-13 12:17   ` Greg Kroah-Hartman
2021-02-13 12:16 ` [RFC PATCH 6/7] regulator: qcom_spmi-regulator: Clean-up " Matti Vaittinen
2021-02-13 12:18 ` [RFC PATCH 7/7] watchdog: retu_wdt: " Matti Vaittinen
2021-02-18 16:28 ` [RFC PATCH 0/7] Add managed version of delayed " mark gross
2021-02-19 10:35   ` Matti Vaittinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7fc66c14-5dc5-d7b4-60ec-060bcf2d78cf@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=agross@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=broonie@kernel.org \
    --cc=cw00.choi@samsung.com \
    --cc=dan.j.williams@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jdelvare@suse.com \
    --cc=jroedel@suse.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=matti.vaittinen@fi.rohmeurope.com \
    --cc=mazziesaccount@gmail.com \
    --cc=mgross@linux.intel.com \
    --cc=myungjoo.ham@samsung.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=saravanak@google.com \
    --cc=sre@kernel.org \
    --cc=wens@csie.org \
    --cc=wim@linux-watchdog.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.