Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp978474imm; Wed, 4 Jul 2018 09:12:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdkltfls7voywWoMCEVUYapZK/F0IehN057HgxtoibSZruoaa4iw5ciAP7RXKzLoSIfpDP5 X-Received: by 2002:a65:4a90:: with SMTP id b16-v6mr2462497pgu.136.1530720725898; Wed, 04 Jul 2018 09:12:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530720725; cv=none; d=google.com; s=arc-20160816; b=GpZHGvM8puWk3j6p2vtcKNAMgbcuvUSi6sUVwxQKTM7N1UrwjANsiKPfHCeK/j/Q/n ioulPKxFfJ6IccO9dYvq8vUGL5OFvSX7UbEq4tuNu4N91RvUKIF+PvTell/9peWdpk1k 12yjpP1FnSodKptxEHvwcTd1sox39JCE3ZXEm4Ycy7+RKLsW+1n6FZXopdistFlEsqLW 3eM8yg9jvCIRutYZRIG1+1vuMTX/QhxD0MwLe1ID8bkly/5YekZDR5Qa15WSeMJLnyp/ A1+5FeLaXA1kjZYKtSEGCaVRRpr/r7ewMSBQeT0RebwcGO99HXovw+D3vPtQlh0Wbdat 149Q== 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:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=v9wU6Lu1f6XwuUbAy6v/dXZ3D/MPrqX6wpk/IUUkW7c=; b=nb0+3iZsgbcWIphPHPwUNDcPg6oz1U9teAqVDPlV+3EMVfeRxGh+tiqkfNJUrdiSVt iPgN4CEvx23xfvySD0tmbtPkZot7SMdbtYmdos4V+g8/U9w2NZBfXHOsHFk5Hjj+oxgz /EAfL3fa9D9/Kj+1zr+1VTbfU4l0adkH9gBaukaO8KZtsgkRM9JU77z9wyDUJjofkwS8 Zj9Ik89Z1c8xE2/zODy6+HEFmwdPnmbICweb43aXGBug8V49KahuwmZc0mFWujMWTKsl vn6MFEKu6QT0AIaceBuWDCmL09qIBsk0uAOftV46V+KqFmA0ha2ltcdCp2rrydQAtCWD AFow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pVBLbCwV; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z23-v6si3758821pfh.266.2018.07.04.09.11.51; Wed, 04 Jul 2018 09:12:05 -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=@gmail.com header.s=20161025 header.b=pVBLbCwV; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752816AbeGDQKv (ORCPT + 99 others); Wed, 4 Jul 2018 12:10:51 -0400 Received: from mail-ua0-f194.google.com ([209.85.217.194]:44564 "EHLO mail-ua0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752165AbeGDQKg (ORCPT ); Wed, 4 Jul 2018 12:10:36 -0400 Received: by mail-ua0-f194.google.com with SMTP id v15-v6so3725825ual.11; Wed, 04 Jul 2018 09:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=v9wU6Lu1f6XwuUbAy6v/dXZ3D/MPrqX6wpk/IUUkW7c=; b=pVBLbCwVSDGGSCZ8PhUv5mTY/3B08r+6tZRnx7gmkixaewSJjh0/KHUYvRFN0DD5uR EDzIiy2mgmvffHyry22DCf7D+bP+qixHht3r0Dc/FBrmtV19iKUqukB/MG9KGoNubJxX QESBIROZptj+CfZ41w70qqGYLa3OxJDQO/q3v0jPyoUnsZoaiuN3PJZrDghgYzYZax6y Wbs0DfUvwB+jJL6iHAV4hxyYUAg/HVP6+osP16qAMjxSU7m26ve/6TWp3toxIgUGj6FV qC1qzIXzB0UVVLHHWMyyHdLDZyGF9d1pb+RzjNIUpwPIY5r7TqkZKQ2yW4hnJsbHaqsL Pw8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=v9wU6Lu1f6XwuUbAy6v/dXZ3D/MPrqX6wpk/IUUkW7c=; b=BPIzymHggsqf30ByllDBQWQrn4nw6+88Lm4mzg/fxC5J/lsDnzdzaBIRA66Bqf8uaq sjNLeS4s857WMYV3dGia9SaaTTTqPh91foTXDULk2i01+ZsrxLqlP+n7/9BLXlLmVcU4 ra6ToYq0cC17OOoXUolXmYHt8+0pnZUwNwpgNMz2nNl4DMipXooVgC7kFL8ubXnStqMW uraNXNtdDW4OMiL7jlJ4LQwceq0mGfpKXMbEJC6kI2pDNRLaR6QMrlYreUNrBf0txcUy S9HhMEEyPzbX4SMR0xyRABhqpLyiwFkvUmJcjq3ThzQ7TOio0Ha5vBfbN7eLaixNSXdr 0GsQ== X-Gm-Message-State: APt69E2u/SYGv5njv/SWMtupUH4i33SW39MPMV0Lirk6oILtkLG7kf/0 k1jTeISeawCir60I6M4TlvdX8qI6ZkSrBCvLrw8= X-Received: by 2002:ab0:1446:: with SMTP id c6-v6mr1567356uae.12.1530720635752; Wed, 04 Jul 2018 09:10:35 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:2149:0:0:0:0:0 with HTTP; Wed, 4 Jul 2018 09:10:35 -0700 (PDT) In-Reply-To: References: From: Andy Shevchenko Date: Wed, 4 Jul 2018 19:10:35 +0300 Message-ID: Subject: Re: [PATCH v3 1/2] IIO: st_accel_i2c.c: Simplify access to driver data To: Nikolaus Voss Cc: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Lorenzo Bianconi , Linus Walleij , Xiongfeng Wang , Javier Martinez Canillas , linux-iio@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 3, 2018 at 8:41 AM, Nikolaus Voss wrote: > Use device_get_match_data API to simplify access to driver data. > Let acpi_device_id table entries point to the same driver data as > of_device_id table entries and uniquify access to driver data by using > device_get_match_data API. Remove unused i2c_device_id .driver_data > fields. > Couple of comments below, otherwise Reviewed-by: Andy Shevchenko > Signed-off-by: Nikolaus Voss > --- > drivers/iio/accel/st_accel_i2c.c | 56 ++++++++++++++------------------ > 1 file changed, 24 insertions(+), 32 deletions(-) > > diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c > index 6bdec8c451e0..c6e08c834f11 100644 > --- a/drivers/iio/accel/st_accel_i2c.c > +++ b/drivers/iio/accel/st_accel_i2c.c > @@ -14,8 +14,8 @@ > #include > #include > #include > +#include > > -#include > #include > #include "st_accel.h" > > @@ -107,7 +107,7 @@ MODULE_DEVICE_TABLE(of, st_accel_of_match); > > #ifdef CONFIG_ACPI > static const struct acpi_device_id st_accel_acpi_match[] = { > - {"SMO8A90", LNG2DM}, > + {"SMO8A90", (kernel_ulong_t)LNG2DM_ACCEL_DEV_NAME}, > { }, Is it done against iio-next? I see two records in this table. (It might make sense to remove comma from terminator, though it's minor change, up to you) > }; > MODULE_DEVICE_TABLE(acpi, st_accel_acpi_match); > @@ -116,24 +116,24 @@ MODULE_DEVICE_TABLE(acpi, st_accel_acpi_match); > #endif > > static const struct i2c_device_id st_accel_id_table[] = { > - { LSM303DLH_ACCEL_DEV_NAME, LSM303DLH }, > - { LSM303DLHC_ACCEL_DEV_NAME, LSM303DLHC }, > - { LIS3DH_ACCEL_DEV_NAME, LIS3DH }, > - { LSM330D_ACCEL_DEV_NAME, LSM330D }, > - { LSM330DL_ACCEL_DEV_NAME, LSM330DL }, > - { LSM330DLC_ACCEL_DEV_NAME, LSM330DLC }, > - { LIS331DLH_ACCEL_DEV_NAME, LIS331DLH }, > - { LSM303DL_ACCEL_DEV_NAME, LSM303DL }, > - { LSM303DLM_ACCEL_DEV_NAME, LSM303DLM }, > - { LSM330_ACCEL_DEV_NAME, LSM330 }, > - { LSM303AGR_ACCEL_DEV_NAME, LSM303AGR }, > - { LIS2DH12_ACCEL_DEV_NAME, LIS2DH12 }, > - { LIS3L02DQ_ACCEL_DEV_NAME, LIS3L02DQ }, > - { LNG2DM_ACCEL_DEV_NAME, LNG2DM }, > - { H3LIS331DL_ACCEL_DEV_NAME, H3LIS331DL }, > - { LIS331DL_ACCEL_DEV_NAME, LIS331DL }, > - { LIS3LV02DL_ACCEL_DEV_NAME, LIS3LV02DL }, > - { LIS2DW12_ACCEL_DEV_NAME, LIS2DW12 }, > + { LSM303DLH_ACCEL_DEV_NAME }, > + { LSM303DLHC_ACCEL_DEV_NAME }, > + { LIS3DH_ACCEL_DEV_NAME }, > + { LSM330D_ACCEL_DEV_NAME }, > + { LSM330DL_ACCEL_DEV_NAME }, > + { LSM330DLC_ACCEL_DEV_NAME }, > + { LIS331DLH_ACCEL_DEV_NAME }, > + { LSM303DL_ACCEL_DEV_NAME }, > + { LSM303DLM_ACCEL_DEV_NAME }, > + { LSM330_ACCEL_DEV_NAME }, > + { LSM303AGR_ACCEL_DEV_NAME }, > + { LIS2DH12_ACCEL_DEV_NAME }, > + { LIS3L02DQ_ACCEL_DEV_NAME }, > + { LNG2DM_ACCEL_DEV_NAME }, > + { H3LIS331DL_ACCEL_DEV_NAME }, > + { LIS331DL_ACCEL_DEV_NAME }, > + { LIS3LV02DL_ACCEL_DEV_NAME }, > + { LIS2DW12_ACCEL_DEV_NAME }, > {}, > }; > MODULE_DEVICE_TABLE(i2c, st_accel_id_table); > @@ -143,6 +143,7 @@ static int st_accel_i2c_probe(struct i2c_client *client, > { > struct iio_dev *indio_dev; > struct st_sensor_data *adata; > + const char *match; > int ret; > > indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*adata)); > @@ -151,19 +152,10 @@ static int st_accel_i2c_probe(struct i2c_client *client, > > adata = iio_priv(indio_dev); > > - if (client->dev.of_node) { > - st_sensors_of_name_probe(&client->dev, st_accel_of_match, > - 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, > - sizeof(client->name)); > - } else if (!id) > - return -ENODEV; > + match = device_get_match_data(&client->dev); > Redundant blank line > + if (match) > + strlcpy(client->name, match, sizeof(client->name)); > > st_sensors_i2c_configure(indio_dev, client, adata); > > -- > 2.17.1 > -- With Best Regards, Andy Shevchenko