Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp893699imm; Fri, 29 Jun 2018 08:04:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeGeFp9JRIVnRAfElW8XB6aXeaRP64FUPvjQ3OsMgB1pSPHQW+a1UqQALthTrgOdHFeaoG1 X-Received: by 2002:a62:3101:: with SMTP id x1-v6mr14679317pfx.246.1530284673551; Fri, 29 Jun 2018 08:04:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530284673; cv=none; d=google.com; s=arc-20160816; b=QUn/2puuICwHd9AIcTgfnnpRM4qth4j4F9eBfL8Nx7aZYFUmLb2nTGYbF9HnLw39bh p+YuT+D/yftmYc4opViL+Et5lP8kkZ3yGswKmTCX7raPYJD+CMwVav1NrDElX0iNkMeL 4wU4/2RguHSiPjRyGEjT7tzoWQP35Rtz0SJzPoYw9NIu8hX4ISZIkEt9dMVsQX4lIuL9 g7jQ0iGShO6tyr6Jy5STLAyRhNjhNNZz02GYYnQAuYjpFl8r02N6lESRdUkTZ/kfR3sM FQ88tpbnN0lTdnMK8gOhhdNXqgrPZlVyhlyn/YOao01ihn4a/M38QecS38/Vf9VkDB7M RbSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:date:from:references :in-reply-to:message-id:arc-authentication-results; bh=iufnmSctdEorkNnGjiHd1JuYAIYPisRPiFheQW+HcrY=; b=MnzP0Ui5nCnCjsP7dPJL7xbNHtU9D3IcizjWHxQ2YfmkaHgaDEnLn6QTy3bXfXJfqK +RnNsaKT9vG5/Plk23SMSOa/5pgYU/A/hqt3iZoAyOY7MjVMgB8YsCFYYcRQfWj+T+tT OebMpYNqoUz+fsZ/qjzPJn5it2hVUArDOl470aD/AFy+dGUP8L2xjVK/gzNrHNkz9IZs jMcew7Ew5DAOpbNH5F+oO0thBDSRKb/3Zr0ghb44aayU4ScWc+ZJwUa+4IBnNvSQ9cMc 6AQO6LrnJXVGBoWwiqJyBl2Dr5xmSZHw21j3rQSaOFdUCC32UDp9+wJkjVcA+zkiuJ18 k49w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 194-v6si8585433pgf.651.2018.06.29.08.04.14; Fri, 29 Jun 2018 08:04:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964971AbeF2LPj (ORCPT + 99 others); Fri, 29 Jun 2018 07:15:39 -0400 Received: from mail.steuer-voss.de ([85.183.69.95]:51598 "EHLO mail.steuer-voss.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935740AbeF2LPd (ORCPT ); Fri, 29 Jun 2018 07:15:33 -0400 X-Virus-Scanned: Debian amavisd-new at mail.steuer-voss.de Received: by mail.steuer-voss.de (Postfix, from userid 1000) id D4DC941BD8; Fri, 29 Jun 2018 13:05:29 +0200 (CEST) Message-Id: In-Reply-To: References: From: Nikolaus Voss Date: Fri, 29 Jun 2018 10:10:10 +0200 Subject: [PATCH 1/3] IIO: st_accel_i2c.c: Use fallback if DT/ACPI enum failed To: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Lorenzo Bianconi , Linus Walleij , Xiongfeng Wang Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, the driver bails out if not explicitly referred to in DT or ACPI tables. This prevents fallback mechanisms from coming into effect, e.g. I2C device ID table match via DT or ACPI PRP0001 HID. However DT/ACPI enum should take precedence over the fallback, so evaluate that first. Signed-off-by: Nikolaus Voss --- drivers/iio/accel/st_accel_i2c.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index 6bdec8c451e0..e360da407027 100644 --- a/drivers/iio/accel/st_accel_i2c.c +++ b/drivers/iio/accel/st_accel_i2c.c @@ -138,8 +138,7 @@ static const struct i2c_device_id st_accel_id_table[] = { }; MODULE_DEVICE_TABLE(i2c, st_accel_id_table); -static int st_accel_i2c_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int st_accel_i2c_probe(struct i2c_client *client) { struct iio_dev *indio_dev; struct st_sensor_data *adata; @@ -156,14 +155,18 @@ static int st_accel_i2c_probe(struct i2c_client *client, client->name, sizeof(client->name)); } else if (ACPI_HANDLE(&client->dev)) { ret = st_sensors_match_acpi_device(&client->dev); - if ((ret < 0) || (ret >= ST_ACCEL_MAX)) - return -ENODEV; - - strlcpy(client->name, st_accel_id_table[ret].name, + if ((ret >= 0) && (ret < ST_ACCEL_MAX)) + strlcpy(client->name, st_accel_id_table[ret].name, sizeof(client->name)); - } else if (!id) - return -ENODEV; + } + /* + * If OF and ACPI enumeration failed, there could still be platform + * information via fallback enumeration or explicit instantiation, so + * check if id table has been matched via client->name. + */ + if (!client->name) + return -ENODEV; st_sensors_i2c_configure(indio_dev, client, adata); @@ -187,7 +190,7 @@ static struct i2c_driver st_accel_driver = { .of_match_table = of_match_ptr(st_accel_of_match), .acpi_match_table = ACPI_PTR(st_accel_acpi_match), }, - .probe = st_accel_i2c_probe, + .probe_new = st_accel_i2c_probe, .remove = st_accel_i2c_remove, .id_table = st_accel_id_table, }; -- 2.17.1