aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorTomasz Figa <t.figa@samsung.com>2012-10-11 04:11:14 -0400
committerLinus Walleij <linus.walleij@linaro.org>2012-10-15 03:10:12 -0400
commit6defe9a0ddc59aa2302473aa3c8b3fdb543fdc1b (patch)
treeb02012ccec313a8833676060fb9f648e5e7f4700 /drivers/pinctrl
parentab663789d69760d2735402f66501f20b60312a3d (diff)
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: Tomasz Figa <t.figa@samsung.com> Reviewed-by: Kyungmin Park <kyungmin.park@samsung.com> Acked-by: Thomas Abraham <thomas.abraham@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/pinctrl-samsung.c18
-rw-r--r--drivers/pinctrl/pinctrl-samsung.h2
2 files changed, 12 insertions, 8 deletions
diff --git a/drivers/pinctrl/pinctrl-samsung.c b/drivers/pinctrl/pinctrl-samsung.c
index f266710a1b04..53493c3c35ff 100644
--- a/drivers/pinctrl/pinctrl-samsung.c
+++ b/drivers/pinctrl/pinctrl-samsung.c
@@ -789,17 +789,18 @@ static const struct of_device_id samsung_pinctrl_dt_match[];
789 789
790/* retrieve the soc specific data */ 790/* retrieve the soc specific data */
791static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data( 791static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data(
792 struct samsung_pinctrl_drv_data *d,
792 struct platform_device *pdev) 793 struct platform_device *pdev)
793{ 794{
794 int id; 795 int id;
795 const struct of_device_id *match; 796 const struct of_device_id *match;
796 const struct device_node *node = pdev->dev.of_node; 797 struct device_node *node = pdev->dev.of_node;
797 struct device_node *np; 798 struct device_node *np;
798 struct samsung_pin_ctrl *ctrl; 799 struct samsung_pin_ctrl *ctrl;
799 struct samsung_pin_bank *bank; 800 struct samsung_pin_bank *bank;
800 int i; 801 int i;
801 802
802 id = of_alias_get_id(pdev->dev.of_node, "pinctrl"); 803 id = of_alias_get_id(node, "pinctrl");
803 if (id < 0) { 804 if (id < 0) {
804 dev_err(&pdev->dev, "failed to get alias id\n"); 805 dev_err(&pdev->dev, "failed to get alias id\n");
805 return NULL; 806 return NULL;
@@ -809,6 +810,7 @@ static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data(
809 810
810 bank = ctrl->pin_banks; 811 bank = ctrl->pin_banks;
811 for (i = 0; i < ctrl->nr_banks; ++i, ++bank) { 812 for (i = 0; i < ctrl->nr_banks; ++i, ++bank) {
813 bank->drvdata = d;
812 bank->pin_base = ctrl->nr_pins; 814 bank->pin_base = ctrl->nr_pins;
813 ctrl->nr_pins += bank->nr_pins; 815 ctrl->nr_pins += bank->nr_pins;
814 if (bank->eint_type == EINT_TYPE_GPIO) { 816 if (bank->eint_type == EINT_TYPE_GPIO) {
@@ -848,18 +850,18 @@ static int __devinit samsung_pinctrl_probe(struct platform_device *pdev)
848 return -ENODEV; 850 return -ENODEV;
849 } 851 }
850 852
851 ctrl = samsung_pinctrl_get_soc_data(pdev);
852 if (!ctrl) {
853 dev_err(&pdev->dev, "driver data not available\n");
854 return -EINVAL;
855 }
856
857 drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL); 853 drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
858 if (!drvdata) { 854 if (!drvdata) {
859 dev_err(dev, "failed to allocate memory for driver's " 855 dev_err(dev, "failed to allocate memory for driver's "
860 "private data\n"); 856 "private data\n");
861 return -ENOMEM; 857 return -ENOMEM;
862 } 858 }
859
860 ctrl = samsung_pinctrl_get_soc_data(drvdata, pdev);
861 if (!ctrl) {
862 dev_err(&pdev->dev, "driver data not available\n");
863 return -EINVAL;
864 }
863 drvdata->ctrl = ctrl; 865 drvdata->ctrl = ctrl;
864 drvdata->dev = dev; 866 drvdata->dev = dev;
865 867
diff --git a/drivers/pinctrl/pinctrl-samsung.h b/drivers/pinctrl/pinctrl-samsung.h
index 5c53f32cca06..ea5dadd35913 100644
--- a/drivers/pinctrl/pinctrl-samsung.h
+++ b/drivers/pinctrl/pinctrl-samsung.h
@@ -112,6 +112,7 @@ struct samsung_pinctrl_drv_data;
112 * @irq_base: starting controller local irq number of the bank. 112 * @irq_base: starting controller local irq number of the bank.
113 * @name: name to be prefixed for each pin in this pin bank. 113 * @name: name to be prefixed for each pin in this pin bank.
114 * @of_node: OF node of the bank. 114 * @of_node: OF node of the bank.
115 * @drvdata: link to controller driver data
115 */ 116 */
116struct samsung_pin_bank { 117struct samsung_pin_bank {
117 u32 pctl_offset; 118 u32 pctl_offset;
@@ -126,6 +127,7 @@ struct samsung_pin_bank {
126 u32 irq_base; 127 u32 irq_base;
127 char *name; 128 char *name;
128 struct device_node *of_node; 129 struct device_node *of_node;
130 struct samsung_pinctrl_drv_data *drvdata;
129}; 131};
130 132
131/** 133/**