From: Danny Kaehn <kaehndan@gmail.com>
To: robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org,
jikos@kernel.org, benjamin.tissoires@redhat.com
Cc: devicetree@vger.kernel.org, linux-input@vger.kernel.org,
ethan.twardy@plexus.com
Subject: [PATCH 4/4] CP2112 Devicetree Support
Date: Sat, 28 Jan 2023 14:26:22 -0600 [thread overview]
Message-ID: <20230128202622.12676-5-kaehndan@gmail.com> (raw)
In-Reply-To: <20230128202622.12676-1-kaehndan@gmail.com>
Bind i2c and gpio interfaces to subnodes with names
"i2c" and "gpio" if they exist, respectively. This
allows the gpio and i2c controllers to be described
in DT as usual.
Signed-off-by: Danny Kaehn <kaehndan@gmail.com>
---
drivers/hid/hid-cp2112.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
index 27cadadda7c9..99e8043e1c34 100644
--- a/drivers/hid/hid-cp2112.c
+++ b/drivers/hid/hid-cp2112.c
@@ -1310,6 +1310,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
dev->adap.algo = &smbus_algorithm;
dev->adap.algo_data = dev;
dev->adap.dev.parent = &hdev->dev;
+ dev->adap.dev.of_node = of_get_child_by_name(hdev->dev.of_node, "i2c");
snprintf(dev->adap.name, sizeof(dev->adap.name),
"CP2112 SMBus Bridge on hidraw%d",
((struct hidraw *)hdev->hidraw)->minor);
@@ -1336,6 +1337,9 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
dev->gc.ngpio = 8;
dev->gc.can_sleep = 1;
dev->gc.parent = &hdev->dev;
+#if defined(CONFIG_OF_GPIO)
+ dev->gc.of_node = of_get_child_by_name(hdev->dev.of_node, "gpio");
+#endif
dev->irq.name = "cp2112-gpio";
dev->irq.irq_startup = cp2112_gpio_irq_startup;
@@ -1391,6 +1395,11 @@ static void cp2112_remove(struct hid_device *hdev)
struct cp2112_device *dev = hid_get_drvdata(hdev);
int i;
+ of_node_put(dev->adap.dev.of_node);
+#if defined(CONFIG_OF_GPIO)
+ of_node_put(dev->gc.of_node);
+#endif
+
sysfs_remove_group(&hdev->dev.kobj, &cp2112_attr_group);
i2c_del_adapter(&dev->adap);
--
2.25.1
next prev parent reply other threads:[~2023-01-28 20:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-28 20:26 [PATCH 0/4] DeviceTree Support for USB-HID Devices and CP2112 Danny Kaehn
2023-01-28 20:26 ` [PATCH 1/4] dt-bindings: hid: Add CP2112 HID USB to SMBus Bridge Danny Kaehn
2023-01-29 11:05 ` Krzysztof Kozlowski
2023-01-29 11:33 ` Krzysztof Kozlowski
2023-01-31 0:25 ` Daniel Kaehn
2023-01-28 20:26 ` [PATCH 2/4] Share USB device devicetree node with child HID device Danny Kaehn
2023-01-29 11:05 ` Krzysztof Kozlowski
2023-01-28 20:26 ` [PATCH 3/4] Fix CP2112 driver not registering GPIO IRQ chip as threaded Danny Kaehn
2023-01-28 20:26 ` Danny Kaehn [this message]
2023-01-29 11:06 ` [PATCH 4/4] CP2112 Devicetree Support Krzysztof Kozlowski
2023-01-31 1:06 ` Daniel Kaehn
2023-01-31 16:45 ` Krzysztof Kozlowski
2023-01-30 16:29 ` [PATCH 0/4] DeviceTree Support for USB-HID Devices and CP2112 Benjamin Tissoires
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=20230128202622.12676-5-kaehndan@gmail.com \
--to=kaehndan@gmail.com \
--cc=benjamin.tissoires@redhat.com \
--cc=devicetree@vger.kernel.org \
--cc=ethan.twardy@plexus.com \
--cc=jikos@kernel.org \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-input@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;
as well as URLs for NNTP newsgroup(s).