public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH V3] max8925_power: Use "IS_ENABLED(CONFIG_OF)" for DT code.
@ 2014-01-27 18:37 Manish Badarkhe
  2014-01-28 11:51 ` Tomasz Figa
  0 siblings, 1 reply; 3+ messages in thread
From: Manish Badarkhe @ 2014-01-27 18:37 UTC (permalink / raw)
  To: linux-samsung-soc, linux-kernel; +Cc: dbaryshkov, dwmw2, badarkhe.manish

Instead of "#ifdef CONFIG_OF" use "IS_ENABLED(CONFIG_OF)"
option for DT code to avoid if-deffery in code.

Signed-off-by: Manish Badarkhe <badarkhe.manish@gmail.com>
---
:100644 100644 b4513f2... 3e54476... M	drivers/power/max8925_power.c
 drivers/power/max8925_power.c |   17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/power/max8925_power.c b/drivers/power/max8925_power.c
index b4513f2..3e54476 100644
--- a/drivers/power/max8925_power.c
+++ b/drivers/power/max8925_power.c
@@ -427,7 +427,6 @@ static int max8925_deinit_charger(struct max8925_power_info *info)
 	return 0;
 }
 
-#ifdef CONFIG_OF
 static struct max8925_power_pdata *
 max8925_power_dt_init(struct platform_device *pdev)
 {
@@ -440,9 +439,6 @@ max8925_power_dt_init(struct platform_device *pdev)
 	int no_insert_detect;
 	struct max8925_power_pdata *pdata;
 
-	if (!nproot)
-		return pdev->dev.platform_data;
-
 	np = of_find_node_by_name(nproot, "charger");
 	if (!np) {
 		dev_err(&pdev->dev, "failed to find charger node\n");
@@ -468,13 +464,6 @@ max8925_power_dt_init(struct platform_device *pdev)
 
 	return pdata;
 }
-#else
-static struct max8925_power_pdata *
-max8925_power_dt_init(struct platform_device *pdev)
-{
-	return pdev->dev.platform_data;
-}
-#endif
 
 static int max8925_power_probe(struct platform_device *pdev)
 {
@@ -483,7 +472,11 @@ static int max8925_power_probe(struct platform_device *pdev)
 	struct max8925_power_info *info;
 	int ret;
 
-	pdata = max8925_power_dt_init(pdev);
+	pdata = dev_get_platdata(&pdev->dev);
+
+	if (!pdata && chip->dev->of_node)
+		pdata = max8925_power_dt_init(pdev);
+
 	if (!pdata) {
 		dev_err(&pdev->dev, "platform data isn't assigned to "
 			"power supply\n");
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V3] max8925_power: Use "IS_ENABLED(CONFIG_OF)" for DT code.
  2014-01-27 18:37 [PATCH V3] max8925_power: Use "IS_ENABLED(CONFIG_OF)" for DT code Manish Badarkhe
@ 2014-01-28 11:51 ` Tomasz Figa
  2014-01-28 15:12   ` Manish Badarkhe
  0 siblings, 1 reply; 3+ messages in thread
From: Tomasz Figa @ 2014-01-28 11:51 UTC (permalink / raw)
  To: Manish Badarkhe, linux-samsung-soc, linux-kernel; +Cc: dbaryshkov, dwmw2

Hi,

On 27.01.2014 19:37, Manish Badarkhe wrote:
> Instead of "#ifdef CONFIG_OF" use "IS_ENABLED(CONFIG_OF)"
> option for DT code to avoid if-deffery in code.
>
> Signed-off-by: Manish Badarkhe <badarkhe.manish@gmail.com>
> ---
> :100644 100644 b4513f2... 3e54476... M	drivers/power/max8925_power.c
>   drivers/power/max8925_power.c |   17 +++++------------
>   1 file changed, 5 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/power/max8925_power.c b/drivers/power/max8925_power.c
> index b4513f2..3e54476 100644
> --- a/drivers/power/max8925_power.c
> +++ b/drivers/power/max8925_power.c
> @@ -427,7 +427,6 @@ static int max8925_deinit_charger(struct max8925_power_info *info)
>   	return 0;
>   }
>
> -#ifdef CONFIG_OF
>   static struct max8925_power_pdata *
>   max8925_power_dt_init(struct platform_device *pdev)
>   {
> @@ -440,9 +439,6 @@ max8925_power_dt_init(struct platform_device *pdev)
>   	int no_insert_detect;
>   	struct max8925_power_pdata *pdata;
>
> -	if (!nproot)
> -		return pdev->dev.platform_data;
> -
>   	np = of_find_node_by_name(nproot, "charger");
>   	if (!np) {
>   		dev_err(&pdev->dev, "failed to find charger node\n");
> @@ -468,13 +464,6 @@ max8925_power_dt_init(struct platform_device *pdev)
>
>   	return pdata;
>   }
> -#else
> -static struct max8925_power_pdata *
> -max8925_power_dt_init(struct platform_device *pdev)
> -{
> -	return pdev->dev.platform_data;
> -}
> -#endif
>
>   static int max8925_power_probe(struct platform_device *pdev)
>   {
> @@ -483,7 +472,11 @@ static int max8925_power_probe(struct platform_device *pdev)
>   	struct max8925_power_info *info;
>   	int ret;
>
> -	pdata = max8925_power_dt_init(pdev);
> +	pdata = dev_get_platdata(&pdev->dev);
> +
> +	if (!pdata && chip->dev->of_node)

Shouldn't IS_ENABLED(CONFIG_OF) also be checked here to let the compiler 
throw max8925_power_dt_init() away if the condition always evaluates to 
false?

Best regards,
Tomasz

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V3] max8925_power: Use "IS_ENABLED(CONFIG_OF)" for DT code.
  2014-01-28 11:51 ` Tomasz Figa
