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=-5.8 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,UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_SANE_2 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 73E52C433E1 for ; Sat, 16 May 2020 15:23:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50792207C3 for ; Sat, 16 May 2020 15:23:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589642619; bh=5+Zfs6hpFVkDklYLEV8HU1cCRNSqPjDrqAYAj/UgYYI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=nV4Mfsnq1W0caG935PCagKhyWznAjbLf7eTBfOFz+C6qtugKqZfEEPtUJAQCP4AUW I0E75rVz+qZKHTu8DThQkjvrDBRnz7FRYUNu31XqjL5Eiso13UVdnzWMw6CtAMpM6K MssNQwPAUIjR2sz0WBkReboNylvN75g3CGA3KLvU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726945AbgEPPXi (ORCPT ); Sat, 16 May 2020 11:23:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:33070 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbgEPPXi (ORCPT ); Sat, 16 May 2020 11:23:38 -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 B9BE32065C; Sat, 16 May 2020 15:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589642618; bh=5+Zfs6hpFVkDklYLEV8HU1cCRNSqPjDrqAYAj/UgYYI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=z9Yq8eTGA0OEJVQ1KLm89KSgdrdazl9Dog3pch0X3Jiq3Cm97iwfSZ360Opg0U0cA wglZ82WExXDCRRuQE1RIJwqudXgVlbkKRuvW1U1qNKVUSgly+tR0j03BvjINTxRYSS ORB0cMGchKSHCosgi2n/+Idr/7kHJyVWI9TSqTvw= Date: Sat, 16 May 2020 16:23:33 +0100 From: Jonathan Cameron To: Sergiu Cuciurean Cc: , , Lars-Peter Clausen , Michael Hennerich , "Stefan Popa" , "Hartmut Knaack" , Peter Meerwald-Stadler Subject: Re: [PATCH] iio: dac: ad5761: Replace indio_dev->mlock with own device lock Message-ID: <20200516162333.647979d5@archlinux> In-Reply-To: <20200514091032.80883-1-sergiu.cuciurean@analog.com> References: <20200514091032.80883-1-sergiu.cuciurean@analog.com> X-Mailer: Claws Mail 3.17.5 (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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 14 May 2020 12:10:28 +0300 Sergiu Cuciurean wrote: > As part of the general cleanup of indio_dev->mlock, this change replaces > it with a local lock on the device's state structure. > > Signed-off-by: Sergiu Cuciurean Applied to the togreg branch of iio.git. Thanks, J > --- > drivers/iio/dac/ad5761.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/iio/dac/ad5761.c b/drivers/iio/dac/ad5761.c > index 4fb42b743f0f..67179944e5c5 100644 > --- a/drivers/iio/dac/ad5761.c > +++ b/drivers/iio/dac/ad5761.c > @@ -57,11 +57,13 @@ enum ad5761_supported_device_ids { > * @use_intref: true when the internal voltage reference is used > * @vref: actual voltage reference in mVolts > * @range: output range mode used > + * @lock lock to protect the data buffer during SPI ops > * @data: cache aligned spi buffer > */ > struct ad5761_state { > struct spi_device *spi; > struct regulator *vref_reg; > + struct mutex lock; > > bool use_intref; > int vref; > @@ -124,9 +126,9 @@ static int ad5761_spi_write(struct iio_dev *indio_dev, u8 addr, u16 val) > struct ad5761_state *st = iio_priv(indio_dev); > int ret; > > - mutex_lock(&indio_dev->mlock); > + mutex_lock(&st->lock); > ret = _ad5761_spi_write(st, addr, val); > - mutex_unlock(&indio_dev->mlock); > + mutex_unlock(&st->lock); > > return ret; > } > @@ -163,9 +165,9 @@ static int ad5761_spi_read(struct iio_dev *indio_dev, u8 addr, u16 *val) > struct ad5761_state *st = iio_priv(indio_dev); > int ret; > > - mutex_lock(&indio_dev->mlock); > + mutex_lock(&st->lock); > ret = _ad5761_spi_read(st, addr, val); > - mutex_unlock(&indio_dev->mlock); > + mutex_unlock(&st->lock); > > return ret; > } > @@ -368,6 +370,8 @@ static int ad5761_probe(struct spi_device *spi) > if (pdata) > voltage_range = pdata->voltage_range; > > + mutex_init(&st->lock); > + > ret = ad5761_spi_set_range(st, voltage_range); > if (ret) > goto disable_regulator_err;