extcon: int3496: Propagate error code of gpiod_to_irq()
Subsystems (2)
PATCH 1/3 extcon: int3496: Propagate error code of gpiod_to_irq()
gpiod_to_irq() doesn't return 0. Thus, we just adjust condition and replace -EINVAL by actual error code it returns.
--- drivers/extcon/extcon-intel-int3496.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/extcon/extcon-intel-int3496.c +2 -2
@@ -100,9 +100,9 @@ static int int3496_probe(struct platform_device *pdev) } data->usb_id_irq =gpiod_to_irq (data->gpio_usb_id); -if (data->usb_id_irq <=0 ) { +if (data->usb_id_irq <0 ) {dev_err (dev,"can't get USB ID IRQ: %d\n" , data->usb_id_irq); -return -EINVAL ; +return data->usb_id_irq; } data->gpio_vbus_en = devm_gpiod_get_index(dev, "vbus en",
Signature · 1 line
2.11.0
PATCH 2/3 extcon: int3496: Rename GPIO pins in accordance with binding
First of all, add an optional binding for external muxer which might be used.
Second, update GPIO pin names in extcon-intel-int3496.c driver to follow the existing binding.
--- Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt | 3 +++ drivers/extcon/extcon-intel-int3496.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt +3 -0
@@ -10,6 +10,9 @@ Either one of id-gpio or vbus-gpio must be present. Both can be present as well. - id-gpio: gpio for USB ID pin. See gpio binding. - vbus-gpio: gpio for USB VBUS pin. +Optional properties: +- mux-gpios: gpio for USB external muxer + Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below: extcon_usb1 { compatible = "linux,extcon-usb-gpio";
drivers/extcon/extcon-intel-int3496.c +2 -2
@@ -105,13 +105,13 @@ static int int3496_probe(struct platform_device *pdev)return data->usb_id_irq; } - data->gpio_vbus_en =devm_gpiod_get_index (dev,"vbus en" , + data->gpio_vbus_en =devm_gpiod_get_index (dev,"vbus" ,INT3496_GPIO_VBUS_EN ,GPIOD_ASIS );if (IS_ERR (data->gpio_vbus_en))dev_info (dev,"can't request VBUS EN GPIO\n" ); - data->gpio_usb_mux =devm_gpiod_get_index (dev,"usb mux" , + data->gpio_usb_mux =devm_gpiod_get_index (dev,"mux" ,INT3496_GPIO_USB_MUX ,GPIOD_ASIS );if (IS_ERR (data->gpio_usb_mux))
Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Chanwoo Choi
maintainerRe: [PATCH v1 2/3] extcon: int3496: Rename GPIO pins in accordance with binding
Hi,
Quoted 17 lines · Andy Shevchenko
First of all, add an optional binding for external muxer which might be used.
Second, update GPIO pin names in
extcon-intel-int3496.cdriver to follow the existing binding.Signed-off-by Andy Shevchenko <[email protected]>--- Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt | 3 +++ drivers/extcon/extcon-intel-int3496.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt +0
-0
Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt Either one of id-gpio or vbus-gpio must be present. Both can be present as well. · line 14
Quoted 5 lines
Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt +2
-0@@ -10,6 +10,9 @@ Either one of id-gpio or vbus-gpio must be present. Both can be present as well. - id-gpio: gpio for USB ID pin. See gpio binding. - vbus-gpio: gpio for USB VBUS pin. +Optional properties: +- mux-gpios: gpio for USB external muxer
The Documentation/extcon/intel-int3496.txt includes already the information for id/vbus/mux pin.
The extcon-usb-gpio.txt is not related with the extcon-int3496 driver.
Quoted 25 lines
Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt +1
-0+ Example: Examples of extcon-usb-gpio node in dra7-evm.dts as listed below: extcon_usb1 { compatible = "linux,extcon-usb-gpio";drivers/extcon/extcon-intel-int3496.c +2
-2@@ -105,13 +105,13 @@ static int int3496_probe(struct platform_device *pdev)return data->usb_id_irq; } - data->gpio_vbus_en =devm_gpiod_get_index (dev,"vbus en" , + data->gpio_vbus_en =devm_gpiod_get_index (dev,"vbus" ,INT3496_GPIO_VBUS_EN ,GPIOD_ASIS );if (IS_ERR (data->gpio_vbus_en))dev_info (dev,"can't request VBUS EN GPIO\n" ); - data->gpio_usb_mux =devm_gpiod_get_index (dev,"usb mux" , + data->gpio_usb_mux =devm_gpiod_get_index (dev,"mux" ,INT3496_GPIO_USB_MUX ,GPIOD_ASIS );if (IS_ERR (data->gpio_usb_mux))
Signature · 3 lines
Best Regards, Chanwoo Choi Samsung Electronics
Re: [PATCH v1 2/3] extcon: int3496: Rename GPIO pins in accordance with binding
Quoted 10 lines · Chanwoo Choi
Quoted 9 lines · Andy Shevchenko
First of all, add an optional binding for external muxer which might be used.
Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt +0
-0@@ -10,6 +10,9 @@ Either one of id-gpio or vbus-gpio must be present. Both can be present as well. - id-gpio: gpio for USB ID pin. See gpio binding. - vbus-gpio: gpio for USB VBUS pin.
Quoted 5 lines
Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt Either one of id-gpio or vbus-gpio must be present. Both can be present as well. · line 14
Quoted 2 lines
Documentation/devicetree/bindings/extcon/extcon-usb-gpio.txt +2
-0+Optional properties: +- mux-gpios: gpio for USB external muxerThe
Documentation/extcon/intel-int3496.txtincludes already the information for id/vbus/mux pin.
Thanks for pointing this out...
Quoted 1 line
The extcon-usb-gpio.txt is not related with the extcon-int3496 driver.
...but the bindings is related to ACPI somehow. I dunno why in extcon-usb-gpio.c we have
if (!np && !ACPI_HANDLE(dev))
...and thus it means either firmware chooses we better to have standardized bindings in both cases.
OTOH mux-gpios indeed doesn't make sense for extcon-usb-gpio.c and would be removed from the bindings.
I'll update patches accordingly.
Signature · 6 lines
With Best Regards, Andy Shevchenko -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/3 extcon: int3496: Add GPIO ACPI mapping table
In reply to Andy ShevchenkoIn order to make GPIO ACPI library stricter prepare users of gpiod_get_index() to correctly behave when there no mapping is provided by firmware.
Here we add explicit mapping between _CRS GpioIo() resources and their names used in the driver.
--- drivers/extcon/extcon-intel-int3496.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/extcon/extcon-intel-int3496.c +19 -0
@@ -45,6 +45,17 @@ static const unsigned int int3496_cable[] = { EXTCON_NONE, }; +static const struct acpi_gpio_params id_gpios = {INT3496_GPIO_USB_ID ,0 , false }; +static const struct acpi_gpio_params vbus_gpios = {INT3496_GPIO_VBUS_EN ,0 , false }; +static const struct acpi_gpio_params mux_gpios = {INT3496_GPIO_USB_MUX ,0 , false }; + +static const struct acpi_gpio_mapping acpi_int3496_default_gpios[] = { + {"id-gpios" , &id_gpios,1 }, + {"vbus-gpios" , &vbus_gpios,1 }, + {"mux-gpios" , &mux_gpios,1 }, + { }, +}; +static void int3496_do_usb_id (struct work_struct *work) { struct int3496_data *data =
@@ -83,6 +94,13 @@ static int int3496_probe(struct platform_device *pdev)struct int3496_data *data;int ret; + ret =acpi_dev_add_driver_gpios (ACPI_COMPANION (dev), + acpi_int3496_default_gpios); +if (ret) { +dev_err (dev,"can't add GPIO ACPI mapping\n" ); +return ret; + } + data =devm_kzalloc (dev,sizeof (*data),GFP_KERNEL );if (!data)return -ENOMEM ;
@@ -154,6 +172,7 @@ static int int3496_remove(struct platform_device *pdev)devm_free_irq (&pdev->dev, data->usb_id_irq, data);cancel_delayed_work_sync (&data->work); +acpi_dev_remove_driver_gpios (ACPI_COMPANION (&pdev->dev));return 0 ; }
Signature · 1 line
2.11.0
Re: [PATCH v1 3/3] extcon: int3496: Add GPIO ACPI mapping table
Hi,
Quoted 49 lines · Andy Shevchenko
In order to make GPIO ACPI library stricter prepare users of
gpiod_get_index()to correctly behave when there no mapping is provided by firmware.Here we add explicit mapping between
_CRSGpioIo()resources and their names used in the driver.Signed-off-by Andy Shevchenko <[email protected]>--- drivers/extcon/extcon-intel-int3496.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/extcon/extcon-intel-int3496.c +18
-0@@ -45,6 +45,17 @@ static const unsigned int int3496_cable[] = { EXTCON_NONE, }; +static const struct acpi_gpio_params id_gpios = {INT3496_GPIO_USB_ID ,0 , false }; +static const struct acpi_gpio_params vbus_gpios = {INT3496_GPIO_VBUS_EN ,0 , false }; +static const struct acpi_gpio_params mux_gpios = {INT3496_GPIO_USB_MUX ,0 , false }; + +static const struct acpi_gpio_mapping acpi_int3496_default_gpios[] = { + {"id-gpios" , &id_gpios,1 }, + {"vbus-gpios" , &vbus_gpios,1 }, + {"mux-gpios" , &mux_gpios,1 }, + { }, +}; +static void int3496_do_usb_id (struct work_struct *work) { struct int3496_data *data =@@ -83,6 +94,13 @@ static int int3496_probe(struct platform_device *pdev)struct int3496_data *data;int ret; + ret =acpi_dev_add_driver_gpios (ACPI_COMPANION (dev), + acpi_int3496_default_gpios); +if (ret) { +dev_err (dev,"can't add GPIO ACPI mapping\n" ); +return ret; + } + data =devm_kzalloc (dev,sizeof (*data),GFP_KERNEL );if (!data)return -ENOMEM ;
drivers/extcon/extcon-intel-int3496.c static int int3496_remove(struct platform_device *pdev) · line 175
Quoted 4 lines
drivers/extcon/extcon-intel-int3496.c +1
-0@@ -154,6 +172,7 @@ static int int3496_remove(struct platform_device *pdev)devm_free_irq (&pdev->dev, data->usb_id_irq, data);cancel_delayed_work_sync (&data->work); +acpi_dev_remove_driver_gpios (ACPI_COMPANION (&pdev->dev));
Need to add the one blank line.
drivers/extcon/extcon-intel-int3496.c static int int3496_remove(struct platform_device *pdev) · line 178
Quoted 3 lines
drivers/extcon/extcon-intel-int3496.c +0
-0return 0 ; }
Looks good to me.
This patch depends on the patch2. So, after resending the v2, I'll merge them if there is no problem.
Signature · 3 lines
Best Regards, Chanwoo Choi Samsung Electronics
Quoted 15 lines · Andy Shevchenko
gpiod_to_irq()doesn't return 0. Thus, we just adjust condition and replace-EINVALby actual error code it returns.--- drivers/extcon/extcon-intel-int3496.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/extcon/extcon-intel-int3496.c +0
-0@@ -100,9 +100,9 @@ static int int3496_probe(struct platform_device *pdev) }
drivers/extcon/extcon-intel-int3496.c static int int3496_probe(struct platform_device *pdev) · line 108
Quoted 10 lines
drivers/extcon/extcon-intel-int3496.c +2
-2data->usb_id_irq =gpiod_to_irq (data->gpio_usb_id); -if (data->usb_id_irq <=0 ) { +if (data->usb_id_irq <0 ) {dev_err (dev,"can't get USB ID IRQ: %d\n" , data->usb_id_irq); -return -EINVAL ; +return data->usb_id_irq; } data->gpio_vbus_en = devm_gpiod_get_index(dev, "vbus en",
Applied it. Thanks.
Signature · 7 lines
Best Regards, Chanwoo Choi Samsung Electronics -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html