From: Manivannan Sadhasivam Date: Tue, 19 May 2026 08:56:01 +0000 (+0530) Subject: power: sequencing: Add an API to return the pwrseq device's 'dev' pointer X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9085f71285375485c86c06071a13111606b404d7;p=thirdparty%2Fkernel%2Flinux.git power: sequencing: Add an API to return the pwrseq device's 'dev' pointer The consumer drivers can make use of the pwrseq device's 'dev' pointer to query the pwrseq provider's DT node to check for existence of specific properties. Hence, add an API to return the pwrseq device's 'dev' pointer to consumers. Note that since pwrseq_get() would've increased the pwrseq refcount, there is no need to increase the refcount in this API again. Tested-by: Wei Deng Signed-off-by: Manivannan Sadhasivam Link: https://patch.msgid.link/20260519-pwrseq-m2-bt-v3-6-b39dc2ae3966@oss.qualcomm.com Signed-off-by: Bartosz Golaszewski --- diff --git a/drivers/power/sequencing/core.c b/drivers/power/sequencing/core.c index 14335c4f813ed..89694092981f7 100644 --- a/drivers/power/sequencing/core.c +++ b/drivers/power/sequencing/core.c @@ -965,6 +965,29 @@ int pwrseq_power_off(struct pwrseq_desc *desc) } EXPORT_SYMBOL_GPL(pwrseq_power_off); +/** + * pwrseq_to_device() - Get the pwrseq device pointer from a descriptor. + * @desc: Descriptor referencing the power sequencer. + * + * Return the 'dev' pointer of the power sequencer device associated with @desc. + * Consumer drivers can use this to query the pwrseq provider's device tree + * node, for example to check for the existence of specific properties. + * + * Since pwrseq_get() already takes a reference to the pwrseq device, this + * function does not take an additional reference. + * + * Returns: + * Pointer to the pwrseq struct device, or NULL if @desc is NULL. + */ +struct device *pwrseq_to_device(struct pwrseq_desc *desc) +{ + if (!desc) + return NULL; + + return &desc->pwrseq->dev; +} +EXPORT_SYMBOL_GPL(pwrseq_to_device); + #if IS_ENABLED(CONFIG_DEBUG_FS) struct pwrseq_debugfs_count_ctx { diff --git a/include/linux/pwrseq/consumer.h b/include/linux/pwrseq/consumer.h index 7d583b4f266e6..3c907c9e1885d 100644 --- a/include/linux/pwrseq/consumer.h +++ b/include/linux/pwrseq/consumer.h @@ -23,6 +23,8 @@ devm_pwrseq_get(struct device *dev, const char *target); int pwrseq_power_on(struct pwrseq_desc *desc); int pwrseq_power_off(struct pwrseq_desc *desc); +struct device *pwrseq_to_device(struct pwrseq_desc *desc); + #else /* CONFIG_POWER_SEQUENCING */ static inline struct pwrseq_desc * __must_check @@ -51,6 +53,11 @@ static inline int pwrseq_power_off(struct pwrseq_desc *desc) return -ENOSYS; } +static inline struct device *pwrseq_to_device(struct pwrseq_desc *desc) +{ + return NULL; +} + #endif /* CONFIG_POWER_SEQUENCING */ #endif /* __POWER_SEQUENCING_CONSUMER_H__ */