power: bq25890: simplify chip name property getter
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>
Sun, 3 May 2020 15:21:10 +0000 (17:21 +0200)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Sun, 3 May 2020 19:49:34 +0000 (21:49 +0200)
Driver rejects unknown chips early in the probe(), so when
bq25890_power_supply_get_property() is made reachable, bq->chip_version
will already be set to correct value - there is no need to check
it again.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/bq25890_charger.c

index aebd125..d44ef48 100644 (file)
@@ -32,6 +32,13 @@ enum bq25890_chip_version {
        BQ25896,
 };
 
+static const char *const bq25890_chip_name[] = {
+       "BQ25890",
+       "BQ25892",
+       "BQ25895",
+       "BQ25896",
+};
+
 enum bq25890_fields {
        F_EN_HIZ, F_EN_ILIM, F_IILIM,                                /* Reg00 */
        F_BHOT, F_BCOLD, F_VINDPM_OFS,                               /* Reg01 */
@@ -400,17 +407,7 @@ static int bq25890_power_supply_get_property(struct power_supply *psy,
                break;
 
        case POWER_SUPPLY_PROP_MODEL_NAME:
-               if (bq->chip_version == BQ25890)
-                       val->strval = "BQ25890";
-               else if (bq->chip_version == BQ25892)
-                       val->strval = "BQ25892";
-               else if (bq->chip_version == BQ25895)
-                       val->strval = "BQ25895";
-               else if (bq->chip_version == BQ25896)
-                       val->strval = "BQ25896";
-               else
-                       val->strval = "UNKNOWN";
-
+               val->strval = bq25890_chip_name[bq->chip_version];
                break;
 
        case POWER_SUPPLY_PROP_ONLINE: