From patchwork Wed Sep 4 09:31:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19746 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f70.google.com (mail-vb0-f70.google.com [209.85.212.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 890CB24869 for ; Wed, 4 Sep 2013 09:32:04 +0000 (UTC) Received: by mail-vb0-f70.google.com with SMTP id h10sf48353vbh.5 for ; Wed, 04 Sep 2013 02:32:04 -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=0DfzljSCx/qa0v9TxIQa7rwmoDn4TM2yKW95CDKNrbg=; b=J0+SA1X46d69u94lYUCfob2yDStFl3lCL2decxi1R4LFg2jbrf0ZPUkolDb0Pee5nS v56Stz7ga/sI8xh7pDOeAf4wWovOfHhqEQP7I548rDZ6mpiQkGye5Mt6twHulhjuqHR0 g6nzjHkwlbrE8WL15pZIBS9OUjmnE/XWsFPEYEKO1uuiRzSGJ5/h5Di1oyGJTYTMx6bI RDmmLWgWa0z4VFXyIwR5SWEppnJ8lqOb0/RVTnQ6J9KfShElkN6LzTcvfSlaJxpIOlgL 1tl3zXx0CoIaJZz1ipgVMHrz6D55EhNZFK54P2/6teCOjw+gis6tPgi9NtzJY8L/QL1p LiUQ== X-Received: by 10.236.223.130 with SMTP id v2mr706691yhp.34.1378287124399; Wed, 04 Sep 2013 02:32:04 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.29.167 with SMTP id l7ls39807qeh.47.gmail; Wed, 04 Sep 2013 02:32:04 -0700 (PDT) X-Received: by 10.58.235.193 with SMTP id uo1mr1774347vec.6.1378287123981; Wed, 04 Sep 2013 02:32:03 -0700 (PDT) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id ur9si998892veb.3.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Sep 2013 02:32:03 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.174; Received: by mail-ve0-f174.google.com with SMTP id d10so41289vea.5 for ; Wed, 04 Sep 2013 02:32:03 -0700 (PDT) X-Gm-Message-State: ALoCoQkuFC8/n/nazDv7Vn4kvwhTpvcyn4Qux3wHtcbmUmALme2G+hNzVaq52YmEPREl9u3NVMi7 X-Received: by 10.52.120.78 with SMTP id la14mr1545178vdb.9.1378287123860; Wed, 04 Sep 2013 02:32:03 -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 u4csp223881vcz; Wed, 4 Sep 2013 02:32:03 -0700 (PDT) X-Received: by 10.15.51.65 with SMTP id m41mr1927317eew.61.1378287122945; Wed, 04 Sep 2013 02:32:02 -0700 (PDT) Received: from mail-ee0-f45.google.com (mail-ee0-f45.google.com [74.125.83.45]) by mx.google.com with ESMTPS id f46si17395476eeo.219.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Sep 2013 02:32:02 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.45 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.83.45; Received: by mail-ee0-f45.google.com with SMTP id c50so34615eek.18 for ; Wed, 04 Sep 2013 02:32:02 -0700 (PDT) X-Received: by 10.14.224.198 with SMTP id x46mr2130990eep.53.1378287122439; Wed, 04 Sep 2013 02:32:02 -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 p5sm38475700eeg.5.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Sep 2013 02:32:01 -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 06/11] iio: pressure-core: st: Expand and rename LPS331AP's channel descriptor Date: Wed, 4 Sep 2013 10:31:38 +0100 Message-Id: <1378287103-21765-7-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1378287103-21765-1-git-send-email-lee.jones@linaro.org> References: <1378287103-21765-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.128.174 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: , Due to the MACRO used, the task of reading, understanding and maintaining the LPS331AP's channel descriptor is substantially difficult. This patch is based on the view that it's better to have easy to read, maintainable code than to save a few lines here and there. For that reason we're expanding the array so initialisation is completed in full. Signed-off-by: Lee Jones --- drivers/iio/pressure/st_pressure_core.c | 45 +++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index becfb25..7ba9299 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -58,16 +58,39 @@ #define ST_PRESS_LPS331AP_OUT_XL_ADDR 0x28 #define ST_TEMP_LPS331AP_OUT_L_ADDR 0x2b -static const struct iio_chan_spec st_press_channels[] = { - ST_SENSORS_LSM_CHANNELS(IIO_PRESSURE, +static const struct iio_chan_spec st_press_lsp331ap_channels[] = { + { + .type = IIO_PRESSURE, + .channel2 = IIO_NO_MOD, + .address = ST_PRESS_LPS331AP_OUT_XL_ADDR, + .scan_index = ST_SENSORS_SCAN_X, + .scan_type = { + .sign = 'u', + .realbits = 24, + .storagebits = 24, + .endianness = IIO_LE, + }, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), - ST_SENSORS_SCAN_X, 0, IIO_NO_MOD, 'u', IIO_LE, 24, 24, - ST_PRESS_LPS331AP_OUT_XL_ADDR), - ST_SENSORS_LSM_CHANNELS(IIO_TEMP, - BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE) | - BIT(IIO_CHAN_INFO_OFFSET), - -1, 0, IIO_NO_MOD, 's', IIO_LE, 16, 16, - ST_TEMP_LPS331AP_OUT_L_ADDR), + .modified = 0, + }, + { + .type = IIO_TEMP, + .channel2 = IIO_NO_MOD, + .address = ST_TEMP_LPS331AP_OUT_L_ADDR, + .scan_index = -1, + .scan_type = { + .sign = 'u', + .realbits = 16, + .storagebits = 16, + .endianness = IIO_LE, + }, + .info_mask_separate = + BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_OFFSET), + .modified = 0, + }, IIO_CHAN_SOFT_TIMESTAMP(1) }; @@ -77,7 +100,7 @@ static const struct st_sensors st_press_sensors[] = { .sensors_supported = { [0] = LPS331AP_PRESS_DEV_NAME, }, - .ch = (struct iio_chan_spec *)st_press_channels, + .ch = (struct iio_chan_spec *)st_press_lsp331ap_channels, .odr = { .addr = ST_PRESS_LPS331AP_ODR_ADDR, .mask = ST_PRESS_LPS331AP_ODR_MASK, @@ -214,7 +237,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_channels); + indio_dev->num_channels = ARRAY_SIZE(st_press_lsp331ap_channels); pdata->current_fullscale = (struct st_sensor_fullscale_avl *) &pdata->sensor->fs.fs_avl[0];