diff options
Diffstat (limited to 'drivers/extcon/extcon-arizona.c')
-rw-r--r-- | drivers/extcon/extcon-arizona.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c index c6347965c639..c2eed30cfc3a 100644 --- a/drivers/extcon/extcon-arizona.c +++ b/drivers/extcon/extcon-arizona.c | |||
@@ -329,14 +329,17 @@ static void arizona_stop_mic(struct arizona_extcon_info *info) | |||
329 | } | 329 | } |
330 | 330 | ||
331 | static struct { | 331 | static struct { |
332 | unsigned int threshold; | ||
332 | unsigned int factor_a; | 333 | unsigned int factor_a; |
333 | unsigned int factor_b; | 334 | unsigned int factor_b; |
334 | } arizona_hpdet_b_ranges[] = { | 335 | } arizona_hpdet_b_ranges[] = { |
335 | { 5528, 362464 }, | 336 | { 100, 5528, 362464 }, |
336 | { 11084, 6186851 }, | 337 | { 169, 11084, 6186851 }, |
337 | { 11065, 65460395 }, | 338 | { 169, 11065, 65460395 }, |
338 | }; | 339 | }; |
339 | 340 | ||
341 | #define ARIZONA_HPDET_B_RANGE_MAX 0x3fb | ||
342 | |||
340 | static struct { | 343 | static struct { |
341 | int min; | 344 | int min; |
342 | int max; | 345 | int max; |
@@ -391,7 +394,8 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info) | |||
391 | >> ARIZONA_HP_IMPEDANCE_RANGE_SHIFT; | 394 | >> ARIZONA_HP_IMPEDANCE_RANGE_SHIFT; |
392 | 395 | ||
393 | if (range < ARRAY_SIZE(arizona_hpdet_b_ranges) - 1 && | 396 | if (range < ARRAY_SIZE(arizona_hpdet_b_ranges) - 1 && |
394 | (val < 100 || val >= 0x3fb)) { | 397 | (val < arizona_hpdet_b_ranges[range].threshold || |
398 | val >= ARIZONA_HPDET_B_RANGE_MAX)) { | ||
395 | range++; | 399 | range++; |
396 | dev_dbg(arizona->dev, "Moving to HPDET range %d\n", | 400 | dev_dbg(arizona->dev, "Moving to HPDET range %d\n", |
397 | range); | 401 | range); |
@@ -404,7 +408,8 @@ static int arizona_hpdet_read(struct arizona_extcon_info *info) | |||
404 | } | 408 | } |
405 | 409 | ||
406 | /* If we go out of range report top of range */ | 410 | /* If we go out of range report top of range */ |
407 | if (val < 100 || val >= 0x3fb) { | 411 | if (val < arizona_hpdet_b_ranges[range].threshold || |
412 | val >= ARIZONA_HPDET_B_RANGE_MAX) { | ||
408 | dev_dbg(arizona->dev, "Measurement out of range\n"); | 413 | dev_dbg(arizona->dev, "Measurement out of range\n"); |
409 | return ARIZONA_HPDET_MAX; | 414 | return ARIZONA_HPDET_MAX; |
410 | } | 415 | } |