From patchwork Tue Sep 10 12:49:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19874 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 0C720246A4 for ; Tue, 10 Sep 2013 12:50:11 +0000 (UTC) Received: by mail-vb0-f70.google.com with SMTP id h10sf8722070vbh.9 for ; Tue, 10 Sep 2013 05:50:10 -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=ps+46xXFmpME6nYEfHZ7pJFoF2reWQxkItS7kFkKbQ4=; b=ZcHlbjoAKGlzaJsCwEKtHEUPVShLpnJZOUUfnDvEr62D0Q4iGrqar8+8xn2Ab5yG/l iuj2VcSPbhhu2XIdZt3EzB6ESIMrrxDjyEcA5GX0Hql0Qb9Jsdg/XCi9jszECyKzNMqn rw93qCIKXU3MK09Mpi0yyAhXy9aAsRFVsXBdK/q251G0zbaqRa/VGcLx3kEQ23j6UYIv IMquBNFc17naHrbTASNOeuHmAkJR3Npe5G7VXdYC+mkiCM/w++k4QJj6EguV05Y/xPaR l+cvQ90y5iHSBDTC3X7tYbcjT15FDxsRFwBFHpnluPQi9IbVTIuRBeQgRtiaYc8D1N3p uPew== X-Received: by 10.236.103.199 with SMTP id f47mr505886yhg.54.1378817410849; Tue, 10 Sep 2013 05:50:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.121.104 with SMTP id lj8ls2379166qeb.11.gmail; Tue, 10 Sep 2013 05:50:10 -0700 (PDT) X-Received: by 10.58.137.167 with SMTP id qj7mr22519154veb.1.1378817410623; Tue, 10 Sep 2013 05:50:10 -0700 (PDT) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id vh9si4394401vcb.100.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:10 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.169 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.169; Received: by mail-ve0-f169.google.com with SMTP id db12so4526463veb.14 for ; Tue, 10 Sep 2013 05:50:10 -0700 (PDT) X-Gm-Message-State: ALoCoQkhRCPncrACAcKz0ra1KA5eETN83/asXjCwI8Z7aVMSIoVvRkaJTS2MsandQagFhRDJFKsP X-Received: by 10.58.211.227 with SMTP id nf3mr7163312vec.20.1378817410351; Tue, 10 Sep 2013 05:50:10 -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 u4csp19397vcz; Tue, 10 Sep 2013 05:50:09 -0700 (PDT) X-Received: by 10.14.99.193 with SMTP id x41mr4115564eef.52.1378817406650; Tue, 10 Sep 2013 05:50:06 -0700 (PDT) Received: from mail-ea0-f182.google.com (mail-ea0-f182.google.com [209.85.215.182]) by mx.google.com with ESMTPS id u46si14831411eeg.196.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 10 Sep 2013 05:50:06 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.182 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.215.182; Received: by mail-ea0-f182.google.com with SMTP id o10so3942432eaj.27 for ; Tue, 10 Sep 2013 05:50:06 -0700 (PDT) X-Received: by 10.15.75.73 with SMTP id k49mr38543610eey.36.1378817406127; Tue, 10 Sep 2013 05:50:06 -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:05 -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 19/38] iio: sensors-core: st: Support sensors which don't have a Data Ready pin Date: Tue, 10 Sep 2013 13:49:20 +0100 Message-Id: <1378817379-8238-20-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.128.169 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: , Not all ST's sensors support data ready, so let's make the declaration of one conditional. Signed-off-by: Lee Jones --- drivers/iio/common/st_sensors/st_sensors_core.c | 24 +++++++++++++++++++----- drivers/iio/pressure/st_pressure_core.c | 3 ++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index eb261a5..b86cad2 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -198,14 +198,11 @@ int st_sensors_set_axis_enable(struct iio_dev *indio_dev, u8 axis_enable) } EXPORT_SYMBOL(st_sensors_set_axis_enable); -int st_sensors_init_sensor(struct iio_dev *indio_dev, - struct st_sensors_platform_data *pdata) +int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev, + struct st_sensors_platform_data *pdata) { - int err; struct st_sensor_data *sdata = iio_priv(indio_dev); - mutex_init(&sdata->tb.buf_lock); - switch (pdata->drdy_int_pin) { case 1: if (sdata->sensor->drdy_irq.mask_int1 == 0) { @@ -231,6 +228,20 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev, goto init_error; } + return 0; +} + +int st_sensors_init_sensor(struct iio_dev *indio_dev, + struct st_sensors_platform_data *pdata) +{ + int err = 0; + struct st_sensor_data *sdata = iio_priv(indio_dev); + + mutex_init(&sdata->tb.buf_lock); + + if (pdata) + err = st_sensors_set_drdy_int_pin(indio_dev, pdata); + err = st_sensors_set_enable(indio_dev, false); if (err < 0) goto init_error; @@ -266,6 +277,9 @@ int st_sensors_set_dataready_irq(struct iio_dev *indio_dev, bool enable) u8 drdy_mask; struct st_sensor_data *sdata = iio_priv(indio_dev); + if (!sdata->sensor->drdy_irq.addr) + return 0; + /* Enable/Disable the interrupt generator 1. */ if (sdata->sensor->drdy_irq.ig1.en_addr > 0) { err = st_sensors_write_data_with_mask(indio_dev, diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 16cfbc5..279aafd 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -232,7 +232,8 @@ int st_press_common_probe(struct iio_dev *indio_dev, pdata->odr = pdata->sensor->odr.odr_avl[0].hz; - if (!plat_data) + /* Some devices don't support a data ready pin. */ + if (!plat_data && pdata->sensor->drdy_irq.addr) plat_data = (struct st_sensors_platform_data *)&default_press_pdata;