Message ID | 20200921162033.840827318@linuxfoundation.org |
---|---|
State | Superseded |
Headers | show
Return-Path: <SRS0=lyed=C6=vger.kernel.org=stable-owner@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 091A7C43468 for <stable@archiver.kernel.org>; Mon, 21 Sep 2020 17:06:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B48A02073A for <stable@archiver.kernel.org>; Mon, 21 Sep 2020 17:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600707965; bh=D6ioDQNlnawCrx2GcOF/N/wwukoyQL0N+drj/kH08Bs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=W2dm/vsiWBMH7LNhjyM3/S2OlzdeXsmVWdhaMulZsmIY9Osd95J1fYv29jUobOm04 FCcyB7eyFwMYsxycC159t4ACnLFLS7+3HA1RJqBOV5xjeJC/wDVE/fc0YforrlL9xF H05vXnIB3rNr6HWRSXmA//liKeOJGaKUYZAZ9H9c= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728564AbgIUQdE (ORCPT <rfc822;stable@archiver.kernel.org>); Mon, 21 Sep 2020 12:33:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:58924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728561AbgIUQdB (ORCPT <rfc822;stable@vger.kernel.org>); Mon, 21 Sep 2020 12:33:01 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AB110239D0; Mon, 21 Sep 2020 16:33:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600705981; bh=D6ioDQNlnawCrx2GcOF/N/wwukoyQL0N+drj/kH08Bs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V+aCAq4unyKq4VxOjFi39ixKmidyfib1zM3Yhfvzx0UkylNzLfSATiTkE0U/dcOQA aWQoIm4cMUeP4yrgf5fZFNhhESYcjgpBuqc9gNmA/ANThLRpYsXtj5Lpk5v5c3YsNX Gzp3kNcs6N5s6v5zDFRQz85NmMgqqr2QCj3dTHBQ= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org, Angelo Compagnucci <angelo.compagnucci@gmail.com>, Stable@vger.kernel.org, Jonathan Cameron <Jonathan.Cameron@huawei.com> Subject: [PATCH 4.4 10/46] iio: adc: mcp3422: fix locking scope Date: Mon, 21 Sep 2020 18:27:26 +0200 Message-Id: <20200921162033.840827318@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162033.346434578@linuxfoundation.org> References: <20200921162033.346434578@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: <stable.vger.kernel.org> X-Mailing-List: stable@vger.kernel.org |
Series |
None
|
expand
|
--- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c @@ -98,16 +98,12 @@ static int mcp3422_update_config(struct { int ret; - mutex_lock(&adc->lock); - ret = i2c_master_send(adc->i2c, &newconfig, 1); if (ret > 0) { adc->config = newconfig; ret = 0; } - mutex_unlock(&adc->lock); - return ret; } @@ -140,6 +136,8 @@ static int mcp3422_read_channel(struct m u8 config; u8 req_channel = channel->channel; + mutex_lock(&adc->lock); + if (req_channel != MCP3422_CHANNEL(adc->config)) { config = adc->config; config &= ~MCP3422_CHANNEL_MASK; @@ -152,7 +150,11 @@ static int mcp3422_read_channel(struct m msleep(mcp3422_read_times[MCP3422_SAMPLE_RATE(adc->config)]); } - return mcp3422_read(adc, value, &config); + ret = mcp3422_read(adc, value, &config); + + mutex_unlock(&adc->lock); + + return ret; } static int mcp3422_read_raw(struct iio_dev *iio,