From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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=-8.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham 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 EC456C3E8AB for ; Sat, 5 Oct 2019 14:38:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B72CC222CC for ; Sat, 5 Oct 2019 14:38:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570286330; bh=qiZsyD7M06mWHJzrVw5CHi8/pa+0MBMq6luev7E2x30=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=zyVSJdoHr6qAmNkMRDzQsdRVpI+cVLfEu2F+l2jwTXR/yUxCMdC/iynr1BPGmqrV3 gLgh7GSHqkFhm9qcpbg8Z5cA+svy2PIYeByGF1gFCGEevNYt2S0Gs5RM88ZMSjV1E5 vaEzBm6nH8qItB3YnSYj3vzom69hJQwOl1Q5pEJ8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728597AbfJEOiu (ORCPT ); Sat, 5 Oct 2019 10:38:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:42996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726167AbfJEOiu (ORCPT ); Sat, 5 Oct 2019 10:38:50 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (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 91C6D222C8; Sat, 5 Oct 2019 14:38:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570286329; bh=qiZsyD7M06mWHJzrVw5CHi8/pa+0MBMq6luev7E2x30=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=oF0AhvgudpDL67zXFVn3EDEdIIdQvKbBvbB5xshwFmfUBxCNJixEaIL70sOC6DttG NuGC8scTY8vajiIGin0C/SWThooVpM+NX3Xsnw8PYPj0By4Wc9HLCURGWyekaoLJVW Td2djJr04lmlALN8aiMy636e5giN4TsyQ91ixrZI= Date: Sat, 5 Oct 2019 15:38:45 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: Subject: Re: [PATCH] iio: gyro: adis16260: remove indio_dev mlock Message-ID: <20191005153837.25e5be57@archlinux> In-Reply-To: <20190919115716.25909-1-alexandru.ardelean@analog.com> References: <20190919115716.25909-1-alexandru.ardelean@analog.com> X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Thu, 19 Sep 2019 14:57:16 +0300 Alexandru Ardelean wrote: > The internal lock that is by the ADIS library should be sufficient to keep > state consistent. There is no need for an extra lock. I'm not sure that's true. In theory we could get two different attempts to set the sampling frequency running concurrently. That could lead to a race between the point where we set the spi frequency for future messages and the point where we set the devices sampling frequency. Bang it stops working. So, whilst it is arguably paranoid I think you do need a lock here, but it should be something that is driver local rather than mlock. thanks, Jonathan > > This patch removes it. > > Signed-off-by: Alexandru Ardelean > --- > drivers/iio/gyro/adis16260.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/drivers/iio/gyro/adis16260.c b/drivers/iio/gyro/adis16260.c > index 207a0ce13439..0fa93d02062a 100644 > --- a/drivers/iio/gyro/adis16260.c > +++ b/drivers/iio/gyro/adis16260.c > @@ -293,7 +293,6 @@ static int adis16260_write_raw(struct iio_dev *indio_dev, > addr = adis16260_addresses[chan->scan_index][1]; > return adis_write_reg_16(adis, addr, val); > case IIO_CHAN_INFO_SAMP_FREQ: > - mutex_lock(&indio_dev->mlock); > if (spi_get_device_id(adis->spi)->driver_data) > t = 256 / val; > else > @@ -310,7 +309,6 @@ static int adis16260_write_raw(struct iio_dev *indio_dev, > adis->spi->max_speed_hz = ADIS16260_SPI_FAST; > ret = adis_write_reg_8(adis, ADIS16260_SMPL_PRD, t); > > - mutex_unlock(&indio_dev->mlock); > return ret; > } > return -EINVAL;