From patchwork Wed Jul 18 07:29:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Ardelean X-Patchwork-Id: 10531491 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9B835602CA for ; Wed, 18 Jul 2018 07:30:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84524290ED for ; Wed, 18 Jul 2018 07:30:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78764290F1; Wed, 18 Jul 2018 07:30:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADEC3290E6 for ; Wed, 18 Jul 2018 07:30:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726708AbeGRIGl (ORCPT ); Wed, 18 Jul 2018 04:06:41 -0400 Received: from mail-eopbgr730046.outbound.protection.outlook.com ([40.107.73.46]:54187 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726067AbeGRIGk (ORCPT ); Wed, 18 Jul 2018 04:06:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=analog.onmicrosoft.com; s=selector1-analog-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bDLQsqhZe9QVczPeAzFJ0z7lLBWM8iclHzisD9x+Tt4=; b=a8wiPetNZ4EgYWC/7ADGEuYDEtcx9dPT3sRd1EA/Ondb6aGhtyFEda11HH8UlJRSs2pPLwYIWCFbAtJhdxpwvZLZ7DXi/nt5PExzPuJILfxfvezb0Qzq7xsIpkHT5UMS48hVPJuEtpFQTVYw3NeQiNvY9s21vnvLLHnvQcAnfFw= Received: from CY1PR03CA0036.namprd03.prod.outlook.com (2603:10b6:600::46) by CY4PR03MB3128.namprd03.prod.outlook.com (2603:10b6:910:53::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.952.21; Wed, 18 Jul 2018 07:30:09 +0000 Received: from BL2FFO11FD017.protection.gbl (2a01:111:f400:7c09::123) by CY1PR03CA0036.outlook.office365.com (2603:10b6:600::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.973.16 via Frontend Transport; Wed, 18 Jul 2018 07:30:09 +0000 Authentication-Results: spf=pass (sender IP is 137.71.25.55) smtp.mailfrom=analog.com; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=bestguesspass action=none header.from=analog.com; Received-SPF: Pass (protection.outlook.com: domain of analog.com designates 137.71.25.55 as permitted sender) receiver=protection.outlook.com; client-ip=137.71.25.55; helo=nwd2mta1.analog.com; Received: from nwd2mta1.analog.com (137.71.25.55) by BL2FFO11FD017.mail.protection.outlook.com (10.173.161.35) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.952.20 via Frontend Transport; Wed, 18 Jul 2018 07:30:09 +0000 Received: from NWD2HUBCAS8.ad.analog.com (nwd2hubcas8.ad.analog.com [10.64.69.108]) by nwd2mta1.analog.com (8.13.8/8.13.8) with ESMTP id w6I7U8rv008126 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Wed, 18 Jul 2018 00:30:08 -0700 Received: from zeus.spd.analog.com (10.64.82.11) by NWD2HUBCAS8.ad.analog.com (10.64.69.108) with Microsoft SMTP Server id 14.3.301.0; Wed, 18 Jul 2018 03:30:08 -0400 Received: from saturn.analog.com ([10.50.1.244]) by zeus.spd.analog.com (8.15.1/8.15.1) with ESMTP id w6I7U68R022202; Wed, 18 Jul 2018 03:30:07 -0400 From: Alexandru Ardelean To: , , , CC: Alexandru Ardelean Subject: [PATCH V4] iio: ad9523: replace core mlock with local lock Date: Wed, 18 Jul 2018 10:29:53 +0300 Message-ID: <20180718072953.15669-1-alexandru.ardelean@analog.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-ADIRoutedOnPrem: True X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.55; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39860400002)(396003)(376002)(346002)(136003)(2980300002)(438002)(189003)(199004)(2201001)(106466001)(316002)(16586007)(336012)(110136005)(86362001)(246002)(2616005)(126002)(8676002)(476003)(26005)(186003)(106002)(77096007)(426003)(478600001)(7696005)(51416003)(47776003)(107886003)(1076002)(50466002)(48376002)(2906002)(4326008)(14444005)(5660300001)(53416004)(6666003)(36756003)(7636002)(305945005)(44832011)(356003)(486006)(8936002)(50226002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR03MB3128; H:nwd2mta1.analog.com; FPR:; SPF:Pass; LANG:en; PTR:nwd2mail10.analog.com; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD017; 1:D4sE4U9yyaCE+ikDsHtnZT8UsO5HrSlK4rU5izdNNj7kYd3pl6CZ4cmVXk/qO6z0tJ1pYMkUj2Ju9lSU3fLQs5kYDfk0SE4yQqwDaMo389aNkVUbhEJYiv2iRQpSc2wt X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8452da8c-cb8a-4ad0-f438-08d5ec804a67 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060); SRVR:CY4PR03MB3128; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB3128; 3:SOIHIIRgD0hPF3cwsZxshEbhxaLpMKP9XXhP4U6Lfcqj0dJcJ1yjzta3JhbnPPKW2O+noC4/udhy8fg0vviiWpofa/y6swg8+XhvUdkDEez6s915i0cWVoBBMXXnpJYkgGstsTxDw36ve6PKkVvoLMCJbn3AicX4CDRCF/zQmsc+JuySGc2BAAs4RgTwV6EXDfY+vZN3RLr8zL0vH7qdrr9JSrWblew/lOQrN/tWdkp//QaaBvIF5RHS7lEtjRnoRMD2QvP8Sd3uqGq8L+/SPBTIVt7Jra+ZkTGDWP0MsJBc6XLQPm4nEMsgk1J+6wCh8J3qTYH+AXgP34GX3YIV069Q6r0tNUPJKVGSJFLZmnk=; 25:KuBhhX7Sz4YSUIJxMFITCdopAjAoPF//RoVTfxGGcbL4GL/QgF2Ih4uCgkFgwVvG9pAEOTGkZafe7pPloafd1SDlGyveoHPlr5XoxE2oQ4GF+numiWdN70dD3/7yUcyS7mNObbFcdny537OxOKTJC8KO/f5HkoZ1ZEuWh6b5MN3dEV6SmUNLGCcSaFBZ3DdqS54cvld6RKEG7zPnkz1VlgJTxL3HiT+x76Az6QoTb9gHM6KnhWntIx1pNw3hHi7IIFpQWNYQr02twQshofAWyRnskVeznMx2QgE31jJWRKa7Sa2OeRIRW2J8B7zrvRnTVkticQZ16BMX6TkPVdr3Jg== X-MS-TrafficTypeDiagnostic: CY4PR03MB3128: X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB3128; 31:NOY8B/cXnWvFPkCtP/c58amrrTCe9trF+hCyyszB+IM1+wxdErXW8An4PGyEc8RIhgChz7ZU3K8yGHHoLK2IQ71qYrW+saApf7roKxDCWXu1YNyvSCePB+tvc5a3zFwZRh24enPJXWDoGzh14adhyIe0/KT3JY6DPqCn0zhrDFNMkzbMte6v5z2vtnM93A4CyS94yf9eEFChsxfkKo1OFHn2P3FVRGgPSv3q+godGHo=; 20:eaE9f+Bf/iFBsspcIb3W0AbfzLRuNbkZkkJNjCNuJtKglb0nt0nlGEv1YhQ4zK/Dm3+F7Hp8fcDkE9xHzkJlp39D+qW9KjlhxCdJEgIQKLnWZdsRAldaoj7nOIGvgSV7zBPcUvu8CZXaDgOj+Pvyqz8s30igljCaqo76/Xe0TNFzMw+YQFKPzduscOYExVZ7Jz8qBlDOuupcWa4baJTkl68wVj3muN5CU/Pgm0/vTIftdIt66ayaDbGCf6H+yXkQlF4hIXzLkexIoNpTKQ77JIFAJPSozSn8UI9xS6reFPiIJQ9S29+qmcFX8L+wKZueTxU55G7TDsE0Ax+mCZ1VcHqrPmncpaQcDz9hWPZ2B/pzgyWR3SQ1e9GGuMPFraZALtdm8RH2c3zkWyiA9D0xzU1aZ0aXOi2Rd5W6Cyqr1rHKngUICi+C4i5QO1JqfvI3eoLOoIzYI0ltoSJQr4oIV4345yrDsX2NfnRVXgJ4nWJrMt6t0X69JBpMxswR15tO X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(232431446821674)(788757137089); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93004095)(3231311)(944501410)(52105095)(3002001)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123562045)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:CY4PR03MB3128; BCL:0; PCL:0; RULEID:; SRVR:CY4PR03MB3128; X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB3128; 4:nRdjrcfTP8ocFvcNGk8vCvZ4ACW2Pxwfqb07Py+4VIZgjq4P69n5VC/GtrQkzMxKyvAVNW/KdUtOOQq2zq++1mRKreGjkR1mMFs3N91TwhfBmNwNhVKihikaTggaLKsc/U/sFhRkwsOxmxO5Dzh9lCDI68ePBOthmamhpRZMlYtQAHaJ2+vgN0GmpRks2m1z3WZmc6njiMAUiOKZveUBAlFGcvIUg12SrrrnbQNTJ83xGyECSfb9Vqt8+ebB5+rqbKdgi8ZNjycZozAGlMWMgF71gEOyVlQLqX9qy7J+meQ87/Vwh98EyaIBew9PzZ0NOsqcIn8qB2foeANs/RwXvA== X-Forefront-PRVS: 0737B96801 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR03MB3128; 23:Sk+0tZGIsgQKQDPIK6j/sUUR1DiJoVpAZGblMFgYd?= =?us-ascii?Q?xGMsVklVcY/WNkDv+6f5F0a8Zcp7eSWnFhPnFtwKzcO/452xc8HX3ynGLf9H?= =?us-ascii?Q?i6urVkISOSVmnBT77Sjh+m7ku0LinopvBs32t56uceHMljkqa3wOKvZPGNG0?= =?us-ascii?Q?XT7k24h5nne1/8zYGTDAkhgxtSo5BqQQQJiBKwzbT5VpZliRam7hGr5Fuula?= =?us-ascii?Q?UNPpZ9MwWd5QVivnGpuJX3g3+3n1SpIQynUCVynLX7HE7u1XEF3YuH0CLPL3?= =?us-ascii?Q?FwAuAe2onlVKXwBUQ+RHBG2j7PkUQq0JZZc9f2x1cOY61wKwuC94NrKpn525?= =?us-ascii?Q?xWrAAc4TI/Wll/jWAhZPYUNRgAHxD87oJWkl+dr+nrfQKqw2SI2o75jyeTH2?= =?us-ascii?Q?2bjMDgb48xz7nbqa5JAx55s1wEBMCOXCmRIyT8f8QCEN2DQLXKVsXKz1SGvx?= =?us-ascii?Q?xOWDHZaUPjO4P+54G8junAozCTAM3Q6djLJoaHpiaqcipVzVC47lOoJ3Nkru?= =?us-ascii?Q?q9b+/Xo0+hkCOnjAUIZZ0dKfu2uVbVFem5xmoK6QLf0j9p9mDpjMRbBOmcEg?= =?us-ascii?Q?v4rJA2ERtyNpk0A+zw48FdCZzJOMVT31gwlSLQfqqAjoZie2bbmhTN2Loc+r?= =?us-ascii?Q?70YcX6QrS/9j/dB7FB1FsvCdmCeABLPIB48LSXGIwHLze6jtTqagCBisa84Q?= =?us-ascii?Q?wGbETGeGShDdizTEOH7tPPimKlH72ccuNo7eYLVTvwXf3/OI0pcSRFWlj9MQ?= =?us-ascii?Q?it5sqTgc4yy7qmeYehIBduH52nfKgzyqHdcek94QiRMWrzAwSVjHf1nWhGFi?= =?us-ascii?Q?8rLeJDEmaXS63uzzYoBen+kRgA9ODVOkq2G7LEk5S6caX85tzaT+BJsjNzjx?= =?us-ascii?Q?YSFAO2R5Q2oYI7OeLsJ79/41FwruC8TJPWT2yQWjjRvktjKYJpzSPNZbHLJG?= =?us-ascii?Q?dfUHMnubm5mF2hewaAYaaLq19zp/MloPGuSlPBsqCYftZcehKVEcUXwBTBij?= =?us-ascii?Q?cW9VRaftJYs84PwS79m9DE0tEoeq0egBQriXkkDfZXnydxGSllAOK5IoFJPT?= =?us-ascii?Q?gs/SGZH5pLDHaApWeHaOjis1YBk?= X-Microsoft-Antispam-Message-Info: 5FvfwX/E/tu8AI9UQhwkPv9vmtwjcL9xfjClKdfrE9gDayoc/OEIDPna9naR2eY7SnqzVyf2sRQi2priQbQeeRPd2aNj4TQwtSWISow/MChqQ4m15cPRXdp0CflG+m4xK8PhIAiaecu/qoZlDohrOZHhLasFZtnkS5Nthxhg48fy7j/eFkfhIrj0+MdF5xeBL+FgmUuNScordx1Bdx7dvsZMwJpSqNx/AtEubCdM9BpheDUEmrQwA5V1JihxKtdCi8CFgztvQXUxP5LAeJUj2LsEeu6odzXUE8od4MFWwFZCeiypGuOCEUgza6vSJxOf40PyfmPZB2J7b+WpguTTpcL/qj2UhnAJlJLYridTgaw= X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB3128; 6:YF8r57u8EDAnIXf9iY1ym0YbkZyXF/Wjscl7Fag53p71ITBsvwzOk97kW9BHYNDbRSYnKNEuXn6S7SCsHid/P5/K+Iry9aAbwbUlemq/ppL90Ic1uLhFSceQNfRwYFL+9gOXVKJjqLg2GJs4+T9wOBurOO8g00619GQGW7fcENRMXshg2Zmfyk8BVQb7cr1yo78f+z91I5GhwGp1FpugIAjKvevOLldgn1l1tqCN2+ipuSH6X8MLya8+JgYI0lh69rCi3hQg+O/S9fHZvkDcUeMQm6SAsS5ZcVtq8LU/qgJLiv5nfPDsVs5WO1jOhyXIHGZQthQAMd4RzGSlc1r8aZJ+FEdInF7r0HSFow0YJlPdwhZUfSL2hx3xI4JjaPPXUIi0s9gnKV9Oga3sdXXVmKCJ6dJ5w49yvi3E8gq8WApEq3upj8+02glK9BSiriEJ/K36mWew7Ifl4E7Q454FMA==; 5:LBWk0UMKuwbxmFAvS4Ra+8lT71w+QfjkJ0tea/XdJQqbj07Nk0zaL0GdG9muhKpQlcSZ+m8ZhFN+Cl812ylCo409EniOgh7DPsyAJjRvmmOw3+TDcw5bL0jloWFulWflBz0T6670d99zPRyznN5G2DVWLaZKI6dZxt4tpJWXWFc=; 24:2z6GKf9BbeZVQfzNseFkWwJi+ObqSbWbuPmXB8W2sJDZPQ5VW9DQvNuOC0KsXdS08IKlanu7Vo147je0AtDC8huBQwar1+koLTlKMVcbaPU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR03MB3128; 7:CoXGEr4XTHu5F+XOnfzmZJS6ChnDxNK9HianigbpOQFvGD0TsiEUoot1stOHuJlcuLJwpUmvnVu3LgdNqmrGcAC7QHCy6m9Ev4sio98tMpWOJqGF+3PNXInJHyXqQo+dan26VdRX22h4UqzWuuynBRpUV5jzfLIRNYbqe/tVlB04K2WriuWJZdL0bFUO8i0YjIHdDZze7tuPsn1M8DYeNb5YvBcyj1bwcxh0lOuSLBO2Ml5F4/KAgncnTap4tFu5 X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2018 07:30:09.0151 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8452da8c-cb8a-4ad0-f438-08d5ec804a67 X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a; Ip=[137.71.25.55]; Helo=[nwd2mta1.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR03MB3128 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Lars-Peter Clausen This is also part of a long term effort to make the use of mlock opaque and single purpose. This lock is required for accessing device registers. Some operations require multiple consecutive R/W operations, during which the device shouldn't be interrupted. Signed-off-by: Lars-Peter Clausen Signed-off-by: Alexandru Ardelean --- V3 -> V4: * updated comment/description of the lock drivers/iio/frequency/ad9523.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c index ddb6a334ae68..2ab175a0664d 100644 --- a/drivers/iio/frequency/ad9523.c +++ b/drivers/iio/frequency/ad9523.c @@ -274,6 +274,13 @@ struct ad9523_state { unsigned long vco_out_freq[AD9523_NUM_CLK_SRC]; unsigned char vco_out_map[AD9523_NUM_CHAN_ALT_CLK_SRC]; + /* + * Lock for accessing device registers. Some operations require + * multiple consecutive R/W operations, during which the device + * shouldn't be interrupted. + */ + struct mutex lock; + /* * DMA (thus cache coherency maintenance) requires the * transfer buffers to live in their own cache lines. @@ -500,6 +507,7 @@ static ssize_t ad9523_store(struct device *dev, { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + struct ad9523_state *st = iio_priv(indio_dev); bool state; int ret; @@ -510,7 +518,7 @@ static ssize_t ad9523_store(struct device *dev, if (!state) return 0; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); switch ((u32)this_attr->address) { case AD9523_SYNC: ret = ad9523_sync(indio_dev); @@ -521,7 +529,7 @@ static ssize_t ad9523_store(struct device *dev, default: ret = -ENODEV; } - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return ret ? ret : len; } @@ -532,15 +540,16 @@ static ssize_t ad9523_show(struct device *dev, { struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + struct ad9523_state *st = iio_priv(indio_dev); int ret; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); ret = ad9523_read(indio_dev, AD9523_READBACK_0); if (ret >= 0) { ret = sprintf(buf, "%d\n", !!(ret & (1 << (u32)this_attr->address))); } - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return ret; } @@ -623,9 +632,9 @@ static int ad9523_read_raw(struct iio_dev *indio_dev, unsigned int code; int ret; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); ret = ad9523_read(indio_dev, AD9523_CHANNEL_CLOCK_DIST(chan->channel)); - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); if (ret < 0) return ret; @@ -659,7 +668,7 @@ static int ad9523_write_raw(struct iio_dev *indio_dev, unsigned int reg; int ret, tmp, code; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); ret = ad9523_read(indio_dev, AD9523_CHANNEL_CLOCK_DIST(chan->channel)); if (ret < 0) goto out; @@ -705,7 +714,7 @@ static int ad9523_write_raw(struct iio_dev *indio_dev, ad9523_io_update(indio_dev); out: - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return ret; } @@ -713,9 +722,10 @@ static int ad9523_reg_access(struct iio_dev *indio_dev, unsigned int reg, unsigned int writeval, unsigned int *readval) { + struct ad9523_state *st = iio_priv(indio_dev); int ret; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); if (readval == NULL) { ret = ad9523_write(indio_dev, reg | AD9523_R1B, writeval); ad9523_io_update(indio_dev); @@ -728,7 +738,7 @@ static int ad9523_reg_access(struct iio_dev *indio_dev, } out_unlock: - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return ret; } @@ -967,6 +977,8 @@ static int ad9523_probe(struct spi_device *spi) st = iio_priv(indio_dev); + mutex_init(&st->lock); + st->reg = devm_regulator_get(&spi->dev, "vcc"); if (!IS_ERR(st->reg)) { ret = regulator_enable(st->reg);