Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1992059imm; Sat, 30 Jun 2018 08:30:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLmxEt7xCX61v+yDto659onlyeiwSdAYE876lVqmRHDw/xHC917O1EpYLw6osNWsU15bTFy X-Received: by 2002:a17:902:b20d:: with SMTP id t13-v6mr19533905plr.121.1530372622874; Sat, 30 Jun 2018 08:30:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530372622; cv=none; d=google.com; s=arc-20160816; b=F1kzpsPSgHgqRmfYl8FOAK2lBA4xvBEjTqcnUSPB/6LV5rQuJRpqTvrXz0yUz8ej9N 007x97HK47GPf88A92GuyIwh+j7O1k8RtwogN74iUSLAR4QIsK43qc81+yjOedoDY/Hm ucVQPe6+P1DYk0U6nWV+K1tBlULIkS6Oyj9dvmNtdj5muutiC4fV0tFDXiFhHkkAxMAC pRZY93QLVmz3SWmfbvWbg7Wdltb/Q5mcRQ5ujKuRgZOnPAk4njk6aApTDoySrutZBkiK fS1HjAv/go2kNOqbWzawOvoA7fy8erAa0JC35bB3HMJe+UCa2ve1X7K4P9QRtEpFJOlQ K59g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature:arc-authentication-results; bh=Ogs0rvscNt72uJMm1QTu4zKBKVJa73yvL+VgYOqO6MM=; b=mQJtZIPSIOwlCYSN4ybN3OpfKtuu7Wl+wXtYgacitfKTG/w5uBeXHW+9UO/D5cNctd Exz3SuxhGOgOwOoK+7qZlnTLdDh53SACdEm/AWbYfAzqwGET0qYsVCogrCm6GLsdesYp 1hatE3ifaCrIE165mABXY+onWwPN7Vj8apOituoT0njIU5OZRilFuKqEoA9gcej0N5RO e35CDfp/d6xuega85WA/1D9nvnfVWRIH2urnbPk0nK6wjLglQpxxH3fGerNrKc5bbapy HV4oOQDlki2sBondoGjNlEgZLEoM+k2pYzJhfcE8BvgMIyjFdaPLWlMdKQ6/+WnqxIyW WYFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KTWkSZLu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m30-v6si4297866pgc.361.2018.06.30.08.30.07; Sat, 30 Jun 2018 08:30:22 -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; dkim=pass header.i=@kernel.org header.s=default header.b=KTWkSZLu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751283AbeF3P2M (ORCPT + 99 others); Sat, 30 Jun 2018 11:28:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:38036 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750802AbeF3P2J (ORCPT ); Sat, 30 Jun 2018 11:28:09 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B74B821939; Sat, 30 Jun 2018 15:28:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1530372488; bh=+ypU/h0QCSgeCYjaj9iH865dSMX7EC7xuWJXimGtAWs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=KTWkSZLuUNq3CiIzEZAZaRle0xNL8kWy3KWA5+bepnGJ6iMJluWkln27EvtIKfyns xQH1JrFhs9/0il9YdRJPQMEbMSFVLoCCDkzMW2PlHiUYWfT+Taq0uHmdxDFFAWkLeF ItSn3z08ObjnbGAu4+D3QfroWzToy9XpZSA/l/6w= Date: Sat, 30 Jun 2018 16:28:03 +0100 From: Jonathan Cameron To: Nikolaus Voss Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Lorenzo Bianconi , Linus Walleij , Xiongfeng Wang , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] IIO: st_accel_i2c.c: Use fallback if DT/ACPI enum failed Message-ID: <20180630162803.3a2ad759@archlinux> In-Reply-To: References: X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 29 Jun 2018 10:10:10 +0200 Nikolaus Voss wrote: > 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 Is the change to probe_new actually related to the rest of the change? I can't immediately see why... If not I would prefer that as a separate change. > --- > 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, > };