From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2487038F8A for ; Mon, 18 Sep 2023 11:42:16 +0000 (UTC) Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39394C3; Mon, 18 Sep 2023 04:42:15 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-503012f4e71so2181240e87.0; Mon, 18 Sep 2023 04:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695037333; x=1695642133; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=6VqtxL5s67XQMQv+XRQaf354eoULULKL7lw9uhdGZpw=; b=gsgmlcdiCdNLdcszGJyGO5eL3F7DxOdnWs8X98QTx+Gqq4rbuwjBDQV39aA2fHY+by BKey1St08/vMHpjBJ6FVnz4E4rhy6HMYu03xiglnEMqGXyf7UBpi9sqxlSAx1dfDYyRv m3WpF2Cm174L84Od3Jk+eAHJu8OqqHmruqe06Oq/93h24FnabsLg7Qw7ayueaXdqHN6E 9T5OMfigx2KX8f92ISXMkbGFny1xk63TnHvtF2qvYa7AQZYBdLjRp9cNVyF1ZuELya14 fIrGQoNQRFDC5TLV+X5BgBiDNSOH445fz7ij6nRgF+JtNNBz+Syf0xew85iyrZfhBW4U lp4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695037333; x=1695642133; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6VqtxL5s67XQMQv+XRQaf354eoULULKL7lw9uhdGZpw=; b=TihEdbx9kTgaRVxonXpUGsRitfJxtgsnH6utXvwDLsD1jMhYDi2X6yQMTPLmLRiIWG u3qNyURVgGmpWyQxLYcGai8u+06xLEfDFk6mkJDmazrHxre1SlQtMQnwS0yhaJynyM1R ZIQkHwT86fX0TlN7pO/L7pFir8UFc0idItfbTrNakojgqIgfDVHTEOtiO2FxMkq1lCTG /b/Nj630USGnHAQGPIomsyBUJMc0qeibeGpAR/eaNsdURndahVXsMQ59C4y3GfkXJ3wJ WnxRbq5E0QTwzghiZPwb32bl/LvWopg308Wab9tqBVz5DdUMKfti53hMQBiNbbCSvF1J jlmA== X-Gm-Message-State: AOJu0Yyaxr8tUQvpp+7D2HnTASAMj39CYPBr2CvjBOwgf7zQP/wE70hw rKgUKA+/mU8iFn1BTOogQCI= X-Google-Smtp-Source: AGHT+IFafyU+jaXJvIwyzFuHlrYPrdMRQAJYuf4EZPKNBQhmlWesULuoeRipZvWIIhfCWnQzdWpPdQ== X-Received: by 2002:a05:6512:1319:b0:500:d96e:f6eb with SMTP id x25-20020a056512131900b00500d96ef6ebmr3906867lfu.19.1695037332892; Mon, 18 Sep 2023 04:42:12 -0700 (PDT) Received: from ?IPV6:2001:14ba:16f8:1500::3? (dc78bmyyyyyyyyyyyyybt-3.rev.dnainternet.fi. [2001:14ba:16f8:1500::3]) by smtp.gmail.com with ESMTPSA id d27-20020ac25edb000000b004ff91a94156sm286576lfq.121.2023.09.18.04.42.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Sep 2023 04:42:12 -0700 (PDT) Message-ID: <4084c827-abf6-0f15-7957-13db50912943@gmail.com> Date: Mon, 18 Sep 2023 14:42:11 +0300 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH 2/3] iio: pressure: Support ROHM BU1390 Content-Language: en-US, en-GB To: Jonathan Cameron Cc: Matti Vaittinen , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Angel Iglesias , Andy Shevchenko , Andreas Klinger , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <08f7085ba1af2fae21c942f6c20a94c237df53ba.1694001462.git.mazziesaccount@gmail.com> <20230910142225.5863a850@jic23-huawei> <20230917102615.618dd01a@jic23-huawei> From: Matti Vaittinen In-Reply-To: <20230917102615.618dd01a@jic23-huawei> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net On 9/17/23 12:26, Jonathan Cameron wrote: > On Thu, 14 Sep 2023 14:47:44 +0300 > Matti Vaittinen wrote: > >> On 9/10/23 16:22, Jonathan Cameron wrote: >>> On Wed, 6 Sep 2023 15:37:48 +0300 >>> Matti Vaittinen wrote: >>> >>>> Support for the ROHM BM1390 pressure sensor. The BM1390GLV-Z can measure >>>> pressures ranging from 300 hPa to 1300 hPa with configurable measurement >>>> averaging and internal FIFO. The sensor does also provide temperature >>>> measurements. >>>> >>>> Sensor does also contain IIR filter implemented in HW. The data-sheet >>>> says the IIR filter can be configured to be "weak", "middle" or >>>> "strong". Some RMS noise figures are provided in data sheet but no >>>> accurate maths for the filter configurations is provided. Hence, the IIR >>>> filter configuration is not supported by this driver and the filter is >>>> configured to the "middle" setting (at least not for now). >> >>>> + >>>> +static irqreturn_t bm1390_irq_thread_handler(int irq, void *private) >>>> +{ >>>> + struct iio_dev *idev = private; >>>> + struct bm1390_data *data = iio_priv(idev); >>>> + int ret = IRQ_NONE; >>>> + >>>> + mutex_lock(&data->mutex); >>>> + >>>> + if (data->trigger_enabled) { >>>> + iio_trigger_poll_nested(data->trig); >>>> + ret = IRQ_HANDLED; >>>> + } >>>> + >>>> + if (data->state == BM1390_STATE_FIFO) { >>> >>> Can this and trigger_enabled be true? >> >> Thanks for asking this question. Intention was that these are mutually >> exclusive. However, I think that the check >> if (iio_device_get_current_mode(idev) == INDIO_BUFFER_TRIGGERED) >> in bm1390_buffer_postenable(), before calling the bm1390_fifo_enable() >> is not 100% race free. >> >> I, however, like the idea of having this check in the buffer-enable >> function - I think it makes the design much more obvious. What I will do >> is adding another check for: >> if (data->trigger_enable) { >> ret = -EBUSY; >> goto unlock_out; >> } >> >> inside the bm1390_fifo_enable() to the section which holds the mutex. > > You could make the exclusive nature obvious in the thread_handler by using an > else if () above. Right. Thanks. > >> >> >> Yours, >> -- Matti >> >> >> > -- Matti Vaittinen Linux kernel developer at ROHM Semiconductors Oulu Finland ~~ When things go utterly wrong vim users can always type :help! ~~