Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PCI/pwrctrl: slot: 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 slot driver, move the power on/off code to
pci_pwrctrl_slot_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-7-9d26da3ce903@oss.qualcomm.com

authored by

Manivannan Sadhasivam and committed by
Bjorn Helgaas
0afc90ce 370d2de0

+35 -14
+35 -14
drivers/pci/pwrctrl/slot.c
··· 17 17 struct pci_pwrctrl pwrctrl; 18 18 struct regulator_bulk_data *supplies; 19 19 int num_supplies; 20 + struct clk *clk; 20 21 }; 21 22 22 - static void devm_slot_pwrctrl_power_off(void *data) 23 + static int slot_pwrctrl_power_on(struct pci_pwrctrl *pwrctrl) 24 + { 25 + struct slot_pwrctrl *slot = container_of(pwrctrl, 26 + struct slot_pwrctrl, pwrctrl); 27 + int ret; 28 + 29 + ret = regulator_bulk_enable(slot->num_supplies, slot->supplies); 30 + if (ret < 0) { 31 + dev_err(slot->pwrctrl.dev, "Failed to enable slot regulators\n"); 32 + return ret; 33 + } 34 + 35 + return clk_prepare_enable(slot->clk); 36 + } 37 + 38 + static int slot_pwrctrl_power_off(struct pci_pwrctrl *pwrctrl) 39 + { 40 + struct slot_pwrctrl *slot = container_of(pwrctrl, 41 + struct slot_pwrctrl, pwrctrl); 42 + 43 + regulator_bulk_disable(slot->num_supplies, slot->supplies); 44 + clk_disable_unprepare(slot->clk); 45 + 46 + return 0; 47 + } 48 + 49 + static void devm_slot_pwrctrl_release(void *data) 23 50 { 24 51 struct slot_pwrctrl *slot = data; 25 52 26 - regulator_bulk_disable(slot->num_supplies, slot->supplies); 53 + slot_pwrctrl_power_off(&slot->pwrctrl); 27 54 regulator_bulk_free(slot->num_supplies, slot->supplies); 28 55 } 29 56 ··· 58 31 { 59 32 struct slot_pwrctrl *slot; 60 33 struct device *dev = &pdev->dev; 61 - struct clk *clk; 62 34 int ret; 63 35 64 36 slot = devm_kzalloc(dev, sizeof(*slot), GFP_KERNEL); ··· 72 46 } 73 47 74 48 slot->num_supplies = ret; 75 - ret = regulator_bulk_enable(slot->num_supplies, slot->supplies); 76 - if (ret < 0) { 77 - dev_err_probe(dev, ret, "Failed to enable slot regulators\n"); 78 - regulator_bulk_free(slot->num_supplies, slot->supplies); 79 - return ret; 80 - } 81 49 82 - ret = devm_add_action_or_reset(dev, devm_slot_pwrctrl_power_off, 83 - slot); 50 + ret = devm_add_action_or_reset(dev, devm_slot_pwrctrl_release, slot); 84 51 if (ret) 85 52 return ret; 86 53 87 - clk = devm_clk_get_optional_enabled(dev, NULL); 88 - if (IS_ERR(clk)) { 89 - return dev_err_probe(dev, PTR_ERR(clk), 54 + slot->clk = devm_clk_get_optional(dev, NULL); 55 + if (IS_ERR(slot->clk)) { 56 + return dev_err_probe(dev, PTR_ERR(slot->clk), 90 57 "Failed to enable slot clock\n"); 91 58 } 59 + 60 + slot_pwrctrl_power_on(&slot->pwrctrl); 92 61 93 62 pci_pwrctrl_init(&slot->pwrctrl, dev); 94 63