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=-14.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 7C93DC433E3 for ; Wed, 26 Aug 2020 08:58:56 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3F0202071E for ; Wed, 26 Aug 2020 08:58:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hYXHZI9u"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=st.com header.i=@st.com header.b="0RLwk4Ot" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F0202071E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=st.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qsCTUInKo4DhPYUEXKMBsm4aPL//r1AdQco0Qo6okYY=; b=hYXHZI9uDUD17UnocNeRbj95Y u15Hujd84LaXWM5ezEGBTGw31BvBZ9ULXykSc5z6U4GhLp+Fh7QXSx7jBPK3QMMZzhlCg7zNyao3F gGSWxr2/JWJsHzvfJcScaai605hd30HV724QaCWMIPpC4w6l5t4g0Yz4YcOIz8LLG0yGxibQly7ti 3e2Rsak8BNQ8QDh5LkVt1Na8i2mttezY60FXUEIYQF6QgHmrNn4428OIdxi4A7Rf+Nuq5WSf6goRv CqA6xPabCHt9qzYugiK2QjqJKqM1B1bAb2wWFguzXaE0id6IfLOFGcRSV5iBE5ioFJX3mcMVbW0es xqzw5zgug==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kArFM-0001wF-7l; Wed, 26 Aug 2020 08:57:32 +0000 Received: from mx08-00178001.pphosted.com ([91.207.212.93] helo=mx07-00178001.pphosted.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kArFI-0001uT-9a for linux-arm-kernel@lists.infradead.org; Wed, 26 Aug 2020 08:57:29 +0000 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 07Q8uxk8013542; Wed, 26 Aug 2020 10:57:19 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=STMicroelectronics; bh=nfnzZRDCN46NnRol+LMu+aCQr7PtIZM6+ud79PtgOvE=; b=0RLwk4OtEiJSTlh+zVA4Y8TG4jTUXDYAYEG2q+wUoaotWfyREEf0g+nJEFpVlbwCg2Hc sHrLpRGW5GRr+/LtewwQLS3KtJ7zu10mVx3/cmalv0gwIsL8fpD04lOpXzY6n+38uhYG pS5fqhfzE2onG4uwGCr18yaAdkKAqsW1qNbMFvrrlm0xc6a09eFxu9MNn7bHAUxP0CXC U2mVhZ6GUKQkKnAg0JkUEMhJHoGA+Zm7BnDJZzsN21B4wui4b6S2mldg4GUJQ+77P6S7 3RDrGigrtRbQDp+nB8OLukZS95lv9OV1WOyK2c2R01t3Gh+VCvKDcgBlcB5tsXlqvyPC fw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 332t8ft355-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Aug 2020 10:57:19 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 24E4310002A; Wed, 26 Aug 2020 10:57:17 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag5node3.st.com [10.75.127.15]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 0E39A21CA7D; Wed, 26 Aug 2020 10:57:17 +0200 (CEST) Received: from [10.211.2.168] (10.75.127.44) by SFHDAG5NODE3.st.com (10.75.127.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 26 Aug 2020 10:57:15 +0200 Subject: Re: [PATCH] iio: stm32-dac: Replace indio_dev->mlock with own device lock To: Alexandru Ardelean , , , , References: <20200826063850.47625-1-alexandru.ardelean@analog.com> From: Fabrice Gasnier Message-ID: <1c32f6b5-deb6-e310-4bc4-a871719cc8f3@st.com> Date: Wed, 26 Aug 2020 10:57:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200826063850.47625-1-alexandru.ardelean@analog.com> Content-Language: en-US X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG7NODE3.st.com (10.75.127.21) To SFHDAG5NODE3.st.com (10.75.127.15) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-08-26_06:2020-08-25, 2020-08-26 signatures=0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200826_045728_715011_BFD44F91 X-CRM114-Status: GOOD ( 28.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergiu Cuciurean , alexandre.torgue@st.com, jic23@kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 8/26/20 8:38 AM, Alexandru Ardelean wrote: > From: Sergiu Cuciurean > > As part of the general cleanup of indio_dev->mlock, this change replaces > it with a local lock on the device's state structure. > > The patch also does a minor whitespace change to align the 'lock' with the > 'common' field via tabs. > > Signed-off-by: Sergiu Cuciurean > Signed-off-by: Alexandru Ardelean > --- > drivers/iio/dac/stm32-dac.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c > index 092c796fa3d9..fc636812c17e 100644 > --- a/drivers/iio/dac/stm32-dac.c > +++ b/drivers/iio/dac/stm32-dac.c > @@ -26,9 +26,11 @@ > /** > * struct stm32_dac - private data of DAC driver > * @common: reference to DAC common data > + * @lock: lock to protect the data buffer during regmap ops Hi Alexandru, I think the same patch has been sent by Sergiu already [1]. Jonathan and I had a minor comment at that time: E.g. could you please update the comment ? [1] https://lkml.org/lkml/2020/5/18/254 > */ > struct stm32_dac { > - struct stm32_dac_common *common; > + struct stm32_dac_common *common; Is above change needed? Best Regards, Fabrice > + struct mutex lock; > }; > > static int stm32_dac_is_enabled(struct iio_dev *indio_dev, int channel) > @@ -58,10 +60,10 @@ static int stm32_dac_set_enable_state(struct iio_dev *indio_dev, int ch, > int ret; > > /* already enabled / disabled ? */ > - mutex_lock(&indio_dev->mlock); > + mutex_lock(&dac->lock); > ret = stm32_dac_is_enabled(indio_dev, ch); > if (ret < 0 || enable == !!ret) { > - mutex_unlock(&indio_dev->mlock); > + mutex_unlock(&dac->lock); > return ret < 0 ? ret : 0; > } > > @@ -69,13 +71,13 @@ static int stm32_dac_set_enable_state(struct iio_dev *indio_dev, int ch, > ret = pm_runtime_get_sync(dev); > if (ret < 0) { > pm_runtime_put_noidle(dev); > - mutex_unlock(&indio_dev->mlock); > + mutex_unlock(&dac->lock); > return ret; > } > } > > ret = regmap_update_bits(dac->common->regmap, STM32_DAC_CR, msk, en); > - mutex_unlock(&indio_dev->mlock); > + mutex_unlock(&dac->lock); > if (ret < 0) { > dev_err(&indio_dev->dev, "%s failed\n", en ? > "Enable" : "Disable"); > @@ -327,6 +329,8 @@ static int stm32_dac_probe(struct platform_device *pdev) > indio_dev->info = &stm32_dac_iio_info; > indio_dev->modes = INDIO_DIRECT_MODE; > > + mutex_init(&dac->lock); > + > ret = stm32_dac_chan_of_init(indio_dev); > if (ret < 0) > return ret; > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel