From patchwork Mon Nov 19 00:53:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kelly X-Patchwork-Id: 10688085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 122EE13BF for ; Mon, 19 Nov 2018 00:54:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9B882995D for ; Mon, 19 Nov 2018 00:54:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C535129962; Mon, 19 Nov 2018 00:54:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 637662995D for ; Mon, 19 Nov 2018 00:54:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726890AbeKSLP7 (ORCPT ); Mon, 19 Nov 2018 06:15:59 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:32799 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725908AbeKSLP7 (ORCPT ); Mon, 19 Nov 2018 06:15:59 -0500 Received: by mail-pg1-f193.google.com with SMTP id z11so10397595pgu.0 for ; Sun, 18 Nov 2018 16:54:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martingkelly-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=HAFfjR5X+6R0KWDnlkejX1k3OdxrexI9I6r7D3guT5w=; b=AkTNzt3f4/4hlFqVigWOKux/o0oZw+DPRqykYANyVQ8+HqOipSIuIRSuDsk4zamHH/ uO/EEQ3UIFf5qeoT1QtfCNMX15Nbd5FaoUhEKkYFw7OiWBG0Ond20KIq0sqijVze9vRU XTUiU1HzsVdHRhHzHzslPIwaEKGvemAAYfPDegVKG3ldsPhCmV2zW/p3GQpbsfXZVjgG bfZCMpJaM7E093hPrzglTCuWDslRx86gA3nosqWsVWVlZbjTRn5Os50PdNotU7//7zkL d68RXVgcSV/52JqmdkeWG5wmNKH7xlCZZdPQUahU935tFYmQvk+YAmUGjZGJNSIuzMiE n4zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HAFfjR5X+6R0KWDnlkejX1k3OdxrexI9I6r7D3guT5w=; b=VNUlqz7potLs8+P+t+fc4Ymt2f8RrxCjkpiG5Vj+QC2Z2ADevwv1VkucpceodZN9QC 0/OYVHqiz8jxgiJNxuIaiiwtA4LYT77nyCyCMQEtlb04omOoHzYHwNU0sOyCMN07ywtb hxWf9oUEH8Pmb6idr11fkk6p39cSkLyIOMrDXNewbRgAzMCB83u1F2FQK1mlhZlv/GIW Jc9wKYol6qjUJ+3AfExxwyC7EYryTz7X/YS4sceOlsA3Fn9iMOOLioYMHGnqni72a1xw g917v7lduF+HjPNc53LR43mCEv9r/CIXtmas1jQK7HPFCd6U9kqTuUwSEO9GACQsJY+J dbJA== X-Gm-Message-State: AGRZ1gIp2kDMuJuNAzl6U4yJyW8N67To2Y+RHBLs4xpj3L3YhDh1T/d1 4XjjvSVzJ7V6O50OUmVnkvMyLmjWDBg= X-Google-Smtp-Source: AJdET5fqrnqalecp0RcUoKsVA8LvZnQH06kpOOZp+pPerMujlWdhJtaN/sUxunvZ18xHY01qvUBsdQ== X-Received: by 2002:a63:1848:: with SMTP id 8mr18008383pgy.81.1542588845535; Sun, 18 Nov 2018 16:54:05 -0800 (PST) Received: from cascade.Home (97-113-254-72.tukw.qwest.net. [97.113.254.72]) by smtp.gmail.com with ESMTPSA id f13sm13523773pfa.132.2018.11.18.16.54.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Nov 2018 16:54:04 -0800 (PST) From: Martin Kelly X-Google-Original-From: Martin Kelly , Jonathan Cameron , Martin Kelly Subject: [PATCH 1/2] iio: bmi160: snap timestamp closer to event Date: Sun, 18 Nov 2018 16:53:46 -0800 Message-Id: <20181119005347.747-1-martin@martingkelly.com> X-Mailer: git-send-email 2.11.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Martin Kelly Currently, we snap the timestamp after reading from the buffer and processing the event. Technically, we can get a slightly more accurate timestamp by snapping it prior to reading the data, since the data was already generated prior to entering the trigger handler. This is not going to make a huge difference, but we might as well improve slightly. Signed-off-by: Martin Kelly Acked-by: Daniel Baluta --- drivers/iio/imu/bmi160/bmi160_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c index c85659ca9507..4d9d59d9e3a9 100644 --- a/drivers/iio/imu/bmi160/bmi160_core.c +++ b/drivers/iio/imu/bmi160/bmi160_core.c @@ -384,6 +384,7 @@ static irqreturn_t bmi160_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; + s64 ts = iio_get_time_ns(indio_dev); struct bmi160_data *data = iio_priv(indio_dev); __le16 buf[16]; /* 3 sens x 3 axis x __le16 + 3 x __le16 pad + 4 x __le16 tstamp */ @@ -399,8 +400,7 @@ static irqreturn_t bmi160_trigger_handler(int irq, void *p) buf[j++] = sample; } - iio_push_to_buffers_with_timestamp(indio_dev, buf, - iio_get_time_ns(indio_dev)); + iio_push_to_buffers_with_timestamp(indio_dev, buf, ts); done: iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; From patchwork Mon Nov 19 00:53:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kelly X-Patchwork-Id: 10688087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D914013B5 for ; Mon, 19 Nov 2018 00:54:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8ED02995B for ; Mon, 19 Nov 2018 00:54:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD4862995D; Mon, 19 Nov 2018 00:54:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8435E2995F for ; Mon, 19 Nov 2018 00:54:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725908AbeKSLQD (ORCPT ); Mon, 19 Nov 2018 06:16:03 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42354 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726895AbeKSLQD (ORCPT ); Mon, 19 Nov 2018 06:16:03 -0500 Received: by mail-pf1-f194.google.com with SMTP id 64so9499600pfr.9 for ; Sun, 18 Nov 2018 16:54:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martingkelly-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6U3SqChqW36OJaTxQrWyg7Ew6SaBHbgZbxiF3lESZ10=; b=TIfNhW+8lZJl8IqPm50dqHGHM0OgD1ueenvEIYGMaec4oLkMVU204xnpQYeB/IchlB 8yMaovu7TIEICZbra5QpyciYulolSECk5F23M/dyALpzduAJ8dmqkVpqropNDLWu3IZ3 r3PNkwSgQBu0cvA3pBG6x2syHM5souSmM3Q0HRoZHdhTk1WkxqqiE4z72fqQgrTr3Q8W iIlcZQ6AdeKHuLduVmv3Yg8byQ5YDsU21DzpVhnoGlPGxIMLL0YLtnjXjiIXpDu8oYew GLkMnBojoY7qlf4aFG1oyoAakG1otXtuTHlEFj4CVIYckUkbgKJj4jRzrGHqXw6HNaHK j6Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6U3SqChqW36OJaTxQrWyg7Ew6SaBHbgZbxiF3lESZ10=; b=JRP+ANMnzBICJzh0PtH4SuxoSfvE7Z+G0xx0JY8LVu782cPq8SjQsv6gU/++SCE7ob IkYQ6ehYxlvXyADm/K6CgL9eConemaHlxVyDR1or/5DPr63SNSv/dECu7pkD7EvpIBhv eH9IzmlqhhjOB2yDga6SyK2QtpuwNoYCvheuQdirbxDtNAS3m+AyGVjkyHSDeSpwM1ZB Zcf3AX1fw3WgtzXMW1sihbUbYuC2Cbt9VTt7unAxws+uc+MbKx+Ff6yDqQ/ORCri0UmI 4q+bCUgCiIhcZTnivMJJDCrdTGb07he1RPLlcbfiySWzQbz4AL+BoPbl0sq9v1y2vUCQ fy6g== X-Gm-Message-State: AGRZ1gLHmsqhf35v6GGJzrG5reyxWRHQcxl00yv/JH7fAdtRTIG+31US rZXTBXIZpO3hQUK/c0vEaQFeKRC+3pg= X-Google-Smtp-Source: AJdET5eikm6ikkI3UsBq93VGp8gt2PQQAwc4xJ7i6G59F1ZwyMSr0z5oRi0hm9PrGqruO1ID1TdVug== X-Received: by 2002:a63:f844:: with SMTP id v4mr18048284pgj.82.1542588849754; Sun, 18 Nov 2018 16:54:09 -0800 (PST) Received: from cascade.Home (97-113-254-72.tukw.qwest.net. [97.113.254.72]) by smtp.gmail.com with ESMTPSA id f13sm13523773pfa.132.2018.11.18.16.54.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Nov 2018 16:54:09 -0800 (PST) From: Martin Kelly X-Google-Original-From: Martin Kelly , Jonathan Cameron , Martin Kelly Subject: [PATCH 2/2] iio: bmi160: use all devm functions in probe Date: Sun, 18 Nov 2018 16:53:47 -0800 Message-Id: <20181119005347.747-2-martin@martingkelly.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181119005347.747-1-martin@martingkelly.com> References: <20181119005347.747-1-martin@martingkelly.com> Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Martin Kelly Currently, we're using the devm version of some but not all functions. Switch to the devm version of iio_triggered_buffer_setup and iio_device_register to simplify the code a bit and decrease the chance of bugs. Signed-off-by: Martin Kelly Acked-by: Daniel Baluta --- drivers/iio/imu/bmi160/bmi160_core.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c index 4d9d59d9e3a9..5e4efaed5e88 100644 --- a/drivers/iio/imu/bmi160/bmi160_core.c +++ b/drivers/iio/imu/bmi160/bmi160_core.c @@ -577,18 +577,16 @@ int bmi160_core_probe(struct device *dev, struct regmap *regmap, indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &bmi160_info; - ret = iio_triggered_buffer_setup(indio_dev, NULL, - bmi160_trigger_handler, NULL); + ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL, + bmi160_trigger_handler, NULL); if (ret < 0) goto uninit; - ret = iio_device_register(indio_dev); + ret = devm_iio_device_register(dev, indio_dev); if (ret < 0) - goto buffer_cleanup; + goto uninit; return 0; -buffer_cleanup: - iio_triggered_buffer_cleanup(indio_dev); uninit: bmi160_chip_uninit(data); return ret; @@ -600,8 +598,6 @@ void bmi160_core_remove(struct device *dev) struct iio_dev *indio_dev = dev_get_drvdata(dev); struct bmi160_data *data = iio_priv(indio_dev); - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); bmi160_chip_uninit(data); } EXPORT_SYMBOL_GPL(bmi160_core_remove);