diff mbox

pinctrl: single: avoid to set read only object

Message ID 1362322904-19570-1-git-send-email-haojian.zhuang@linaro.org
State Superseded
Headers show

Commit Message

Haojian Zhuang March 3, 2013, 3:01 p.m. UTC
drivers/pinctrl/pinctrl-single.c:1441:3: error: assignment of member
‘is_generic’ in read-only object
make[2]: *** [drivers/pinctrl/pinctrl-single.o] Error 1

Since pcs_pinconf_ops is changed to read only structure, probe()
function can't set is_generic variable any more. So append new
pcs_pinconf_generic_ops.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
---
 drivers/pinctrl/pinctrl-single.c |   27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

Comments

Tony Lindgren March 4, 2013, 7:44 p.m. UTC | #1
* Haojian Zhuang <haojian.zhuang@linaro.org> [130303 07:05]:
> drivers/pinctrl/pinctrl-single.c:1441:3: error: assignment of member
> ‘is_generic’ in read-only object
> make[2]: *** [drivers/pinctrl/pinctrl-single.o] Error 1
> 
> Since pcs_pinconf_ops is changed to read only structure, probe()
> function can't set is_generic variable any more. So append new
> pcs_pinconf_generic_ops.
> 
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

Acked-by: Tony Lindgren <tony@atomide.com>

