Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1347313ybk; Sat, 16 May 2020 08:27:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxW/76P9YCyXac5MbA+s+5DJuxjXpAYFJyAsA2KX+o2elb5Np++vfs2vXSYLusMp6yrJtNR X-Received: by 2002:a17:906:ff54:: with SMTP id zo20mr8069609ejb.124.1589642833383; Sat, 16 May 2020 08:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589642833; cv=none; d=google.com; s=arc-20160816; b=NIdt3e5fVZPf/AR2k86EmyBmo1XNUSpWWuCQrGaH91S8MhJ9A1tPriRGYFIIrYb1/s U3QBMcbvFyaljj/Jro/4bsr+8Tfp3OMxKxWjm57wwtuLXffk3mCTfayQA8Llfl2SlCyR ycWiOVI/NdbceuK+SUXC9hYTROJwGuK1vJP1bVQKAGQL94USsoAEscxjAs55DK0s+Vph h2nZmQitMkOzukoXQjkVVIKWgTBwm6GVjMQA0zbfvv1XhiCJeNA0QdkBDwEydY0L6vu4 UIdx0/Vwx3zLbBVY+yppt+34lOwseCeiGNsiXQmSp0GcHUfH1yHwhJUMF89QxLibuh3Z kmCA== 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:subject:cc:to:from:date :dkim-signature; bh=DBnHh+RVDcuH0Fyph7g1KJLAcjpQsEr7eZpZHISk6N8=; b=aE0rB2qVHHX41/1ooADS3yivtbLwV5MplYMVrDbqwXa0/alIVjM2wq7b63R3CBu9iC zzDSCFcymSKxLGnaP4WCaz2R+/ZegJ16xH9fDIUL6SWsXe65OP6MfOGq0zYAI65SHKT8 AtiW2DeiapKk7ron9tXGP5b/BtGonkrsmmjlZYYjZiFrgynmoBsTcPBhuTlYK4wK8H8T sst6gyll9mqaZhMGRQ/2ZbOhmI8HWaVUNli0I7Jn/ZtBqzC6/xk7VEYBD280IQb78eOS LGIqn4bfLFLa3qU9lM+hfrMcMtUGrFFsep3pj3OCOf+PBUma2HGhofpPMywf88PrK21r JS1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jM1QHtrk; 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 a63si3192284ede.399.2020.05.16.08.26.49; Sat, 16 May 2020 08:27:13 -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=jM1QHtrk; 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 S1726876AbgEPPZS (ORCPT + 99 others); Sat, 16 May 2020 11:25:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:33778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbgEPPZR (ORCPT ); Sat, 16 May 2020 11:25:17 -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 1C5F72065C; Sat, 16 May 2020 15:25:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589642717; bh=T0JwmiMwnEPZ35ne+oNIwIDDnaDStjbnxIotzzfP080=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jM1QHtrkkPobQilhC3RLiRCwLiR7e6p4TmG7jCQDIlTzR8ufSDn/1m4kf12Fx7hHf QUe8OX3DUfxuzefyqm50+jz+vdKaWwT5C5tzWcjEUIMyESUNyLKsmhKA6cKbx2pMam 2+aYLE8U5Ky2k54DCmnrtHZx1V1BlW0CEG9ak05Y= Date: Sat, 16 May 2020 16:25:10 +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: ad5764: Replace indio_dev->mlock with own device lock Message-ID: <20200516162510.13ba3656@archlinux> In-Reply-To: <20200514091215.80958-1-sergiu.cuciurean@analog.com> References: <20200514091215.80958-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:12:12 +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 and pushed out as testing. Thanks, Jonathan > --- > drivers/iio/dac/ad5764.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/iio/dac/ad5764.c b/drivers/iio/dac/ad5764.c > index f7ab211604a1..5b0f0fe354f6 100644 > --- a/drivers/iio/dac/ad5764.c > +++ b/drivers/iio/dac/ad5764.c > @@ -46,6 +46,7 @@ struct ad5764_chip_info { > * @spi: spi_device > * @chip_info: chip info > * @vref_reg: vref supply regulators > + * @lock lock to protect the data buffer during SPI ops > * @data: spi transfer buffers > */ > > @@ -53,6 +54,7 @@ struct ad5764_state { > struct spi_device *spi; > const struct ad5764_chip_info *chip_info; > struct regulator_bulk_data vref_reg[2]; > + struct mutex lock; > > /* > * DMA (thus cache coherency maintenance) requires the > @@ -126,11 +128,11 @@ static int ad5764_write(struct iio_dev *indio_dev, unsigned int reg, > struct ad5764_state *st = iio_priv(indio_dev); > int ret; > > - mutex_lock(&indio_dev->mlock); > + mutex_lock(&st->lock); > st->data[0].d32 = cpu_to_be32((reg << 16) | val); > > ret = spi_write(st->spi, &st->data[0].d8[1], 3); > - mutex_unlock(&indio_dev->mlock); > + mutex_unlock(&st->lock); > > return ret; > } > @@ -151,7 +153,7 @@ static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg, > }, > }; > > - mutex_lock(&indio_dev->mlock); > + mutex_lock(&st->lock); > > st->data[0].d32 = cpu_to_be32((1 << 23) | (reg << 16)); > > @@ -159,7 +161,7 @@ static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg, > if (ret >= 0) > *val = be32_to_cpu(st->data[1].d32) & 0xffff; > > - mutex_unlock(&indio_dev->mlock); > + mutex_unlock(&st->lock); > > return ret; > } > @@ -295,6 +297,8 @@ static int ad5764_probe(struct spi_device *spi) > indio_dev->num_channels = AD5764_NUM_CHANNELS; > indio_dev->channels = st->chip_info->channels; > > + mutex_init(&st->lock); > + > if (st->chip_info->int_vref == 0) { > st->vref_reg[0].supply = "vrefAB"; > st->vref_reg[1].supply = "vrefCD";