Commit ff360d62 authored by Andy Shevchenko's avatar Andy Shevchenko

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
parent 359164fa
...@@ -1414,9 +1414,6 @@ static int intel_pinctrl_probe(struct platform_device *pdev, ...@@ -1414,9 +1414,6 @@ static int intel_pinctrl_probe(struct platform_device *pdev,
struct intel_pinctrl *pctrl; struct intel_pinctrl *pctrl;
int i, ret, irq; int i, ret, irq;
if (!soc_data)
return -EINVAL;
pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL); pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);
if (!pctrl) if (!pctrl)
return -ENOMEM; return -ENOMEM;
...@@ -1505,11 +1502,26 @@ int intel_pinctrl_probe_by_hid(struct platform_device *pdev) ...@@ -1505,11 +1502,26 @@ int intel_pinctrl_probe_by_hid(struct platform_device *pdev)
const struct intel_pinctrl_soc_data *data; const struct intel_pinctrl_soc_data *data;
data = device_get_match_data(&pdev->dev); data = device_get_match_data(&pdev->dev);
if (!data)
return -ENODATA;
return intel_pinctrl_probe(pdev, data); return intel_pinctrl_probe(pdev, data);
} }
EXPORT_SYMBOL_GPL(intel_pinctrl_probe_by_hid); EXPORT_SYMBOL_GPL(intel_pinctrl_probe_by_hid);
int intel_pinctrl_probe_by_uid(struct platform_device *pdev) 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 *data = NULL;
const struct intel_pinctrl_soc_data **table; const struct intel_pinctrl_soc_data **table;
...@@ -1532,15 +1544,15 @@ int intel_pinctrl_probe_by_uid(struct platform_device *pdev) ...@@ -1532,15 +1544,15 @@ int intel_pinctrl_probe_by_uid(struct platform_device *pdev)
id = platform_get_device_id(pdev); id = platform_get_device_id(pdev);
if (!id) if (!id)
return -ENODEV; return ERR_PTR(-ENODEV);
table = (const struct intel_pinctrl_soc_data **)id->driver_data; table = (const struct intel_pinctrl_soc_data **)id->driver_data;
data = table[pdev->id]; 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 #ifdef CONFIG_PM_SLEEP
static bool intel_pinctrl_should_save(struct intel_pinctrl *pctrl, unsigned int pin) static bool intel_pinctrl_should_save(struct intel_pinctrl *pctrl, unsigned int pin)
......
...@@ -194,6 +194,8 @@ struct intel_pinctrl_soc_data { ...@@ -194,6 +194,8 @@ struct intel_pinctrl_soc_data {
size_t ncommunities; size_t ncommunities;
}; };
const struct intel_pinctrl_soc_data *intel_pinctrl_get_soc_data(struct platform_device *pdev);
struct intel_pad_context; struct intel_pad_context;
struct intel_community_context; struct intel_community_context;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment