* [PATCH v1] usb: typec: tcpci: Refactor tcpc_presenting_cc1_rd macro
@ 2021-03-10 22:35 Badhri Jagan Sridharan
2021-03-10 23:54 ` Guenter Roeck
2021-03-11 8:27 ` Heikki Krogerus
0 siblings, 2 replies; 3+ messages in thread
From: Badhri Jagan Sridharan @ 2021-03-10 22:35 UTC (permalink / raw)
To: Guenter Roeck, Heikki Krogerus, Greg Kroah-Hartman
Cc: linux-usb, linux-kernel, Kyle Tso, stable, Badhri Jagan Sridharan
Defining one macro instead of two for tcpc_presenting_*_rd.
This is a follow up of the comment left by Heikki Krogerus.
https://patchwork.kernel.org/project/linux-usb/patch/
20210304070931.1947316-1-badhri@google.com/
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
---
drivers/usb/typec/tcpm/tcpci.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
index 027afd7dfdce..25b480752266 100644
--- a/drivers/usb/typec/tcpm/tcpci.c
+++ b/drivers/usb/typec/tcpm/tcpci.c
@@ -24,14 +24,10 @@
#define AUTO_DISCHARGE_PD_HEADROOM_MV 850
#define AUTO_DISCHARGE_PPS_HEADROOM_MV 1250
-#define tcpc_presenting_cc1_rd(reg) \
+#define tcpc_presenting_rd(reg, cc) \
(!(TCPC_ROLE_CTRL_DRP & (reg)) && \
- (((reg) & (TCPC_ROLE_CTRL_CC1_MASK << TCPC_ROLE_CTRL_CC1_SHIFT)) == \
- (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC1_SHIFT)))
-#define tcpc_presenting_cc2_rd(reg) \
- (!(TCPC_ROLE_CTRL_DRP & (reg)) && \
- (((reg) & (TCPC_ROLE_CTRL_CC2_MASK << TCPC_ROLE_CTRL_CC2_SHIFT)) == \
- (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC2_SHIFT)))
+ (((reg) & (TCPC_ROLE_CTRL_## cc ##_MASK << TCPC_ROLE_CTRL_## cc ##_SHIFT)) == \
+ (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_## cc ##_SHIFT)))
struct tcpci {
struct device *dev;
@@ -201,11 +197,11 @@ static int tcpci_get_cc(struct tcpc_dev *tcpc,
*cc1 = tcpci_to_typec_cc((reg >> TCPC_CC_STATUS_CC1_SHIFT) &
TCPC_CC_STATUS_CC1_MASK,
reg & TCPC_CC_STATUS_TERM ||
- tcpc_presenting_cc1_rd(role_control));
+ tcpc_presenting_rd(role_control, CC1));
*cc2 = tcpci_to_typec_cc((reg >> TCPC_CC_STATUS_CC2_SHIFT) &
TCPC_CC_STATUS_CC2_MASK,
reg & TCPC_CC_STATUS_TERM ||
- tcpc_presenting_cc2_rd(role_control));
+ tcpc_presenting_rd(role_control, CC2));
return 0;
}
--
2.31.0.rc1.246.gcd05c9c855-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] usb: typec: tcpci: Refactor tcpc_presenting_cc1_rd macro
2021-03-10 22:35 [PATCH v1] usb: typec: tcpci: Refactor tcpc_presenting_cc1_rd macro Badhri Jagan Sridharan
@ 2021-03-10 23:54 ` Guenter Roeck
2021-03-11 8:27 ` Heikki Krogerus
1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2021-03-10 23:54 UTC (permalink / raw)
To: Badhri Jagan Sridharan
Cc: Heikki Krogerus, Greg Kroah-Hartman, linux-usb, linux-kernel,
Kyle Tso, stable
On Wed, Mar 10, 2021 at 02:35:36PM -0800, Badhri Jagan Sridharan wrote:
> Defining one macro instead of two for tcpc_presenting_*_rd.
> This is a follow up of the comment left by Heikki Krogerus.
>
> https://patchwork.kernel.org/project/linux-usb/patch/
> 20210304070931.1947316-1-badhri@google.com/
>
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Guenter
> ---
> drivers/usb/typec/tcpm/tcpci.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> index 027afd7dfdce..25b480752266 100644
> --- a/drivers/usb/typec/tcpm/tcpci.c
> +++ b/drivers/usb/typec/tcpm/tcpci.c
> @@ -24,14 +24,10 @@
> #define AUTO_DISCHARGE_PD_HEADROOM_MV 850
> #define AUTO_DISCHARGE_PPS_HEADROOM_MV 1250
>
> -#define tcpc_presenting_cc1_rd(reg) \
> +#define tcpc_presenting_rd(reg, cc) \
> (!(TCPC_ROLE_CTRL_DRP & (reg)) && \
> - (((reg) & (TCPC_ROLE_CTRL_CC1_MASK << TCPC_ROLE_CTRL_CC1_SHIFT)) == \
> - (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC1_SHIFT)))
> -#define tcpc_presenting_cc2_rd(reg) \
> - (!(TCPC_ROLE_CTRL_DRP & (reg)) && \
> - (((reg) & (TCPC_ROLE_CTRL_CC2_MASK << TCPC_ROLE_CTRL_CC2_SHIFT)) == \
> - (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC2_SHIFT)))
> + (((reg) & (TCPC_ROLE_CTRL_## cc ##_MASK << TCPC_ROLE_CTRL_## cc ##_SHIFT)) == \
> + (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_## cc ##_SHIFT)))
>
> struct tcpci {
> struct device *dev;
> @@ -201,11 +197,11 @@ static int tcpci_get_cc(struct tcpc_dev *tcpc,
> *cc1 = tcpci_to_typec_cc((reg >> TCPC_CC_STATUS_CC1_SHIFT) &
> TCPC_CC_STATUS_CC1_MASK,
> reg & TCPC_CC_STATUS_TERM ||
> - tcpc_presenting_cc1_rd(role_control));
> + tcpc_presenting_rd(role_control, CC1));
> *cc2 = tcpci_to_typec_cc((reg >> TCPC_CC_STATUS_CC2_SHIFT) &
> TCPC_CC_STATUS_CC2_MASK,
> reg & TCPC_CC_STATUS_TERM ||
> - tcpc_presenting_cc2_rd(role_control));
> + tcpc_presenting_rd(role_control, CC2));
>
> return 0;
> }
> --
> 2.31.0.rc1.246.gcd05c9c855-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] usb: typec: tcpci: Refactor tcpc_presenting_cc1_rd macro
2021-03-10 22:35 [PATCH v1] usb: typec: tcpci: Refactor tcpc_presenting_cc1_rd macro Badhri Jagan Sridharan
2021-03-10 23:54 ` Guenter Roeck
@ 2021-03-11 8:27 ` Heikki Krogerus
1 sibling, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2021-03-11 8:27 UTC (permalink / raw)
To: Badhri Jagan Sridharan
Cc: Guenter Roeck, Greg Kroah-Hartman, linux-usb, linux-kernel,
Kyle Tso, stable
On Wed, Mar 10, 2021 at 02:35:36PM -0800, Badhri Jagan Sridharan wrote:
> Defining one macro instead of two for tcpc_presenting_*_rd.
> This is a follow up of the comment left by Heikki Krogerus.
>
> https://patchwork.kernel.org/project/linux-usb/patch/
> 20210304070931.1947316-1-badhri@google.com/
>
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/tcpm/tcpci.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/tcpci.c b/drivers/usb/typec/tcpm/tcpci.c
> index 027afd7dfdce..25b480752266 100644
> --- a/drivers/usb/typec/tcpm/tcpci.c
> +++ b/drivers/usb/typec/tcpm/tcpci.c
> @@ -24,14 +24,10 @@
> #define AUTO_DISCHARGE_PD_HEADROOM_MV 850
> #define AUTO_DISCHARGE_PPS_HEADROOM_MV 1250
>
> -#define tcpc_presenting_cc1_rd(reg) \
> +#define tcpc_presenting_rd(reg, cc) \
> (!(TCPC_ROLE_CTRL_DRP & (reg)) && \
> - (((reg) & (TCPC_ROLE_CTRL_CC1_MASK << TCPC_ROLE_CTRL_CC1_SHIFT)) == \
> - (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC1_SHIFT)))
> -#define tcpc_presenting_cc2_rd(reg) \
> - (!(TCPC_ROLE_CTRL_DRP & (reg)) && \
> - (((reg) & (TCPC_ROLE_CTRL_CC2_MASK << TCPC_ROLE_CTRL_CC2_SHIFT)) == \
> - (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_CC2_SHIFT)))
> + (((reg) & (TCPC_ROLE_CTRL_## cc ##_MASK << TCPC_ROLE_CTRL_## cc ##_SHIFT)) == \
> + (TCPC_ROLE_CTRL_CC_RD << TCPC_ROLE_CTRL_## cc ##_SHIFT)))
>
> struct tcpci {
> struct device *dev;
> @@ -201,11 +197,11 @@ static int tcpci_get_cc(struct tcpc_dev *tcpc,
> *cc1 = tcpci_to_typec_cc((reg >> TCPC_CC_STATUS_CC1_SHIFT) &
> TCPC_CC_STATUS_CC1_MASK,
> reg & TCPC_CC_STATUS_TERM ||
> - tcpc_presenting_cc1_rd(role_control));
> + tcpc_presenting_rd(role_control, CC1));
> *cc2 = tcpci_to_typec_cc((reg >> TCPC_CC_STATUS_CC2_SHIFT) &
> TCPC_CC_STATUS_CC2_MASK,
> reg & TCPC_CC_STATUS_TERM ||
> - tcpc_presenting_cc2_rd(role_control));
> + tcpc_presenting_rd(role_control, CC2));
>
> return 0;
> }
> --
> 2.31.0.rc1.246.gcd05c9c855-goog
thanks,
--
heikki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-11 8:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 22:35 [PATCH v1] usb: typec: tcpci: Refactor tcpc_presenting_cc1_rd macro Badhri Jagan Sridharan
2021-03-10 23:54 ` Guenter Roeck
2021-03-11 8:27 ` Heikki Krogerus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).