aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/rmi4/rmi_bus.c
diff options
context:
space:
mode:
authorAndrew Duggan <aduggan@synaptics.com>2016-03-10 15:46:32 -0800
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2016-03-10 16:02:41 -0800
commitd8a8b3edfd922e3886684a3434bd2b752167ff29 (patch)
tree7a43bd47dfdab7f209bf6aa68698401db679241d /drivers/input/rmi4/rmi_bus.c
parentInput: synaptics-rmi4 - add I2C transport driver (diff)
downloadlinux-dev-d8a8b3edfd922e3886684a3434bd2b752167ff29.tar.xz
linux-dev-d8a8b3edfd922e3886684a3434bd2b752167ff29.zip
Input: synaptics-rmi4 - add device tree support for RMI4 I2C devices
Add devicetree binding for I2C devices and add bindings for optional parameters in the function drivers. Parameters for function drivers are defined in child nodes for each of the functions. Signed-off-by: Andrew Duggan <aduggan@synaptics.com> Acked-by: Rob Herring <robh@kernel.org> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Tested-by: Linus Walleij <linus.walleij@linaro.org> Tested-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/rmi4/rmi_bus.c')
-rw-r--r--drivers/input/rmi4/rmi_bus.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/drivers/input/rmi4/rmi_bus.c b/drivers/input/rmi4/rmi_bus.c
index 0a2bd5a0f2b7..434477ea0c4e 100644
--- a/drivers/input/rmi4/rmi_bus.c
+++ b/drivers/input/rmi4/rmi_bus.c
@@ -153,6 +153,21 @@ static int rmi_function_match(struct device *dev, struct device_driver *drv)
return fn->fd.function_number == handler->func;
}
+#ifdef CONFIG_OF
+static void rmi_function_of_probe(struct rmi_function *fn)
+{
+ char of_name[9];
+
+ snprintf(of_name, sizeof(of_name), "rmi4-f%02x",
+ fn->fd.function_number);
+ fn->dev.of_node = of_find_node_by_name(
+ fn->rmi_dev->xport->dev->of_node, of_name);
+}
+#else
+static inline void rmi_function_of_probe(struct rmi_function *fn)
+{}
+#endif
+
static int rmi_function_probe(struct device *dev)
{
struct rmi_function *fn = to_rmi_function(dev);
@@ -160,6 +175,8 @@ static int rmi_function_probe(struct device *dev)
to_rmi_function_handler(dev->driver);
int error;
+ rmi_function_of_probe(fn);
+
if (handler->probe) {
error = handler->probe(fn);
return error;
@@ -325,6 +342,24 @@ err_unregister_function_handlers:
return ret;
}
+int rmi_of_property_read_u32(struct device *dev, u32 *result,
+ const char *prop, bool optional)
+{
+ int retval;
+ u32 val = 0;
+
+ retval = of_property_read_u32(dev->of_node, prop, &val);
+ if (retval && (!optional && retval == -EINVAL)) {
+ dev_err(dev, "Failed to get %s value: %d\n",
+ prop, retval);
+ return retval;
+ }
+ *result = val;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(rmi_of_property_read_u32);
+
static int __init rmi_bus_init(void)
{
int error;