From 2045c352812e5a2eec0aa9d2b1e5d2fe1127b919 Mon Sep 17 00:00:00 2001 From: Manivannan Sadhasivam Date: Fri, 16 Jan 2026 12:23:04 -0600 Subject: [PATCH] PCI/pwrctrl: pwrseq: Factor out power on/off code to helpers In order to allow the pwrctrl core to control the power on/off logic of the pwrctrl pwrseq driver, move the power on/off code to pci_pwrctrl_pwrseq_power_{off/on} helper functions. Signed-off-by: Manivannan Sadhasivam Signed-off-by: Bjorn Helgaas Reviewed-by: Bartosz Golaszewski Link: https://patch.msgid.link/20260115-pci-pwrctrl-rework-v5-8-9d26da3ce903@oss.qualcomm.com --- drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c b/drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c index e33beda149cf..9b698c5426c5 100644 --- a/drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c +++ b/drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c @@ -52,11 +52,27 @@ static const struct pwrseq_pwrctrl_pdata pwrseq_pwrctrl_qcom_wcn_pdata = { .validate_device = pwrseq_pwrctrl_qcm_wcn_validate_device, }; +static int pwrseq_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl) +{ + struct pwrseq_pwrctrl *pwrseq = container_of(pwrctrl, + struct pwrseq_pwrctrl, pwrctrl); + + return pwrseq_power_on(pwrseq->pwrseq); +} + +static int pwrseq_pwrctrl_power_off(struct pci_pwrctrl *pwrctrl) +{ + struct pwrseq_pwrctrl *pwrseq = container_of(pwrctrl, + struct pwrseq_pwrctrl, pwrctrl); + + return pwrseq_power_off(pwrseq->pwrseq); +} + static void devm_pwrseq_pwrctrl_power_off(void *data) { - struct pwrseq_desc *pwrseq = data; + struct pwrseq_pwrctrl *pwrseq = data; - pwrseq_power_off(pwrseq); + pwrseq_pwrctrl_power_off(&pwrseq->pwrctrl); } static int pwrseq_pwrctrl_probe(struct platform_device *pdev) @@ -85,13 +101,13 @@ static int pwrseq_pwrctrl_probe(struct platform_device *pdev) return dev_err_probe(dev, PTR_ERR(pwrseq->pwrseq), "Failed to get the power sequencer\n"); - ret = pwrseq_power_on(pwrseq->pwrseq); + ret = pwrseq_pwrctrl_power_on(&pwrseq->pwrctrl); if (ret) return dev_err_probe(dev, ret, "Failed to power-on the device\n"); ret = devm_add_action_or_reset(dev, devm_pwrseq_pwrctrl_power_off, - pwrseq->pwrseq); + pwrseq); if (ret) return ret; -- 2.47.3