diff mbox series

[v4,6/6] button: make button_get_by_label() case insensitive

Message ID 20250331-qcom-phones-v4-6-f52e57d3b8c6@linaro.org
State New
Headers show
Series Better smartphone support (Qualcomm) | expand

Commit Message

Caleb Connolly March 31, 2025, 12:23 p.m. UTC
This function is already doing a fuzzy match, since there are no
guarantees that a given label is unique.

Ignoring case makes it much easier to catch "Volume down" or "Volume
Down" in board-agnostic code.

Tested-by: Danila Tikhonov <danila@jiaxyga.com> # google-sunfish
Tested-by: Jens Reidel <adrian@mainlining.org> # xiaomi-davinci
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
---
 drivers/button/button-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Neil Armstrong April 1, 2025, 8:41 a.m. UTC | #1
On 31/03/2025 14:23, Caleb Connolly wrote:
> This function is already doing a fuzzy match, since there are no
> guarantees that a given label is unique.
> 
> Ignoring case makes it much easier to catch "Volume down" or "Volume
> Down" in board-agnostic code.
> 
> Tested-by: Danila Tikhonov <danila@jiaxyga.com> # google-sunfish
> Tested-by: Jens Reidel <adrian@mainlining.org> # xiaomi-davinci
> Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
> ---
>   drivers/button/button-uclass.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/button/button-uclass.c b/drivers/button/button-uclass.c
> index 729983d58701867f7ea18e9b5f87e7404bca3dce..025917887e80f2fe9cbd3777e04035d20fa34713 100644
> --- a/drivers/button/button-uclass.c
> +++ b/drivers/button/button-uclass.c
> @@ -20,9 +20,9 @@ int button_get_by_label(const char *label, struct udevice **devp)
>   	uclass_id_foreach_dev(UCLASS_BUTTON, dev, uc) {
>   		struct button_uc_plat *uc_plat = dev_get_uclass_plat(dev);
>   
>   		/* Ignore the top-level button node */
> -		if (uc_plat->label && !strcmp(label, uc_plat->label))
> +		if (uc_plat->label && !strcasecmp(label, uc_plat->label))
>   			return uclass_get_device_tail(dev, 0, devp);
>   	}
>   
>   	return -ENODEV;
> 

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
diff mbox series

Patch

diff --git a/drivers/button/button-uclass.c b/drivers/button/button-uclass.c
index 729983d58701867f7ea18e9b5f87e7404bca3dce..025917887e80f2fe9cbd3777e04035d20fa34713 100644
--- a/drivers/button/button-uclass.c
+++ b/drivers/button/button-uclass.c
@@ -20,9 +20,9 @@  int button_get_by_label(const char *label, struct udevice **devp)
 	uclass_id_foreach_dev(UCLASS_BUTTON, dev, uc) {
 		struct button_uc_plat *uc_plat = dev_get_uclass_plat(dev);
 
 		/* Ignore the top-level button node */
-		if (uc_plat->label && !strcmp(label, uc_plat->label))
+		if (uc_plat->label && !strcasecmp(label, uc_plat->label))
 			return uclass_get_device_tail(dev, 0, devp);
 	}
 
 	return -ENODEV;