pwm: pxa: Use driver_data field to store pwm_nr
PATCH 1/1 pwm: pxa: Use driver_data field to store pwm_nr
The driver_data field was used to store information about PWM_ID_BASE and HAS_SECONDARY_PWM. PWM_ID_BASE is not used now after convert to pwm framework. This patch stores the pwm_nr in driver_data field to simplify the code.
--- drivers/pwm/pwm-pxa.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/pwm/pwm-pxa.c +4 -7
@@ -22,13 +22,10 @@#include <asm/div64.h> -#define HAS_SECONDARY_PWM 0x10 -#define PWM_ID_BASE (d) ((d) & 0xf) -static const struct platform_device_id pwm_id_table[] = { -/* PWM has_secondary_pwm? */ - {"pxa25x-pwm" ,0 }, - {"pxa27x-pwm" ,0 |HAS_SECONDARY_PWM }, +/* PWM pwm_nr */ + {"pxa25x-pwm" ,1 }, + {"pxa27x-pwm" ,2 }, {"pxa168-pwm" ,1 }, {"pxa910-pwm" ,1 }, { },
@@ -145,7 +142,7 @@ static int pwm_probe(struct platform_device *pdev) pwm->chip.dev = &pdev->dev; pwm->chip.ops = &pxa_pwm_ops; pwm->chip.base =-1 ; - pwm->chip.npwm = (id->driver_data &HAS_SECONDARY_PWM ) ?2 :1 ; + pwm->chip.npwm = id->driver_data; r =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (r ==NULL ) {
Signature · 1 line
1.7.10.4
Quoted 31 lines · Axel Lin
The
driver_datafield was used to store information aboutPWM_ID_BASEandHAS_SECONDARY_PWM.PWM_ID_BASEis not used now after convert to pwm framework. This patch stores thepwm_nrindriver_datafield to simplify the code.Signed-off-by Axel Lin <[email protected]>--- drivers/pwm/pwm-pxa.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)drivers/pwm/pwm-pxa.c +3
-6@@ -22,13 +22,10 @@#include <asm/div64.h> -#define HAS_SECONDARY_PWM 0x10 -#define PWM_ID_BASE (d) ((d) & 0xf) -static const struct platform_device_id pwm_id_table[] = { -/* PWM has_secondary_pwm? */ - {"pxa25x-pwm" ,0 }, - {"pxa27x-pwm" ,0 |HAS_SECONDARY_PWM }, +/* PWM pwm_nr */ + {"pxa25x-pwm" ,1 }, + {"pxa27x-pwm" ,2 }, {"pxa168-pwm" ,1 }, {"pxa910-pwm" ,1 }, { },
drivers/pwm/pwm-pxa.c static int pwm_probe(struct platform_device *pdev) · line 145
Quoted 5 lines
drivers/pwm/pwm-pxa.c +1
-1@@ -145,7 +142,7 @@ static int pwm_probe(struct platform_device *pdev) pwm->chip.dev = &pdev->dev; pwm->chip.ops = &pxa_pwm_ops; pwm->chip.base =-1 ; - pwm->chip.npwm = (id->driver_data &HAS_SECONDARY_PWM ) ?2 :1 ; + pwm->chip.npwm = id->driver_data;
I'd rather keep the flag for a bit more readability?
Quoted 8 lines
drivers/pwm/pwm-pxa.c +0
-1r =platform_get_resource (pdev,IORESOURCE_MEM ,0 );if (r ==NULL ) { --1.7.10.4
2013/4/1 Eric Miao <[email protected]>:
Quoted 31 lines · Axel Lin
Quoted 30 lines
The
driver_datafield was used to store information aboutPWM_ID_BASEandHAS_SECONDARY_PWM.PWM_ID_BASEis not used now after convert to pwm framework. This patch stores thepwm_nrindriver_datafield to simplify the code.Signed-off-by Axel Lin <[email protected]>--- drivers/pwm/pwm-pxa.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)drivers/pwm/pwm-pxa.c +3
-6@@ -22,13 +22,10 @@#include <asm/div64.h> -#define HAS_SECONDARY_PWM 0x10 -#define PWM_ID_BASE (d) ((d) & 0xf) -static const struct platform_device_id pwm_id_table[] = { -/* PWM has_secondary_pwm? */ - {"pxa25x-pwm" ,0 }, - {"pxa27x-pwm" ,0 |HAS_SECONDARY_PWM }, +/* PWM pwm_nr */ + {"pxa25x-pwm" ,1 }, + {"pxa27x-pwm" ,2 }, {"pxa168-pwm" ,1 }, {"pxa910-pwm" ,1 }, { },
Quoted 8 lines
drivers/pwm/pwm-pxa.c static int pwm_probe(struct platform_device *pdev) · line 145
Quoted 6 lines
drivers/pwm/pwm-pxa.c +1
-1@@ -145,7 +142,7 @@ static int pwm_probe(struct platform_device *pdev) pwm->chip.dev = &pdev->dev; pwm->chip.ops = &pxa_pwm_ops; pwm->chip.base =-1 ; - pwm->chip.npwm = (id->driver_data &HAS_SECONDARY_PWM ) ?2 :1 ; + pwm->chip.npwm = id->driver_data;I'd rather keep the flag for a bit more readability?
Well, I'd send a patch to just remove PWM_ID_BASE which is not used now.
Regards,
Axel