@ 2014-01-28 15:12   ` Manish Badarkhe
  0 siblings, 0 replies; 3+ messages in thread
From: Manish Badarkhe @ 2014-01-28 15:12 UTC (permalink / raw)
  To: Tomasz Figa
  Cc: linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Dmitry Eremin-Solenikov, David Woodhouse

Hi Tomasz,

On Tue, Jan 28, 2014 at 5:21 PM, Tomasz Figa <t.figa@samsung.com> wrote:
> Hi,
>
>
> On 27.01.2014 19:37, Manish Badarkhe wrote:
>>
>> Instead of "#ifdef CONFIG_OF" use "IS_ENABLED(CONFIG_OF)"
>> option for DT code to avoid if-deffery in code.
>>
>> Signed-off-by: Manish Badarkhe <badarkhe.manish@gmail.com>
>> ---
>> :100644 100644 b4513f2... 3e54476... M  drivers/power/max8925_power.c
>>   drivers/power/max8925_power.c |   17 +++++------------
>>   1 file changed, 5 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/power/max8925_power.c b/drivers/power/max8925_power.c
>> index b4513f2..3e54476 100644
>> --- a/drivers/power/max8925_power.c
>> +++ b/drivers/power/max8925_power.c
>> @@ -427,7 +427,6 @@ static int max8925_deinit_charger(struct
>> max8925_power_info *info)
>>         return 0;
>>   }
>>
>> -#ifdef CONFIG_OF
>>   static struct max8925_power_pdata *
>>   max8925_power_dt_init(struct platform_device *pdev)
>>   {
>> @@ -440,9 +439,6 @@ max8925_power_dt_init(struct platform_device *pdev)
>>         int no_insert_detect;
>>         struct max8925_power_pdata *pdata;
>>
>> -       if (!nproot)
>> -               return pdev->dev.platform_data;
>> -
>>         np = of_find_node_by_name(nproot, "charger");
>>         if (!np) {
>>                 dev_err(&pdev->dev, "failed to find charger node\n");
>> @@ -468,13 +464,6 @@ max8925_power_dt_init(struct platform_device *pdev)
>>
>>         return pdata;
>>   }
>> -#else
>> -static struct max8925_power_pdata *
>> -max8925_power_dt_init(struct platform_device *pdev)
>> -{
>> -       return pdev->dev.platform_data;
>> -}
>> -#endif
>>
>>   static int max8925_power_probe(struct platform_device *pdev)
>>   {
>> @@ -483,7 +472,11 @@ static int max8925_power_probe(struct platform_device
>> *pdev)
>>         struct max8925_power_info *info;
>>         int ret;
>>
>> -       pdata = max8925_power_dt_init(pdev);
>> +       pdata = dev_get_platdata(&pdev->dev);
>> +
>> +       if (!pdata && chip->dev->of_node)
>
>
> Shouldn't IS_ENABLED(CONFIG_OF) also be checked here to let the compiler
> throw max8925_power_dt_init() away if the condition always evaluates to
> false?

oops, I missed that. I will add it and repost patch.

Thanks
Manish Badarkhe

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-01-28 15:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-27 18:37 [PATCH V3] max8925_power: Use "IS_ENABLED(CONFIG_OF)" for DT code Manish Badarkhe
2014-01-28 11:51 ` Tomasz Figa
2014-01-28 15:12   ` Manish Badarkhe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox