Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755963AbbBPSOi (ORCPT ); Mon, 16 Feb 2015 13:14:38 -0500 Received: from mga14.intel.com ([192.55.52.115]:56472 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753942AbbBPSOg (ORCPT ); Mon, 16 Feb 2015 13:14:36 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,589,1418112000"; d="scan'208";a="686461095" From: Irina Tirdea To: Jonathan Cameron , linux-iio@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Srinivas Pandruvada , Adriana Reus , Irina Tirdea Subject: [PATCH v2 1/2] iio: gyro: bmg160: use available_scan_masks Date: Mon, 16 Feb 2015 20:14:09 +0200 Message-Id: <1424110450-16398-2-git-send-email-irina.tirdea@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424110450-16398-1-git-send-email-irina.tirdea@intel.com> References: <1424110450-16398-1-git-send-email-irina.tirdea@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2062 Lines: 62 Use available_scan_masks to allow the iio core to select the data to send to userspace depending on which axes are enabled, instead of doing this in the driver's interrupt handler. This also fixes the issue of accessing the buffer scan_mask instead of active_scan_mask, since these might not be the same due to client devices. Signed-off-by: Irina Tirdea Reviewed-by: Srinivas Pandruvada --- drivers/iio/gyro/bmg160.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c index 60451b3..6ccf333 100644 --- a/drivers/iio/gyro/bmg160.c +++ b/drivers/iio/gyro/bmg160.c @@ -115,6 +115,7 @@ enum bmg160_axis { AXIS_X, AXIS_Y, AXIS_Z, + AXIS_MAX, }; static const struct { @@ -814,6 +815,8 @@ static const struct iio_info bmg160_info = { .driver_module = THIS_MODULE, }; +static const unsigned long bmg160_scan_masks[] = {0x7, 0}; + static irqreturn_t bmg160_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; @@ -822,8 +825,7 @@ static irqreturn_t bmg160_trigger_handler(int irq, void *p) int bit, ret, i = 0; mutex_lock(&data->mutex); - for_each_set_bit(bit, indio_dev->buffer->scan_mask, - indio_dev->masklength) { + for (bit = 0; bit < AXIS_MAX; bit++) ret = i2c_smbus_read_word_data(data->client, BMG160_AXIS_TO_REG(bit)); if (ret < 0) { @@ -1060,6 +1062,7 @@ static int bmg160_probe(struct i2c_client *client, indio_dev->dev.parent = &client->dev; indio_dev->channels = bmg160_channels; indio_dev->num_channels = ARRAY_SIZE(bmg160_channels); + indio_dev->available_scan_masks = bmg160_scan_masks; indio_dev->name = name; indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &bmg160_info; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/