Skip to contentSkip to conversation

usb: typec: tcpci: mask event interrupts when remove driver

PATCH Superseded Jun Li 3 participants 4 messages Jan 19, 2020 – Jan 20, 2020

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jun Li

author
#0 lore raw

PATCH 1/1 usb: typec: tcpci: mask event interrupts when remove driver

This is to prevent any possible events generated while unregister tpcm port.

---
 drivers/usb/typec/tcpm/tcpci.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/usb/typec/tcpm/tcpci.c +8 -0
index c1f7073..3b42ef8 100644
@@ -581,6 +581,14 @@ static int tcpci_probe(struct i2c_client *client,
 static int tcpci_remove(struct i2c_client *client)
 {
 	struct tcpci_chip *chip = i2c_get_clientdata(client);
+	u16 val = 0;
+	int err;
+
+	/* Disable chip interrupts before unregistger port */
+	err = regmap_raw_write(chip->data.regmap, TCPC_ALERT_MASK, &val,
+			       sizeof(u16));
+	if (err < 0)
+		return err;
 
 	tcpci_unregister_port(chip->tcpci);
 
Signature · 1 line
2.7.4
#1 lore raw
Quoted 7 lines · Jun Li

This is to prevent any possible events generated while unregister tpcm port.

---
 drivers/usb/typec/tcpm/tcpci.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Does this need to be backported to older kernels? If so, how far back? Any idea what commit caused this issue?

thanks,

greg k-h

#2 lore raw
In reply to Jun Li
Quoted 4 lines · Jun Li

This is to prevent any possible events generated while unregister tpcm port.

Fixes 74e656d6b0551 ("staging: typec: Type-C Port Controller Interface driver (tcpci)")
Quoted 9 lines
---
  drivers/usb/typec/tcpm/tcpci.c | 8 ++++++++
  1 file changed, 8 insertions(+)
drivers/usb/typec/tcpm/tcpci.c +0 -0
index c1f7073..3b42ef8 100644

drivers/usb/typec/tcpm/tcpci.c static int tcpci_probe(struct i2c_client *client, · line 589

Quoted 9 lines
drivers/usb/typec/tcpm/tcpci.c +6 -0
@@ -581,6 +581,14 @@ static int tcpci_probe(struct i2c_client *client,
  static int tcpci_remove(struct i2c_client *client)
  {
  	struct tcpci_chip *chip = i2c_get_clientdata(client);
+	u16 val = 0;
+	int err;
+
+	/* Disable chip interrupts before unregistger port */
+	err = regmap_raw_write(chip->data.regmap, TCPC_ALERT_MASK, &val,
+			       sizeof(u16));

I would suggest

	err = tcpci_write16(chip, TCPC_ALERT_MASK, 0);

Guenter

Quoted 6 lines
drivers/usb/typec/tcpm/tcpci.c +2 -0
+	if (err < 0)
+		return err;
 
  	tcpci_unregister_port(chip->tcpci);
 
author
#3 lore raw

Hi Guenter,

Quoted 9 lines

-----Original Message-----
From: Guenter Roeck <[email protected]> On Behalf Of Guenter Roeck
Sent: 2020年1月19日 23:03
To: Jun Li <[email protected]>; [email protected]
Cc: [email protected]; [email protected]; dl-linux-imx <[email protected]>
Subject: Re: [PATCH] usb: typec: tcpci: mask event interrupts when remove driver

Quoted 8 lines
Quoted 4 lines · Jun Li

This is to prevent any possible events generated while unregister tpcm port.

Fixes 74e656d6b0551 ("staging: typec: Type-C Port Controller Interface

driver (tcpci)")

Thanks, I will add the stable tag.

Quoted 22 lines
Quoted 10 lines
---
  drivers/usb/typec/tcpm/tcpci.c | 8 ++++++++
  1 file changed, 8 insertions(+)
(quoted diff) +0 -0

b/drivers/usb/typec/tcpm/tcpci.c index c1f7073..3b42ef8 100644

drivers/usb/typec/tcpm/tcpci.c static int tcpci_probe(struct i2c_client *client, · line 589

Quoted 9 lines
drivers/usb/typec/tcpm/tcpci.c +6 -0
@@ -581,6 +581,14 @@ static int tcpci_probe(struct i2c_client *client,
  static int tcpci_remove(struct i2c_client *client)
  {
  	struct tcpci_chip *chip = i2c_get_clientdata(client);
+	u16 val = 0;
+	int err;
+
+	/* Disable chip interrupts before unregistger port */
+	err = regmap_raw_write(chip->data.regmap, TCPC_ALERT_MASK, &val,
+			       sizeof(u16));

I would suggest

Quoted 1 line
	err = tcpci_write16(chip, TCPC_ALERT_MASK, 0);

OK, this is simpler, will send out V2.

Li Jun

Quoted 9 lines

Guenter

Quoted 6 lines
drivers/usb/typec/tcpm/tcpci.c +2 -0
+	if (err < 0)
+		return err;
 
  	tcpci_unregister_port(chip->tcpci);