> ---
>  drivers/pinctrl/pinctrl-single.c |   27 +++++++++++++++++++++------
>  1 file changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
> index 4cdcf85..c80ffa8 100644
> --- a/drivers/pinctrl/pinctrl-single.c
> +++ b/drivers/pinctrl/pinctrl-single.c
> @@ -734,6 +734,18 @@ static const struct pinconf_ops pcs_pinconf_ops = {
>  	.pin_config_dbg_show = pcs_pinconf_dbg_show,
>  	.pin_config_group_dbg_show = pcs_pinconf_group_dbg_show,
>  	.pin_config_config_dbg_show = pcs_pinconf_config_dbg_show,
> +	.is_generic = false,
> +};
> +
> +static const struct pinconf_ops pcs_pinconf_generic_ops = {
> +	.pin_config_get = pcs_pinconf_get,
> +	.pin_config_set = pcs_pinconf_set,
> +	.pin_config_group_get = pcs_pinconf_group_get,
> +	.pin_config_group_set = pcs_pinconf_group_set,
> +	.pin_config_dbg_show = pcs_pinconf_dbg_show,
> +	.pin_config_group_dbg_show = pcs_pinconf_group_dbg_show,
> +	.pin_config_config_dbg_show = pcs_pinconf_config_dbg_show,
> +	.is_generic = true,
>  };
>  
>  /**
> @@ -1435,10 +1447,8 @@ static int pcs_probe(struct platform_device *pdev)
>  	pcs->desc.name = DRIVER_NAME;
>  	pcs->desc.pctlops = &pcs_pinctrl_ops;
>  	pcs->desc.pmxops = &pcs_pinmux_ops;
> -	pcs->desc.confops = &pcs_pinconf_ops;
> +	pcs->desc.confops = match->data;
>  	pcs->desc.owner = THIS_MODULE;
> -	if (match->data)
> -		pcs_pinconf_ops.is_generic = true;
>  
>  	ret = pcs_allocate_pin_table(pcs);
>  	if (ret < 0)
> @@ -1479,9 +1489,14 @@ static int pcs_remove(struct platform_device *pdev)
>  }
>  
>  static struct of_device_id pcs_of_match[] = {
> -	{ .compatible = "pinctrl-single", .data = (void *)false },
> -	{ .compatible = "pinconf-single", .data = (void *)true },
> -	{ },
> +	{
> +		.compatible = "pinctrl-single",
> +		.data = (void *)&pcs_pinconf_ops,
> +	}, {
> +		.compatible = "pinconf-single",
> +		.data = (void *)&pcs_pinconf_generic_ops,
> +       	}, {
> +	},
>  };
>  MODULE_DEVICE_TABLE(of, pcs_of_match);
>  
> -- 
> 1.7.10.4
>
Linus Walleij March 7, 2013, 7:48 a.m. UTC | #2
On Sun, Mar 3, 2013 at 4:01 PM, Haojian Zhuang
<haojian.zhuang@linaro.org> wrote:

> drivers/pinctrl/pinctrl-single.c:1441:3: error: assignment of member
> ‘is_generic’ in read-only object
> make[2]: *** [drivers/pinctrl/pinctrl-single.o] Error 1
>
> Since pcs_pinconf_ops is changed to read only structure, probe()
> function can't set is_generic variable any more. So append new
> pcs_pinconf_generic_ops.
>
> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>

Isn't this fixed by Axel's much simpler patch?

Yours,
Linus Walleij
Haojian Zhuang March 7, 2013, 3:37 p.m. UTC | #3
On 7 March 2013 15:48, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Sun, Mar 3, 2013 at 4:01 PM, Haojian Zhuang
> <haojian.zhuang@linaro.org> wrote:
>
>> drivers/pinctrl/pinctrl-single.c:1441:3: error: assignment of member
>> ‘is_generic’ in read-only object
>> make[2]: *** [drivers/pinctrl/pinctrl-single.o] Error 1
>>
>> Since pcs_pinconf_ops is changed to read only structure, probe()
>> function can't set is_generic variable any more. So append new
>> pcs_pinconf_generic_ops.
>>
>> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
>
> Isn't this fixed by Axel's much simpler patch?
>
> Yours,
> Linus Walleij

Yes, I prefer to use Axel's fix.

Regards
Haojian
Tony Lindgren March 7, 2013, 4:36 p.m. UTC | #4
* Haojian Zhuang <haojian.zhuang@linaro.org> [130307 07:42]:
> On 7 March 2013 15:48, Linus Walleij <linus.walleij@linaro.org> wrote:
> > On Sun, Mar 3, 2013 at 4:01 PM, Haojian Zhuang
> > <haojian.zhuang@linaro.org> wrote:
> >
> >> drivers/pinctrl/pinctrl-single.c:1441:3: error: assignment of member
> >> ‘is_generic’ in read-only object
> >> make[2]: *** [drivers/pinctrl/pinctrl-single.o] Error 1
> >>
> >> Since pcs_pinconf_ops is changed to read only structure, probe()
> >> function can't set is_generic variable any more. So append new
> >> pcs_pinconf_generic_ops.
> >>
> >> Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
> >
> > Isn't this fixed by Axel's much simpler patch?
> 
> Yes, I prefer to use Axel's fix.

Yes that's better.

Tony
diff mbox

Patch

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 4cdcf85..c80ffa8 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -734,6 +734,18 @@  static const struct pinconf_ops pcs_pinconf_ops = {
 	.pin_config_dbg_show = pcs_pinconf_dbg_show,
 	.pin_config_group_dbg_show = pcs_pinconf_group_dbg_show,
 	.pin_config_config_dbg_show = pcs_pinconf_config_dbg_show,
+	.is_generic = false,
+};
+
+static const struct pinconf_ops pcs_pinconf_generic_ops = {
+	.pin_config_get = pcs_pinconf_get,
+	.pin_config_set = pcs_pinconf_set,
+	.pin_config_group_get = pcs_pinconf_group_get,
+	.pin_config_group_set = pcs_pinconf_group_set,
+	.pin_config_dbg_show = pcs_pinconf_dbg_show,
+	.pin_config_group_dbg_show = pcs_pinconf_group_dbg_show,
+	.pin_config_config_dbg_show = pcs_pinconf_config_dbg_show,
+	.is_generic = true,
 };
 
 /**
@@ -1435,10 +1447,8 @@  static int pcs_probe(struct platform_device *pdev)
 	pcs->desc.name = DRIVER_NAME;
 	pcs->desc.pctlops = &pcs_pinctrl_ops;
 	pcs->desc.pmxops = &pcs_pinmux_ops;
-	pcs->desc.confops = &pcs_pinconf_ops;
+	pcs->desc.confops = match->data;
 	pcs->desc.owner = THIS_MODULE;
-	if (match->data)
-		pcs_pinconf_ops.is_generic = true;
 
 	ret = pcs_allocate_pin_table(pcs);
 	if (ret < 0)
@@ -1479,9 +1489,14 @@  static int pcs_remove(struct platform_device *pdev)
 }
 
 static struct of_device_id pcs_of_match[] = {
-	{ .compatible = "pinctrl-single", .data = (void *)false },
-	{ .compatible = "pinconf-single", .data = (void *)true },
-	{ },
+	{
+		.compatible = "pinctrl-single",
+		.data = (void *)&pcs_pinconf_ops,
+	}, {
+		.compatible = "pinconf-single",
+		.data = (void *)&pcs_pinconf_generic_ops,
+       	}, {
+	},
 };
 MODULE_DEVICE_TABLE(of, pcs_of_match);