diff mbox series

[14/18] platform/chrome: cros_kbd_led_backlight: provide ID table for avoiding fallback match

Message ID 20240329075630.2069474-15-tzungbi@kernel.org
State Handled Elsewhere
Headers show
Series platform/chrome: provide ID table for avoiding fallback match | expand

Commit Message

Tzung-Bi Shih March 29, 2024, 7:56 a.m. UTC
Instead of using fallback driver name match, provide ID table[1] for the
primary match.

Also shrink the name for fitting to [2].

[1]: https://elixir.bootlin.com/linux/v6.8/source/drivers/base/platform.c#L1353
[2]: https://elixir.bootlin.com/linux/v6.8/source/include/linux/mod_devicetable.h#L608

Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
---
 drivers/platform/chrome/cros_kbd_led_backlight.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Krzysztof Kozlowski March 29, 2024, 3:53 p.m. UTC | #1
On 29/03/2024 08:56, Tzung-Bi Shih wrote:
> Instead of using fallback driver name match, provide ID table[1] for the
> primary match.
> 
> Also shrink the name for fitting to [2].
> 
> [1]: https://elixir.bootlin.com/linux/v6.8/source/drivers/base/platform.c#L1353
> [2]: https://elixir.bootlin.com/linux/v6.8/source/include/linux/mod_devicetable.h#L608
> 

I think this should be two commits, where the first one is a fix (Fixes
tag) for the size of name.


Best regards,
Krzysztof
Benson Leung March 29, 2024, 8:20 p.m. UTC | #2
On Fri, Mar 29, 2024 at 03:56:26PM +0800, Tzung-Bi Shih wrote:
> Instead of using fallback driver name match, provide ID table[1] for the
> primary match.
> 
> Also shrink the name for fitting to [2].
> 
> [1]: https://elixir.bootlin.com/linux/v6.8/source/drivers/base/platform.c#L1353
> [2]: https://elixir.bootlin.com/linux/v6.8/source/include/linux/mod_devicetable.h#L608
> 
> Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>

Reviewed-by: Benson Leung <bleung@chromium.org>

> ---
>  drivers/platform/chrome/cros_kbd_led_backlight.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/chrome/cros_kbd_led_backlight.c b/drivers/platform/chrome/cros_kbd_led_backlight.c
> index 793fd3f1015d..b83e4f328620 100644
> --- a/drivers/platform/chrome/cros_kbd_led_backlight.c
> +++ b/drivers/platform/chrome/cros_kbd_led_backlight.c
> @@ -9,6 +9,7 @@
>  #include <linux/init.h>
>  #include <linux/kernel.h>
>  #include <linux/leds.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
>  #include <linux/platform_data/cros_ec_commands.h>
> @@ -247,17 +248,23 @@ static const struct of_device_id keyboard_led_of_match[] = {
>  MODULE_DEVICE_TABLE(of, keyboard_led_of_match);
>  #endif
>  
> +static const struct platform_device_id keyboard_led_id[] = {
> +	{ "cros-keyboard-leds", 0 },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(platform, keyboard_led_id);
> +
>  static struct platform_driver keyboard_led_driver = {
>  	.driver		= {
> -		.name	= "chromeos-keyboard-leds",
> +		.name	= "cros-keyboard-leds",
>  		.acpi_match_table = ACPI_PTR(keyboard_led_acpi_match),
>  		.of_match_table = of_match_ptr(keyboard_led_of_match),
>  	},
>  	.probe		= keyboard_led_probe,
> +	.id_table	= keyboard_led_id,
>  };
>  module_platform_driver(keyboard_led_driver);
>  
>  MODULE_AUTHOR("Simon Que <sque@chromium.org>");
>  MODULE_DESCRIPTION("ChromeOS Keyboard backlight LED Driver");
>  MODULE_LICENSE("GPL");
> -MODULE_ALIAS("platform:chromeos-keyboard-leds");
> -- 
> 2.44.0.478.gd926399ef9-goog
> 
>
Tzung-Bi Shih April 1, 2024, 3:11 a.m. UTC | #3
On Fri, Mar 29, 2024 at 04:53:48PM +0100, Krzysztof Kozlowski wrote:
> On 29/03/2024 08:56, Tzung-Bi Shih wrote:
> > Instead of using fallback driver name match, provide ID table[1] for the
> > primary match.
> > 
> > Also shrink the name for fitting to [2].
> > 
> > [1]: https://elixir.bootlin.com/linux/v6.8/source/drivers/base/platform.c#L1353
> > [2]: https://elixir.bootlin.com/linux/v6.8/source/include/linux/mod_devicetable.h#L608
> > 
> 
> I think this should be two commits, where the first one is a fix (Fixes
> tag) for the size of name.

Splitted to 2 commits in v2[3].  It doesn't include a Fixes tag as the compiler
complaints the oversize only if putting the original driver name to struct
platform_device_id.

[3]: https://patchwork.kernel.org/project/chrome-platform/patch/20240401030052.2887845-6-tzungbi@kernel.org/
diff mbox series

Patch

diff --git a/drivers/platform/chrome/cros_kbd_led_backlight.c b/drivers/platform/chrome/cros_kbd_led_backlight.c
index 793fd3f1015d..b83e4f328620 100644
--- a/drivers/platform/chrome/cros_kbd_led_backlight.c
+++ b/drivers/platform/chrome/cros_kbd_led_backlight.c
@@ -9,6 +9,7 @@ 
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/leds.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/platform_data/cros_ec_commands.h>
@@ -247,17 +248,23 @@  static const struct of_device_id keyboard_led_of_match[] = {
 MODULE_DEVICE_TABLE(of, keyboard_led_of_match);
 #endif
 
+static const struct platform_device_id keyboard_led_id[] = {
+	{ "cros-keyboard-leds", 0 },
+	{}
+};
+MODULE_DEVICE_TABLE(platform, keyboard_led_id);
+
 static struct platform_driver keyboard_led_driver = {
 	.driver		= {
-		.name	= "chromeos-keyboard-leds",
+		.name	= "cros-keyboard-leds",
 		.acpi_match_table = ACPI_PTR(keyboard_led_acpi_match),
 		.of_match_table = of_match_ptr(keyboard_led_of_match),
 	},
 	.probe		= keyboard_led_probe,
+	.id_table	= keyboard_led_id,
 };
 module_platform_driver(keyboard_led_driver);
 
 MODULE_AUTHOR("Simon Que <sque@chromium.org>");
 MODULE_DESCRIPTION("ChromeOS Keyboard backlight LED Driver");
 MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:chromeos-keyboard-leds");