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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D015C07E9D for ; Sat, 24 Sep 2022 15:24:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229674AbiIXPY3 (ORCPT ); Sat, 24 Sep 2022 11:24:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229798AbiIXPYT (ORCPT ); Sat, 24 Sep 2022 11:24:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7878B19C06 for ; Sat, 24 Sep 2022 08:24:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 12F5061347 for ; Sat, 24 Sep 2022 15:24:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E98AC433D6; Sat, 24 Sep 2022 15:24:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664033057; bh=1gU88OznqaSWekwuxOljVASWVDCEECwP7hlnsm3KYxU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Hnm6vfhU/N7dfe3NIpZ49rKxs3MqJXnXw+iVVBWr+yP9VAY63FN9TNbqoyidgU/Va PKUdViywZtBMeUUusa01YT7ZMNh43kdgSi501FFfj9YaQT5HwA7QijzoKq+kwArvmn qAvdApyg365QYCRSOzXrNySVOcXXkJALyoKdV+sv1agMGJJ1XjXGj0Lech990NOX8y QRAbS0tsI2zQHxOf1IZBjGVhVCZwXVSopWtf3ODV6XeRNp6BqWe67unkgdgGG136WO TFlfaiUONuNrgxiimU2oF7CIkSmT5bodwGaPLv+EGMDZPUt7PNIBPk2RCEXMUzetr4 9BEFxaHppt1DA== Date: Sat, 24 Sep 2022 16:24:19 +0100 From: Jonathan Cameron To: Nuno =?UTF-8?B?U8Oh?= Cc: , , , , , Chunyan Zhang , Michael Hennerich , Martin Blumenstingl , Sascha Hauer , Cixi Geng , Kevin Hilman , Vladimir Zapolskiy , Pengutronix Kernel Team , Alexandru Ardelean , Fabio Estevam , Andriy Tryshnivskyy , Haibo Chen , Shawn Guo , Hans de Goede , Miquel Raynal , Jerome Brunet , Heiko Stuebner , Florian Boor , Ciprian Regus , Lars-Peter Clausen , Andy Shevchenko , Neil Armstrong , Baolin Wang , Jyoti Bhayana , Chen-Yu Tsai , Orson Zhai Subject: Re: [PATCH 03/15] iio: adc: axp288_adc: do not use internal iio_dev lock Message-ID: <20220924162419.341bbe85@jic23-huawei> In-Reply-To: <20220920112821.975359-4-nuno.sa@analog.com> References: <20220920112821.975359-1-nuno.sa@analog.com> <20220920112821.975359-4-nuno.sa@analog.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Tue, 20 Sep 2022 13:28:09 +0200 Nuno S=C3=A1 wrote: > The iio_device lock is only meant for internal use. Hence define a > device local lock to protect against concurrent accesses. >=20 > Signed-off-by: Nuno S=C3=A1 Looks good. Not sure how we missed cleaning this one up earlier given how simple it is! Anyhow, given Andy's feedback I'll wait for v2 to pick this up. > --- > drivers/iio/adc/axp288_adc.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c > index 580361bd9849..3bbb96156739 100644 > --- a/drivers/iio/adc/axp288_adc.c > +++ b/drivers/iio/adc/axp288_adc.c > @@ -9,6 +9,7 @@ > =20 > #include > #include > +#include > #include > #include > #include > @@ -50,6 +51,8 @@ enum axp288_adc_id { > struct axp288_adc_info { > int irq; > struct regmap *regmap; > + /* lock to protect against multiple access to the device */ > + struct mutex lock; > bool ts_enabled; > }; > =20 > @@ -161,7 +164,7 @@ static int axp288_adc_read_raw(struct iio_dev *indio_= dev, > int ret; > struct axp288_adc_info *info =3D iio_priv(indio_dev); > =20 > - mutex_lock(&indio_dev->mlock); > + mutex_lock(&info->lock); > switch (mask) { > case IIO_CHAN_INFO_RAW: > if (axp288_adc_set_ts(info, AXP288_ADC_TS_CURRENT_ON_ONDEMAND, > @@ -178,7 +181,7 @@ static int axp288_adc_read_raw(struct iio_dev *indio_= dev, > default: > ret =3D -EINVAL; > } > - mutex_unlock(&indio_dev->mlock); > + mutex_unlock(&info->lock); > =20 > return ret; > } > @@ -264,6 +267,7 @@ static int axp288_adc_probe(struct platform_device *p= dev) > return -ENOMEM; > =20 > info =3D iio_priv(indio_dev); > + mutex_init(&info->lock); > info->irq =3D platform_get_irq(pdev, 0); > if (info->irq < 0) > return info->irq;