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

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

power: smb349-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: Ie3f6ce6a88d2b4bd5348e5e8f8c1cb650e15dc77
Signed-off-by: default avatarAnirudh Ghayal <aghayal@codeaurora.org>
parent ca14acdf
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -1194,6 +1194,7 @@ static int smb349_charger_probe(struct i2c_client *client,
	int rc, irq;
	struct smb349_charger *chip;
	struct power_supply *usb_psy;
	u8 reg = 0;

	usb_psy = power_supply_get_by_name("usb");
	if (!usb_psy) {
@@ -1211,6 +1212,13 @@ static int smb349_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 = smb349_read_reg(chip, CHG_OTH_CURRENT_CTRL_REG, &reg);
	if (rc) {
		pr_err("Failed to detect SMB349, device may be absent\n");
		return -ENODEV;
	}

	rc = smb_parse_dt(chip);
	if (rc) {
		dev_err(&client->dev, "Couldn't parse DT nodes rc=%d\n", rc);