From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 343CFC43381 for ; Thu, 18 Feb 2021 18:35:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00DED64EB3 for ; Thu, 18 Feb 2021 18:35:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232468AbhBRSfT (ORCPT ); Thu, 18 Feb 2021 13:35:19 -0500 Received: from mga18.intel.com ([134.134.136.126]:24502 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233602AbhBRQbv (ORCPT ); Thu, 18 Feb 2021 11:31:51 -0500 IronPort-SDR: bEyzum6oA3kRNfGD43MyymPdSDcJ+YLrFnc3BUYF/gw9kptZX4OG1ZwNBsD3WxCrvDUs5uAT7K NywfAw+4poJQ== X-IronPort-AV: E=McAfee;i="6000,8403,9898"; a="171226748" X-IronPort-AV: E=Sophos;i="5.81,187,1610438400"; d="scan'208";a="171226748" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Feb 2021 08:28:22 -0800 IronPort-SDR: 8wV6FNxP8SE0d4WHFpdRVuaFuCTVydh3gBnRbO6D/bXLTESQYwmiHqSvYcvTGhorUg/aee8is/ q6876h3NGC7Q== X-IronPort-AV: E=Sophos;i="5.81,187,1610438400"; d="scan'208";a="367582619" Received: from smtp.ostc.intel.com ([10.54.29.231]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Feb 2021 08:28:21 -0800 Received: from localhost (mtg-dev.jf.intel.com [10.54.74.10]) by smtp.ostc.intel.com (Postfix) with ESMTP id 25BFD6365; Thu, 18 Feb 2021 08:28:21 -0800 (PST) Date: Thu, 18 Feb 2021 08:28:21 -0800 From: mark gross To: Matti Vaittinen Cc: mazziesaccount@gmail.com, Greg Kroah-Hartman , "Rafael J. Wysocki" , MyungJoo Ham , Chanwoo Choi , Andy Gross , Bjorn Andersson , Jean Delvare , Guenter Roeck , Hans de Goede , Mark Gross , Sebastian Reichel , Chen-Yu Tsai , Liam Girdwood , Mark Brown , Wim Van Sebroeck , Saravana Kannan , Heikki Krogerus , Andy Shevchenko , Joerg Roedel , Dan Williams , Bartosz Golaszewski , 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 0/7] Add managed version of delayed work init Message-ID: <20210218162821.GP154917@linux.intel.com> Reply-To: mgross@linux.intel.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org On Sat, Feb 13, 2021 at 01:58:17PM +0200, Matti Vaittinen wrote: > It's not rare that device drivers need delayed work. > It's not rare that this work needs driver's data. > > Often this means that driver must ensure the work is not queued when > driver exits. Usually this is done by ensuring new work is not added and > then calling cancel_delayed_work_sync() at remove(). In many cases this > may also require cleanup at probe error path - which is easy to forget. > > It might be helpful for (a) few drivers if there was a work init why the (a) and not just a? > function which would ensure cancel_delayed_work_sync() is called at > driver exit. So this series implements one on top of devm and replaces > the obvious cases where only thing remove call-back in a driver does is > cancelling the work. There might be other cases where we could switch > more than just work cancellation to use managed version and thus get rid > of remove. > > Main reson why this is RFC is that I had hard time deciding where this > function should be introduced. It's not nice to include all device stuff > in workqueue - because many workqueue users are not interested in > devices. In same way, not all of the devices are interested in WQs. > OTOH, adding own file just for this sounds like an overkill. s/own/one --mark > > This time I decided that it is more correct that devices use WQs than > that WQs use devices. Hence the function is introduced in > include/linux/device.h and drivers/base/devres.c > > -- > > Matti Vaittinen (7): > drivers: base: Add resource managed version of delayed work init > extconn: Clean-up few drivers by using managed work init > hwmon: raspberry-pi: Clean-up few drivers by using managed work init > platform/x86: gpd pocket fan: Clean-up by using managed work init > power: supply: Clean-up few drivers by using managed work init > regulator: qcom_spmi-regulator: Clean-up by using managed work init > watchdog: retu_wdt: Clean-up by using managed work init > > drivers/base/devres.c | 33 ++++++++++++++++++++ > drivers/extcon/extcon-gpio.c | 14 ++------- > drivers/extcon/extcon-intel-int3496.c | 15 ++------- > drivers/extcon/extcon-palmas.c | 16 +++------- > drivers/extcon/extcon-qcom-spmi-misc.c | 16 +++------- > drivers/hwmon/raspberrypi-hwmon.c | 16 +++------- > drivers/platform/x86/gpd-pocket-fan.c | 16 +++------- > drivers/power/supply/axp20x_usb_power.c | 15 +++------ > drivers/power/supply/bq24735-charger.c | 17 +++------- > drivers/power/supply/ltc2941-battery-gauge.c | 19 ++++------- > drivers/power/supply/sbs-battery.c | 15 +++------ > drivers/regulator/qcom_spmi-regulator.c | 33 +++++--------------- > drivers/watchdog/retu_wdt.c | 21 +++---------- > include/linux/device.h | 5 +++ > 14 files changed, 95 insertions(+), 156 deletions(-) > > > base-commit: 92bf22614b21a2706f4993b278017e437f7785b3 > -- > 2.25.4 > > > -- > Matti Vaittinen, Linux device drivers > ROHM Semiconductors, Finland SWDC > Kiviharjunlenkki 1E > 90220 OULU > FINLAND > > ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ > Simon says - in Latin please. > ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ > Thanks to Simon Glass for the translation =]