All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Sebastian Reichel <sre@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Andrejus Basovas <cpp@gcc.lt>,
	linux-pm@vger.kernel.org
Subject: [PATCH v2 09/10] power: supply: axp288_fuel_gauge: Move the AXP20X_CC_CTRL check together with the other checks
Date: Fri, 30 Jul 2021 11:56:06 +0200	[thread overview]
Message-ID: <20210730095607.57541-10-hdegoede@redhat.com> (raw)
In-Reply-To: <20210730095607.57541-1-hdegoede@redhat.com>

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>
---
 drivers/power/supply/axp288_fuel_gauge.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/power/supply/axp288_fuel_gauge.c b/drivers/power/supply/axp288_fuel_gauge.c
index 8db8ab0827e4..016d8d6bec40 100644
--- a/drivers/power/supply/axp288_fuel_gauge.c
+++ b/drivers/power/supply/axp288_fuel_gauge.c
@@ -627,16 +627,6 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev)
 	if (dmi_check_system(axp288_no_battery_list))
 		return -ENODEV;
 
-	/*
-	 * On some devices the fuelgauge and charger parts of the axp288 are
-	 * not used, check that the fuelgauge is enabled (CC_CTRL != 0).
-	 */
-	ret = regmap_read(axp20x->regmap, AXP20X_CC_CTRL, &val);
-	if (ret < 0)
-		return ret;
-	if (val == 0)
-		return -ENODEV;
-
 	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
 	if (!info)
 		return -ENOMEM;
@@ -671,6 +661,18 @@ static int axp288_fuel_gauge_probe(struct platform_device *pdev)
 		}
 	}
 
+	/*
+	 * On some devices the fuelgauge and charger parts of the axp288 are
+	 * not used, check that the fuelgauge is enabled (CC_CTRL != 0).
+	 */
+	ret = regmap_read(axp20x->regmap, AXP20X_CC_CTRL, &val);
+	if (ret < 0)
+		goto out_free_iio_chan;
+	if (val == 0) {
+		ret = -ENODEV;
+		goto out_free_iio_chan;
+	}
+
 	ret = fuel_gauge_reg_readb(info, AXP288_FG_DES_CAP1_REG);
 	if (ret < 0)
 		goto out_free_iio_chan;
-- 
2.31.1


  parent reply	other threads:[~2021-07-30  9:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-30  9:55 [PATCH v2 00/10] power: supply: axp288_fuel_gauge: Reduce number of register accesses + cleanups Hans de Goede
2021-07-30  9:55 ` [PATCH v2 01/10] power: supply: axp288_fuel_gauge: Fix define alignment Hans de Goede
2021-07-30  9:55 ` [PATCH v2 02/10] power: supply: axp288_fuel_gauge: Remove debugfs support Hans de Goede
2021-07-30  9:56 ` [PATCH v2 03/10] power: supply: axp288_fuel_gauge: Silence the chatty IRQ mapping code Hans de Goede
2021-07-30  9:56 ` [PATCH v2 04/10] power: supply: axp288_fuel_gauge: Report register-address on readb / writeb errors Hans de Goede
2021-07-30  9:56 ` [PATCH v2 05/10] power: supply: axp288_fuel_gauge: Drop retry logic from fuel_gauge_reg_readb() Hans de Goede
2021-07-30  9:56 ` [PATCH v2 06/10] power: supply: axp288_fuel_gauge: Store struct device pointer in axp288_fg_info Hans de Goede
2021-07-30  9:56 ` [PATCH v2 07/10] power: supply: axp288_fuel_gauge: Only read PWR_OP_MODE, FG_LOW_CAP_REG regs once Hans de Goede
2021-07-30  9:56 ` [PATCH v2 08/10] power: supply: axp288_fuel_gauge: Refresh all registers in one go Hans de Goede
2021-07-30 13:39   ` kernel test robot
2021-07-30 13:39     ` kernel test robot
2021-07-30 16:14   ` kernel test robot
2021-07-30 16:14     ` kernel test robot
2021-08-01 11:23     ` Hans de Goede
2021-08-01 11:23       ` Hans de Goede
2021-07-30  9:56 ` Hans de Goede [this message]
2021-07-30  9:56 ` [PATCH v2 10/10] power: supply: axp288_fuel_gauge: Take the P-Unit semaphore only once during probe() Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210730095607.57541-10-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=cpp@gcc.lt \
    --cc=linux-pm@vger.kernel.org \
    --cc=sre@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.