From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-244106.protonmail.ch (mail-244106.protonmail.ch [109.224.244.106]) (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 0E0A047ECF7 for ; Mon, 7 Sep 2026 16:37:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.224.244.106 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788799023; cv=none; b=OPIRCDGh+spXZ+hkfBYIparWuVJTFO2q4LiRLNadBZ/JNTCh6fx471PpCcDX3CjRBL9iTj6OkYENkYTzXHaVcPLrr4xQ8FfVPGta0rEqWrZAfkehkQrUS2G1I6IePJUXAtZAwARm7WRvb8bq5i5li7YVSpixUDpXkWjNX6U3fGU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788799023; c=relaxed/simple; bh=T+cZQoxjvvdKvEz4jWQUjvixBBJodZHlypMocmDmZKA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=npGr/yN7KtxkGQUdF52vwD/8digAdmrAysnUTpBWEiVtQDNuqINpdQmblCVKEfyQmzwxnnB3vuG1NdEDthDyC+Mo31YuNQ5TL/atZZ17eiXXU52B59ZpnehXI+i2M49Cko+VvEEpPm6i3RlFfz8nNMzaGq8nMENc/aa8jzS69y8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=geanix.com; spf=pass smtp.mailfrom=geanix.com; dkim=pass (2048-bit key) header.d=geanix.com header.i=@geanix.com header.b=EZQ0J6LB; arc=none smtp.client-ip=109.224.244.106 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=geanix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=geanix.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=geanix.com header.i=@geanix.com header.b="EZQ0J6LB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=geanix.com; s=protonmail; t=1788799018; x=1789058218; bh=qXaUM0YuwV9bgSLoOldbbvDAXx7PzgYVmcb6b0j/A0M=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID:From:To: Cc:Date:Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=EZQ0J6LB4ApWRXOrKL02IRjf0z55a9PdevcBQZQjLcihPtmh4Q4xGM/33aS6bHtpu X5GiCP/DIuBlXDHS1JuSo+affe1h7qUOCFnG0pSmGAnSHJ4dMYV8WHVb2KDmeXWT2L ig10w3RKvpdFSZEbyQKINhhBK/ZZjseMbp6X1C1vvXCNdgoOIuqvapamDZ1JHtnpX0 oBlYLYrpU6tWHQ7S/ri99dICDIbNQt5nxEm6bdAxNBWiLuJdsLOEF6YYp15oG1mDWk ewQyzbqBmu8iNCDTmf5RIy9CsSDLeWqDY3NTywcRuVKUAVacSQPg15AeZ7rk35uKP9 qaZ8PUHoPmqNg== X-Pm-Submission-Id: 4hdt5511wbz2ScWg From: Esben Haabendal To: "Joshua Crofts" Cc: "Jonathan Cameron" , "Lars-Peter Clausen" , "Rob Herring" , "Krzysztof Kozlowski" , "Conor Dooley" , "Martin Kepplinger" , "Sean Nyekjaer" , "David Lechner" , Nuno =?utf-8?Q?S=C3=A1?= , "Andy Shevchenko" , "Martin Kepplinger" , , , Subject: Re: [PATCH v8 9/9] iio: accel: mma8452: Support interrupt sharing In-Reply-To: <20260907171022.00007100@gmail.com> References: <20260907-mma8452-open-drain-v8-0-c17407e22118@geanix.com> <20260907-mma8452-open-drain-v8-9-c17407e22118@geanix.com> <20260907171022.00007100@gmail.com> Date: Mon, 07 Sep 2026 18:36:56 +0200 Message-ID: <87ecf581cn.fsf@geanix.com> User-Agent: Gnus/5.13 (Gnus v5.13) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain "Joshua Crofts" writes: > On Mon, 07 Sep 2026 16:51:04 +0200 > Esben Haabendal wrote: > >> Adding support for sharing interrupt line with other device requires the >> interrupt handler to handle runtime PM suspension properly, ignoring the >> irq if the device is suspended (maybe even off). And while at it, we use >> the PM reference to ensure we do not get suspended while processing an irq. >> >> In order to prevent the chip from raising irq while suspended (that is when >> using fixed regulator, where suspend just means setting the device in >> STANDBY mode), we disable all interrupt sources by clearing CTRL_REG4, and >> then restores the value again when resuming. >> >> With that in place, it is safe to add the IRQF_SHARED flag. >> >> Keep in mind that the device by default is using push-pull for the irq pin, >> which might require additional hardware design to allow interrupt sharing. >> >> Signed-off-by: Esben Haabendal >> --- > > ... > >> @@ -1784,29 +1796,62 @@ static void mma8452_remove(struct i2c_client *client) >> #ifdef CONFIG_PM >> static int mma8452_runtime_suspend(struct device *dev) >> { >> - struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); >> + struct i2c_client *client = to_i2c_client(dev); >> + struct iio_dev *indio_dev = i2c_get_clientdata(client); >> struct mma8452_data *data = iio_priv(indio_dev); >> int ret; >> >> - scoped_guard(mutex, &data->lock) >> - ret = mma8452_standby(data); >> + guard(mutex)(&data->lock); >> + > > Hmm, this patch might benefit from breaking it into multiple patches > (the change from scoped_guard to guard, the local pointers etc. along > the fact that these aren't mentioned in the commit message), but > that's up to Jonathan. I will try and improve the commit message. I don't think that breaking it up makes a lot of sense. The change from guard() to scoped_guard() is closely tied to the rest of the changes. At least I am not sure if it is even sane to make that change without the rest of this commit. It might be fine. Probably is, but is it worth to risk causing trouble for older kernels? Regarding the local pointers, I assume you mean the added struct i2c_client and struct device pointers. They are only used in the added code, so I don't see how I can split that out in a meaningful way. I don't mind making such changes, I just don't see what I am expected to do. /Esben