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

Commit c6bf7911 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "power: smb135x-charger: Add mutex locking in parallel enable path"

parents b070c5e7 a7c6c9ea
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -6498,8 +6498,12 @@ static irqreturn_t fastchg_handler(int irq, void *_chip)
	struct smbchg_chip *chip = _chip;

	pr_smb(PR_INTERRUPT, "p2f triggered\n");

	if (is_usb_present(chip) || is_dc_present(chip)) {
		smbchg_detect_parallel_charger(chip);
		smbchg_parallel_usb_check_ok(chip);
	}

	if (chip->psy_registered)
		power_supply_changed(&chip->batt_psy);
	smbchg_charging_status_change(chip);
+8 −1
Original line number Diff line number Diff line
@@ -529,6 +529,7 @@ struct smb1351_charger {
	int			slave_fcc_ma_before_esr;
	int			workaround_flags;

	struct mutex		parallel_config_lock;
	int			parallel_pin_polarity_setting;
	bool			is_slave;
	bool			use_external_fg;
@@ -2562,10 +2563,12 @@ static int smb1351_parallel_set_property(struct power_supply *psy,
		}
		break;
	case POWER_SUPPLY_PROP_PRESENT:
		mutex_lock(&chip->parallel_config_lock);
		rc = smb1351_parallel_set_chg_present(chip, val->intval);
		if (rc)
			pr_err("Set charger %spresent failed\n",
					val->intval ? "" : "un-");
		mutex_unlock(&chip->parallel_config_lock);
		break;
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
		if (chip->parallel_charger_present) {
@@ -4663,6 +4666,7 @@ static int smb1351_parallel_slave_probe(struct i2c_client *client,
				EN_BY_PIN_HIGH_ENABLE : EN_BY_PIN_LOW_ENABLE;

	i2c_set_clientdata(client, chip);
	mutex_init(&chip->parallel_config_lock);

	chip->parallel_psy.name		= "usb-parallel";
	chip->parallel_psy.type		= POWER_SUPPLY_TYPE_USB_PARALLEL;
@@ -4695,6 +4699,7 @@ fail_register_psy:
	wakeup_source_trash(&chip->smb1351_ws.source);
	mutex_destroy(&chip->irq_complete);
	mutex_destroy(&chip->fcc_lock);
	mutex_destroy(&chip->parallel_config_lock);
	return rc;
}

@@ -4717,8 +4722,10 @@ static int smb1351_charger_remove(struct i2c_client *client)
	wakeup_source_trash(&chip->smb1351_ws.source);
	mutex_destroy(&chip->irq_complete);
	mutex_destroy(&chip->fcc_lock);
	if (is_parallel_slave(client))
	if (is_parallel_slave(client)) {
		mutex_destroy(&chip->parallel_config_lock);
		mutex_destroy(&chip->parallel.lock);
	}
	debugfs_remove_recursive(chip->debug_root);
	return 0;
}
+5 −0
Original line number Diff line number Diff line
@@ -375,6 +375,7 @@ struct smb135x_chg {
	struct mutex			otg_oc_count_lock;
	struct delayed_work		hvdcp_det_work;

	struct mutex			parallel_config_lock;
	bool				parallel_charger;
	bool				parallel_charger_present;
	bool				bms_controlled_charging;
@@ -1959,7 +1960,9 @@ static int smb135x_parallel_set_property(struct power_supply *psy,
			chip->chg_enabled = val->intval;
		break;
	case POWER_SUPPLY_PROP_PRESENT:
		mutex_lock(&chip->parallel_config_lock);
		rc = smb135x_parallel_set_chg_present(chip, val->intval);
		mutex_unlock(&chip->parallel_config_lock);
		break;
	case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
		if (chip->parallel_charger_present) {
@@ -4437,6 +4440,7 @@ static int smb135x_parallel_charger_probe(struct i2c_client *client,
	mutex_init(&chip->path_suspend_lock);
	mutex_init(&chip->current_change_lock);
	mutex_init(&chip->read_write_lock);
	mutex_init(&chip->parallel_config_lock);
	wakeup_source_init(&chip->wake_source.source, "smb_wake_source");

	match = of_match_node(smb135x_match_table, node);
@@ -4495,6 +4499,7 @@ static int smb135x_charger_remove(struct i2c_client *client)

	if (chip->parallel_charger) {
		power_supply_unregister(&chip->parallel_psy);
		mutex_destroy(&chip->parallel_config_lock);
		goto mutex_destroy;
	}