Chrome platform driver development
 help / color / mirror / Atom feed
From: Tzung-Bi Shih <tzungbi@google.com>
To: bleung@chromium.org, groeck@chromium.org, robh+dt@kernel.org
Cc: chrome-platform@lists.linux.dev, tzungbi@google.com,
	 devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/5] platform/chrome: cros_kbd_led_backlight: support OF match
Date: Mon, 14 Feb 2022 13:36:45 +0800	[thread overview]
Message-ID: <20220214053646.3088298-5-tzungbi@google.com> (raw)
In-Reply-To: <20220214053646.3088298-1-tzungbi@google.com>

Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
---
 .../platform/chrome/cros_kbd_led_backlight.c    | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/chrome/cros_kbd_led_backlight.c b/drivers/platform/chrome/cros_kbd_led_backlight.c
index 814f2b74c602..ba853e55d29a 100644
--- a/drivers/platform/chrome/cros_kbd_led_backlight.c
+++ b/drivers/platform/chrome/cros_kbd_led_backlight.c
@@ -10,6 +10,7 @@
 #include <linux/kernel.h>
 #include <linux/leds.h>
 #include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 
@@ -128,8 +129,11 @@ static int keyboard_led_probe(struct platform_device *pdev)
 	int error;
 
 	drvdata = acpi_device_get_match_data(&pdev->dev);
-	if (!drvdata)
-		return -EINVAL;
+	if (!drvdata) {
+		drvdata = of_device_get_match_data(&pdev->dev);
+		if (!drvdata)
+			return -EINVAL;
+	}
 
 	if (drvdata->init) {
 		error = drvdata->init(pdev);
@@ -161,10 +165,19 @@ static const struct acpi_device_id keyboard_led_acpi_match[] = {
 };
 MODULE_DEVICE_TABLE(acpi, keyboard_led_acpi_match);
 
+static const struct of_device_id keyboard_led_of_match[] = {
+	{
+		.compatible = "google,cros-kbd-led-backlight",
+	},
+	{}
+};
+MODULE_DEVICE_TABLE(of, keyboard_led_of_match);
+
 static struct platform_driver keyboard_led_driver = {
 	.driver		= {
 		.name	= "chromeos-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,
 };
-- 
2.35.1.265.g69c8d7142f-goog


  parent reply	other threads:[~2022-02-14  5:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-14  5:36 [PATCH 0/5] platform/chrome: cros_kbd_led_backlight: add EC PWM backend Tzung-Bi Shih
2022-02-14  5:36 ` [PATCH 1/5] platform/chrome: cros_kbd_led_backlight: sort headers alphabetically Tzung-Bi Shih
2022-02-14  5:36 ` [PATCH 2/5] platform/chrome: cros_kbd_led_backlight: separate ACPI backend Tzung-Bi Shih
2022-02-14  5:36 ` [PATCH 3/5] dt-bindings: add google,cros-kbd-led-backlight Tzung-Bi Shih
2022-03-02 21:54   ` Rob Herring
2022-02-14  5:36 ` Tzung-Bi Shih [this message]
2022-02-16  1:10   ` [PATCH 4/5] platform/chrome: cros_kbd_led_backlight: support OF match Prashant Malani
2022-02-16  2:31     ` Tzung-Bi Shih
2022-02-14  5:36 ` [PATCH 5/5] platform/chrome: cros_kbd_led_backlight: support EC PWM backend Tzung-Bi Shih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220214053646.3088298-5-tzungbi@google.com \
    --to=tzungbi@google.com \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=devicetree@vger.kernel.org \
    --cc=groeck@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox