提交 6defe9a0 编写于 作者: T Tomasz Figa 提交者: Linus Walleij

pinctrl: samsung: Hold pointer to driver data in bank struct

This patch is a preparation for converting the pinctrl-samsung driver to
one GPIO chip and IRQ domain per bank. It allows one having only
a pointer to particular bank struct to access driver data struct.
Signed-off-by: NTomasz Figa <t.figa@samsung.com>
Reviewed-by: NKyungmin Park <kyungmin.park@samsung.com>
Acked-by: NThomas Abraham <thomas.abraham@linaro.org>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 ab663789
...@@ -789,17 +789,18 @@ static const struct of_device_id samsung_pinctrl_dt_match[]; ...@@ -789,17 +789,18 @@ static const struct of_device_id samsung_pinctrl_dt_match[];
/* retrieve the soc specific data */ /* retrieve the soc specific data */
static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data( static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data(
struct samsung_pinctrl_drv_data *d,
struct platform_device *pdev) struct platform_device *pdev)
{ {
int id; int id;
const struct of_device_id *match; const struct of_device_id *match;
const struct device_node *node = pdev->dev.of_node; struct device_node *node = pdev->dev.of_node;
struct device_node *np; struct device_node *np;
struct samsung_pin_ctrl *ctrl; struct samsung_pin_ctrl *ctrl;
struct samsung_pin_bank *bank; struct samsung_pin_bank *bank;
int i; int i;
id = of_alias_get_id(pdev->dev.of_node, "pinctrl"); id = of_alias_get_id(node, "pinctrl");
if (id < 0) { if (id < 0) {
dev_err(&pdev->dev, "failed to get alias id\n"); dev_err(&pdev->dev, "failed to get alias id\n");
return NULL; return NULL;
...@@ -809,6 +810,7 @@ static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data( ...@@ -809,6 +810,7 @@ static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data(
bank = ctrl->pin_banks; bank = ctrl->pin_banks;
for (i = 0; i < ctrl->nr_banks; ++i, ++bank) { for (i = 0; i < ctrl->nr_banks; ++i, ++bank) {
bank->drvdata = d;
bank->pin_base = ctrl->nr_pins; bank->pin_base = ctrl->nr_pins;
ctrl->nr_pins += bank->nr_pins; ctrl->nr_pins += bank->nr_pins;
if (bank->eint_type == EINT_TYPE_GPIO) { if (bank->eint_type == EINT_TYPE_GPIO) {
...@@ -848,18 +850,18 @@ static int __devinit samsung_pinctrl_probe(struct platform_device *pdev) ...@@ -848,18 +850,18 @@ static int __devinit samsung_pinctrl_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
} }
ctrl = samsung_pinctrl_get_soc_data(pdev);
if (!ctrl) {
dev_err(&pdev->dev, "driver data not available\n");
return -EINVAL;
}
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
if (!drvdata) { if (!drvdata) {
dev_err(dev, "failed to allocate memory for driver's " dev_err(dev, "failed to allocate memory for driver's "
"private data\n"); "private data\n");
return -ENOMEM; return -ENOMEM;
} }
ctrl = samsung_pinctrl_get_soc_data(drvdata, pdev);
if (!ctrl) {
dev_err(&pdev->dev, "driver data not available\n");
return -EINVAL;
}
drvdata->ctrl = ctrl; drvdata->ctrl = ctrl;
drvdata->dev = dev; drvdata->dev = dev;
......
...@@ -112,6 +112,7 @@ struct samsung_pinctrl_drv_data; ...@@ -112,6 +112,7 @@ struct samsung_pinctrl_drv_data;
* @irq_base: starting controller local irq number of the bank. * @irq_base: starting controller local irq number of the bank.
* @name: name to be prefixed for each pin in this pin bank. * @name: name to be prefixed for each pin in this pin bank.
* @of_node: OF node of the bank. * @of_node: OF node of the bank.
* @drvdata: link to controller driver data
*/ */
struct samsung_pin_bank { struct samsung_pin_bank {
u32 pctl_offset; u32 pctl_offset;
...@@ -126,6 +127,7 @@ struct samsung_pin_bank { ...@@ -126,6 +127,7 @@ struct samsung_pin_bank {
u32 irq_base; u32 irq_base;
char *name; char *name;
struct device_node *of_node; struct device_node *of_node;
struct samsung_pinctrl_drv_data *drvdata;
}; };
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册