diff mbox

[2/2] gpio-rcar: Remove #ifdef CONFIG_OF around OF-specific sections

Message ID 1371496527-13149-3-git-send-email-laurent.pinchart+renesas@ideasonboard.com (mailing list archive)
State New, archived
Headers show

Commit Message

Laurent Pinchart June 17, 2013, 7:15 p.m. UTC
All functions and data types used by OF-specific code paths are declared
in <linux/of.h> regardless of CONFIG_OF. Replace the #ifdef CONFIG_OF
guard with a if(IS_SELECTED(CONFIG_OF)) and let the compiler optimize
the unused code away.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/gpio/gpio-rcar.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Sergei Shtylyov June 17, 2013, 7:19 p.m. UTC | #1
Hello.

On 06/17/2013 11:15 PM, Laurent Pinchart wrote:

> All functions and data types used by OF-specific code paths are declared
> in <linux/of.h> regardless of CONFIG_OF. Replace the #ifdef CONFIG_OF
> guard with a if(IS_SELECTED(CONFIG_OF)) and let the compiler optimize

    You're using IS_ENABLED() actually.

> the unused code away.

> Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> ---
>   drivers/gpio/gpio-rcar.c | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)

> diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
> index 5a693dd..7fd09ef 100644
> --- a/drivers/gpio/gpio-rcar.c
> +++ b/drivers/gpio/gpio-rcar.c
> @@ -279,16 +279,13 @@ static struct irq_domain_ops gpio_rcar_irq_domain_ops = {
>   static void gpio_rcar_parse_pdata(struct gpio_rcar_priv *p)
>   {
>   	struct gpio_rcar_config *pdata = p->pdev->dev.platform_data;
> -#ifdef CONFIG_OF
>   	struct device_node *np = p->pdev->dev.of_node;
>   	struct of_phandle_args args;
>   	int ret;
> -#endif
>
> -	if (pdata)
> +	if (pdata) {
>   		p->config = *pdata;
> -#ifdef CONFIG_OF
> -	else if (np) {
> +	} else if (IS_ENABLED(CONFIG_OF) && np) {
>   		ret = of_parse_phandle_with_args(np, "gpio-ranges",
>   				"#gpio-range-cells", 0, &args);
>   		p->config.number_of_pins = ret == 0 && args.args_count == 3

WBR, Sergei
Laurent Pinchart June 17, 2013, 7:21 p.m. UTC | #2
On Monday 17 June 2013 23:19:07 Sergei Shtylyov wrote:
> Hello.
> 
> On 06/17/2013 11:15 PM, Laurent Pinchart wrote:
> > All functions and data types used by OF-specific code paths are declared
> > in <linux/of.h> regardless of CONFIG_OF. Replace the #ifdef CONFIG_OF
> > guard with a if(IS_SELECTED(CONFIG_OF)) and let the compiler optimize
> 
>     You're using IS_ENABLED() actually.

Oops. We should fix gcc to check the commit messages :-)

Simon, could you fix this while applying, or should I resubmit ?

> > the unused code away.
> > 
> > Signed-off-by: Laurent Pinchart
> > <laurent.pinchart+renesas@ideasonboard.com>
> > ---
> > 
> >   drivers/gpio/gpio-rcar.c | 8 ++------
> >   1 file changed, 2 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
> > index 5a693dd..7fd09ef 100644
> > --- a/drivers/gpio/gpio-rcar.c
> > +++ b/drivers/gpio/gpio-rcar.c
> > @@ -279,16 +279,13 @@ static struct irq_domain_ops
> > gpio_rcar_irq_domain_ops = {> 
> >   static void gpio_rcar_parse_pdata(struct gpio_rcar_priv *p)
> >   {
> >   
> >   	struct gpio_rcar_config *pdata = p->pdev->dev.platform_data;
> > 
> > -#ifdef CONFIG_OF
> > 
> >   	struct device_node *np = p->pdev->dev.of_node;
> >   	struct of_phandle_args args;
> >   	int ret;
> > 
> > -#endif
> > 
> > -	if (pdata)
> > +	if (pdata) {
> > 
> >   		p->config = *pdata;
> > 
> > -#ifdef CONFIG_OF
> > -	else if (np) {
> > +	} else if (IS_ENABLED(CONFIG_OF) && np) {
> > 
> >   		ret = of_parse_phandle_with_args(np, "gpio-ranges",
> >   		
> >   				"#gpio-range-cells", 0, &args);
> >   		
> >   		p->config.number_of_pins = ret == 0 && args.args_count == 3
Simon Horman June 18, 2013, 8:02 a.m. UTC | #3
On Mon, Jun 17, 2013 at 09:21:08PM +0200, Laurent Pinchart wrote:
> On Monday 17 June 2013 23:19:07 Sergei Shtylyov wrote:
> > Hello.
> > 
> > On 06/17/2013 11:15 PM, Laurent Pinchart wrote:
> > > All functions and data types used by OF-specific code paths are declared
> > > in <linux/of.h> regardless of CONFIG_OF. Replace the #ifdef CONFIG_OF
> > > guard with a if(IS_SELECTED(CONFIG_OF)) and let the compiler optimize
> > 
> >     You're using IS_ENABLED() actually.
> 
> Oops. We should fix gcc to check the commit messages :-)
> 
> Simon, could you fix this while applying, or should I resubmit ?

Please re-spin, thanks.
diff mbox

Patch

diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 5a693dd..7fd09ef 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -279,16 +279,13 @@  static struct irq_domain_ops gpio_rcar_irq_domain_ops = {
 static void gpio_rcar_parse_pdata(struct gpio_rcar_priv *p)
 {
 	struct gpio_rcar_config *pdata = p->pdev->dev.platform_data;
-#ifdef CONFIG_OF
 	struct device_node *np = p->pdev->dev.of_node;
 	struct of_phandle_args args;
 	int ret;
-#endif
 
-	if (pdata)
+	if (pdata) {
 		p->config = *pdata;
-#ifdef CONFIG_OF
-	else if (np) {
+	} else if (IS_ENABLED(CONFIG_OF) && np) {
 		ret = of_parse_phandle_with_args(np, "gpio-ranges",
 				"#gpio-range-cells", 0, &args);
 		p->config.number_of_pins = ret == 0 && args.args_count == 3
@@ -296,7 +293,6 @@  static void gpio_rcar_parse_pdata(struct gpio_rcar_priv *p)
 					 : RCAR_MAX_GPIO_PER_BANK;
 		p->config.gpio_base = -1;
 	}
-#endif
 
 	if (p->config.number_of_pins == 0 ||
 	    p->config.number_of_pins > RCAR_MAX_GPIO_PER_BANK) {