leds: leds-mc13783: Remove duplicate field in platform data
Subsystems (5)
PATCH 2/3 leds: leds-mc13783: Remove unneeded mc13xxx_{un}lock
In reply to Alexander ShiyanLED registers are used only in this driver, so no additional locking is needed. Read-Modify-Write cycle in workqueue is already protected by regmap.
--- drivers/leds/leds-mc13783.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/leds/leds-mc13783.c +1 -12
@@ -117,9 +117,7 @@ static void mc13xxx_led_work(struct work_struct *work)BUG (); } -mc13xxx_lock (led->master);mc13xxx_reg_rmw (led->master, reg, mask << shift, value << shift); -mc13xxx_unlock (led->master); } static void mc13xxx_led_set(struct led_classdev *led_cdev,
@@ -164,19 +162,12 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev) leds->num_leds = num_leds;platform_set_drvdata (pdev, leds); -mc13xxx_lock (mcdev);for (i =0 ; i < devtype->num_regs; i++) { reg = pdata->led_control[i];WARN_ON (reg >= (1 <<24 )); ret =mc13xxx_reg_write (mcdev,MC13XXX_REG_LED_CONTROL (i), reg);if (ret) -break ; - } -mc13xxx_unlock (mcdev); - -if (ret) { -dev_err (&pdev->dev,"Unable to init LED driver\n" ); -return ret; +return ret; }for (i =0 ; i < num_leds; i++) {
@@ -237,10 +228,8 @@ static int mc13xxx_led_remove(struct platform_device *pdev)cancel_work_sync (&leds->led[i].work); } -mc13xxx_lock (mcdev);for (i =0 ; i < leds->devtype->num_regs; i++)mc13xxx_reg_write (mcdev,MC13XXX_REG_LED_CONTROL (i),0 ); -mc13xxx_unlock (mcdev);return 0 ; }
Signature · 1 line
1.8.3.2
PATCH 1/3 leds: leds-mc13783: Remove duplicate field in platform data
LED platform data are overwhelmed by excessive field "max_cur" which just replicates few bits of "led_control" field. This patch removes this field and adds a definition for the current settings in the header.
--- arch/arm/mach-imx/mach-mx31moboard.c | 16 ++++---- drivers/leds/leds-mc13783.c | 76 ------------------------------------ include/linux/mfd/mc13xxx.h | 37 +++++++++++++----- 3 files changed, 36 insertions(+), 93 deletions(-)
arch/arm/mach-imx/mach-mx31moboard.c +8 -8
@@ -236,32 +236,26 @@ static struct mc13xxx_led_platform_data moboard_led[] = { { .id = MC13783_LED_R1, .name = "coreboard-led-4:red", - .max_current = 2, }, { .id = MC13783_LED_G1, .name = "coreboard-led-4:green", - .max_current = 2, }, { .id = MC13783_LED_B1, .name = "coreboard-led-4:blue", - .max_current = 2, }, { .id = MC13783_LED_R2, .name = "coreboard-led-5:red", - .max_current = 3, }, { .id = MC13783_LED_G2, .name = "coreboard-led-5:green", - .max_current = 3, }, { .id = MC13783_LED_B2, .name = "coreboard-led-5:blue", - .max_current = 3, }, };
@@ -271,8 +265,14 @@ static struct mc13xxx_leds_platform_data moboard_leds = { .led_control[0] = MC13783_LED_C0_ENABLE | MC13783_LED_C0_ABMODE(0), .led_control[1] = MC13783_LED_C1_SLEWLIM, .led_control[2] = MC13783_LED_C2_SLEWLIM, - .led_control[3] = MC13783_LED_C3_PERIOD(0), - .led_control[4] = MC13783_LED_C3_PERIOD(0), + .led_control[3 ] =MC13783_LED_C3_PERIOD (0 ) | +MC13783_LED_C3_CURRENT_R1 (2 ) | +MC13783_LED_C3_CURRENT_G1 (2 ) | + MC13783_LED_C3_CURRENT_B1(2), + .led_control[4 ] =MC13783_LED_C4_PERIOD (0 ) | +MC13783_LED_C4_CURRENT_R2 (3 ) | +MC13783_LED_C4_CURRENT_G2 (3 ) | + MC13783_LED_C4_CURRENT_B2(3), };static struct mc13xxx_buttons_platform_data moboard_buttons = {
drivers/leds/leds-mc13783.c +0 -76
100 lines not on this page · raw message
include/linux/mfd/mc13xxx.h +28 -9
@@ -112,9 +112,6 @@ struct mc13xxx_led_platform_data {int id;const char *name;const char *default_trigger; - -/* Three or two bits current selection depending on the led */ -char max_current; };#define MAX_LED_CONTROL_REGS 6
@@ -123,7 +120,7 @@ struct mc13xxx_leds_platform_data {struct mc13xxx_led_platform_data *led;int num_leds; -/* LED Control 0 */ +/* MC13783 LED Control 0 */ #define MC13783_LED_C0_ENABLE (1 << 0)#define MC13783_LED_C0_TRIODE_MD (1 << 7)#define MC13783_LED_C0_TRIODE_AD (1 << 8)
@@ -131,21 +128,43 @@ struct mc13xxx_leds_platform_data {#define MC13783_LED_C0_BOOST (1 << 10)#define MC13783_LED_C0_ABMODE (x) (((x) & 0x7) << 11)#define MC13783_LED_C0_ABREF (x) (((x) & 0x3) << 14) -/* LED Control 1 */ +/* MC13783 LED Control 1 */ #define MC13783_LED_C1_TC1HALF (1 << 18)#define MC13783_LED_C1_SLEWLIM (1 << 23) -/* LED Control 2 */ +/* MC13783 LED Control 2 */ +#define MC13783_LED_C2_CURRENT_MD (x) (((x) & 0x7) << 0) +#define MC13783_LED_C2_CURRENT_AD (x) (((x) & 0x7) << 3) +#define MC13783_LED_C2_CURRENT_KP (x) (((x) & 0x7) << 6)#define MC13783_LED_C2_PERIOD (x) (((x) & 0x3) << 21)#define MC13783_LED_C2_SLEWLIM (1 << 23) -/* LED Control 3 */ +/* MC13783 LED Control 3 */ +#define MC13783_LED_C3_CURRENT_R1 (x) (((x) & 0x3) << 0) +#define MC13783_LED_C3_CURRENT_G1 (x) (((x) & 0x3) << 2) +#define MC13783_LED_C3_CURRENT_B1 (x) (((x) & 0x3) << 4)#define MC13783_LED_C3_PERIOD (x) (((x) & 0x3) << 21)#define MC13783_LED_C3_TRIODE_TC1 (1 << 23) -/* LED Control 4 */ +/* MC13783 LED Control 4 */ +#define MC13783_LED_C4_CURRENT_R2 (x) (((x) & 0x3) << 0) +#define MC13783_LED_C4_CURRENT_G2 (x) (((x) & 0x3) << 2) +#define MC13783_LED_C4_CURRENT_B2 (x) (((x) & 0x3) << 4)#define MC13783_LED_C4_PERIOD (x) (((x) & 0x3) << 21)#define MC13783_LED_C4_TRIODE_TC2 (1 << 23) -/* LED Control 5 */ +/* MC13783 LED Control 5 */ +#define MC13783_LED_C5_CURRENT_R3 (x) (((x) & 0x3) << 0) +#define MC13783_LED_C5_CURRENT_G3 (x) (((x) & 0x3) << 2) +#define MC13783_LED_C5_CURRENT_B3 (x) (((x) & 0x3) << 4)#define MC13783_LED_C5_PERIOD (x) (((x) & 0x3) << 21)#define MC13783_LED_C5_TRIODE_TC3 (1 << 23) +/* MC13892 LED Control 0 */ +#define MC13892_LED_C0_CURRENT_MD (x) (((x) & 0x7) << 9) +#define MC13892_LED_C0_CURRENT_AD (x) (((x) & 0x7) << 21) +/* MC13892 LED Control 1 */ +#define MC13892_LED_C1_CURRENT_KP (x) (((x) & 0x7) << 9) +/* MC13892 LED Control 2 */ +#define MC13892_LED_C2_CURRENT_R (x) (((x) & 0x7) << 9) +#define MC13892_LED_C2_CURRENT_G (x) (((x) & 0x7) << 21) +/* MC13892 LED Control 3 */ +#define MC13892_LED_C3_CURRENT_B (x) (((x) & 0x7) << 9)u32 led_control[MAX_LED_CONTROL_REGS ]; };
Signature · 1 line
1.8.3.2
Quoted 5 lines · Alexander Shiyan
LED platform data are overwhelmed by excessive field "
max_cur" which just replicates few bits of "led_control" field. This patch removes this field and adds a definition for the current settings in the header.
Looks good to me, if Sascha is OK, I can take this patch through my tree.
Thanks,
-Bryan
Quoted 243 lines
Signed-off-by Alexander Shiyan <[email protected]>--- arch/arm/mach-imx/mach-mx31moboard.c | 16 ++++---- drivers/leds/leds-mc13783.c | 76 ------------------------------------ include/linux/mfd/mc13xxx.h | 37 +++++++++++++----- 3 files changed, 36 insertions(+), 93 deletions(-)arch/arm/mach-imx/mach-mx31moboard.c +8
-8@@ -236,32 +236,26 @@ static struct mc13xxx_led_platform_data moboard_led[] = { { .id = MC13783_LED_R1, .name = "coreboard-led-4:red", - .max_current = 2, }, { .id = MC13783_LED_G1, .name = "coreboard-led-4:green", - .max_current = 2, }, { .id = MC13783_LED_B1, .name = "coreboard-led-4:blue", - .max_current = 2, }, { .id = MC13783_LED_R2, .name = "coreboard-led-5:red", - .max_current = 3, }, { .id = MC13783_LED_G2, .name = "coreboard-led-5:green", - .max_current = 3, }, { .id = MC13783_LED_B2, .name = "coreboard-led-5:blue", - .max_current = 3, }, };@@ -271,8 +265,14 @@ static struct mc13xxx_leds_platform_data moboard_leds = { .led_control[0] = MC13783_LED_C0_ENABLE | MC13783_LED_C0_ABMODE(0), .led_control[1] = MC13783_LED_C1_SLEWLIM, .led_control[2] = MC13783_LED_C2_SLEWLIM, - .led_control[3] = MC13783_LED_C3_PERIOD(0), - .led_control[4] = MC13783_LED_C3_PERIOD(0), + .led_control[3 ] =MC13783_LED_C3_PERIOD (0 ) | +MC13783_LED_C3_CURRENT_R1 (2 ) | +MC13783_LED_C3_CURRENT_G1 (2 ) | + MC13783_LED_C3_CURRENT_B1(2), + .led_control[4 ] =MC13783_LED_C4_PERIOD (0 ) | +MC13783_LED_C4_CURRENT_R2 (3 ) | +MC13783_LED_C4_CURRENT_G2 (3 ) | + MC13783_LED_C4_CURRENT_B2(3), };static struct mc13xxx_buttons_platform_data moboard_buttons = {drivers/leds/leds-mc13783.c +0
-76@@ -132,75 +132,6 @@ static void mc13xxx_led_set(struct led_classdev *led_cdev,schedule_work (&led->work); } -static int __init mc13xxx_led_setup (struct mc13xxx_led *led,int max_current) -{ -int shift, mask, reg, ret, bank; - -switch (led->id) { -case MC13783_LED_MD : - reg =MC13XXX_REG_LED_CONTROL (2 ); - shift =0 ; - mask =0x07 ; -break ; -case MC13783_LED_AD : - reg =MC13XXX_REG_LED_CONTROL (2 ); - shift =3 ; - mask =0x07 ; -break ; -case MC13783_LED_KP : - reg =MC13XXX_REG_LED_CONTROL (2 ); - shift =6 ; - mask =0x07 ; -break ; -case MC13783_LED_R1 : -case MC13783_LED_G1 : -case MC13783_LED_B1 : -case MC13783_LED_R2 : -case MC13783_LED_G2 : -case MC13783_LED_B2 : -case MC13783_LED_R3 : -case MC13783_LED_G3 : -case MC13783_LED_B3 : - bank = (led->id -MC13783_LED_R1 ) /3 ; - reg =MC13XXX_REG_LED_CONTROL (3 ) + bank; - shift = ((led->id -MC13783_LED_R1 ) - bank *3 ) *2 ; - mask =0x03 ; -break ; -case MC13892_LED_MD : - reg =MC13XXX_REG_LED_CONTROL (0 ); - shift =9 ; - mask =0x07 ; -break ; -case MC13892_LED_AD : - reg =MC13XXX_REG_LED_CONTROL (0 ); - shift =21 ; - mask =0x07 ; -break ; -case MC13892_LED_KP : - reg =MC13XXX_REG_LED_CONTROL (1 ); - shift =9 ; - mask =0x07 ; -break ; -case MC13892_LED_R : -case MC13892_LED_G : -case MC13892_LED_B : - bank = (led->id -MC13892_LED_R ) /2 ; - reg =MC13XXX_REG_LED_CONTROL (2 ) + bank; - shift = ((led->id -MC13892_LED_R ) - bank *2 ) *12 +9 ; - mask =0x07 ; -break ; -default : -BUG (); - } - -mc13xxx_lock (led->master); - ret =mc13xxx_reg_rmw (led->master, reg, mask << shift, - max_current << shift); -mc13xxx_unlock (led->master); - -return ret; -} -static int __init mc13xxx_led_probe (struct platform_device *pdev) {struct mc13xxx_leds_platform_data *pdata =dev_get_platdata (&pdev->dev);@@ -250,14 +181,12 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev)for (i =0 ; i < num_leds; i++) {const char *name, *trig; -char max_current; ret = -EINVAL ; id = pdata->led[i].id; name = pdata->led[i].name; trig = pdata->led[i].default_trigger; - max_current = pdata->led[i].max_current;if ((id > devtype->led_max) || (id < devtype->led_min)) {dev_err (&pdev->dev,"Invalid ID %i\n" , id);@@ -280,11 +209,6 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev)INIT_WORK (&leds->led[i].work, mc13xxx_led_work); - ret =mc13xxx_led_setup (&leds->led[i], max_current); -if (ret) { -dev_err (&pdev->dev,"Unable to setup LED %i\n" , id); -break ; - } ret =led_classdev_register (pdev->dev.parent, &leds->led[i].cdev);if (ret) {include/linux/mfd/mc13xxx.h +28
-10@@ -112,9 +112,6 @@ struct mc13xxx_led_platform_data {int id;const char *name;const char *default_trigger; - -/* Three or two bits current selection depending on the led */ -char max_current; };#define MAX_LED_CONTROL_REGS 6@@ -123,7 +120,7 @@ struct mc13xxx_leds_platform_data {struct mc13xxx_led_platform_data *led;int num_leds; -/* LED Control 0 */ +/* MC13783 LED Control 0 */ #define MC13783_LED_C0_ENABLE (1 << 0)#define MC13783_LED_C0_TRIODE_MD (1 << 7)#define MC13783_LED_C0_TRIODE_AD (1 << 8)@@ -131,21 +128,43 @@ struct mc13xxx_leds_platform_data {#define MC13783_LED_C0_BOOST (1 << 10)#define MC13783_LED_C0_ABMODE (x) (((x) & 0x7) << 11)#define MC13783_LED_C0_ABREF (x) (((x) & 0x3) << 14) -/* LED Control 1 */ +/* MC13783 LED Control 1 */ #define MC13783_LED_C1_TC1HALF (1 << 18)#define MC13783_LED_C1_SLEWLIM (1 << 23) -/* LED Control 2 */ +/* MC13783 LED Control 2 */ +#define MC13783_LED_C2_CURRENT_MD (x) (((x) & 0x7) << 0) +#define MC13783_LED_C2_CURRENT_AD (x) (((x) & 0x7) << 3) +#define MC13783_LED_C2_CURRENT_KP (x) (((x) & 0x7) << 6)#define MC13783_LED_C2_PERIOD (x) (((x) & 0x3) << 21)#define MC13783_LED_C2_SLEWLIM (1 << 23) -/* LED Control 3 */ +/* MC13783 LED Control 3 */ +#define MC13783_LED_C3_CURRENT_R1 (x) (((x) & 0x3) << 0) +#define MC13783_LED_C3_CURRENT_G1 (x) (((x) & 0x3) << 2) +#define MC13783_LED_C3_CURRENT_B1 (x) (((x) & 0x3) << 4)#define MC13783_LED_C3_PERIOD (x) (((x) & 0x3) << 21)#define MC13783_LED_C3_TRIODE_TC1 (1 << 23) -/* LED Control 4 */ +/* MC13783 LED Control 4 */ +#define MC13783_LED_C4_CURRENT_R2 (x) (((x) & 0x3) << 0) +#define MC13783_LED_C4_CURRENT_G2 (x) (((x) & 0x3) << 2) +#define MC13783_LED_C4_CURRENT_B2 (x) (((x) & 0x3) << 4)#define MC13783_LED_C4_PERIOD (x) (((x) & 0x3) << 21)#define MC13783_LED_C4_TRIODE_TC2 (1 << 23) -/* LED Control 5 */ +/* MC13783 LED Control 5 */ +#define MC13783_LED_C5_CURRENT_R3 (x) (((x) & 0x3) << 0) +#define MC13783_LED_C5_CURRENT_G3 (x) (((x) & 0x3) << 2) +#define MC13783_LED_C5_CURRENT_B3 (x) (((x) & 0x3) << 4)#define MC13783_LED_C5_PERIOD (x) (((x) & 0x3) << 21)#define MC13783_LED_C5_TRIODE_TC3 (1 << 23) +/* MC13892 LED Control 0 */ +#define MC13892_LED_C0_CURRENT_MD (x) (((x) & 0x7) << 9) +#define MC13892_LED_C0_CURRENT_AD (x) (((x) & 0x7) << 21) +/* MC13892 LED Control 1 */ +#define MC13892_LED_C1_CURRENT_KP (x) (((x) & 0x7) << 9) +/* MC13892 LED Control 2 */ +#define MC13892_LED_C2_CURRENT_R (x) (((x) & 0x7) << 9) +#define MC13892_LED_C2_CURRENT_G (x) (((x) & 0x7) << 21) +/* MC13892 LED Control 3 */ +#define MC13892_LED_C3_CURRENT_B (x) (((x) & 0x7) << 9)u32 led_control[MAX_LED_CONTROL_REGS ]; }; --1.8.3.2
Re: [PATCH 2/3] leds: leds-mc13783: Remove unneeded mc13xxx_{un}lock
In reply to Alexander ShiyanQuoted 4 lines · Alexander Shiyan
LED registers are used only in this driver, so no additional locking is needed. Read-Modify-Write cycle in workqueue is already protected by regmap.
Good, I will merge this.
Thanks,
-Bryan
Quoted 54 lines
Signed-off-by Alexander Shiyan <[email protected]>--- drivers/leds/leds-mc13783.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)drivers/leds/leds-mc13783.c +1
-13@@ -117,9 +117,7 @@ static void mc13xxx_led_work(struct work_struct *work)BUG (); } -mc13xxx_lock (led->master);mc13xxx_reg_rmw (led->master, reg, mask << shift, value << shift); -mc13xxx_unlock (led->master); } static void mc13xxx_led_set(struct led_classdev *led_cdev,@@ -164,19 +162,12 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev) leds->num_leds = num_leds;platform_set_drvdata (pdev, leds); -mc13xxx_lock (mcdev);for (i =0 ; i < devtype->num_regs; i++) { reg = pdata->led_control[i];WARN_ON (reg >= (1 <<24 )); ret =mc13xxx_reg_write (mcdev,MC13XXX_REG_LED_CONTROL (i), reg);if (ret) -break ; - } -mc13xxx_unlock (mcdev); - -if (ret) { -dev_err (&pdev->dev,"Unable to init LED driver\n" ); -return ret; +return ret; }for (i =0 ; i < num_leds; i++) {@@ -237,10 +228,8 @@ static int mc13xxx_led_remove(struct platform_device *pdev)cancel_work_sync (&leds->led[i].work); } -mc13xxx_lock (mcdev);for (i =0 ; i < leds->devtype->num_regs; i++)mc13xxx_reg_write (mcdev,MC13XXX_REG_LED_CONTROL (i),0 ); -mc13xxx_unlock (mcdev);return 0 ; } --1.8.3.2