]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI/pwrctrl: pwrseq: Factor out power on/off code to helpers
authorManivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Fri, 16 Jan 2026 18:23:04 +0000 (12:23 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 16 Jan 2026 19:23:37 +0000 (13:23 -0600)
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 <manivannan.sadhasivam@oss.qualcomm.com
>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260115-pci-pwrctrl-rework-v5-8-9d26da3ce903@oss.qualcomm.com
drivers/pci/pwrctrl/pci-pwrctrl-pwrseq.c

index e33beda149cfe5c589e3a071de8a9029a6df4b7d..9b698c5426c50ad74d00565840f9b29073c06c5c 100644 (file)
@@ -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;