[PATCH v5 039/111] pwm: Provide wrappers for storing and getting driver private data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- To: linux-pwm@xxxxxxxxxxxxxxx, Hector Martin <marcan@xxxxxxxxx>, Sven Peter <sven@xxxxxxxxxxxxx>, Nicolas Ferre <nicolas.ferre@xxxxxxxxxxxxx>, Alexandre Belloni <alexandre.belloni@xxxxxxxxxxx>, Claudiu Beznea <claudiu.beznea@xxxxxxxxx>, Florian Fainelli <florian.fainelli@xxxxxxxxxxxx>, Ray Jui <rjui@xxxxxxxxxxxx>, Scott Branden <sbranden@xxxxxxxxxxxx>, Alexander Shiyan <shc_work@xxxxxxx>, Benson Leung <bleung@xxxxxxxxxxxx>, Shawn Guo <shawnguo@xxxxxxxxxx>, Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>, Paul Cercueil <paul@xxxxxxxxxxxxxxx>, Vladimir Zapolskiy <vz@xxxxxxxxx>, Hans de Goede <hdegoede@xxxxxxxxxx>, Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>, Matthias Brugger <matthias.bgg@xxxxxxxxx>, AngeloGioacchino Del Regno <angelogioacchino.delregno@xxxxxxxxxxxxx>, Neil Armstrong <neil.armstrong@xxxxxxxxxx>, Kevin Hilman <khilman@xxxxxxxxxxxx>, Conor Dooley <conor.dooley@xxxxxxxxxxxxx>, Daire McNamara <daire.mcnamara@xxxxxxxxxxxxx>, Jonathan Neuschäfer <j.neuschaefer@xxxxxxx>, Heiko Stuebner <heiko@xxxxxxxxx>, Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxx>, Palmer Dabbelt <palmer@xxxxxxxxxxx>, Paul Walmsley <paul.walmsley@xxxxxxxxxx>, Michael Walle <mwalle@xxxxxxxxxx>, Orson Zhai <orsonzhai@xxxxxxxxx>, Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>, Chunyan Zhang <zhang.lyra@xxxxxxxxx>, Fabrice Gasnier <fabrice.gasnier@xxxxxxxxxxx>, Maxime Coquelin <mcoquelin.stm32@xxxxxxxxx>, Alexandre Torgue <alexandre.torgue@xxxxxxxxxxx>, Chen-Yu Tsai <wens@xxxxxxxx>, Jernej Skrabec <jernej.skrabec@xxxxxxxxx>, Samuel Holland <samuel@xxxxxxxxxxxx>, Hammer Hsieh <hammerh0314@xxxxxxxxx>, Thierry Reding <thierry.reding@xxxxxxxxx>, Jonathan Hunter <jonathanh@xxxxxxxxxx>, Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@xxxxxxxxxxxxx>, Sean Anderson <sean.anderson@xxxxxxxx>, Michal Simek <michal.simek@xxxxxxx>, Linus Walleij <linus.walleij@xxxxxxxxxx>, Bartosz Golaszewski <brgl@xxxxxxxx>, Andrzej Hajda <andrzej.hajda@xxxxxxxxx>, Robert Foss <rfoss@xxxxxxxxxx>, Maarten Lankhorst <maarten.lankhorst@xxxxxxxxxxxxxxx>, Maxime Ripard <mripard@xxxxxxxxxx>, Thomas Zimmermann <tzimmermann@xxxxxxx>, David Airlie <airlied@xxxxxxxxx>, Daniel Vetter <daniel@xxxxxxxx>, Pavel Machek <pavel@xxxxxx>, Lee Jones <lee@xxxxxxxxxx>, Anjelique Melendez <quic_amelende@xxxxxxxxxxx>, Andi Shyti <andi.shyti@xxxxxxxxxx>, Lu Hongfei <luhongfei@xxxxxxxx>, Bjorn Andersson <quic_bjorande@xxxxxxxxxxx>, Luca Weiss <luca@xxxxxxxxx>, Johan Hovold <johan@xxxxxxxxxx>, Alex Elder <elder@xxxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
- Subject: [PATCH v5 039/111] pwm: Provide wrappers for storing and getting driver private data
- From: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
- Date: Thu, 25 Jan 2024 13:09:01 +0100
- In-reply-to: <cover.1706182805.git.u.kleine-koenig@pengutronix.de>
- References: <cover.1706182805.git.u.kleine-koenig@pengutronix.de>
These functions are useful to store and query driver private data a
After struct pwm_chip got its own struct device, this can make use of
dev_get_drvdata() and dev_set_drvdata() on that device. These functions
are required already now to convert drivers to pwmchip_alloc() which
must happen before changing pwm_chip::dev.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
---
include/linux/pwm.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/include/linux/pwm.h b/include/linux/pwm.h
index d7966918f301..2c49d2fe2fe7 100644
--- a/include/linux/pwm.h
+++ b/include/linux/pwm.h
@@ -272,6 +272,7 @@ struct pwm_ops {
* @npwm: number of PWMs controlled by this chip
* @of_xlate: request a PWM device given a device tree PWM specifier
* @atomic: can the driver's ->apply() be called in atomic context
+ * @driver_data: Private pointer for driver specific info
* @pwms: array of PWM devices allocated by the framework
*/
struct pwm_chip {
@@ -286,6 +287,7 @@ struct pwm_chip {
bool atomic;
/* only used internally by the PWM framework */
+ void *driver_data;
struct pwm_device *pwms;
};
@@ -294,6 +296,24 @@ static inline struct device *pwmchip_parent(struct pwm_chip *chip)
return chip->dev;
}
+static inline void *pwmchip_get_drvdata(struct pwm_chip *chip)
+{
+ /*
+ * After pwm_chip got a dedicated struct device, this can be replaced by
+ * dev_get_drvdata(&chip->dev);
+ */
+ return chip->driver_data;
+}
+
+static inline void pwmchip_set_drvdata(struct pwm_chip *chip, void *data)
+{
+ /*
+ * After pwm_chip got a dedicated struct device, this can be replaced by
+ * dev_set_drvdata(&chip->dev, data);
+ */
+ chip->driver_data = data;
+}
+
#if IS_ENABLED(CONFIG_PWM)
/* PWM user APIs */
int pwm_apply_might_sleep(struct pwm_device *pwm, const struct pwm_state *state);
--
2.43.0
_______________________________________________
greybus-dev mailing list -- greybus-dev@xxxxxxxxxxxxxxxx
To unsubscribe send an email to greybus-dev-leave@xxxxxxxxxxxxxxxx
[Index of Archives]
[Asterisk App Development]
[PJ SIP]
[Gnu Gatekeeper]
[IETF Sipping]
[Info Cyrus]
[ALSA User]
[Fedora Linux Users]
[Linux SCTP]
[DCCP]
[Gimp]
[Yosemite News]
[Deep Creek Hot Springs]
[Yosemite Campsites]
[ISDN Cause Codes]
[Asterisk Books]