Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp820951imm; Tue, 3 Jul 2018 00:06:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd6omkWXRx+Wkqh6qJxvaEiNfLNearh/zIK9C8jWConiHVSaoAEJ8uRm1E0LhmNfiBWVliN X-Received: by 2002:a62:4a51:: with SMTP id x78-v6mr28584817pfa.45.1530601567309; Tue, 03 Jul 2018 00:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530601567; cv=none; d=google.com; s=arc-20160816; b=ApnI1f50bD/Atct6kMqN7uZ8eLpFmt0NRWysVjIPVoSshDn1jrhJ4+TNDuniMgwF2j Ce0KdMq2IZm+ASvfh+8L9jcuxfp3Ao3sWRp7mysj2r81m97hpo+07ju65R7dvxmYkdl9 8JpcJFwvo492j/Sr88HkIhLXd5/6ERakbpbi7JQSS/pBIX08qbgWdBfhErykKv5OXe4I oCB+Ht/9l1clA6FBJY/hP02Juo7tDhPGmue7GdLXaRYMbzricsxlgIgzRk9PPLfzmKbj jIHLr2iyNtRdxh4vaGLFfb4K9IKKPbGoJ7gecKHLTphWymzSuLY5F1HosILGluyQvOsz OOig== 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=wtgAvDtTbQyyY+1jMh4N2vW4ubYoPHy0FsIKnOR7214=; b=CuYr5uSIzHUTMDM8rHgscPtCDxvGGnx0X8yoIZaHQLWyMQ9crNEELC5Qk0XK2JuMqN /1hFghBFlI6A2CKAVGM4P6leYKsE3MPIOV7KO/7njyakawZ8dWXI8jjZozlwnWggP7z2 ZeV6QTR6ccBw7Yn5Ez8ZPgLw989+lyJxG5ZcrlEACvqDusi9yjV9XqF45S0oM8TWjnMV 44QC9AIgCc6hlcf97E0TLMxbSgitYfA1I+MpC5VKbCuLK64cgvO9lP1xwuIMbsLZg8WE LzQ426oNL9apX9Fc36teMm4fO7LWcgjjc8UcBTFJPdbr3eaqqrMWGqxJ3KO0AOTjY0sa HPnw== 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 f11-v6si430717plr.316.2018.07.03.00.05.53; Tue, 03 Jul 2018 00:06:07 -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 S1753903AbeGCHD6 (ORCPT + 99 others); Tue, 3 Jul 2018 03:03:58 -0400 Received: from mail.steuer-voss.de ([85.183.69.95]:55122 "EHLO mail.steuer-voss.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753557AbeGCHDz (ORCPT ); Tue, 3 Jul 2018 03:03:55 -0400 X-Virus-Scanned: Debian amavisd-new at mail.steuer-voss.de Received: by mail.steuer-voss.de (Postfix, from userid 1000) id EA53341C50; Tue, 3 Jul 2018 09:03:48 +0200 (CEST) Message-Id: <1212fde5edcf360231282c9d2487712fc5b4d6f8.1530599660.git.nikolaus.voss@loewensteinmedical.de> In-Reply-To: References: From: Nikolaus Voss Date: Tue, 3 Jul 2018 07:41:00 +0200 Subject: [PATCH v2 1/2] IIO: st_accel_i2c.c: Simplify access to driver data To: Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Lorenzo Bianconi , Linus Walleij , Xiongfeng Wang , Andy Shevchenko , nv@vosn.de 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 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. Signed-off-by: Nikolaus Voss --- drivers/iio/accel/st_accel_i2c.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index 6bdec8c451e0..163f7ec189b0 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}, { }, }; MODULE_DEVICE_TABLE(acpi, st_accel_acpi_match); @@ -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,13 @@ 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; + match = of_device_get_match_data(&client->dev); - strlcpy(client->name, st_accel_id_table[ret].name, - sizeof(client->name)); - } else if (!id) - return -ENODEV; + if (!match) + match = acpi_device_get_match_data(&client->dev); + if (match) + strlcpy(client->name, match, sizeof(client->name)); st_sensors_i2c_configure(indio_dev, client, adata); -- 2.17.1