diff mbox

[RFC,v4,2/8] usb: typec: helper for checking cable plug orientation

Message ID 20180608112941.26332-3-heikki.krogerus@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Heikki Krogerus June 8, 2018, 11:29 a.m. UTC
This adds function typec_get_orientation() that can be used
for checking the current cable plug orientation.

Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/usb/typec/class.c | 11 +++++++++++
 include/linux/usb/typec.h |  1 +
 2 files changed, 12 insertions(+)

Comments

Mats Karrman June 12, 2018, 6:56 p.m. UTC | #1
Hi Heikki,

On 2018-06-08 13:29, Heikki Krogerus wrote:

> This adds function typec_get_orientation() that can be used
> for checking the current cable plug orientation.
>
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
>   drivers/usb/typec/class.c | 11 +++++++++++
>   include/linux/usb/typec.h |  1 +
>   2 files changed, 12 insertions(+)
>
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 53df10df2f9d..02db9bcbac0c 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -1279,6 +1279,17 @@ int typec_set_orientation(struct typec_port *port,
>   }
>   EXPORT_SYMBOL_GPL(typec_set_orientation);
>   
> +/**
> + * typec_get_orientation - Get USB Type-C cable plug orientation
> + * @port: USB Type-C Port
> + *
> + * Get current cable plug orientation for @port.
> + */
> +enum typec_orientation typec_get_orientation(struct typec_port *port)
> +{
> +	return port->orientation;
> +}

+EXPORT_SYMBOL_GPL(typec_get_orientation);

Isn't this a candidate for an inline?

BR // Mats

> +
>   /**
>    * typec_set_mode - Set mode of operation for USB Type-C connector
>    * @port: USB Type-C port for the connector
> diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
> index 672b39bb0adc..a5f6433e218b 100644
> --- a/include/linux/usb/typec.h
> +++ b/include/linux/usb/typec.h
> @@ -265,6 +265,7 @@ void typec_set_pwr_opmode(struct typec_port *port, enum typec_pwr_opmode mode);
>   
>   int typec_set_orientation(struct typec_port *port,
>   			  enum typec_orientation orientation);
> +enum typec_orientation typec_get_orientation(struct typec_port *port);
>   int typec_set_mode(struct typec_port *port, int mode);
>   
>   #endif /* __LINUX_USB_TYPEC_H */
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Guenter Roeck June 12, 2018, 10:18 p.m. UTC | #2
On Tue, Jun 12, 2018 at 08:56:31PM +0200, Mats Karrman wrote:
> Hi Heikki,
> 
> On 2018-06-08 13:29, Heikki Krogerus wrote:
> 
> >This adds function typec_get_orientation() that can be used
> >for checking the current cable plug orientation.
> >
> >Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> >---
> >  drivers/usb/typec/class.c | 11 +++++++++++
> >  include/linux/usb/typec.h |  1 +
> >  2 files changed, 12 insertions(+)
> >
> >diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> >index 53df10df2f9d..02db9bcbac0c 100644
> >--- a/drivers/usb/typec/class.c
> >+++ b/drivers/usb/typec/class.c
> >@@ -1279,6 +1279,17 @@ int typec_set_orientation(struct typec_port *port,
> >  }
> >  EXPORT_SYMBOL_GPL(typec_set_orientation);
> >+/**
> >+ * typec_get_orientation - Get USB Type-C cable plug orientation
> >+ * @port: USB Type-C Port
> >+ *
> >+ * Get current cable plug orientation for @port.
> >+ */
> >+enum typec_orientation typec_get_orientation(struct typec_port *port)
> >+{
> >+	return port->orientation;
> >+}
> 
> +EXPORT_SYMBOL_GPL(typec_get_orientation);
> 
> Isn't this a candidate for an inline?
> 

Currently struct typec_port is class private. To make this function inline,
struct typec_port would have to be moved from drivers/usb/typec/class.c to
include/linux/usb/typec.h. That doesn't sound like a good idea to me.

Guenter

