diff mbox series

[v5,09/18] usb: dwc3: qcom: Add support for usb-conn-gpio connectors

Message ID 20200207201654.641525-10-bryan.odonoghue@linaro.org (mailing list archive)
State Superseded
Headers show
Series Enable Qualcomm QCS 404 HS/SS USB | expand

Commit Message

Bryan O'Donoghue Feb. 7, 2020, 8:16 p.m. UTC
This patch adds a routine to find a usb-conn-gpio in the main DWC3 code.
This will be useful in a subsequent patch where we will reuse the current
extcon VBUS notifier with usb-conn-gpio.

Cc: Andy Gross <agross@kernel.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: linux-arm-msm@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Acked-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 drivers/usb/dwc3/dwc3-qcom.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

Comments

Jack Pham Feb. 7, 2020, 8:43 p.m. UTC | #1
Hi Bryan,

On Fri, Feb 07, 2020 at 08:16:45PM +0000, Bryan O'Donoghue wrote:
> This patch adds a routine to find a usb-conn-gpio in the main DWC3 code.
> This will be useful in a subsequent patch where we will reuse the current
> extcon VBUS notifier with usb-conn-gpio.
> 
> ---
>  drivers/usb/dwc3/dwc3-qcom.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 261af9e38ddd..fc66ca3316ef 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -550,6 +550,21 @@ static const struct dwc3_acpi_pdata sdm845_acpi_pdata = {
>  	.ss_phy_irq_index = 2
>  };
>  
> +static bool dwc3_qcom_find_gpio_usb_connector(struct platform_device *pdev)

Why not just squash this patch into "[PATCH v5 12/18] usb: dwc3: qcom:
Enable gpio-usb-conn based role-switching" where it is actually used?

Jack
Bryan O'Donoghue Feb. 7, 2020, 9:24 p.m. UTC | #2
On 07/02/2020 20:43, Jack Pham wrote:
> Hi Bryan,
> 
> On Fri, Feb 07, 2020 at 08:16:45PM +0000, Bryan O'Donoghue wrote:
>> This patch adds a routine to find a usb-conn-gpio in the main DWC3 code.
>> This will be useful in a subsequent patch where we will reuse the current
>> extcon VBUS notifier with usb-conn-gpio.
>>
>> ---
>>   drivers/usb/dwc3/dwc3-qcom.c | 15 +++++++++++++++
>>   1 file changed, 15 insertions(+)
>>
>> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
>> index 261af9e38ddd..fc66ca3316ef 100644
>> --- a/drivers/usb/dwc3/dwc3-qcom.c
>> +++ b/drivers/usb/dwc3/dwc3-qcom.c
>> @@ -550,6 +550,21 @@ static const struct dwc3_acpi_pdata sdm845_acpi_pdata = {
>>   	.ss_phy_irq_index = 2
>>   };
>>   
>> +static bool dwc3_qcom_find_gpio_usb_connector(struct platform_device *pdev)
> 
> Why not just squash this patch into "[PATCH v5 12/18] usb: dwc3: qcom:
> Enable gpio-usb-conn based role-switching" where it is actually used?

IMO its best practice to have smaller patches.

This one adds the routine.
12/18 uses the routine but also

- Triggers a notifer role-switch binding
- Adds an if/else for extcon

Believe it or not I had an internal debate about splitting #12 into two 
patches !

---
bod
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 261af9e38ddd..fc66ca3316ef 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -550,6 +550,21 @@  static const struct dwc3_acpi_pdata sdm845_acpi_pdata = {
 	.ss_phy_irq_index = 2
 };
 
+static bool dwc3_qcom_find_gpio_usb_connector(struct platform_device *pdev)
+{
+	struct device_node	*np;
+	bool			retval = false;
+
+	np = of_get_child_by_name(pdev->dev.of_node, "connector");
+	if (np) {
+		if (of_device_is_compatible(np, "gpio-usb-b-connector"))
+			retval = true;
+	}
+	of_node_put(np);
+
+	return retval;
+}
+
 static int dwc3_qcom_probe(struct platform_device *pdev)
 {
 	struct device_node	*np = pdev->dev.of_node;