diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2020-07-29 14:57:06 +0300 |
---|---|---|
committer | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2020-08-18 16:46:39 +0300 |
commit | ff360d62d9fe02081431412e05950a23f71ec98a (patch) | |
tree | 3cca88f0e336db20672e34e9518bb50eb6097f9c /drivers/pinctrl/intel | |
parent | 359164fa730c45641ec597f48ab33c03d955e824 (diff) |
pinctrl: intel: Extract intel_pinctrl_get_soc_data() helper for wider use
intel_pinctrl_get_soc_data() helper can be used in few driver instead of
open-coded variants. Thus, extract it as a standalone API.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/pinctrl/intel')
-rw-r--r-- | drivers/pinctrl/intel/pinctrl-intel.c | 24 | ||||
-rw-r--r-- | drivers/pinctrl/intel/pinctrl-intel.h | 2 |
2 files changed, 20 insertions, 6 deletions
diff --git a/drivers/pinctrl/intel/pinctrl-intel.c b/drivers/pinctrl/intel/pinctrl-intel.c index b64997b303e0..154ce3f908cd 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.c +++ b/drivers/pinctrl/intel/pinctrl-intel.c @@ -1414,9 +1414,6 @@ static int intel_pinctrl_probe(struct platform_device *pdev, struct intel_pinctrl *pctrl; int i, ret, irq; - if (!soc_data) - return -EINVAL; - pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL); if (!pctrl) return -ENOMEM; @@ -1505,12 +1502,27 @@ int intel_pinctrl_probe_by_hid(struct platform_device *pdev) const struct intel_pinctrl_soc_data *data; data = device_get_match_data(&pdev->dev); + if (!data) + return -ENODATA; + return intel_pinctrl_probe(pdev, data); } EXPORT_SYMBOL_GPL(intel_pinctrl_probe_by_hid); int intel_pinctrl_probe_by_uid(struct platform_device *pdev) { + const struct intel_pinctrl_soc_data *data; + + data = intel_pinctrl_get_soc_data(pdev); + if (IS_ERR(data)) + return PTR_ERR(data); + + return intel_pinctrl_probe(pdev, data); +} +EXPORT_SYMBOL_GPL(intel_pinctrl_probe_by_uid); + +const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_device *pdev) +{ const struct intel_pinctrl_soc_data *data = NULL; const struct intel_pinctrl_soc_data **table; struct acpi_device *adev; @@ -1532,15 +1544,15 @@ int intel_pinctrl_probe_by_uid(struct platform_device *pdev) id = platform_get_device_id(pdev); if (!id) - return -ENODEV; + return ERR_PTR(-ENODEV); table = (const struct intel_pinctrl_soc_data **)id->driver_data; data = table[pdev->id]; } - return intel_pinctrl_probe(pdev, data); + return data ?: ERR_PTR(-ENODATA); } -EXPORT_SYMBOL_GPL(intel_pinctrl_probe_by_uid); +EXPORT_SYMBOL_GPL(intel_pinctrl_get_soc_data); #ifdef CONFIG_PM_SLEEP static bool intel_pinctrl_should_save(struct intel_pinctrl *pctrl, unsigned int pin) diff --git a/drivers/pinctrl/intel/pinctrl-intel.h b/drivers/pinctrl/intel/pinctrl-intel.h index 4e17308d33e9..3b0564ae9b15 100644 --- a/drivers/pinctrl/intel/pinctrl-intel.h +++ b/drivers/pinctrl/intel/pinctrl-intel.h @@ -194,6 +194,8 @@ struct intel_pinctrl_soc_data { size_t ncommunities; }; +const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_device *pdev); + struct intel_pad_context; struct intel_community_context; |