Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1349121ybk; Sat, 16 May 2020 08:30:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiRr+1cjB6TfMx5XhGRj3AEGQVz/fbMPvtRjP8x7COKtqrHtZkOE556NEmbg5LIsgdB2O3 X-Received: by 2002:a05:6402:30b4:: with SMTP id df20mr7193267edb.158.1589643014072; Sat, 16 May 2020 08:30:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589643014; cv=none; d=google.com; s=arc-20160816; b=SGonN7itY2u9dmIhcexeR4vmNJOkoMnQ2G+bVYBkV/PaxCmsN4FELupbhKj4G1ZO1p TYd10W8kFL99zo7rX1BiEm/XSTZdl+BeETc9PcdngBmDIUzwadMmna4CzVXg/+g6ndpf B+uXPk+MaV0AA4K0xB8h8nw1ZSbMkSpfctuUbIxEiiiJ+w+77teZH9myuieYPYWDR4jb 43BzbXu4ZuYVrDKRmgqVSgoOb5qXHuSkOkq3uv8tutDiyLvAhcVDb7Al0/YniUimmkMg 8xV3yM1Gd/wj8urYyCKdIaW+BprjHiF5+zONV077VTi8RIF0OnIEvnXl70dzdVZ+8Wmd EWdg== 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=NHEY1V7ZXR9z7Ed7va4M7vYiMDDUOZfWk9jy+efhf7U=; b=igqxz34GN/mbWAeY0odSs31kcmbZnGDkF5J6/jrN5Csk7vLtMLfb7yHhNkmaYCu318 1RFALMv7g3eLPWVLc9kIve29Pcyr7qAjXUtEWrKNTy9QD66EO2wrfMUP+QDTowM2WEOY y7zPtpjRtdWJFpz0GUaeBEYC6BIK6itemHGKM6/QQD96Hb381/EqSs9wc/fThYqNOkAU 2lwIA/fxc7TTvNHEx/+c0nIONQ4VffP+fwoTzTJXCitqAa9vv29o/WiqLWZz8Vs6SA29 //CTUzvLHC2FXORA05o4k7sHujh3Fkk1ILIks0a8Rcdm4vqz/TIzrlATmoe1RxXPx9Kh +eTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yhzqgr6J; 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 z6si3469348ejb.147.2020.05.16.08.29.51; Sat, 16 May 2020 08:30:14 -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=Yhzqgr6J; 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 S1726936AbgEPP1j (ORCPT + 99 others); Sat, 16 May 2020 11:27:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:35154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726715AbgEPP1j (ORCPT ); Sat, 16 May 2020 11:27:39 -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 86F652065C; Sat, 16 May 2020 15:27:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589642858; bh=ZPXKLSvA67ABmYzHMRhZ4zr3Hz8urY4fRCL7lFkBP18=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Yhzqgr6JK4sjWLINCXIRlIvXj/PVoWANEwakky1BNXdpjYsGTN6AQ+ECh6LfnqtFC auw8zvGJrxXWnmDgABZdWX8buFNzzjglbtjQf3fv558HbYPP8/zbMUs8bibx1UWTSx S9oGey3YDw/sEJoua5np+x/gHeO3iUKZsbi5M2rc= Date: Sat, 16 May 2020 16:27:34 +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: ad5421: Replace indio_dev->mlock with own device lock Message-ID: <20200516162734.5888c326@archlinux> In-Reply-To: <20200514091756.81425-1-sergiu.cuciurean@analog.com> References: <20200514091756.81425-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:17:53 +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. Thanks, J > --- > drivers/iio/dac/ad5421.c | 21 +++++++++++++-------- > 1 file changed, 13 insertions(+), 8 deletions(-) > > diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c > index 63063e85cd0a..fec27764cea8 100644 > --- a/drivers/iio/dac/ad5421.c > +++ b/drivers/iio/dac/ad5421.c > @@ -62,12 +62,14 @@ > * @current_range: current range which the device is configured for > * @data: spi transfer buffers > * @fault_mask: software masking of events > + * @lock lock to protect the data buffer during SPI ops > */ > struct ad5421_state { > struct spi_device *spi; > unsigned int ctrl; > enum ad5421_current_range current_range; > unsigned int fault_mask; > + struct mutex lock; > > /* > * DMA (thus cache coherency maintenance) requires the > @@ -142,11 +144,12 @@ static int ad5421_write_unlocked(struct iio_dev *indio_dev, > static int ad5421_write(struct iio_dev *indio_dev, unsigned int reg, > unsigned int val) > { > + struct ad5421_state *st = iio_priv(indio_dev); > int ret; > > - mutex_lock(&indio_dev->mlock); > + mutex_lock(&st->lock); > ret = ad5421_write_unlocked(indio_dev, reg, val); > - mutex_unlock(&indio_dev->mlock); > + mutex_unlock(&st->lock); > > return ret; > } > @@ -166,7 +169,7 @@ static int ad5421_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)); > > @@ -174,7 +177,7 @@ static int ad5421_read(struct iio_dev *indio_dev, unsigned int reg) > if (ret >= 0) > ret = be32_to_cpu(st->data[1].d32) & 0xffff; > > - mutex_unlock(&indio_dev->mlock); > + mutex_unlock(&st->lock); > > return ret; > } > @@ -185,14 +188,14 @@ static int ad5421_update_ctrl(struct iio_dev *indio_dev, unsigned int set, > struct ad5421_state *st = iio_priv(indio_dev); > unsigned int ret; > > - mutex_lock(&indio_dev->mlock); > + mutex_lock(&st->lock); > > st->ctrl &= ~clr; > st->ctrl |= set; > > ret = ad5421_write_unlocked(indio_dev, AD5421_REG_CTRL, st->ctrl); > > - mutex_unlock(&indio_dev->mlock); > + mutex_unlock(&st->lock); > > return ret; > } > @@ -400,12 +403,12 @@ static int ad5421_write_event_config(struct iio_dev *indio_dev, > return -EINVAL; > } > > - mutex_lock(&indio_dev->mlock); > + mutex_lock(&st->lock); > if (state) > st->fault_mask |= mask; > else > st->fault_mask &= ~mask; > - mutex_unlock(&indio_dev->mlock); > + mutex_unlock(&st->lock); > > return 0; > } > @@ -491,6 +494,8 @@ static int ad5421_probe(struct spi_device *spi) > indio_dev->channels = ad5421_channels; > indio_dev->num_channels = ARRAY_SIZE(ad5421_channels); > > + mutex_init(&st->lock); > + > st->ctrl = AD5421_CTRL_WATCHDOG_DISABLE | > AD5421_CTRL_AUTO_FAULT_READBACK; >