From patchwork Mon Sep 9 10:10:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 19833 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6D00325A57 for ; Mon, 9 Sep 2013 10:10:38 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id k4sf87848qaq.4 for ; Mon, 09 Sep 2013 03:10:38 -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=loUO1Fwa7/cXBcePEIT4zWj1yvo5OY8yRGMRW/pzBes=; b=EU0EMIf96CSQUJo9Fny9aqzhhvBFiPQbrAdKilwA/xZthJ4RRnpr4j2rsAh5C8QSsN JWWkDpbuI5KhLDd6STAdLX6X/UHO8nlvXAbAm2lR8reKjMs5LclbeVEI9GTSeuLQFRNt mSRH4wSzj8wXVis1N0NPz8PFXwVbJC0NraMO4FqyNg2SWgyecGEaY7guVccOFayvOH86 WkZq6louG/bjbAvE5K6on7Qi8HEnAOu1U76M7OWfFDIaoMC5nq8lBWaE863v76Vey8b0 sXz4jSgo40nroqIarLuy82Dz8YyfThp0Gonzviq0U1ZEd0eBFtG5x4ANsCoPiaDA4Ut4 dZ9g== X-Received: by 10.236.223.130 with SMTP id v2mr6140794yhp.34.1378721438240; Mon, 09 Sep 2013 03:10:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.99.72 with SMTP id eo8ls1752952qeb.41.gmail; Mon, 09 Sep 2013 03:10:38 -0700 (PDT) X-Received: by 10.52.162.66 with SMTP id xy2mr13476338vdb.3.1378721438110; Mon, 09 Sep 2013 03:10:38 -0700 (PDT) Received: from mail-vb0-f44.google.com (mail-vb0-f44.google.com [209.85.212.44]) by mx.google.com with ESMTPS id un5si2977938vcb.22.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Sep 2013 03:10:38 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.44 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.44; Received: by mail-vb0-f44.google.com with SMTP id e13so3880043vbg.31 for ; Mon, 09 Sep 2013 03:10:38 -0700 (PDT) X-Gm-Message-State: ALoCoQktZ3KjNbGmAaj3/7JCRtYBroEA7+2j4b7/3uWmrbmncUKOJV0ufgMIi7e98J6FxqIOb+tn X-Received: by 10.52.119.228 with SMTP id kx4mr14140753vdb.12.1378721437995; Mon, 09 Sep 2013 03:10:37 -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 u4csp78980vcz; Mon, 9 Sep 2013 03:10:37 -0700 (PDT) X-Received: by 10.15.36.9 with SMTP id h9mr29431781eev.30.1378721436952; Mon, 09 Sep 2013 03:10:36 -0700 (PDT) Received: from mail-ea0-f176.google.com (mail-ea0-f176.google.com [209.85.215.176]) by mx.google.com with ESMTPS id c49si9577206eeg.57.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 09 Sep 2013 03:10:36 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.215.176 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.215.176; Received: by mail-ea0-f176.google.com with SMTP id q16so3022861ead.35 for ; Mon, 09 Sep 2013 03:10:36 -0700 (PDT) X-Received: by 10.14.122.132 with SMTP id t4mr29388965eeh.20.1378721436459; Mon, 09 Sep 2013 03:10:36 -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:36 -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 14/14] iio: sensors-core: st: Support sensors which don't have a Data Ready pin Date: Mon, 9 Sep 2013 11:10:10 +0100 Message-Id: <1378721410-30937-15-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.44 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 05030e4..8c4c54c 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) { @@ -228,6 +225,20 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev, return -EINVAL; } + 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) return err; @@ -262,6 +273,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 330701c..d650039 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -377,7 +377,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;