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

power: supply: axp288_fuel_gauge: Move the AXP20X_CC_CTRL check together with the other checks

The I2C-bus to the XPower AXP288 is shared between the Linux kernel and
the SoCs P-Unit. The P-Unit has a semaphore which the kernel must "lock"
before it may use the bus. If not explicitly taken by the I2C-driver,
then this semaphore is automatically taken by the I2C-bus-driver for
each I2C-transfer.

Move the AXP20X_CC_CTRL check done in probe() together with the other
register-accesses done in probe, so that we can take the semaphore once
for the entire set of register-accesses.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Hans de Goede and committed by
Sebastian Reichel
964b3e9b 394088f0

+12 -10
+12 -10
drivers/power/supply/axp288_fuel_gauge.c
··· 627 627 if (dmi_check_system(axp288_no_battery_list)) 628 628 return -ENODEV; 629 629 630 - /* 631 - * On some devices the fuelgauge and charger parts of the axp288 are 632 - * not used, check that the fuelgauge is enabled (CC_CTRL != 0). 633 - */ 634 - ret = regmap_read(axp20x->regmap, AXP20X_CC_CTRL, &val); 635 - if (ret < 0) 636 - return ret; 637 - if (val == 0) 638 - return -ENODEV; 639 - 640 630 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); 641 631 if (!info) 642 632 return -ENOMEM; ··· 659 669 660 670 goto out_free_iio_chan; 661 671 } 672 + } 673 + 674 + /* 675 + * On some devices the fuelgauge and charger parts of the axp288 are 676 + * not used, check that the fuelgauge is enabled (CC_CTRL != 0). 677 + */ 678 + ret = regmap_read(axp20x->regmap, AXP20X_CC_CTRL, &val); 679 + if (ret < 0) 680 + goto out_free_iio_chan; 681 + if (val == 0) { 682 + ret = -ENODEV; 683 + goto out_free_iio_chan; 662 684 } 663 685 664 686 ret = fuel_gauge_reg_readb(info, AXP288_FG_DES_CAP1_REG);