Hi > -----Original Message----- > From: Guenter Roeck [mailto:groeck7@xxxxxxxxx] On Behalf Of Guenter Roeck > Sent: Tuesday, September 26, 2017 9:34 PM > To: Jun Li <jun.li@xxxxxxx>; gregkh@xxxxxxxxxxxxxxxxxxx; robh+dt@xxxxxxxxxx; > mark.rutland@xxxxxxx; heikki.krogerus@xxxxxxxxxxxxxxx > Cc: yueyao@xxxxxxxxxx; o_leveque@xxxxxxxxx; Peter Chen > <peter.chen@xxxxxxx>; A.s. Dong <aisheng.dong@xxxxxxx>; linux- > usb@xxxxxxxxxxxxxxx; devicetree@xxxxxxxxxxxxxxx > Subject: Re: [PATCH 05/12] staging: typec: tcpci: register port before request irq > > On 09/25/2017 05:45 PM, Li Jun wrote: > > With that we can clear any pending events and the port is registered > > so driver can be ready to handle typec events once we request irq. > > > > Signed-off-by: Peter Chen <peter.chen@xxxxxxx> > > Signed-off-by: Li Jun <jun.li@xxxxxxx> > > --- > > drivers/staging/typec/tcpci.c | 11 +++++------ > > 1 file changed, 5 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/staging/typec/tcpci.c > > b/drivers/staging/typec/tcpci.c index 0119453..6d608b4 100644 > > --- a/drivers/staging/typec/tcpci.c > > +++ b/drivers/staging/typec/tcpci.c > > @@ -552,15 +552,14 @@ static int tcpci_probe(struct i2c_client *client, > > /* Disable chip interrupts */ > > tcpci_write16(tcpci, TCPC_ALERT_MASK, 0); > > > > - err = devm_request_threaded_irq(tcpci->dev, client->irq, NULL, > > + tcpci->port = tcpm_register_port(tcpci->dev, &tcpci->tcpc); > > + if (IS_ERR(tcpci->port)) > > + return PTR_ERR(tcpci->port); > > + > > + return devm_request_threaded_irq(tcpci->dev, client->irq, NULL, > > tcpci_irq, > > IRQF_ONESHOT | IRQF_TRIGGER_LOW, > > dev_name(tcpci->dev), tcpci); > > - if (err < 0) > > - return err; > > - > > - tcpci->port = tcpm_register_port(tcpci->dev, &tcpci->tcpc); > > - return PTR_ERR_OR_ZERO(tcpci->port); > > This leaves the port registered if registering the irq fails. I will add an error handling with tcpm_unregister_port(). > > > } > > > > static int tcpci_remove(struct i2c_client *client) > > ��.n��������+%������w��{.n�����{���)��jg��������ݢj����G�������j:+v���w�m������w�������h�����٥