Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3132860ybi; Thu, 18 Jul 2019 21:40:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwp3o8TQXuPNepZju0VCBc6GL9EfFH8eyANZLvMoCFHge9eg62gY/+59kVtdrEh72HklXXn X-Received: by 2002:a63:2cd5:: with SMTP id s204mr38482304pgs.95.1563511225415; Thu, 18 Jul 2019 21:40:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511225; cv=none; d=google.com; s=arc-20160816; b=zmawrVZrGSJwQ1zz5Qj4XDceGjQdlQIBq78ukcs5slTTQXotCqndIGW2oBvC1NjQ1M Ey6TaEp3+sfbDqYsbGWbrFGXq0KJXndNFeHWT0y/Vrxd1B+fjNuRpOfS9O5dR/EcHwEY V9xUuiNBqsZUmnSvdi0tI3WEcrFHjUDTG95X73erdS+1/Zuc8CMEHIjnZXo2SI0TCO48 LgvHRfD/XfN8kGMej3t3m787jXlN5zbTYeb9ygTBDWi/SjudiG5G3Bn3J5Qcld86657u 1U+MbMM/B9sFKyAHyTZRYunSLRY10e++6UBydHZ1kMerSsn/OcI0sHfQjJRC/AcnxerP ug4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HFnKh8wSMunfmwAYETptAmV3z1uxcYmoZ/SCQW8qlVU=; b=i1oSO47hLlxlOpofqhizpODaZPwoLf2zz+f+OVEmQWxgxyPKq+rtLs0K+IbqpfNWKd FJxwGftJbIR0irirrL5q2gMqyOF7ktuidQssszjbBpehD1LaMh+Vi3WyGvdn1KUSHBaS 9QT/iKOOgGGWUaoFp8Nk6QMnWySEqApjkv+s/okIe81I9N0VL9guYifT9vTuM2MHYFXo 6QqKgfhzf+ps/9tUUNBp4cHaAGa09BdRhn+NTZAVQPX0CCiZtZgLG6nVezgZ/8O+HgHS VdCi3xHlZjY9HZYJzPVWeFpG0EXrgJAAnSHO66wwag58CvzpVISjslm04XwMXJ2528uS 9AeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yh6hcVIF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 186si640548pgc.248.2019.07.18.21.40.10; Thu, 18 Jul 2019 21:40:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yh6hcVIF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727279AbfGSEjH (ORCPT + 99 others); Fri, 19 Jul 2019 00:39:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:58548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728452AbfGSD7F (ORCPT ); Thu, 18 Jul 2019 23:59:05 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E952A21850; Fri, 19 Jul 2019 03:59:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508744; bh=QeqbiBHLeOYnomZOPhjCcLO0gyl5URbYFXDGeDoVHTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yh6hcVIF40otaGE538bJM62KAWrO2i0NqUl2Hu8soVbS3m9ZELnFeiwtExxKaMLCF RPaF5ZcCph/6zF6lOzGS61d7tmwlwIPjWKek0cLDxokkznyOaMEbO6FdEx81JaU7cw Aoa51N7tvQhlfehDMWb+ceDqvMijUlTPBwGn1OaY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alexandru Ardelean , Jonathan Cameron , Sasha Levin , linux-iio@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 065/171] iio: adxl372: fix iio_triggered_buffer_{pre,post}enable positions Date: Thu, 18 Jul 2019 23:54:56 -0400 Message-Id: <20190719035643.14300-65-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexandru Ardelean [ Upstream commit 0e4f0b42f42d88507b48282c8915f502551534e4 ] The iio_triggered_buffer_{predisable,postenable} functions attach/detach the poll functions. For the predisable hook, the disable code should occur before detaching the poll func, and for the postenable hook, the poll func should be attached before the enable code. Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/accel/adxl372.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c index 3b84cb243a87..055227cb3d43 100644 --- a/drivers/iio/accel/adxl372.c +++ b/drivers/iio/accel/adxl372.c @@ -782,10 +782,14 @@ static int adxl372_buffer_postenable(struct iio_dev *indio_dev) unsigned int mask; int i, ret; - ret = adxl372_set_interrupts(st, ADXL372_INT1_MAP_FIFO_FULL_MSK, 0); + ret = iio_triggered_buffer_postenable(indio_dev); if (ret < 0) return ret; + ret = adxl372_set_interrupts(st, ADXL372_INT1_MAP_FIFO_FULL_MSK, 0); + if (ret < 0) + goto err; + mask = *indio_dev->active_scan_mask; for (i = 0; i < ARRAY_SIZE(adxl372_axis_lookup_table); i++) { @@ -793,8 +797,10 @@ static int adxl372_buffer_postenable(struct iio_dev *indio_dev) break; } - if (i == ARRAY_SIZE(adxl372_axis_lookup_table)) - return -EINVAL; + if (i == ARRAY_SIZE(adxl372_axis_lookup_table)) { + ret = -EINVAL; + goto err; + } st->fifo_format = adxl372_axis_lookup_table[i].fifo_format; st->fifo_set_size = bitmap_weight(indio_dev->active_scan_mask, @@ -814,26 +820,25 @@ static int adxl372_buffer_postenable(struct iio_dev *indio_dev) if (ret < 0) { st->fifo_mode = ADXL372_FIFO_BYPASSED; adxl372_set_interrupts(st, 0, 0); - return ret; + goto err; } - return iio_triggered_buffer_postenable(indio_dev); + return 0; + +err: + iio_triggered_buffer_predisable(indio_dev); + return ret; } static int adxl372_buffer_predisable(struct iio_dev *indio_dev) { struct adxl372_state *st = iio_priv(indio_dev); - int ret; - - ret = iio_triggered_buffer_predisable(indio_dev); - if (ret < 0) - return ret; adxl372_set_interrupts(st, 0, 0); st->fifo_mode = ADXL372_FIFO_BYPASSED; adxl372_configure_fifo(st); - return 0; + return iio_triggered_buffer_predisable(indio_dev); } static const struct iio_buffer_setup_ops adxl372_buffer_ops = { -- 2.20.1