From patchwork Tue Sep 10 12:49:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19880 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F26CF25EA3 for ; Tue, 10 Sep 2013 12:50:16 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id dn14sf27393332obc.6 for ; Tue, 10 Sep 2013 05:50:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=/1LI1zJdgIi0Jtyr1i8bbuRhi3fbq+lLVCC21Zo5TG4=; b=LNyd4STUXIeA3eD1UhegOE5Axl5G+JWtimRVDBShkr5fMpzUcQ2ui36yHYKmRFYo0o Dp9CwePaHqIrIT9iz+9rqaAPNkpeJ+OwgpxcvvRZU4lbEcPmjLT6PeEpJ4bMf2lybSXw kbUz3iDbJ0UjabMGSgK7wnUl9iD32Wdvo94qzSqiXY2Lsh8XJRw4IPk4OFHVvVPoL7D5 Fvi1odlDX6g54A1T4/IeDMA9nLq+hTrU3bkG9+RLinhlJ0l/7ZtQ3ygsnI3CENDCrp88 707PNIqRFC4a1atKVchR072xhY4BUTvRRwXH/X8Xi9XJkiRkv0F3B+oQC3YV8ptgQc0v gs0A== X-Received: by 10.182.105.227 with SMTP id gp3mr4192068obb.23.1378817416403; Tue, 10 Sep 2013 05:50:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.16.6 with SMTP id b6ls781520qed.79.gmail; Tue, 10 Sep 2013 05:50:16 -0700 (PDT) X-Received: by 10.58.100.144 with SMTP id ey16mr1156814veb.25.1378817416157; Tue, 10 Sep 2013 05:50:16 -0700 (PDT) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id b5si4388397vel.138.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:16 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.171; Received: by mail-vc0-f171.google.com with SMTP id ij15so4862013vcb.2 for ; Tue, 10 Sep 2013 05:50:16 -0700 (PDT) X-Gm-Message-State: ALoCoQlDg50Ve02BMJfACFGoBP3B3R71WZrMp/16UXbIDCo7QPD0yrJTdAQnYib4BEZESrIg861F X-Received: by 10.52.165.237 with SMTP id zb13mr1090378vdb.28.1378817416074; Tue, 10 Sep 2013 05:50:16 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp19406vcz; Tue, 10 Sep 2013 05:50:15 -0700 (PDT) X-Received: by 10.15.32.136 with SMTP id a8mr2748837eev.71.1378817412940; Tue, 10 Sep 2013 05:50:12 -0700 (PDT) Received: from mail-ea0-f170.google.com (mail-ea0-f170.google.com [209.85.215.170]) by mx.google.com with ESMTPS id h46si14854018eex.103.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:12 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.170 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.215.170; Received: by mail-ea0-f170.google.com with SMTP id h14so3848824eak.29 for ; Tue, 10 Sep 2013 05:50:12 -0700 (PDT) X-Received: by 10.14.172.133 with SMTP id t5mr38468472eel.35.1378817412276; Tue, 10 Sep 2013 05:50:12 -0700 (PDT) Received: from localhost.localdomain (cpc15-aztw25-2-0-cust493.aztw.cable.virginmedia.com. [92.233.57.238]) by mx.google.com with ESMTPSA id z12sm31123277eev.6.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:11 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, jic23@cam.ac.uk Cc: arnd@arndb.de, linus.walleij@linaro.org, denis.ciocca@st.com, linux-iio@vger.kernel.org, Lee Jones Subject: [PATCH 25/38] iio: pressure-core: st: Allow for number of channels to vary Date: Tue, 10 Sep 2013 13:49:26 +0100 Message-Id: <1378817379-8238-26-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1378817379-8238-1-git-send-email-lee.jones@linaro.org> References: <1378817379-8238-1-git-send-email-lee.jones@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , At the moment the number of channels specified is dictated by the first sensor supported by the driver. As we add support for more sensors this is likely to vary. Instead of using the ARRAY_SIZE() of the LPS331AP's channel specifier we'll use a new adaptable 'struct st_sensors' element instead. Signed-off-by: Lee Jones --- drivers/iio/pressure/st_pressure_core.c | 3 ++- include/linux/iio/common/st_sensors.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 60c2ee4..3abada2 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -107,6 +107,7 @@ static const struct st_sensors st_press_sensors[] = { [0] = LPS331AP_PRESS_DEV_NAME, }, .ch = (struct iio_chan_spec *)st_press_lps331ap_channels, + .num_ch = ARRAY_SIZE(st_press_lps331ap_channels), .odr = { .addr = ST_PRESS_LPS331AP_ODR_ADDR, .mask = ST_PRESS_LPS331AP_ODR_MASK, @@ -245,7 +246,7 @@ int st_press_common_probe(struct iio_dev *indio_dev, pdata->num_data_channels = ST_PRESS_NUMBER_DATA_CHANNELS; pdata->multiread_bit = pdata->sensor->multi_read_bit; indio_dev->channels = pdata->sensor->ch; - indio_dev->num_channels = ARRAY_SIZE(st_press_lps331ap_channels); + indio_dev->num_channels = pdata->sensor->num_ch; if (pdata->sensor->fs.addr != 0) pdata->current_fullscale = (struct st_sensor_fullscale_avl *) diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index e51f654..e732fda 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -184,6 +184,7 @@ struct st_sensors { u8 wai; char sensors_supported[ST_SENSORS_MAX_4WAI][ST_SENSORS_MAX_NAME]; struct iio_chan_spec *ch; + int num_ch; struct st_sensor_odr odr; struct st_sensor_power pw; struct st_sensor_axis enable_axis;