Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp827455imm; Sat, 7 Jul 2018 09:35:17 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfvyCojI38Xe1NCwozHZ29LKX+kdKWu1VYaMxBR0dtojsIagMlrxE03ct6Wz9cSCnVK2mav X-Received: by 2002:a62:a8e:: with SMTP id 14-v6mr14860496pfk.57.1530981317391; Sat, 07 Jul 2018 09:35:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530981317; cv=none; d=google.com; s=arc-20160816; b=c7769rtMbKK2P9T+42SACiz/jTk/2KIUHLalhHHFfgYBSsaK7tKsCSqvMiIr9Jswrw qJy7T0T7UJaKe4sV+LPNQqaEll5u24DI/8vLFEJSn6kLk5dv8XfCpHCY4+7PgcFk14QJ tgxbre7C6xyaedfXBKNXQEQp/kbgOg4sb8I61gBWx9BlVQ4BLHRCQZRycdnpEvwr4/Sd Hw0JjHcdlJgq9vyEZDNB9VpFgQ0UztSHcyFjssiiUo8ep71iCsrssx0k0WSfzP5sbCws IvRugAmePX4PPF7tPpTyvbslnMfu+fhTS3CYCeirbf2LFs/MXgcWAcksSTiYtc/CF8Qr K+Xw== 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=UySXHczrsQJ1LrqIW7EkoNJ/X3HDEIqTF4aUzIiQTp4=; b=fDY06sD6yzKkJNk/KwZolThv6Ke8lOai+ZBj9hQOIF4oe+0tshC6XWEADKR7oCocrx 7dC3RqgOD1HCySggoa0dp8R6cRaP4bkR6QiCcV84kxuDMIXsJjPMcdlnArRki99w9gtA W4h6vIksRbD+cDGC0YUjCsD/NcXtUnI0s/5kDXiFlfZ7r4geeJ/j3yhYwvHFjnL/a8Z+ bF4VGfv2mj8zaQMDSwZSE22J8aCXAod5vms4d1RDhmGoZiftyOToPjGaTw6/y9JEvuSm gVyG3+xF4PLOaulIPe3pD6MmEKPu+c01JuclepIxc3XT3LhhUtg4BvG2ia/a7R8KOrZP /NTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="dZQxCS/7"; 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 l6-v6si9919835pgl.628.2018.07.07.09.35.00; Sat, 07 Jul 2018 09:35:17 -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="dZQxCS/7"; 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 S1754269AbeGGQeP (ORCPT + 99 others); Sat, 7 Jul 2018 12:34:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:52032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754229AbeGGQeO (ORCPT ); Sat, 7 Jul 2018 12:34:14 -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 73A12215F1; Sat, 7 Jul 2018 16:34:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1530981253; bh=KGzBPb6JbW02aSzFTBJoERC29K+cps3tmt4ljilpOUc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=dZQxCS/7gPQzctNMVPsVfi7PnjuajKp4zElKxyI8ruQHlkoFO0LLQIQjprAGopMF4 AjGuzzolf1zsTiQCN1rd1ZxxJN24elLkOOPKVTVzYJtzfzkpzmairggyMmjTcw20Pd ECP9R9kfIPioN5nCC9cU7vlGzLR70QtyX8Q3JHPs= Date: Sat, 7 Jul 2018 17:34:08 +0100 From: Jonathan Cameron To: Nikolaus Voss Cc: Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Lorenzo Bianconi , Linus Walleij , Xiongfeng Wang , nv@vosn.de, Javier Martinez Canillas , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/2] IIO: st_accel_i2c.c: Simplify access to driver data Message-ID: <20180707173408.12d5701a@archlinux> In-Reply-To: <954eea265614f551e1c32b02a71578cc80a32020.1530782560.git.nikolaus.voss@loewensteinmedical.de> References: <954eea265614f551e1c32b02a71578cc80a32020.1530782560.git.nikolaus.voss@loewensteinmedical.de> 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 Tue, 3 Jul 2018 07:41:00 +0200 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. > > Reviewed-by: Andy Shevchenko > Signed-off-by: Nikolaus Voss Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it. Thanks and was interesting to follow the discussion I missed mid week! Jonathan > --- > drivers/iio/accel/st_accel_i2c.c | 59 ++++++++++++++------------------ > 1 file changed, 25 insertions(+), 34 deletions(-) > > diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c > index 056dddb27236..d02298f0256c 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,8 +107,8 @@ MODULE_DEVICE_TABLE(of, st_accel_of_match); > > #ifdef CONFIG_ACPI > static const struct acpi_device_id st_accel_acpi_match[] = { > - {"SMO8840", LNG2DM}, > - {"SMO8A90", LNG2DM}, > + {"SMO8840", (kernel_ulong_t)LNG2DM_ACCEL_DEV_NAME}, > + {"SMO8A90", (kernel_ulong_t)LNG2DM_ACCEL_DEV_NAME}, > { }, > }; > MODULE_DEVICE_TABLE(acpi, st_accel_acpi_match); > @@ -117,24 +117,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); > @@ -144,6 +144,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)); > @@ -152,19 +153,9 @@ 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); > + if (match) > + strlcpy(client->name, match, sizeof(client->name)); > > st_sensors_i2c_configure(indio_dev, client, adata); >