Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Bryan Wu <cooloney@gmail.com>

authored by

Alexander Shiyan and committed by
Bryan Wu
01a7a063 33ca1532

+36 -93
+8 -8
arch/arm/mach-imx/mach-mx31moboard.c
··· 236 236 { 237 237 .id = MC13783_LED_R1, 238 238 .name = "coreboard-led-4:red", 239 - .max_current = 2, 240 239 }, 241 240 { 242 241 .id = MC13783_LED_G1, 243 242 .name = "coreboard-led-4:green", 244 - .max_current = 2, 245 243 }, 246 244 { 247 245 .id = MC13783_LED_B1, 248 246 .name = "coreboard-led-4:blue", 249 - .max_current = 2, 250 247 }, 251 248 { 252 249 .id = MC13783_LED_R2, 253 250 .name = "coreboard-led-5:red", 254 - .max_current = 3, 255 251 }, 256 252 { 257 253 .id = MC13783_LED_G2, 258 254 .name = "coreboard-led-5:green", 259 - .max_current = 3, 260 255 }, 261 256 { 262 257 .id = MC13783_LED_B2, 263 258 .name = "coreboard-led-5:blue", 264 - .max_current = 3, 265 259 }, 266 260 }; 267 261 ··· 265 271 .led_control[0] = MC13783_LED_C0_ENABLE | MC13783_LED_C0_ABMODE(0), 266 272 .led_control[1] = MC13783_LED_C1_SLEWLIM, 267 273 .led_control[2] = MC13783_LED_C2_SLEWLIM, 268 - .led_control[3] = MC13783_LED_C3_PERIOD(0), 269 - .led_control[4] = MC13783_LED_C3_PERIOD(0), 274 + .led_control[3] = MC13783_LED_C3_PERIOD(0) | 275 + MC13783_LED_C3_CURRENT_R1(2) | 276 + MC13783_LED_C3_CURRENT_G1(2) | 277 + MC13783_LED_C3_CURRENT_B1(2), 278 + .led_control[4] = MC13783_LED_C4_PERIOD(0) | 279 + MC13783_LED_C4_CURRENT_R2(3) | 280 + MC13783_LED_C4_CURRENT_G2(3) | 281 + MC13783_LED_C4_CURRENT_B2(3), 270 282 }; 271 283 272 284 static struct mc13xxx_buttons_platform_data moboard_buttons = {
-76
drivers/leds/leds-mc13783.c
··· 132 132 schedule_work(&led->work); 133 133 } 134 134 135 - static int __init mc13xxx_led_setup(struct mc13xxx_led *led, int max_current) 136 - { 137 - int shift, mask, reg, ret, bank; 138 - 139 - switch (led->id) { 140 - case MC13783_LED_MD: 141 - reg = MC13XXX_REG_LED_CONTROL(2); 142 - shift = 0; 143 - mask = 0x07; 144 - break; 145 - case MC13783_LED_AD: 146 - reg = MC13XXX_REG_LED_CONTROL(2); 147 - shift = 3; 148 - mask = 0x07; 149 - break; 150 - case MC13783_LED_KP: 151 - reg = MC13XXX_REG_LED_CONTROL(2); 152 - shift = 6; 153 - mask = 0x07; 154 - break; 155 - case MC13783_LED_R1: 156 - case MC13783_LED_G1: 157 - case MC13783_LED_B1: 158 - case MC13783_LED_R2: 159 - case MC13783_LED_G2: 160 - case MC13783_LED_B2: 161 - case MC13783_LED_R3: 162 - case MC13783_LED_G3: 163 - case MC13783_LED_B3: 164 - bank = (led->id - MC13783_LED_R1) / 3; 165 - reg = MC13XXX_REG_LED_CONTROL(3) + bank; 166 - shift = ((led->id - MC13783_LED_R1) - bank * 3) * 2; 167 - mask = 0x03; 168 - break; 169 - case MC13892_LED_MD: 170 - reg = MC13XXX_REG_LED_CONTROL(0); 171 - shift = 9; 172 - mask = 0x07; 173 - break; 174 - case MC13892_LED_AD: 175 - reg = MC13XXX_REG_LED_CONTROL(0); 176 - shift = 21; 177 - mask = 0x07; 178 - break; 179 - case MC13892_LED_KP: 180 - reg = MC13XXX_REG_LED_CONTROL(1); 181 - shift = 9; 182 - mask = 0x07; 183 - break; 184 - case MC13892_LED_R: 185 - case MC13892_LED_G: 186 - case MC13892_LED_B: 187 - bank = (led->id - MC13892_LED_R) / 2; 188 - reg = MC13XXX_REG_LED_CONTROL(2) + bank; 189 - shift = ((led->id - MC13892_LED_R) - bank * 2) * 12 + 9; 190 - mask = 0x07; 191 - break; 192 - default: 193 - BUG(); 194 - } 195 - 196 - mc13xxx_lock(led->master); 197 - ret = mc13xxx_reg_rmw(led->master, reg, mask << shift, 198 - max_current << shift); 199 - mc13xxx_unlock(led->master); 200 - 201 - return ret; 202 - } 203 - 204 135 static int __init mc13xxx_led_probe(struct platform_device *pdev) 205 136 { 206 137 struct mc13xxx_leds_platform_data *pdata = dev_get_platdata(&pdev->dev); ··· 181 250 182 251 for (i = 0; i < num_leds; i++) { 183 252 const char *name, *trig; 184 - char max_current; 185 253 186 254 ret = -EINVAL; 187 255 188 256 id = pdata->led[i].id; 189 257 name = pdata->led[i].name; 190 258 trig = pdata->led[i].default_trigger; 191 - max_current = pdata->led[i].max_current; 192 259 193 260 if ((id > devtype->led_max) || (id < devtype->led_min)) { 194 261 dev_err(&pdev->dev, "Invalid ID %i\n", id); ··· 209 280 210 281 INIT_WORK(&leds->led[i].work, mc13xxx_led_work); 211 282 212 - ret = mc13xxx_led_setup(&leds->led[i], max_current); 213 - if (ret) { 214 - dev_err(&pdev->dev, "Unable to setup LED %i\n", id); 215 - break; 216 - } 217 283 ret = led_classdev_register(pdev->dev.parent, 218 284 &leds->led[i].cdev); 219 285 if (ret) {
+28 -9
include/linux/mfd/mc13xxx.h
··· 112 112 int id; 113 113 const char *name; 114 114 const char *default_trigger; 115 - 116 - /* Three or two bits current selection depending on the led */ 117 - char max_current; 118 115 }; 119 116 120 117 #define MAX_LED_CONTROL_REGS 6 ··· 120 123 struct mc13xxx_led_platform_data *led; 121 124 int num_leds; 122 125 123 - /* LED Control 0 */ 126 + /* MC13783 LED Control 0 */ 124 127 #define MC13783_LED_C0_ENABLE (1 << 0) 125 128 #define MC13783_LED_C0_TRIODE_MD (1 << 7) 126 129 #define MC13783_LED_C0_TRIODE_AD (1 << 8) ··· 128 131 #define MC13783_LED_C0_BOOST (1 << 10) 129 132 #define MC13783_LED_C0_ABMODE(x) (((x) & 0x7) << 11) 130 133 #define MC13783_LED_C0_ABREF(x) (((x) & 0x3) << 14) 131 - /* LED Control 1 */ 134 + /* MC13783 LED Control 1 */ 132 135 #define MC13783_LED_C1_TC1HALF (1 << 18) 133 136 #define MC13783_LED_C1_SLEWLIM (1 << 23) 134 - /* LED Control 2 */ 137 + /* MC13783 LED Control 2 */ 138 + #define MC13783_LED_C2_CURRENT_MD(x) (((x) & 0x7) << 0) 139 + #define MC13783_LED_C2_CURRENT_AD(x) (((x) & 0x7) << 3) 140 + #define MC13783_LED_C2_CURRENT_KP(x) (((x) & 0x7) << 6) 135 141 #define MC13783_LED_C2_PERIOD(x) (((x) & 0x3) << 21) 136 142 #define MC13783_LED_C2_SLEWLIM (1 << 23) 137 - /* LED Control 3 */ 143 + /* MC13783 LED Control 3 */ 144 + #define MC13783_LED_C3_CURRENT_R1(x) (((x) & 0x3) << 0) 145 + #define MC13783_LED_C3_CURRENT_G1(x) (((x) & 0x3) << 2) 146 + #define MC13783_LED_C3_CURRENT_B1(x) (((x) & 0x3) << 4) 138 147 #define MC13783_LED_C3_PERIOD(x) (((x) & 0x3) << 21) 139 148 #define MC13783_LED_C3_TRIODE_TC1 (1 << 23) 140 - /* LED Control 4 */ 149 + /* MC13783 LED Control 4 */ 150 + #define MC13783_LED_C4_CURRENT_R2(x) (((x) & 0x3) << 0) 151 + #define MC13783_LED_C4_CURRENT_G2(x) (((x) & 0x3) << 2) 152 + #define MC13783_LED_C4_CURRENT_B2(x) (((x) & 0x3) << 4) 141 153 #define MC13783_LED_C4_PERIOD(x) (((x) & 0x3) << 21) 142 154 #define MC13783_LED_C4_TRIODE_TC2 (1 << 23) 143 - /* LED Control 5 */ 155 + /* MC13783 LED Control 5 */ 156 + #define MC13783_LED_C5_CURRENT_R3(x) (((x) & 0x3) << 0) 157 + #define MC13783_LED_C5_CURRENT_G3(x) (((x) & 0x3) << 2) 158 + #define MC13783_LED_C5_CURRENT_B3(x) (((x) & 0x3) << 4) 144 159 #define MC13783_LED_C5_PERIOD(x) (((x) & 0x3) << 21) 145 160 #define MC13783_LED_C5_TRIODE_TC3 (1 << 23) 161 + /* MC13892 LED Control 0 */ 162 + #define MC13892_LED_C0_CURRENT_MD(x) (((x) & 0x7) << 9) 163 + #define MC13892_LED_C0_CURRENT_AD(x) (((x) & 0x7) << 21) 164 + /* MC13892 LED Control 1 */ 165 + #define MC13892_LED_C1_CURRENT_KP(x) (((x) & 0x7) << 9) 166 + /* MC13892 LED Control 2 */ 167 + #define MC13892_LED_C2_CURRENT_R(x) (((x) & 0x7) << 9) 168 + #define MC13892_LED_C2_CURRENT_G(x) (((x) & 0x7) << 21) 169 + /* MC13892 LED Control 3 */ 170 + #define MC13892_LED_C3_CURRENT_B(x) (((x) & 0x7) << 9) 146 171 u32 led_control[MAX_LED_CONTROL_REGS]; 147 172 }; 148 173