From patchwork Fri Sep 29 22:44:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 9978805 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 499C860311 for ; Fri, 29 Sep 2017 22:45:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B991291D6 for ; Fri, 29 Sep 2017 22:45:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3006F298B8; Fri, 29 Sep 2017 22:45:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D433D291D6 for ; Fri, 29 Sep 2017 22:45:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752584AbdI2WpC (ORCPT ); Fri, 29 Sep 2017 18:45:02 -0400 Received: from mail-pg0-f49.google.com ([74.125.83.49]:49467 "EHLO mail-pg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752576AbdI2Wo7 (ORCPT ); Fri, 29 Sep 2017 18:44:59 -0400 Received: by mail-pg0-f49.google.com with SMTP id v13so503541pgq.6 for ; Fri, 29 Sep 2017 15:44:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:subject:date:message-id; bh=BKZdaXFdFFP+li2uGb0HidBEiSCP/9w2Vmiq89ySQpQ=; b=OgOPXrrjlnIVOofstJihxBXhBQXEwdhj55KA/TrWANrYyFFYi4G1XAalsXbjk9eqKY tk4Nj0vJ5U0V8eKcV+tbQL5jHcgKr5fiD49k8KGY+JhTYNfVaRUJheeQBIVrts4FdqFq 77T+WFiXkCA9rDWXz9wR74PwFEOu2fOeTgGaQcctxETgiNVcg0RZ0n5HiFYhCwNiYaQA LW3Pkc8uhCwGQ9dnWotJBb3/doZhSR60PlsNXKyYfltq5nd6M5gTx30x2k+Bccza00Oq iZdfVv+fQrcIH5BqVt45A9J1bDZFpsDkyUbbb+Hwc6M1VcCaLcABv0k0pmy8YM3z1gsP 7I8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=BKZdaXFdFFP+li2uGb0HidBEiSCP/9w2Vmiq89ySQpQ=; b=gzTFoWatb9mSu1tp0O/uB8fLdF1YeWxPUtyeFi9moqoKo0T2vh+Qi/OMk6mVrbrtzU WMemtLbIK0MCMIv5U4AAoNBaMUTJJCXP6BTpYx4tK6AAvUwT2OYhcV8XHPooXe3gzZRF 0Ug+dufhVL2HEZwuvG08OO7+qggC2y4jSyyaT0GAGOeHxh63g8wyxSeEtphza50O4FVM H5Y5hQJrv7r7iJuPIZcIX0VbppOyh0GiHQA0DlXCqCqrf/vLLF2BtBmuU4L1VOqv55A3 WPR6E2BfWt798+2wMcmm3VgjztPSbot9tsXrJryEkUWBeHw+PPaV26f8NuT8o1OU8HLj i36w== X-Gm-Message-State: AMCzsaXjIVvWYRLAtBr4Olqdm6o+69QOwL+u79ZoNlaFr7rTrZzRJZ52 ErEAv3WpHDBorcMrXipASqDAVg== X-Google-Smtp-Source: AOwi7QB8jSYHYa4EJYXL0k5UV6BfdgLu2fRvd3Y7ATFI16X69aFmFKDrYGykYMw0x4lcYXOMu6UfpA== X-Received: by 10.84.252.149 with SMTP id y21mr340040pll.65.1506725098931; Fri, 29 Sep 2017 15:44:58 -0700 (PDT) Received: from rajat.mtv.corp.google.com ([172.22.112.48]) by smtp.gmail.com with ESMTPSA id v24sm9033232pfi.132.2017.09.29.15.44.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Sep 2017 15:44:58 -0700 (PDT) From: Rajat Jain To: Jiri Kosina , Benjamin Tissoires , David Arcari , Mika Westerberg , Andy Shevchenko , HungNien Chen , Hans de Goede , Brian Norris , Rajat Jain , Dmitry Torokhov , dtor@google.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, rajatxjain@gmail.com Subject: [PATCH] HID: i2c-hid: Use device properties (instead of device tree) Date: Fri, 29 Sep 2017 15:44:41 -0700 Message-Id: <20170929224441.98176-1-rajatja@google.com> X-Mailer: git-send-email 2.14.2.822.g60be5d43e6-goog Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use the device properties (that can be provided by ACPI systems as well as non ACPI systems) instead of device tree properties (that are not provided ACPI systems). This required some minor code restructuring. Signed-off-by: Rajat Jain --- I don't think its a big deal, but just FYI, this changes the order in which we look for HID register address from (device tree -> platform_data -> ACPI) to (platform data -> device tree -> ACPI) drivers/hid/i2c-hid/i2c-hid.c | 44 ++++++++++++++----------------------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c index 77396145d2d0..718afceb2395 100644 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -908,45 +908,36 @@ static inline int i2c_hid_acpi_pdata(struct i2c_client *client, static inline void i2c_hid_acpi_fix_up_power(struct device *dev) {} #endif -#ifdef CONFIG_OF -static int i2c_hid_of_probe(struct i2c_client *client, +static int i2c_hid_fwnode_probe(struct i2c_client *client, struct i2c_hid_platform_data *pdata) { struct device *dev = &client->dev; u32 val; int ret; - ret = of_property_read_u32(dev->of_node, "hid-descr-addr", &val); - if (ret) { - dev_err(&client->dev, "HID register address not provided\n"); - return -ENODEV; - } - if (val >> 16) { - dev_err(&client->dev, "Bad HID register address: 0x%08x\n", - val); - return -EINVAL; + ret = device_property_read_u32(dev, "hid-descr-addr", &val); + if (ret || val >> 16) { + /* Couldn't read using fwnode, try ACPI next */ + if (!i2c_hid_acpi_pdata(client, pdata)) { + dev_err(dev, "Bad/Not provided HID register address\n"); + return -ENODEV; + } } pdata->hid_descriptor_address = val; - ret = of_property_read_u32(dev->of_node, "post-power-on-delay-ms", - &val); + ret = device_property_read_u32(dev, "post-power-on-delay-ms", &val); if (!ret) pdata->post_power_delay_ms = val; return 0; } +#ifdef CONFIG_OF static const struct of_device_id i2c_hid_of_match[] = { { .compatible = "hid-over-i2c" }, {}, }; MODULE_DEVICE_TABLE(of, i2c_hid_of_match); -#else -static inline int i2c_hid_of_probe(struct i2c_client *client, - struct i2c_hid_platform_data *pdata) -{ - return -ENODEV; -} #endif static int i2c_hid_probe(struct i2c_client *client, @@ -977,19 +968,12 @@ static int i2c_hid_probe(struct i2c_client *client, if (!ihid) return -ENOMEM; - if (client->dev.of_node) { - ret = i2c_hid_of_probe(client, &ihid->pdata); + if (platform_data) { + ihid->pdata = *platform_data; + } else if (dev_fwnode(&client->dev)) { + ret = i2c_hid_fwnode_probe(client, &ihid->pdata); if (ret) goto err; - } else if (!platform_data) { - ret = i2c_hid_acpi_pdata(client, &ihid->pdata); - if (ret) { - dev_err(&client->dev, - "HID register address not provided\n"); - goto err; - } - } else { - ihid->pdata = *platform_data; } ihid->pdata.supply = devm_regulator_get(&client->dev, "vdd");