Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp885840pxu; Mon, 23 Nov 2020 06:37:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyT6QY+kwRMhXQVYENNMK4McI14hkX3feZcwgp1uwAHi0qFIxNAhnYuw9JL+TFOaetKfsFd X-Received: by 2002:aa7:ce82:: with SMTP id y2mr48275156edv.6.1606142274526; Mon, 23 Nov 2020 06:37:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606142274; cv=none; d=google.com; s=arc-20160816; b=zNra9AAJppn3TqMtBxp2S9DTxm0gYhXG7eviIKEXkKgWoOGStH5vD2Igfgo/0ytysD WrdVifTaKqBqOd7vau2gMYNPcZp6+rK41xMvmN9TsshBpmwOWzE6Jy74fcnCPTULT5Tk USNKjuzrn0ujmE74WyHcGCXPTR0U3h7ZKLAiCvABPSJKzWDbmMJd0CKoXmqPD1MV/YMV 9D4lUX5KDB722tAhYRzFzqhkhetXB0fWxN4m5LpNgjai7RZzctCyOXZAwpvG05m2TPwX N9LRjousOxlcQ6K8idx+YXZ99IMmTCfh69QMVstIIqvIEbD1m6zxciRcCU/w4p2ePIuo wigw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=iIKfm/NW0yP9KoW7TL4f/BBlhT0bk6zqzMopyqaRubY=; b=NOgC1ndwpD/xKMtPCmmqnTo1MpCu9cWwMVfzrhuh17c2t4PJMP/Y0M0calYDo9e+qX GKBANLWV9GIuofh42oeBMBUmQKpdCzdzZCwN69SzNabOTW993+qNZHSh+LCQ44sYcfgi PeLydWSQlvOOC3fByxGYkhZalMh9sai+RfKjQN4y8Ib++qE+X4JcX+J0i84g2HNV22Ga wIuM0z5ys2ga8Eq03DFo/iw8DHWxCZLkbHYFshZ9edYI/Uauyj4QQfjyWlWhgUJFguRk ZH1HDC4bRronU91aUuBH1CSOJGJ74Nb5EX9+xZByoRTYUzYIrRMCGUut67QJ7D7RDoeA xAug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m7si3673501edv.566.2020.11.23.06.37.29; Mon, 23 Nov 2020 06:37:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=analog.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388906AbgKWOfW (ORCPT + 99 others); Mon, 23 Nov 2020 09:35:22 -0500 Received: from mx0a-00128a01.pphosted.com ([148.163.135.77]:17504 "EHLO mx0a-00128a01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733292AbgKWOfW (ORCPT ); Mon, 23 Nov 2020 09:35:22 -0500 Received: from pps.filterd (m0167089.ppops.net [127.0.0.1]) by mx0a-00128a01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0ANEQIm7022742; Mon, 23 Nov 2020 09:35:18 -0500 Received: from nwd2mta4.analog.com ([137.71.173.58]) by mx0a-00128a01.pphosted.com with ESMTP id 34y0p8514y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Nov 2020 09:35:17 -0500 Received: from SCSQMBX10.ad.analog.com (SCSQMBX10.ad.analog.com [10.77.17.5]) by nwd2mta4.analog.com (8.14.7/8.14.7) with ESMTP id 0ANEZG7h049467 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=FAIL); Mon, 23 Nov 2020 09:35:16 -0500 Received: from SCSQMBX11.ad.analog.com (10.77.17.10) by SCSQMBX10.ad.analog.com (10.77.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Mon, 23 Nov 2020 06:35:14 -0800 Received: from zeus.spd.analog.com (10.66.68.11) by SCSQMBX11.ad.analog.com (10.77.17.10) with Microsoft SMTP Server id 15.1.1779.2 via Frontend Transport; Mon, 23 Nov 2020 06:35:14 -0800 Received: from localhost.localdomain ([10.48.65.12]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id 0ANEZAqO024147; Mon, 23 Nov 2020 09:35:12 -0500 From: Alexandru Ardelean To: , CC: , , , , , Alexandru Ardelean Subject: [PATCH 2/2] iio: cros_ec: un-indent block that configures motion sensor fifo Date: Mon, 23 Nov 2020 16:40:17 +0200 Message-ID: <20201123144017.18311-2-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201123144017.18311-1-alexandru.ardelean@analog.com> References: <20201123144017.18311-1-alexandru.ardelean@analog.com> MIME-Version: 1.0 Content-Type: text/plain X-ADIRuleOP-NewSCL: Rule Triggered X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312,18.0.737 definitions=2020-11-23_11:2020-11-23,2020-11-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 adultscore=0 mlxscore=0 malwarescore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011230099 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change also reverses the condition of the FIFO setup. If the feature setup does not include a EC_FEATURE_MOTION_SENSE_FIFO flag, then the IIO triggered buffer setup is done and first and early exit is performed. It'a done like this because the code block (for the IIO triggered buffer setup) is smaller. The code block for the EC_FEATURE_MOTION_SENSE_FIFO flag has been un-indented. Signed-off-by: Alexandru Ardelean --- .../cros_ec_sensors/cros_ec_sensors_core.c | 63 +++++++++---------- 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c index 9470014936f2..921eccd4f6a6 100644 --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c @@ -258,6 +258,7 @@ int cros_ec_sensors_core_init(struct platform_device *pdev, struct cros_ec_sensor_platform *sensor_platform = dev_get_platdata(dev); u32 ver_mask; int frequencies[ARRAY_SIZE(state->frequencies) / 2] = { 0 }; + struct iio_buffer *buffer; int ret, i; platform_set_drvdata(pdev, indio_dev); @@ -324,37 +325,7 @@ int cros_ec_sensors_core_init(struct platform_device *pdev, (frequencies[i] % 1000) * 1000; } - if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE_FIFO)) { - /* - * Create a software buffer, feed by the EC FIFO. - * We can not use trigger here, as events are generated - * as soon as sample_frequency is set. - */ - struct iio_buffer *buffer; - - buffer = devm_iio_kfifo_allocate(dev); - if (!buffer) - return -ENOMEM; - - iio_device_attach_buffer(indio_dev, buffer); - indio_dev->modes = INDIO_BUFFER_SOFTWARE; - - ret = cros_ec_sensorhub_register_push_data( - sensor_hub, sensor_platform->sensor_num, - indio_dev, push_data); - if (ret) - return ret; - - ret = devm_add_action_or_reset( - dev, cros_ec_sensors_core_clean, pdev); - if (ret) - return ret; - - /* Timestamp coming from FIFO are in ns since boot. */ - ret = iio_device_set_clock(indio_dev, CLOCK_BOOTTIME); - if (ret) - return ret; - } else { + if (!cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE_FIFO)) { const struct attribute **fifo_attrs; if (has_hw_fifo) @@ -366,14 +337,36 @@ int cros_ec_sensors_core_init(struct platform_device *pdev, * The only way to get samples in buffer is to set a * software trigger (systrig, hrtimer). */ - ret = devm_iio_triggered_buffer_setup_ext( + return devm_iio_triggered_buffer_setup_ext( dev, indio_dev, NULL, trigger_capture, NULL, fifo_attrs); - if (ret) - return ret; } - return 0; + /* + * Create a software buffer, feed by the EC FIFO. + * We can not use trigger here, as events are generated + * as soon as sample_frequency is set. + */ + buffer = devm_iio_kfifo_allocate(dev); + if (!buffer) + return -ENOMEM; + + iio_device_attach_buffer(indio_dev, buffer); + indio_dev->modes = INDIO_BUFFER_SOFTWARE; + + ret = cros_ec_sensorhub_register_push_data( + sensor_hub, sensor_platform->sensor_num, + indio_dev, push_data); + if (ret) + return ret; + + ret = devm_add_action_or_reset( + dev, cros_ec_sensors_core_clean, pdev); + if (ret) + return ret; + + /* Timestamp coming from FIFO are in ns since boot. */ + return iio_device_set_clock(indio_dev, CLOCK_BOOTTIME); } EXPORT_SYMBOL_GPL(cros_ec_sensors_core_init); -- 2.17.1