Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ca14acdf authored by Anirudh Ghayal's avatar Anirudh Ghayal Committed by Gerrit - the friendly Code Review server
Browse files

power: smb135x-charger: Add a check to detect if the charger is present



There is a possibility that the device is instantiated in the device
tree but is not present on the board. Add a dummy read to check if
this is case and bail out.

Change-Id: Ia90baa4bebfad7d95c5075b439f0dd26c921daf1
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent 3b8cc3fc
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -2015,7 +2015,7 @@ static int smb135x_charger_probe(struct i2c_client *client,
	int rc;
	struct smb135x_chg *chip;
	struct power_supply *usb_psy;
	u8 version;
	u8 version, reg = 0;

	usb_psy = power_supply_get_by_name("usb");
	if (!usb_psy) {
@@ -2033,6 +2033,13 @@ static int smb135x_charger_probe(struct i2c_client *client,
	chip->dev = &client->dev;
	chip->usb_psy = usb_psy;

	/* probe the device to check if its actually connected */
	rc = smb135x_read(chip, CFG_4_REG, &reg);
	if (rc) {
		pr_err("Failed to detect SMB135x, device may be absent\n");
		return -ENODEV;
	}

	rc = smb_parse_dt(chip);
	if (rc < 0) {
		dev_err(&client->dev, "Unable to parse DT nodes\n");