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

Commit 3e17c1ba authored by Vatsal Bucha's avatar Vatsal Bucha Committed by Gerrit - the friendly Code Review server
Browse files

drivers: fsa: Fix mute on USB digital hs after SSR



Mute is observed on USB digital headset after SSR due to
headset removal being called. Do not reset switch settings
during fsa unregister to resolve this.

Change-Id: Ia2e349b3913ebfefbf8c19316b2c70b6c314cb92
Signed-off-by: default avatarVatsal Bucha <vbucha@codeaurora.org>
parent dc603f56
Loading
Loading
Loading
Loading
+23 −3
Original line number Diff line number Diff line
/* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -236,8 +236,11 @@ EXPORT_SYMBOL(fsa4480_reg_notifier);
int fsa4480_unreg_notifier(struct notifier_block *nb,
			     struct device_node *node)
{
	int rc = 0;
	struct i2c_client *client = of_find_i2c_device_by_node(node);
	struct fsa4480_priv *fsa_priv;
	struct device *dev;
	union power_supply_propval mode;

	if (!client)
		return -EINVAL;
@@ -245,10 +248,27 @@ int fsa4480_unreg_notifier(struct notifier_block *nb,
	fsa_priv = (struct fsa4480_priv *)i2c_get_clientdata(client);
	if (!fsa_priv)
		return -EINVAL;
	dev = fsa_priv->dev;
	if (!dev)
		return -EINVAL;

	mutex_lock(&fsa_priv->notification_lock);
	/* get latest mode within locked context */
	rc = power_supply_get_property(fsa_priv->usb_psy,
			POWER_SUPPLY_PROP_TYPEC_MODE, &mode);
	if (rc) {
		dev_dbg(dev, "%s: Unable to read USB TYPEC_MODE: %d\n",
			__func__, rc);
		goto done;
	}
	/* Do not reset switch settings for usb digital hs */
	if (mode.intval != POWER_SUPPLY_TYPEC_SINK)
		fsa4480_usbc_update_settings(fsa_priv, 0x18, 0x98);
	return blocking_notifier_chain_unregister
	rc = blocking_notifier_chain_unregister
					(&fsa_priv->fsa4480_notifier, nb);
done:
	mutex_unlock(&fsa_priv->notification_lock);
	return rc;
}
EXPORT_SYMBOL(fsa4480_unreg_notifier);