> BR // Mats
> 
> >+
> >  /**
> >   * typec_set_mode - Set mode of operation for USB Type-C connector
> >   * @port: USB Type-C port for the connector
> >diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
> >index 672b39bb0adc..a5f6433e218b 100644
> >--- a/include/linux/usb/typec.h
> >+++ b/include/linux/usb/typec.h
> >@@ -265,6 +265,7 @@ void typec_set_pwr_opmode(struct typec_port *port, enum typec_pwr_opmode mode);
> >  int typec_set_orientation(struct typec_port *port,
> >  			  enum typec_orientation orientation);
> >+enum typec_orientation typec_get_orientation(struct typec_port *port);
> >  int typec_set_mode(struct typec_port *port, int mode);
> >  #endif /* __LINUX_USB_TYPEC_H */
> >
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Heikki Krogerus June 13, 2018, 12:33 p.m. UTC | #3
On Tue, Jun 12, 2018 at 03:18:42PM -0700, Guenter Roeck wrote:
> On Tue, Jun 12, 2018 at 08:56:31PM +0200, Mats Karrman wrote:
> > Hi Heikki,
> > 
> > On 2018-06-08 13:29, Heikki Krogerus wrote:
> > 
> > >This adds function typec_get_orientation() that can be used
> > >for checking the current cable plug orientation.
> > >
> > >Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > >---
> > >  drivers/usb/typec/class.c | 11 +++++++++++
> > >  include/linux/usb/typec.h |  1 +
> > >  2 files changed, 12 insertions(+)
> > >
> > >diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> > >index 53df10df2f9d..02db9bcbac0c 100644
> > >--- a/drivers/usb/typec/class.c
> > >+++ b/drivers/usb/typec/class.c
> > >@@ -1279,6 +1279,17 @@ int typec_set_orientation(struct typec_port *port,
> > >  }
> > >  EXPORT_SYMBOL_GPL(typec_set_orientation);
> > >+/**
> > >+ * typec_get_orientation - Get USB Type-C cable plug orientation
> > >+ * @port: USB Type-C Port
> > >+ *
> > >+ * Get current cable plug orientation for @port.
> > >+ */
> > >+enum typec_orientation typec_get_orientation(struct typec_port *port)
> > >+{
> > >+	return port->orientation;
> > >+}
> > 
> > +EXPORT_SYMBOL_GPL(typec_get_orientation);
> > 
> > Isn't this a candidate for an inline?
> > 
> 
> Currently struct typec_port is class private. To make this function inline,
> struct typec_port would have to be moved from drivers/usb/typec/class.c to
> include/linux/usb/typec.h. That doesn't sound like a good idea to me.

Yes, let's keep the structure protected.

But thanks for the report, I'll fix it.


Br,
diff mbox

Patch

diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
index 53df10df2f9d..02db9bcbac0c 100644
--- a/drivers/usb/typec/class.c
+++ b/drivers/usb/typec/class.c
@@ -1279,6 +1279,17 @@  int typec_set_orientation(struct typec_port *port,
 }
 EXPORT_SYMBOL_GPL(typec_set_orientation);
 
+/**
+ * typec_get_orientation - Get USB Type-C cable plug orientation
+ * @port: USB Type-C Port
+ *
+ * Get current cable plug orientation for @port.
+ */
+enum typec_orientation typec_get_orientation(struct typec_port *port)
+{
+	return port->orientation;
+}
+
 /**
  * typec_set_mode - Set mode of operation for USB Type-C connector
  * @port: USB Type-C port for the connector
diff --git a/include/linux/usb/typec.h b/include/linux/usb/typec.h
index 672b39bb0adc..a5f6433e218b 100644
--- a/include/linux/usb/typec.h
+++ b/include/linux/usb/typec.h
@@ -265,6 +265,7 @@  void typec_set_pwr_opmode(struct typec_port *port, enum typec_pwr_opmode mode);
 
 int typec_set_orientation(struct typec_port *port,
 			  enum typec_orientation orientation);
+enum typec_orientation typec_get_orientation(struct typec_port *port);
 int typec_set_mode(struct typec_port *port, int mode);
 
 #endif /* __LINUX_USB_TYPEC_H */