Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1638242 > unrolled thread
| Started by | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| First post | 2017-05-09 18:10 +0200 |
| Last post | 2017-05-09 23:20 +0200 |
| Articles | 7 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 1/7] staging: typec: tcpci: declare private structure as static Guenter Roeck <linux@roeck-us.net> - 2017-05-09 18:10 +0200
[PATCH 2/7] staging: typec: fusb302: Fix module autoload Guenter Roeck <linux@roeck-us.net> - 2017-05-09 18:10 +0200
[PATCH 4/7] staging: typec: tcpm: Drop duplicate PD messages Guenter Roeck <linux@roeck-us.net> - 2017-05-09 18:10 +0200
[PATCH 3/7] staging: typec: fusb302: Fix chip->vbus_present init value Guenter Roeck <linux@roeck-us.net> - 2017-05-09 18:10 +0200
[PATCH 5/7] staging: typec: tcpm: Set correct flags in PD request messages Guenter Roeck <linux@roeck-us.net> - 2017-05-09 18:10 +0200
Re: [PATCH 1/7] staging: typec: tcpci: declare private structure as static Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-09 19:50 +0200
Re: [PATCH 1/7] staging: typec: tcpci: declare private structure as static Guenter Roeck <linux@roeck-us.net> - 2017-05-09 23:20 +0200
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Date | 2017-05-09 18:10 +0200 |
| Subject | [PATCH 1/7] staging: typec: tcpci: declare private structure as static |
| Message-ID | <tFfS1-41K-3@gated-at.bofh.it> |
From: Olivier Leveque <o_leveque@orange.fr>
This fixes a sparse warning regarding an undeclared symbol. Since the
structure tcpci_tcpc_config is private to tcpci.c, it should be declared as
static.
Signed-off-by: Olivier Leveque <o_leveque@orange.fr>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/staging/typec/tcpci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/typec/tcpci.c b/drivers/staging/typec/tcpci.c
index 5e5be74c7850..df72d8b01e73 100644
--- a/drivers/staging/typec/tcpci.c
+++ b/drivers/staging/typec/tcpci.c
@@ -425,7 +425,7 @@ static const struct regmap_config tcpci_regmap_config = {
.max_register = 0x7F, /* 0x80 .. 0xFF are vendor defined */
};
-const struct tcpc_config tcpci_tcpc_config = {
+static const struct tcpc_config tcpci_tcpc_config = {
.type = TYPEC_PORT_DFP,
.default_role = TYPEC_SINK,
};
--
2.7.4
[toc] | [next] | [standalone]
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Date | 2017-05-09 18:10 +0200 |
| Subject | [PATCH 2/7] staging: typec: fusb302: Fix module autoload |
| Message-ID | <tFfS1-41K-11@gated-at.bofh.it> |
| In reply to | #1638242 |
From: Javier Martinez Canillas <javier@dowhile0.org>
If the driver is built as a module, autoload won't work because the module
alias information is not filled. So user-space can't match the registered
device with the corresponding module.
Export the OF and I2C device ID table entries as module aliases, using the
MODULE_DEVICE_TABLE() macro.
Before this patch:
$ modinfo drivers/staging/typec/fusb302/fusb302.ko | grep alias
$
After this patch:
$ modinfo drivers/staging/typec/fusb302/fusb302.ko | grep alias
alias: of:N*T*Cfcs,fusb302C*
alias: of:N*T*Cfcs,fusb302
alias: i2c:typec_fusb302
Signed-off-by: Javier Martinez Canillas <javier@dowhile0.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/staging/typec/fusb302/fusb302.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/staging/typec/fusb302/fusb302.c
index 2cee9a952c9b..aa460f93a293 100644
--- a/drivers/staging/typec/fusb302/fusb302.c
+++ b/drivers/staging/typec/fusb302/fusb302.c
@@ -1787,11 +1787,13 @@ static const struct of_device_id fusb302_dt_match[] = {
{.compatible = "fcs,fusb302"},
{},
};
+MODULE_DEVICE_TABLE(of, fusb302_dt_match);
static const struct i2c_device_id fusb302_i2c_device_id[] = {
{"typec_fusb302", 0},
{},
};
+MODULE_DEVICE_TABLE(i2c, fusb302_i2c_device_id);
static const struct dev_pm_ops fusb302_pm_ops = {
.suspend = fusb302_pm_suspend,
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Date | 2017-05-09 18:10 +0200 |
| Subject | [PATCH 4/7] staging: typec: tcpm: Drop duplicate PD messages |
| Message-ID | <tFfS2-41K-19@gated-at.bofh.it> |
| In reply to | #1638242 |
Per USB PD standard, we have to drop duplicate PD messages.
We can not expect lower protocol layers to drop such messages,
since lower layers don't know if a message was dropped somewhere
else in the stack.
Originally-from: Puma Hsu <puma_hsu@htc.com>
Cc: Yueyao Zhu <yueyao.zhu@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
drivers/staging/typec/pd.h | 10 ++++++++++
drivers/staging/typec/tcpm.c | 29 +++++++++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/drivers/staging/typec/pd.h b/drivers/staging/typec/pd.h
index 8d97bdb95f23..510ef7279900 100644
--- a/drivers/staging/typec/pd.h
+++ b/drivers/staging/typec/pd.h
@@ -92,6 +92,16 @@ static inline unsigned int pd_header_type_le(__le16 header)
return pd_header_type(le16_to_cpu(header));
}
+static inline unsigned int pd_header_msgid(u16 header)
+{
+ return (header >> PD_HEADER_ID_SHIFT) & PD_HEADER_ID_MASK;
+}
+
+static inline unsigned int pd_header_msgid_le(__le16 header)
+{
+ return pd_header_msgid(le16_to_cpu(header));
+}
+
#define PD_MAX_PAYLOAD 7
struct pd_message {
diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c
index abba655ba00a..c5d8b129c4f4 100644
--- a/drivers/staging/typec/tcpm.c
+++ b/drivers/staging/typec/tcpm.c
@@ -238,6 +238,7 @@ struct tcpm_port {
unsigned int hard_reset_count;
bool pd_capable;
bool explicit_contract;
+ unsigned int rx_msgid;
/* Partner capabilities/requests */
u32 sink_request;
@@ -1415,6 +1416,7 @@ static void tcpm_pd_ctrl_request(struct tcpm_port *port,
break;
case SOFT_RESET_SEND:
port->message_id = 0;
+ port->rx_msgid = -1;
if (port->pwr_role == TYPEC_SOURCE)
next_state = SRC_SEND_CAPABILITIES;
else
@@ -1503,6 +1505,22 @@ static void tcpm_pd_rx_handler(struct work_struct *work)
port->attached);
if (port->attached) {
+ enum pd_ctrl_msg_type type = pd_header_type_le(msg->header);
+ unsigned int msgid = pd_header_msgid_le(msg->header);
+
+ /*
+ * USB PD standard, 6.6.1.2:
+ * "... if MessageID value in a received Message is the
+ * same as the stored value, the receiver shall return a
+ * GoodCRC Message with that MessageID value and drop
+ * the Message (this is a retry of an already received
+ * Message). Note: this shall not apply to the Soft_Reset
+ * Message which always has a MessageID value of zero."
+ */
+ if (msgid == port->rx_msgid && type != PD_CTRL_SOFT_RESET)
+ goto done;
+ port->rx_msgid = msgid;
+
/*
* If both ends believe to be DFP/host, we have a data role
* mismatch.
@@ -1520,6 +1538,7 @@ static void tcpm_pd_rx_handler(struct work_struct *work)
}
}
+done:
mutex_unlock(&port->lock);
kfree(event);
}
@@ -1957,6 +1976,12 @@ static void tcpm_reset_port(struct tcpm_port *port)
port->attached = false;
port->pd_capable = false;
+ /*
+ * First Rx ID should be 0; set this to a sentinel of -1 so that
+ * we can check tcpm_pd_rx_handler() if we had seen it before.
+ */
+ port->rx_msgid = -1;
+
port->tcpc->set_pd_rx(port->tcpc, false);
tcpm_init_vbus(port); /* also disables charging */
tcpm_init_vconn(port);
@@ -2170,6 +2195,7 @@ static void run_state_machine(struct tcpm_port *port)
port->pwr_opmode = TYPEC_PWR_MODE_USB;
port->caps_count = 0;
port->message_id = 0;
+ port->rx_msgid = -1;
port->explicit_contract = false;
tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0);
break;
@@ -2329,6 +2355,7 @@ static void run_state_machine(struct tcpm_port *port)
typec_set_pwr_opmode(port->typec_port, TYPEC_PWR_MODE_USB);
port->pwr_opmode = TYPEC_PWR_MODE_USB;
port->message_id = 0;
+ port->rx_msgid = -1;
port->explicit_contract = false;
tcpm_set_state(port, SNK_DISCOVERY, 0);
break;
@@ -2496,6 +2523,7 @@ static void run_state_machine(struct tcpm_port *port)
/* Soft_Reset states */
case SOFT_RESET:
port->message_id = 0;
+ port->rx_msgid = -1;
tcpm_pd_send_control(port, PD_CTRL_ACCEPT);
if (port->pwr_role == TYPEC_SOURCE)
tcpm_set_state(port, SRC_SEND_CAPABILITIES, 0);
@@ -2504,6 +2532,7 @@ static void run_state_machine(struct tcpm_port *port)
break;
case SOFT_RESET_SEND:
port->message_id = 0;
+ port->rx_msgid = -1;
if (tcpm_pd_send_control(port, PD_CTRL_SOFT_RESET))
tcpm_set_state_cond(port, hard_reset_state(port), 0);
else
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Date | 2017-05-09 18:10 +0200 |
| Subject | [PATCH 3/7] staging: typec: fusb302: Fix chip->vbus_present init value |
| Message-ID | <tFfS2-41K-23@gated-at.bofh.it> |
| In reply to | #1638242 |
From: Yueyao Zhu <yueyao.zhu@gmail.com> FUSB_REG_STATUS0 & FUSB_REG_STATUS0_VBUSOK = 0x40 & 0x80 is always zero. Fix the code to what it is intended to be: check the VBUSOK bit of the value read from address FUSB_REG_STATUS0. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Yueyao Zhu <yueyao.zhu@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net> --- drivers/staging/typec/fusb302/fusb302.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/typec/fusb302/fusb302.c b/drivers/staging/typec/fusb302/fusb302.c index aa460f93a293..d8b50b49bb2d 100644 --- a/drivers/staging/typec/fusb302/fusb302.c +++ b/drivers/staging/typec/fusb302/fusb302.c @@ -489,7 +489,7 @@ static int tcpm_init(struct tcpc_dev *dev) ret = fusb302_i2c_read(chip, FUSB_REG_STATUS0, &data); if (ret < 0) return ret; - chip->vbus_present = !!(FUSB_REG_STATUS0 & FUSB_REG_STATUS0_VBUSOK); + chip->vbus_present = !!(data & FUSB_REG_STATUS0_VBUSOK); ret = fusb302_i2c_read(chip, FUSB_REG_DEVICE_ID, &data); if (ret < 0) return ret; -- 2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Date | 2017-05-09 18:10 +0200 |
| Subject | [PATCH 5/7] staging: typec: tcpm: Set correct flags in PD request messages |
| Message-ID | <tFfS2-41K-27@gated-at.bofh.it> |
| In reply to | #1638242 |
We do support USB PD communication, and devices supported by this driver typically use USB power for purposes other than USB communication. Originally-from: Puma Hsu <puma_hsu@htc.com> Cc: Yueyao Zhu <yueyao.zhu@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net> --- drivers/staging/typec/tcpm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/typec/tcpm.c b/drivers/staging/typec/tcpm.c index c5d8b129c4f4..a385f7e2a6fd 100644 --- a/drivers/staging/typec/tcpm.c +++ b/drivers/staging/typec/tcpm.c @@ -1738,8 +1738,7 @@ static int tcpm_pd_build_request(struct tcpm_port *port, u32 *rdo) } ma = min(ma, port->max_snk_ma); - /* XXX: Any other flags need to be set? */ - flags = 0; + flags = RDO_USB_COMM | RDO_NO_SUSPEND; /* Set mismatch bit if offered power is less than operating power */ mw = ma * mv / 1000; -- 2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2017-05-09 19:50 +0200 |
| Subject | Re: [PATCH 1/7] staging: typec: tcpci: declare private structure as static |
| Message-ID | <tFhqO-4Wx-11@gated-at.bofh.it> |
| In reply to | #1638242 |
On Tue, May 09, 2017 at 09:04:53AM -0700, Guenter Roeck wrote: > From: Olivier Leveque <o_leveque@orange.fr> > > This fixes a sparse warning regarding an undeclared symbol. Since the > structure tcpci_tcpc_config is private to tcpci.c, it should be declared as > static. > > Signed-off-by: Olivier Leveque <o_leveque@orange.fr> > Signed-off-by: Guenter Roeck <linux@roeck-us.net> > --- > drivers/staging/typec/tcpci.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Are any of these bugfixes for 4.12-stable, or can they wait for 4.13-rc1? thanks, greg k-h
[toc] | [prev] | [next] | [standalone]
| From | Guenter Roeck <linux@roeck-us.net> |
|---|---|
| Date | 2017-05-09 23:20 +0200 |
| Subject | Re: [PATCH 1/7] staging: typec: tcpci: declare private structure as static |
| Message-ID | <tFkI1-7kb-5@gated-at.bofh.it> |
| In reply to | #1638324 |
On Tue, May 09, 2017 at 07:46:17PM +0200, Greg Kroah-Hartman wrote: > On Tue, May 09, 2017 at 09:04:53AM -0700, Guenter Roeck wrote: > > From: Olivier Leveque <o_leveque@orange.fr> > > > > This fixes a sparse warning regarding an undeclared symbol. Since the > > structure tcpci_tcpc_config is private to tcpci.c, it should be declared as > > static. > > > > Signed-off-by: Olivier Leveque <o_leveque@orange.fr> > > Signed-off-by: Guenter Roeck <linux@roeck-us.net> > > --- > > drivers/staging/typec/tcpci.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > Are any of these bugfixes for 4.12-stable, or can they wait for > 4.13-rc1? > They should all go into v4.12. There are no functionality enhancements, only real bug fixes. Thanks, Guenter
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web