Received: by 10.223.164.202 with SMTP id h10csp189881wrb; Mon, 13 Nov 2017 05:01:54 -0800 (PST) X-Google-Smtp-Source: AGs4zMb7ad0/Ty3I7GoupgB9QZr2GUei1l8WXqKQvzWbnxp6EDPUVTxSqVHn6WntZv/PlqNfYGmc X-Received: by 10.99.3.88 with SMTP id 85mr8745916pgd.111.1510578114455; Mon, 13 Nov 2017 05:01:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510578114; cv=none; d=google.com; s=arc-20160816; b=n4W0A1ACIbXsXSCXAumShjk4j4aNpZJm2JS1WYt5yBNQ1YfwhV3rmilyN2kNOclmn6 bjtf2JO7kOvPeS+4vXQ2vNerI99RYnoyyuSlmjDnUwSTLNuK0PL3++mttTb3EI5BtD4C NNdYszXZCB2fG+kqfdRU/BGmmurtfHJk9L/FdA+4qNn5IUIKcUsJoX4G0BSSbhGBgSfU POx3ZVL5ueDjRUr7n5o6JHMTweFPHoiBihTILgELcyQLKuSPAHyuIBxaPbCZF4v+CJOz 6N3PKwblM3a6vFbJ04SFBrDMUyzLXXq1UOxaWalvbVcSnbdePLXeue26qsmsL+knEtKC Y0YQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=sqgxhs4G5xbvuEoBlArBP74zhkCKizDCF/qzhTmO91c=; b=j5bbu0ZFFOvW+d4fRZebKbFrtvhcBEKSqMp+OUxwkoWyC2Sm+BuEmbtXB/0RBzncwl 2RkeIqM4C8XyAy3W6n2VNFfLmMTX5K48jf0CFbs1bkGqpi46UBRdgBJqPqCE3im5FYTB 4JErkFQ3kUDkS1ljYdw7MlIybZ8I7BMASWLtCRRlLMn3m/CIctwg9AjpUiUMtMxEk3+a xZsHygITgXmz0CkfLue/Tf4P+6tbtx7gJrdfPfpB2Cb3PgisXUbyoCExS/YO+w2R0krz YJ4LAgvsCdDpbCoidKfx8FPeXcL7+shXr1MU6qgG6ubTCz45JeQowMF3yg01DnDe+WJz tljA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u4si15359675pfd.201.2017.11.13.05.01.41; Mon, 13 Nov 2017 05:01:54 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753559AbdKMNAA (ORCPT + 95 others); Mon, 13 Nov 2017 08:00:00 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:49856 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754151AbdKMM75 (ORCPT ); Mon, 13 Nov 2017 07:59:57 -0500 Received: from localhost (LFbn-1-12253-150.w90-92.abo.wanadoo.fr [90.92.67.150]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id DB330A95; Mon, 13 Nov 2017 12:59:56 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alison Schofield , Jonathan Cameron , Sasha Levin Subject: [PATCH 4.9 22/87] iio: pressure: ms5611: claim direct mode during oversampling changes Date: Mon, 13 Nov 2017 13:55:39 +0100 Message-Id: <20171113125617.423505106@linuxfoundation.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171113125615.304035578@linuxfoundation.org> References: <20171113125615.304035578@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alison Schofield [ Upstream commit 3bc1abcddb24f55b9c251e03caa4f9bd22ff748b ] Driver was checking for direct mode before changing oversampling ratios, but was not locking it. Use the claim/release helper functions to guarantee the device stays in direct mode while the oversampling ratios are being updated. Continue to use the drivers private state lock to protect against conflicting direct mode access of the state data. Signed-off-by: Alison Schofield Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/iio/pressure/ms5611_core.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) --- a/drivers/iio/pressure/ms5611_core.c +++ b/drivers/iio/pressure/ms5611_core.c @@ -308,6 +308,7 @@ static int ms5611_write_raw(struct iio_d { struct ms5611_state *st = iio_priv(indio_dev); const struct ms5611_osr *osr = NULL; + int ret; if (mask != IIO_CHAN_INFO_OVERSAMPLING_RATIO) return -EINVAL; @@ -321,12 +322,11 @@ static int ms5611_write_raw(struct iio_d if (!osr) return -EINVAL; - mutex_lock(&st->lock); + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; - if (iio_buffer_enabled(indio_dev)) { - mutex_unlock(&st->lock); - return -EBUSY; - } + mutex_lock(&st->lock); if (chan->type == IIO_TEMP) st->temp_osr = osr; @@ -334,6 +334,8 @@ static int ms5611_write_raw(struct iio_d st->pressure_osr = osr; mutex_unlock(&st->lock); + iio_device_release_direct_mode(indio_dev); + return 0; } From 1584578516048538794@xxx Mon Nov 20 09:57:13 +0000 2017 X-GM-THRID: 1584578516048538794 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread