Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp929285ybt; Wed, 17 Jun 2020 18:10:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZVUHl1gzKMLLLskl62c6XQWk+brFxOpVG0mBSYzl0ZGL7miICOW4VWT2SEr2tuFJZtGrD X-Received: by 2002:aa7:c2c7:: with SMTP id m7mr1779499edp.148.1592442636456; Wed, 17 Jun 2020 18:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592442636; cv=none; d=google.com; s=arc-20160816; b=RujqeF1sBEUWTfe7uPAkYo3V7d8kB6zp/YywvUxt3X9z9bby6aqAWVdeiyS4vlvpkn yg7/nAxUc5q3MyscM5thdFlyQ4XtOdMVIcANk86ucuRtvHU2Rl0biUBqvGX5K/5SvnSO 0htxQhhfb0p0aMMLIdhnGjzcsxWHrzTp2etyyPVOLWXEwsksihncSzg1LNyvldmV6Bfg WTMQ6/iZFfX8xy02EoDihqLxL9Z3L2J9g1TA3g+30q2M/lt/6CPZVbsaaGPEyAt+PJ3I eSEHECHxvoTZI4rDIBE3J8751V6Dd9BFXxoihYpWLSidwsk+yN+injL6n0ZWkriaGIOc U4GQ== 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=6FPLqlxLXECxYygyTSrMTBGa5/jL1MSwNNWu1m/nCMQ=; b=PGlvCNpGw/BPwtAQ/nDLKjFahp52DYbd1DWcHZn6bVJcewfBv/r9gMz5zq6t3FIxDs eTSlHcMiwnLdjqvc5DXUGJgzrP03wbuOJM4Qzd1jsWuA/1ooScoG3GB/IrvsDC5rKZyn y39yt1yhNYb4vkK6q8cSVaUdJq81rex8x2nCGjF/HeFFtUsblsQpcuYdOoec7vUNO+UO vO5xUEX0ZyodleZTwJLPBV+PCrX8FcWnz7AkcIxFMYQ6lljT7jOr0FH9zj0hhKgVOA9E BXDdNSXpIKMC7CpCm+hPYGWrevq9qeQZ54wmVhe5drjvB2nyqTfsvu9M//+4wnkaY4Dw 22Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=J+HEWI6A; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c15si958764eja.376.2020.06.17.18.10.13; Wed, 17 Jun 2020 18:10:36 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=J+HEWI6A; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727769AbgFRBIT (ORCPT + 99 others); Wed, 17 Jun 2020 21:08:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:33822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727112AbgFRBIS (ORCPT ); Wed, 17 Jun 2020 21:08:18 -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 0A83921D6C; Thu, 18 Jun 2020 01:08:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592442497; bh=uq/vJ5FGrTpOVRKK3JW4bg+gc1FHs5ImLSPzkZZ8Tqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J+HEWI6Apo7cwq5Tj1d8qqRQ7drZ2y7GHgxvE+0RvMPjoQvC4Ur5HwYwl0XV0oOnd YW5c40zfWLNwG3yH7445SNhWfLRmq+1O/PmhGVMHI61bQ63Sleb4wzGMmqvUS8QgKK YE57Gh+TNfFWvi56w8GPI/voivoenUI44dmtQuQ8= 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.7 009/388] iio: light: isl29125: fix iio_triggered_buffer_{predisable,postenable} positions Date: Wed, 17 Jun 2020 21:01:46 -0400 Message-Id: <20200618010805.600873-9-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200618010805.600873-1-sashal@kernel.org> References: <20200618010805.600873-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 9b7a12c3e090cf3fba6f66f1f23abbc6e0e86021 ] 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. This change reworks the predisable/postenable hooks so that the pollfunc is attached/detached in the correct position. It also balances the calls a bit, by grouping the preenable and the iio_triggered_buffer_postenable() into a single isl29125_buffer_postenable() function. Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- drivers/iio/light/isl29125.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/iio/light/isl29125.c b/drivers/iio/light/isl29125.c index e37894f0ae0b..95611f5eff01 100644 --- a/drivers/iio/light/isl29125.c +++ b/drivers/iio/light/isl29125.c @@ -213,13 +213,24 @@ static const struct iio_info isl29125_info = { .attrs = &isl29125_attribute_group, }; -static int isl29125_buffer_preenable(struct iio_dev *indio_dev) +static int isl29125_buffer_postenable(struct iio_dev *indio_dev) { struct isl29125_data *data = iio_priv(indio_dev); + int err; + + err = iio_triggered_buffer_postenable(indio_dev); + if (err) + return err; data->conf1 |= ISL29125_MODE_RGB; - return i2c_smbus_write_byte_data(data->client, ISL29125_CONF1, + err = i2c_smbus_write_byte_data(data->client, ISL29125_CONF1, data->conf1); + if (err) { + iio_triggered_buffer_predisable(indio_dev); + return err; + } + + return 0; } static int isl29125_buffer_predisable(struct iio_dev *indio_dev) @@ -227,19 +238,18 @@ static int isl29125_buffer_predisable(struct iio_dev *indio_dev) struct isl29125_data *data = iio_priv(indio_dev); int ret; - ret = iio_triggered_buffer_predisable(indio_dev); - if (ret < 0) - return ret; - data->conf1 &= ~ISL29125_MODE_MASK; data->conf1 |= ISL29125_MODE_PD; - return i2c_smbus_write_byte_data(data->client, ISL29125_CONF1, + ret = i2c_smbus_write_byte_data(data->client, ISL29125_CONF1, data->conf1); + + iio_triggered_buffer_predisable(indio_dev); + + return ret; } static const struct iio_buffer_setup_ops isl29125_buffer_setup_ops = { - .preenable = isl29125_buffer_preenable, - .postenable = &iio_triggered_buffer_postenable, + .postenable = isl29125_buffer_postenable, .predisable = isl29125_buffer_predisable, }; -- 2.25.1