| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * ADP5061 I2C Programmable Linear Battery Charger |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright 2018 Analog Devices Inc. |
|---|
| 5 | | - * |
|---|
| 6 | | - * Licensed under the GPL-2. |
|---|
| 7 | 6 | */ |
|---|
| 8 | 7 | |
|---|
| 9 | 8 | #include <linux/init.h> |
|---|
| .. | .. |
|---|
| 428 | 427 | if (ret < 0) |
|---|
| 429 | 428 | return ret; |
|---|
| 430 | 429 | |
|---|
| 431 | | - chg_type = adp5061_chg_type[ADP5061_CHG_STATUS_1_CHG_STATUS(status1)]; |
|---|
| 432 | | - if (chg_type > ADP5061_CHG_FAST_CV) |
|---|
| 430 | + chg_type = ADP5061_CHG_STATUS_1_CHG_STATUS(status1); |
|---|
| 431 | + if (chg_type >= ARRAY_SIZE(adp5061_chg_type)) |
|---|
| 433 | 432 | val->intval = POWER_SUPPLY_STATUS_UNKNOWN; |
|---|
| 434 | 433 | else |
|---|
| 435 | | - val->intval = chg_type; |
|---|
| 434 | + val->intval = adp5061_chg_type[chg_type]; |
|---|
| 436 | 435 | |
|---|
| 437 | 436 | return ret; |
|---|
| 438 | 437 | } |
|---|