From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754125AbcEaNUc (ORCPT ); Tue, 31 May 2016 09:20:32 -0400 Received: from www381.your-server.de ([78.46.137.84]:50652 "EHLO www381.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751505AbcEaNUa (ORCPT ); Tue, 31 May 2016 09:20:30 -0400 Subject: Re: [PATCH 2/7] iio: adc: ad7791: claim direct mode when writing frequency To: Jonathan Cameron , Daniel Baluta , Alison Schofield References: Cc: "Hennerich, Michael" , Hartmut Knaack , Peter Meerwald-Stadler , "linux-iio@vger.kernel.org" , Linux Kernel Mailing List From: Lars-Peter Clausen Message-ID: <574D8F92.4040405@metafoo.de> Date: Tue, 31 May 2016 15:20:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Authenticated-Sender: lars@metafoo.de Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/29/2016 07:06 PM, Jonathan Cameron wrote: > On 25/05/16 11:34, Daniel Baluta wrote: >> On Tue, May 24, 2016 at 10:16 PM, Alison Schofield wrote: >>> Driver was checking for direct mode and trying to lock it, but >>> left a gap where mode could change before the desired operation. >>> Use iio_device_claim_direct_mode() to guarantee device stays in >>> direct mode. >>> >>> Signed-off-by: Alison Schofield >>> Cc: Daniel Baluta >> >> Looks good to me. We could use an Acked-by from Lars here. >> >> Acked-by: Daniel Baluta > This one is a little more interesting. I wonder if we wouldn't be better > off taking the lock for the whole function rather than dropping it for > short periods. It will only be locked once. sysfs_streq() will only match for a single item. But you are right the code could be refactored to make that more clearer. First run the lookup look and then apply afterwards.