diff options
author | Finn Thain <fthain@telegraphics.com.au> | 2018-07-02 04:21:19 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2018-07-31 05:56:43 -0400 |
commit | b5c7cccaacdfa8d707da3e65970b15070f56df5e (patch) | |
tree | e3190148ddc2b8d1d6d645c3c0aaca82299a73d3 /drivers/macintosh | |
parent | ebd722275f9cfc6752e29d2412fa3816ca05764b (diff) |
macintosh/via-pmu: Clean up interrupt statistics
Replace an open-coded ffs() with the function call.
Simplify an if-else cascade using a switch statement.
Correct a typo and an indentation issue.
Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'drivers/macintosh')
-rw-r--r-- | drivers/macintosh/via-pmu.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index a68e7a6f00cc..3da5d40309d4 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c | |||
@@ -1355,7 +1355,8 @@ pmu_resume(void) | |||
1355 | static void | 1355 | static void |
1356 | pmu_handle_data(unsigned char *data, int len) | 1356 | pmu_handle_data(unsigned char *data, int len) |
1357 | { | 1357 | { |
1358 | unsigned char ints, pirq; | 1358 | unsigned char ints; |
1359 | int idx; | ||
1359 | int i = 0; | 1360 | int i = 0; |
1360 | 1361 | ||
1361 | asleep = 0; | 1362 | asleep = 0; |
@@ -1377,25 +1378,24 @@ pmu_handle_data(unsigned char *data, int len) | |||
1377 | ints &= ~(PMU_INT_ADB_AUTO | PMU_INT_AUTO_SRQ_POLL); | 1378 | ints &= ~(PMU_INT_ADB_AUTO | PMU_INT_AUTO_SRQ_POLL); |
1378 | 1379 | ||
1379 | next: | 1380 | next: |
1380 | |||
1381 | if (ints == 0) { | 1381 | if (ints == 0) { |
1382 | if (i > pmu_irq_stats[10]) | 1382 | if (i > pmu_irq_stats[10]) |
1383 | pmu_irq_stats[10] = i; | 1383 | pmu_irq_stats[10] = i; |
1384 | return; | 1384 | return; |
1385 | } | 1385 | } |
1386 | |||
1387 | for (pirq = 0; pirq < 8; pirq++) | ||
1388 | if (ints & (1 << pirq)) | ||
1389 | break; | ||
1390 | pmu_irq_stats[pirq]++; | ||
1391 | i++; | 1386 | i++; |
1392 | ints &= ~(1 << pirq); | 1387 | |
1388 | idx = ffs(ints) - 1; | ||
1389 | ints &= ~BIT(idx); | ||
1390 | |||
1391 | pmu_irq_stats[idx]++; | ||
1393 | 1392 | ||
1394 | /* Note: for some reason, we get an interrupt with len=1, | 1393 | /* Note: for some reason, we get an interrupt with len=1, |
1395 | * data[0]==0 after each normal ADB interrupt, at least | 1394 | * data[0]==0 after each normal ADB interrupt, at least |
1396 | * on the Pismo. Still investigating... --BenH | 1395 | * on the Pismo. Still investigating... --BenH |
1397 | */ | 1396 | */ |
1398 | if ((1 << pirq) & PMU_INT_ADB) { | 1397 | switch (BIT(idx)) { |
1398 | case PMU_INT_ADB: | ||
1399 | if ((data[0] & PMU_INT_ADB_AUTO) == 0) { | 1399 | if ((data[0] & PMU_INT_ADB_AUTO) == 0) { |
1400 | struct adb_request *req = req_awaiting_reply; | 1400 | struct adb_request *req = req_awaiting_reply; |
1401 | if (!req) { | 1401 | if (!req) { |
@@ -1433,25 +1433,28 @@ next: | |||
1433 | adb_input(data+1, len-1, 1); | 1433 | adb_input(data+1, len-1, 1); |
1434 | #endif /* CONFIG_ADB */ | 1434 | #endif /* CONFIG_ADB */ |
1435 | } | 1435 | } |
1436 | } | 1436 | break; |
1437 | |||
1437 | /* Sound/brightness button pressed */ | 1438 | /* Sound/brightness button pressed */ |
1438 | else if ((1 << pirq) & PMU_INT_SNDBRT) { | 1439 | case PMU_INT_SNDBRT: |
1439 | #ifdef CONFIG_PMAC_BACKLIGHT | 1440 | #ifdef CONFIG_PMAC_BACKLIGHT |
1440 | if (len == 3) | 1441 | if (len == 3) |
1441 | pmac_backlight_set_legacy_brightness_pmu(data[1] >> 4); | 1442 | pmac_backlight_set_legacy_brightness_pmu(data[1] >> 4); |
1442 | #endif | 1443 | #endif |
1443 | } | 1444 | break; |
1445 | |||
1444 | /* Tick interrupt */ | 1446 | /* Tick interrupt */ |
1445 | else if ((1 << pirq) & PMU_INT_TICK) { | 1447 | case PMU_INT_TICK: |
1446 | /* Environement or tick interrupt, query batteries */ | 1448 | /* Environment or tick interrupt, query batteries */ |
1447 | if (pmu_battery_count) { | 1449 | if (pmu_battery_count) { |
1448 | if ((--query_batt_timer) == 0) { | 1450 | if ((--query_batt_timer) == 0) { |
1449 | query_battery_state(); | 1451 | query_battery_state(); |
1450 | query_batt_timer = BATTERY_POLLING_COUNT; | 1452 | query_batt_timer = BATTERY_POLLING_COUNT; |
1451 | } | 1453 | } |
1452 | } | 1454 | } |
1453 | } | 1455 | break; |
1454 | else if ((1 << pirq) & PMU_INT_ENVIRONMENT) { | 1456 | |
1457 | case PMU_INT_ENVIRONMENT: | ||
1455 | if (pmu_battery_count) | 1458 | if (pmu_battery_count) |
1456 | query_battery_state(); | 1459 | query_battery_state(); |
1457 | pmu_pass_intr(data, len); | 1460 | pmu_pass_intr(data, len); |
@@ -1461,7 +1464,9 @@ next: | |||
1461 | via_pmu_event(PMU_EVT_POWER, !!(data[1]&8)); | 1464 | via_pmu_event(PMU_EVT_POWER, !!(data[1]&8)); |
1462 | via_pmu_event(PMU_EVT_LID, data[1]&1); | 1465 | via_pmu_event(PMU_EVT_LID, data[1]&1); |
1463 | } | 1466 | } |
1464 | } else { | 1467 | break; |
1468 | |||
1469 | default: | ||
1465 | pmu_pass_intr(data, len); | 1470 | pmu_pass_intr(data, len); |
1466 | } | 1471 | } |
1467 | goto next; | 1472 | goto next; |