All of lore.kernel.org
 help / color / mirror / Atom feed
* [v2,3/6] usb: typec: ucsi: add port num info
@ 2019-01-30 14:47 Heikki Krogerus
  0 siblings, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2019-01-30 14:47 UTC (permalink / raw)
  To: Ajay Gupta; +Cc: linux-usb, Ajay Gupta

On Mon, Jan 28, 2019 at 12:37:28PM -0800, Ajay Gupta wrote:
> Read PD port number information and save. It will be
> required while sending PD_PORT_ENABLE command.
> 
> Signed-off-by: Ajay Gupta <ajayg@nvidia.com>
> ---
> Changes from v1:
> 	- Updated commit message
> 	- Used mask and shift instead of bitfield
> 
>  drivers/usb/typec/ucsi/ucsi_ccg.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
> index 3155ee6be357..f71387a21693 100644
> --- a/drivers/usb/typec/ucsi/ucsi_ccg.c
> +++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
> @@ -172,6 +172,7 @@ struct ucsi_ccg {
>  #define DEV_CMD_PENDING	1
>  	struct ccg_resp dev_resp;
>  	u8 cmd_resp;
> +	int port_num;
>  };
>  
>  static int ccg_read(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len)
> @@ -526,6 +527,12 @@ static int ucsi_ccg_probe(struct i2c_client *client,
>  		return status;
>  	}
>  
> +	if ((uc->info.mode & CCG_DEVINFO_PDPORTS_MASK) >>
> +			CCG_DEVINFO_PDPORTS_SHIFT)

No need to shift.

> +		uc->port_num = 2;
> +	else
> +		uc->port_num = 1;

        uc->port_num = 1

	if (uc->info.mode & CCG_DEVINFO_PDPORTS_MASK)
                uc->port_num++;

Or just:

        uc->port_num = !!(uc->info.mode & CCG_DEVINFO_PDPORTS_MASK) + 1;

thanks,

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [v2,3/6] usb: typec: ucsi: add port num info
@ 2019-01-31  1:07 Ajay Gupta
  0 siblings, 0 replies; 3+ messages in thread
From: Ajay Gupta @ 2019-01-31  1:07 UTC (permalink / raw)
  To: Heikki Krogerus, Ajay Gupta; +Cc: linux-usb

Hi Heikki,

> On Mon, Jan 28, 2019 at 12:37:28PM -0800, Ajay Gupta wrote:
> > Read PD port number information and save. It will be required while
> > sending PD_PORT_ENABLE command.
> >
> > Signed-off-by: Ajay Gupta <ajayg@nvidia.com>
> > ---
> > Changes from v1:
> > 	- Updated commit message
> > 	- Used mask and shift instead of bitfield
> >
> >  drivers/usb/typec/ucsi/ucsi_ccg.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> >
> > diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c
> > b/drivers/usb/typec/ucsi/ucsi_ccg.c
> > index 3155ee6be357..f71387a21693 100644
> > --- a/drivers/usb/typec/ucsi/ucsi_ccg.c
> > +++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
> > @@ -172,6 +172,7 @@ struct ucsi_ccg {
> >  #define DEV_CMD_PENDING	1
> >  	struct ccg_resp dev_resp;
> >  	u8 cmd_resp;
> > +	int port_num;
> >  };
> >
> >  static int ccg_read(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len)
> > @@ -526,6 +527,12 @@ static int ucsi_ccg_probe(struct i2c_client *client,
> >  		return status;
> >  	}
> >
> > +	if ((uc->info.mode & CCG_DEVINFO_PDPORTS_MASK) >>
> > +			CCG_DEVINFO_PDPORTS_SHIFT)
> 
> No need to shift.
Ok.
> 
> > +		uc->port_num = 2;
> > +	else
> > +		uc->port_num = 1;
> 
>         uc->port_num = 1
> 
> 	if (uc->info.mode & CCG_DEVINFO_PDPORTS_MASK)
>                 uc->port_num++;
This looks better.

thanks
> nvpublic
> Or just:
> 
>         uc->port_num = !!(uc->info.mode & CCG_DEVINFO_PDPORTS_MASK) + 1;
> 
> thanks,
> 
> --
> heikki

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [v2,3/6] usb: typec: ucsi: add port num info
@ 2019-01-28 20:37 Ajay Gupta
  0 siblings, 0 replies; 3+ messages in thread
From: Ajay Gupta @ 2019-01-28 20:37 UTC (permalink / raw)
  To: heikki.krogerus; +Cc: linux-usb, Ajay Gupta

Read PD port number information and save. It will be
required while sending PD_PORT_ENABLE command.

Signed-off-by: Ajay Gupta <ajayg@nvidia.com>
---
Changes from v1:
	- Updated commit message
	- Used mask and shift instead of bitfield

 drivers/usb/typec/ucsi/ucsi_ccg.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/usb/typec/ucsi/ucsi_ccg.c b/drivers/usb/typec/ucsi/ucsi_ccg.c
index 3155ee6be357..f71387a21693 100644
--- a/drivers/usb/typec/ucsi/ucsi_ccg.c
+++ b/drivers/usb/typec/ucsi/ucsi_ccg.c
@@ -172,6 +172,7 @@ struct ucsi_ccg {
 #define DEV_CMD_PENDING	1
 	struct ccg_resp dev_resp;
 	u8 cmd_resp;
+	int port_num;
 };
 
 static int ccg_read(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len)
@@ -526,6 +527,12 @@ static int ucsi_ccg_probe(struct i2c_client *client,
 		return status;
 	}
 
+	if ((uc->info.mode & CCG_DEVINFO_PDPORTS_MASK) >>
+			CCG_DEVINFO_PDPORTS_SHIFT)
+		uc->port_num = 2;
+	else
+		uc->port_num = 1;
+
 	status = devm_request_threaded_irq(dev, client->irq, NULL,
 					   ccg_irq_handler,
 					   IRQF_ONESHOT | IRQF_TRIGGER_HIGH,

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-31  1:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-30 14:47 [v2,3/6] usb: typec: ucsi: add port num info Heikki Krogerus
  -- strict thread matches above, loose matches on Subject: below --
2019-01-31  1:07 Ajay Gupta
2019-01-28 20:37 Ajay Gupta

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.