From patchwork Wed Oct 24 10:38:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Ranostay X-Patchwork-Id: 10654515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6D23717F0 for ; Wed, 24 Oct 2018 10:39:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 57A322A18B for ; Wed, 24 Oct 2018 10:39:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C0162A234; Wed, 24 Oct 2018 10:39:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EBF22A233 for ; Wed, 24 Oct 2018 10:39:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727117AbeJXTGh (ORCPT ); Wed, 24 Oct 2018 15:06:37 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33151 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726916AbeJXTGh (ORCPT ); Wed, 24 Oct 2018 15:06:37 -0400 Received: by mail-wr1-f67.google.com with SMTP id u1-v6so5030773wrn.0 for ; Wed, 24 Oct 2018 03:39:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7Va6jtAmjPupNFLQxShJntJTvRnh5DiV01k7Zuk7W5I=; b=KfXI9LA58ByqbRRLdTyEmPSQ3cc5Qy7MNfYxtJhcvQ3Kv31WH9XD5lDN/rusqjlK5A P7nvVfwj0AgyeqjMDbdBQGuZxhhDHqdII+38v1YuVB/uV39xSj/ythEhrq9tPmA2DovL 2t7lf/AuH1LPS20evWmT+difsUGsrfzYNaRlg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7Va6jtAmjPupNFLQxShJntJTvRnh5DiV01k7Zuk7W5I=; b=rfoA6C3dUAYhgN/TK+myZkbxdNkqbDBWf2o+EW1QPdUiEvs/7i5q2G/LGO2U78xzyK jyz0iQPbJPnAo2OIkR6pVThDx6j4OOdTv0PIrPjfqpIyuClByS9SNTMQkWJ0bMGaWodV MATgghYGTN78uI9GuLrC4q908Lv0PEDzOoSTv9DBxtK8fafkpLlqT3j6LD+2dZTLxq2d Jw2V/HtSj7AtpILsUb2Zvb8HrIOfgAiMuwLCgjXLHIWs7EIxJnwiEP49OQWz31fSKZQ4 A/lsdnc6iNVH8SvEviDki3BviO0t1WIiAoz4EzFxU9Pkz/uMyL1K+8QcZ6XhUXCn4Di1 IGyA== X-Gm-Message-State: AGRZ1gL+5WUK61VMPT/KxyzZZi2GXD/ffBVMw8piO2D7tHudBYxyO6sV lgkDjNVRRDsQEEDMdC2OGykIag== X-Google-Smtp-Source: AJdET5fOwvo7shoH922rL53RS4uBPBg2WHTxSp8uuvyrZQ/2qbsZXv53goKAtgAPxquqoXHW0witdw== X-Received: by 2002:adf:bc84:: with SMTP id g4-v6mr2397625wrh.250.1540377542128; Wed, 24 Oct 2018 03:39:02 -0700 (PDT) Received: from roguebox.c.hoisthospitality.com ([185.7.230.213]) by smtp.gmail.com with ESMTPSA id e142-v6sm10012170wmf.20.2018.10.24.03.39.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Oct 2018 03:39:01 -0700 (PDT) From: Matt Ranostay To: jic23@kernel.org Cc: linux-iio@vger.kernel.org, Matt Ranostay Subject: [PATCH 1/2] iio: potentiometer: tpl0102: switch to using pointer to chip config Date: Wed, 24 Oct 2018 11:38:57 +0100 Message-Id: <20181024103858.28201-2-matt.ranostay@konsulko.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181024103858.28201-1-matt.ranostay@konsulko.com> References: <20181024103858.28201-1-matt.ranostay@konsulko.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP More concise to have a pointer to tpl0102_cfg struct in the iio_priv data than an integer to an index of an array. Signed-off-by: Matt Ranostay Reviewed-by: Slawomir Stepien --- drivers/iio/potentiometer/tpl0102.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iio/potentiometer/tpl0102.c b/drivers/iio/potentiometer/tpl0102.c index ca1cce58fe20..8e8adabe672b 100644 --- a/drivers/iio/potentiometer/tpl0102.c +++ b/drivers/iio/potentiometer/tpl0102.c @@ -37,7 +37,7 @@ static const struct tpl0102_cfg tpl0102_cfg[] = { struct tpl0102_data { struct regmap *regmap; - unsigned long devid; + const struct tpl0102_cfg *cfg; }; static const struct regmap_config tpl0102_regmap_config = { @@ -72,8 +72,8 @@ static int tpl0102_read_raw(struct iio_dev *indio_dev, return ret ? ret : IIO_VAL_INT; } case IIO_CHAN_INFO_SCALE: - *val = 1000 * tpl0102_cfg[data->devid].kohms; - *val2 = tpl0102_cfg[data->devid].max_pos; + *val = 1000 * data->cfg->kohms; + *val2 = data->cfg->max_pos; return IIO_VAL_FRACTIONAL; } @@ -89,7 +89,7 @@ static int tpl0102_write_raw(struct iio_dev *indio_dev, if (mask != IIO_CHAN_INFO_RAW) return -EINVAL; - if (val >= tpl0102_cfg[data->devid].max_pos || val < 0) + if (val >= data->cfg->max_pos || val < 0) return -EINVAL; return regmap_write(data->regmap, chan->channel, val); @@ -113,7 +113,7 @@ static int tpl0102_probe(struct i2c_client *client, data = iio_priv(indio_dev); i2c_set_clientdata(client, indio_dev); - data->devid = id->driver_data; + data->cfg = &tpl0102_cfg[id->driver_data]; data->regmap = devm_regmap_init_i2c(client, &tpl0102_regmap_config); if (IS_ERR(data->regmap)) { dev_err(dev, "regmap initialization failed\n"); @@ -123,7 +123,7 @@ static int tpl0102_probe(struct i2c_client *client, indio_dev->dev.parent = dev; indio_dev->info = &tpl0102_info; indio_dev->channels = tpl0102_channels; - indio_dev->num_channels = tpl0102_cfg[data->devid].wipers; + indio_dev->num_channels = data->cfg->wipers; indio_dev->name = client->name; return devm_iio_device_register(dev, indio_dev);