Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4316867imj; Tue, 12 Feb 2019 13:43:41 -0800 (PST) X-Google-Smtp-Source: AHgI3IYNpoB2BXZChtOX9bjGKzptPBaPty/+X3XEzyO3HhEXLQIDKMvQnZ4EZ5eHWzGhcwWb+1p3 X-Received: by 2002:a17:902:b214:: with SMTP id t20mr5962995plr.248.1550007821387; Tue, 12 Feb 2019 13:43:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550007821; cv=none; d=google.com; s=arc-20160816; b=J//p78jE3shkDCbhZyBqIeyFbwnPQFQdMkvmD7p6t/ihVvY7458YMi+Bd+Kt2iRYL7 01A28mXzKAEx+bnyrmQoDGbb7Npa91lUta5GFDs3LCs/BY9JUMOWG9BOE5KOp9lizhnF SIjiIbn51iUoyUvWGzeXwEY5gKkl7OlrJN389b5lQ+wfNgCRX2YILKSw/1XI16IE0TUC yKlqmsCFBGt8ufZsHqK3hcXIp33HxLPpU1eH/fVtE3VpOO+6F6DBK/QYoI63f6EQEKcm BSJRwAet1Kx4DaCyq2ymu40guw8i723YkNYRoPCU/iMdsoVNeJJqydHLeG2DBabuQ654 H+nQ== 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=9rIi2NUVDQqdNxtAYeAG+ZutJ1yR8KSZmxX/Bs/tZsw=; b=hfUKBMIHjb7eotgL/4Lsf+4NcjUwakqrGCr17MUeaMS47z8EcNOnDn/rAN16gC7Gey Fyib9bctUvEwWjjosAKmHYjAVNUKS7kwETzpkFfjBGbvYKkG5xOWK7Gyq3abrFkqBchc OUEQM1OPN2dww1XRvXVXrLjai6BU/RQIQapucOpyjUswKQowVa4U393PcUWTyfg+fLXr nWC03SirJpdpJemLT1h1YRXYSuQzQpDWoIc4T0oC6hOAP0S5lG1AMrbAXc6DROcty+qm Y20VPO6v+NiOmhq93P/gNjtcPGGB73IFaCmJxUOQUfMSYvK5Znt7Bs4mUpILJNTGyz2+ 9RtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=skkl4+V5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id c12si2251873pfo.86.2019.02.12.13.43.02; Tue, 12 Feb 2019 13:43:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=skkl4+V5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1731212AbfBLUfv (ORCPT + 99 others); Tue, 12 Feb 2019 15:35:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:45650 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727733AbfBLUfu (ORCPT ); Tue, 12 Feb 2019 15:35:50 -0500 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (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 916E3222BE; Tue, 12 Feb 2019 20:35:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550003750; bh=xgjB4tBcTRaeShPv0xeqGqF5KleQWyPU2pH73C5XnY0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=skkl4+V5+/jDplhAwrIZqFuKe+YGrQakJWpR51wr/2VB39Xi/2g76+4/N8QEGm8Hk XjQeooV1l2v4HjUAi+8Gc50yQ5SfY+SlKmynCVLhg3x1DhT53eopK8UX2wMuat6BCO YQd33A0fg88psDvO/H7yswZ2G1oOrnx/WT2xZfyM= Date: Tue, 12 Feb 2019 20:35:43 +0000 From: Jonathan Cameron To: Justin Chen Cc: David Lechner , linux-iio@vger.kernel.org, linux-gpio@vger.kernel.org, bcm-kernel-feedback-list , Florian Fainelli , bgolaszewski@baylibre.com, Linus Walleij , knaack.h@gmx.de, lars@metafoo.de, Peter Meerwald-Stadler , linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: adc: ti-ads7950: add GPIO support Message-ID: <20190212203544.181b8c19@archlinux> In-Reply-To: References: <1549653856-47409-1-git-send-email-justinpopo6@gmail.com> <20190209170042.69a78684@archlinux> <2e692086-4be5-10ea-34b0-4444995c4275@lechnology.com> <20190211200557.7648d447@archlinux> X-Mailer: Claws Mail 3.17.3 (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 Mon, 11 Feb 2019 12:17:37 -0800 Justin Chen wrote: > On Mon, Feb 11, 2019 at 12:06 PM Jonathan Cameron wrote: > > > > On Sat, 9 Feb 2019 12:56:11 -0600 > > David Lechner wrote: > > > > > On 2/9/19 11:00 AM, Jonathan Cameron wrote: > > > > Nope. This is a state lock used to protect against transitions between > > > > different modes of the IIO device (buffered vs polled), it > > > > isn't suitable for general use. > > > > > > > > The driver should be modified to handle that correctly. > > > > We have iio_claim_direct_mode etc that deal with the case > > > > where a device can't do certain operations whilst in buffered > > > > mode. Note it can fail and should. > > > > > > > > Seems there are more drivers still doing this than I thought. > > > > If anyone is bored and wants to clean them out, that would be > > > > most appreciated! > > > > > > > > If you need locking to protect a local buffer or the device > > > > state, define a new lock to do it with clearly documented > > > > scope. > > > > > > Just as a reminder, there is a use case for this particular > > > chip that requires buffered mode and direct mode at the same > > > time. > > > > > > https://patchwork.kernel.org/patch/10539021/ > > > https://patchwork.kernel.org/patch/10527757/ > > > > Thanks, I had indeed forgotten that entirely. > > So it should have a local lock and not take mlock explicitly at all. > > > Thanks for all the feedback. > So If I am understanding this correctly. I should create a local lock > to synchronize three different type of transactions (buffered, direct, > gpio). > I do not want to use iio_claim_direct_mode because that doesn't allow > simultaneous use of buffered mode and direct mode, which is necessary > for this driver because of the above mentioned patch. No, you should create a local lock to do just one thing. Protect the buffers used in those transactions. There is no need to protect anything else explicitly. On some devices there are multiple transaction writes, but I don't recall that being the case here. Jonathan > > Justin > > Jonathan