From patchwork Mon Sep 9 10:10:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19826 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f71.google.com (mail-qe0-f71.google.com [209.85.128.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 63E4325A57 for ; Mon, 9 Sep 2013 10:10:31 +0000 (UTC) Received: by mail-qe0-f71.google.com with SMTP id a11sf3363027qen.2 for ; Mon, 09 Sep 2013 03:10:31 -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=jiR6SqT7HD7lh4loe7+xB/3m89KiXW13NgQHt4p29tE=; b=Y60+Iy6EmyyMOtzEJAdRCegkm3JyVgU8494QZ6jTJmZOIaY1ig/ftUOgq8VrzFua53 31umNnxJhV1evCAL+BQfDnvvIDiAMG8S0kFY+yhSN64htJ+Zy+ZlEAa5DpKEYh0r3RMT hZMwX1SXPfDdbUraTnpPjkRiJpTp3XOuqh0f8n+VuCKWwHhrhK5xexa8C6JYBPNw3nps 0GB738/hjn6D7KO6lVTRS6xUwS9lnTV/9UR8rS59RKa7FvYwC/LrPDwLFMvbOut/S71a A1+i2kFHUFZ8mQVd61bbzBH1n6fCM9icUvDiR4yK3CGMU5tG52O9CPme7D/UGl7ivWiH hM0A== X-Received: by 10.236.207.103 with SMTP id m67mr5994922yho.1.1378721431140; Mon, 09 Sep 2013 03:10:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.29.167 with SMTP id l7ls1808424qeh.47.gmail; Mon, 09 Sep 2013 03:10:31 -0700 (PDT) X-Received: by 10.220.88.13 with SMTP id y13mr1119759vcl.20.1378721431044; Mon, 09 Sep 2013 03:10:31 -0700 (PDT) Received: from mail-vb0-f43.google.com (mail-vb0-f43.google.com [209.85.212.43]) by mx.google.com with ESMTPS id tj1si2951965vdc.131.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Sep 2013 03:10:31 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.43 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.43; Received: by mail-vb0-f43.google.com with SMTP id h11so3937219vbh.30 for ; Mon, 09 Sep 2013 03:10:30 -0700 (PDT) X-Gm-Message-State: ALoCoQlprurfTppWXaIG15hh/2jTxr6RFJwSkhoXLB5VARS76xK+MEMoCbf778zRsyzlfNXjt1GE X-Received: by 10.58.246.8 with SMTP id xs8mr17095753vec.9.1378721430937; Mon, 09 Sep 2013 03:10:30 -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 u4csp78973vcz; Mon, 9 Sep 2013 03:10:30 -0700 (PDT) X-Received: by 10.14.174.195 with SMTP id x43mr3033274eel.47.1378721429764; Mon, 09 Sep 2013 03:10:29 -0700 (PDT) Received: from mail-ea0-f171.google.com (mail-ea0-f171.google.com [209.85.215.171]) by mx.google.com with ESMTPS id h46si9524362eex.283.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Sep 2013 03:10:29 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.171 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.215.171; Received: by mail-ea0-f171.google.com with SMTP id n15so3033787ead.30 for ; Mon, 09 Sep 2013 03:10:29 -0700 (PDT) X-Received: by 10.14.174.8 with SMTP id w8mr54870eel.84.1378721429267; Mon, 09 Sep 2013 03:10:29 -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 m54sm20768068eex.2.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Sep 2013 03:10:28 -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 07/14] iio: pressure-core: st: Allow for number of channels to vary Date: Mon, 9 Sep 2013 11:10:03 +0100 Message-Id: <1378721410-30937-8-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1378721410-30937-1-git-send-email-lee.jones@linaro.org> References: <1378721410-30937-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.212.43 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 506b02d..93bff9b 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;