Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3131920ybi; Thu, 18 Jul 2019 21:39:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqz5t4bjnuzG7C//6KFuxEQ1DjmXIv1E0m3E+/rzXExdCHKxApNy7o858uJkAHritlwpgry+ X-Received: by 2002:a17:902:788e:: with SMTP id q14mr54948649pll.234.1563511152876; Thu, 18 Jul 2019 21:39:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511152; cv=none; d=google.com; s=arc-20160816; b=Gy1jela/5DSIsSpbsB31fPJlovH2BU6aCJG4Z2pMPwbBqJSLBlgFPVFFIBwmK3J4T2 /Zj5J6q9nfz1I0XfhOg1dKcaaiJHR5COCZh+4MHG5dZ3I0Cu1Q9uSTSEYkoQ1tU21W+8 Fbj1ZVJGYCqKWXHdOETChnHBvua7LAhTF9/dmYYRbHp5wbb4nCvLE/yMnfPRSqaxtCzf vzaO3sHncDxUpOtIh+6Tw8LjP1bWdnW/JX8P5eXQWrCD/RJU9gBzCy7t5CdAsf+7DOF8 5D1bNu7hgcwaPrpyRVJ21iAHy8klaLu3E94IHRWmSI2J2NSzyRLlRpiCXddw0L2wuUfQ ulbg== 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=05F3aq2TARylgtnrp6fkZICzRwTi7QLL3RzF7AWPJLQ=; b=bFpLaZAGb1p6pkwDpZsPkSA4hBdvick4sF+0VveoqYMRGNarFBq5WcrTVKcQMY4rjH Yde2WuaALAoRNWoeZ0Z7vMUMYmH67hFcsUlOb31HjiJyIxOJKlTeQZE5gQHA8B91Rnf0 CWQ53ecdPju0Y4xbPX2Zq9f3jEMkqhimlTCGKgOrGNPc+aK2AvzuAm8k+y1FmK+RFzqp OgxLgs8kxU6CMaNCD+Yb//bWhVk7cZgoleROWnb5UC1NT1VjJve5qAj1QXElrgBdEdRZ /WvpunOiSuiv/6GJY0VvEBHDyTMqeIMjtApDV65r3UodhqKC8CrMl0h6T1Ed1gfBmBdW b/aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="2a/LfTbc"; 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 z23si4588711pgi.116.2019.07.18.21.38.57; Thu, 18 Jul 2019 21:39:12 -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="2a/LfTbc"; 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 S2389356AbfGSEhy (ORCPT + 99 others); Fri, 19 Jul 2019 00:37:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:59294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728795AbfGSD7i (ORCPT ); Thu, 18 Jul 2019 23:59:38 -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 6CA162189F; Fri, 19 Jul 2019 03:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508777; bh=9f1wajjvi5fzOiQPCP16sLyUiNuP4qgvjsgcriCP8us=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2a/LfTbcb12rrIGe+d3zYnH+a+BKUGKzQwX8Z+4IGIi4PPCEDQwjYK3JtzToMiva/ xzbRwunUyOkQx7bXUPSrkg6rkp9dnjAKAd9/+HcYd9XTYtg6l1754rF1CDPgAqxdGu r/fwfIoxmIGspwggS7Nnmm8LILssyv8fpN+0nzTg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alexandru Ardelean , Denis Ciocca , Jonathan Cameron , Sasha Levin , linux-iio@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 084/171] iio: st_accel: fix iio_triggered_buffer_{pre,post}enable positions Date: Thu, 18 Jul 2019 23:55:15 -0400 Message-Id: <20190719035643.14300-84-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 05b8bcc96278c9ef927a6f25a98e233e55de42e1 ] 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 Acked-by: Denis Ciocca Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/accel/st_accel_buffer.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/iio/accel/st_accel_buffer.c b/drivers/iio/accel/st_accel_buffer.c index 54f2ae91f614..0205c0167cdd 100644 --- a/drivers/iio/accel/st_accel_buffer.c +++ b/drivers/iio/accel/st_accel_buffer.c @@ -45,17 +45,19 @@ static int st_accel_buffer_postenable(struct iio_dev *indio_dev) goto allocate_memory_error; } - err = st_sensors_set_axis_enable(indio_dev, - (u8)indio_dev->active_scan_mask[0]); + err = iio_triggered_buffer_postenable(indio_dev); if (err < 0) goto st_accel_buffer_postenable_error; - err = iio_triggered_buffer_postenable(indio_dev); + err = st_sensors_set_axis_enable(indio_dev, + (u8)indio_dev->active_scan_mask[0]); if (err < 0) - goto st_accel_buffer_postenable_error; + goto st_sensors_set_axis_enable_error; return err; +st_sensors_set_axis_enable_error: + iio_triggered_buffer_predisable(indio_dev); st_accel_buffer_postenable_error: kfree(adata->buffer_data); allocate_memory_error: @@ -64,20 +66,22 @@ static int st_accel_buffer_postenable(struct iio_dev *indio_dev) static int st_accel_buffer_predisable(struct iio_dev *indio_dev) { - int err; + int err, err2; struct st_sensor_data *adata = iio_priv(indio_dev); - err = iio_triggered_buffer_predisable(indio_dev); - if (err < 0) - goto st_accel_buffer_predisable_error; - err = st_sensors_set_axis_enable(indio_dev, ST_SENSORS_ENABLE_ALL_AXIS); if (err < 0) goto st_accel_buffer_predisable_error; err = st_sensors_set_enable(indio_dev, false); + if (err < 0) + goto st_accel_buffer_predisable_error; st_accel_buffer_predisable_error: + err2 = iio_triggered_buffer_predisable(indio_dev); + if (!err) + err = err2; + kfree(adata->buffer_data); return err; } -- 2.20.1