From patchwork Mon Sep 16 16:02:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 20359 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 342452486B for ; Mon, 16 Sep 2013 16:02:50 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id z20sf4610083yhz.7 for ; Mon, 16 Sep 2013 09:02:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version: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=4sEvleeEzfrPEz+2uezgIgfUl2uJZs+EnedD8RYxhXg=; b=cr5GtsILd/zKKrsII4S2oyc36zgdLCQqiEfKzuC9JMWXvJZ5liGCoySg2r9nL5dhmX maAQW/Fny19LIlBhGkMpBnKnoRZXvsdg/Hve6g0eI+1Erl03Nj571QsEBspWwJ93rjSc aHt7JpuxreS8rWrJ9MoZAQg2C54w6hBaLaUVWHGc/9SDcfS+a4sTh/j8BrKEFMXbMg6B k5Z9c8gtms015ct5AOaHg5bf2+4K/rD/fbEEcE92Z20WwxhKdFUtj5iAyYdfVNE9HNaH AdrMCQBul0guujuXwVSHfRdS8ottVgRRAxr54+/yi9WDkmaVMtcidGaY1MpS+qsmB+5Z MGlA== X-Gm-Message-State: ALoCoQlPbV9JJSObiTVK3b2fxau1Xu27ZEcxnxWiFkoqaveqyEc1xmQDk9qSja45ix7QBOIg+1g3 X-Received: by 10.236.17.161 with SMTP id j21mr465658yhj.55.1379347369872; Mon, 16 Sep 2013 09:02:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.99.72 with SMTP id eo8ls2379591qeb.41.gmail; Mon, 16 Sep 2013 09:02:49 -0700 (PDT) X-Received: by 10.221.47.193 with SMTP id ut1mr27586481vcb.8.1379347369757; Mon, 16 Sep 2013 09:02:49 -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 dt10si7270130vdb.8.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Sep 2013 09:02:49 -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 e13so3078113vbg.31 for ; Mon, 16 Sep 2013 09:02:49 -0700 (PDT) X-Received: by 10.52.100.202 with SMTP id fa10mr23284760vdb.0.1379347369651; Mon, 16 Sep 2013 09:02:49 -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 u4csp104938vcz; Mon, 16 Sep 2013 09:02:49 -0700 (PDT) X-Received: by 10.15.10.5 with SMTP id f5mr1446735eet.87.1379347368107; Mon, 16 Sep 2013 09:02:48 -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 7si16794483eeo.289.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Sep 2013 09:02:48 -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 c50so2114070eek.4 for ; Mon, 16 Sep 2013 09:02:47 -0700 (PDT) X-Received: by 10.14.119.196 with SMTP id n44mr834963eeh.116.1379347367556; Mon, 16 Sep 2013 09:02:47 -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 z12sm43061275eev.6.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Sep 2013 09:02:47 -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 11/20] iio: sensors-core: st: Support sensors which don't have a Data Ready pin Date: Mon, 16 Sep 2013 17:02:17 +0100 Message-Id: <1379347346-823-12-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1379347346-823-1-git-send-email-lee.jones@linaro.org> References: <1379347346-823-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 | 33 ++++++++++++++++--------- drivers/iio/pressure/st_pressure_core.c | 3 ++- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 793136a..2672630 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -198,21 +198,17 @@ 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) { dev_err(&indio_dev->dev, "DRDY on INT1 not available.\n"); - err = -EINVAL; - goto init_error; + return -EINVAL; } sdata->drdy_int_pin = 1; break; @@ -220,17 +216,29 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev, if (sdata->sensor->drdy_irq.mask_int2 == 0) { dev_err(&indio_dev->dev, "DRDY on INT2 not available.\n"); - err = -EINVAL; - goto init_error; + return -EINVAL; } sdata->drdy_int_pin = 2; break; default: dev_err(&indio_dev->dev, "DRDY on pdata not valid.\n"); - err = -EINVAL; - goto init_error; + return -EINVAL; } + return 0; +} + +int st_sensors_init_sensor(struct iio_dev *indio_dev, + struct st_sensors_platform_data *pdata) +{ + struct st_sensor_data *sdata = iio_priv(indio_dev); + int err = 0; + + 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 +274,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 93bff9b..3abada2 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -254,7 +254,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;