From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796026892; b=NblWI/+2imNosOrOrvLnN+Fs9s0G17JIQyiHYOa1m/IaB0X4IUKS+vqiTqqTRh+i/DHH g8HarTAwozVYuNWH2V5tOaIBsaaCtDacKpKj7xKt1Ev4KO8up655v9bi9dKtmfJJGjZ53 5sc0FyQ5hMy9d1Cis9XKB3WfV8GHf0eTNg6kEWs5m2nOAWZO+b+AgNOgqkerd4cY9QZBW AgQcdvcnb8N4xyVYyiOTFbxIj96exyowGeWC2xCv7cJUHIiF6IPMVZ+mrnNff61WbwILX GtjZO/Q5rJfAqcmvOBmRkwT1g59Al9JhEm0DvAyXHoz2ZUIFaAl4BfqL+py/0q0Pm7A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796026892; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=zeTkGYbTBPlDHMwWRHjZ7XQcXiKd3qfFdBuLlwj0GPw=; b=4rVTMPqMQ6Lz6M9Ui4Pw2m5WNXM4Ip/MCqpXWcw3+rYY0bMkq8KL+kUAGfhrG/TIyBpH ySNZ/O/7/2EcQIpbbdK8OraJK0ywtQ6aptcsBWw1FSSjk8Kv/E7POZnSWYOlCQTzi8WQF LVsBMTXQn2dPmp9AtFh/5kIE+ciSXc5iPFOVTc5trcBliDkhFSRj+OqsqJIraahL2tx33 sMNQq/gaefdNDt1FfHHEfHCb9Qai3hs+t7Hd1Wqr3t+yYBNB6EHyQ2Ulb+0pFhV5+IBVZ bg5Tdv5VGQGL7yu7TsYE6DP+ZvEo3MuFdmoFWp/WSuNxXtMxAViYIyjEic9MbzH1A5g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Qm2j15Bc; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A36E1606A31C for ; Mon, 30 Nov 2026 08:21:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Qm2j15Bc Received: by smtp.kernel.org (Postfix) with ESMTPSA id B60621F00897; Mon, 30 Nov 2026 08:21:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796026892; bh=zeTkGYbTBPlDHMwWRHjZ7XQcXiKd3qfFdBuLlwj0GPw=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Qm2j15BcDJNzmhbDnS1wqYZ2jtEPgbj1hUqX+M0YRqQDJL/txxAbyFG0vmWY67Let mEZGkBjtYZQeqWN4dnBCaQi0NaKWRKGMKJz6bBG2ORy3gORNVm0m7GniHVewfQF3D5 AlxU/QNSRbFgoHoeh4DJj3l8dOHKB1w0oJ5FvEEHhAD272ho+tsw+lFdugmnxq3RSX EdBq8jer3GHY1gtqeYN7kKT0MHQ4al5iq/Bb8Le2EKGnbZSDeXUAz/5wMeAno++K/H JxWdIgDE0GCDaso/aHNasjKOD06H5ZIyJx9w3FI9kAUTZzQI5upR6V4y66fDGg0ayU 94vei9cWFc4aA== Date: Mon, 30 Nov 2026 09:21:30 +0100 From: Lorenzo Bianconi To: Jonathan Cameron Cc: linux-iio@vger.kernel.org, linux@analog.com, David Lechner , Nuno =?iso-8859-1?Q?S=E1?= , Andy Shevchenko , Michael Hennerich , Radu Sabau , Song Qiang , Siratul Islam , Alisa-Dariana Roman , Ramona Bolboaca , Jean-Baptiste Maneyrol , Jonathan Cameron Subject: Re: [PATCH 09/15] iio: humidity: hts221: use iio_trigger_set_default_immutable() Message-ID: References: <20261130-messing-immutable3323-v1-0-f44aa3082603@oss.qualcomm.com> <20261130-messing-immutable3323-v1-9-f44aa3082603@oss.qualcomm.com> X-Mailing-List: linux-iio@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="BZDVsvLQaMe1OKwC" Content-Disposition: inline In-Reply-To: <20261130-messing-immutable3323-v1-9-f44aa3082603@oss.qualcomm.com> --BZDVsvLQaMe1OKwC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Nov 30, Jonathan Cameron wrote: > From: Jonathan Cameron >=20 > Use iio_trigger_set_default_immutable() rather than taking a reference > to the trigger in probe(). The IIO core now takes the reference during > iio_device_register(), so it is not leaked if probe() fails after the > trigger is set up. >=20 > Previously the reference was taken even if devm_iio_trigger_register() > failed, hitting the WARN_ONCE() in iio_trigger_get() for an unregistered > trigger. Return the error before setting the default trigger instead. >=20 > The driver only accepts its own data ready trigger and used > hts221_validate_trigger() to enforce that. That callback is equivalent > to iio_validate_own_trigger(). An immutable trigger gives the same > guarantee. >=20 > Potential userspace ABI impact. Previously the trigger could be cleared > by writing an empty string, or any name that is not a registered trigger, > to current_trigger. That now fails with -EPERM, as does selecting a > different trigger, which previously failed with -EINVAL. Writing the name > of the current trigger still succeeds. Userspace software may exist that > is dependent on the tear down behavior however that userspace would not > have worked with the existing immutable triggers so needs fixing anyway. >=20 > Signed-off-by: Jonathan Cameron Reviewed-by: Lorenzo Bianconi > --- > drivers/iio/humidity/hts221_buffer.c | 6 +++--- > drivers/iio/humidity/hts221_core.c | 9 --------- > 2 files changed, 3 insertions(+), 12 deletions(-) >=20 > diff --git a/drivers/iio/humidity/hts221_buffer.c b/drivers/iio/humidity/= hts221_buffer.c > index ee81d5e73ab5..5e6f9c9eb08d 100644 > --- a/drivers/iio/humidity/hts221_buffer.c > +++ b/drivers/iio/humidity/hts221_buffer.c > @@ -134,10 +134,10 @@ int hts221_allocate_trigger(struct iio_dev *iio_dev) > hw->trig->ops =3D &hts221_trigger_ops; > =20 > err =3D devm_iio_trigger_register(hw->dev, hw->trig); > + if (err) > + return err; > =20 > - iio_dev->trig =3D iio_trigger_get(hw->trig); > - > - return err; > + return iio_trigger_set_default_immutable(iio_dev, hw->trig); > } > =20 > static int hts221_buffer_preenable(struct iio_dev *iio_dev) > diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/ht= s221_core.c > index 47a10884d812..2b5e71aa7b2e 100644 > --- a/drivers/iio/humidity/hts221_core.c > +++ b/drivers/iio/humidity/hts221_core.c > @@ -522,19 +522,10 @@ static int hts221_write_raw(struct iio_dev *iio_dev, > return ret; > } > =20 > -static int hts221_validate_trigger(struct iio_dev *iio_dev, > - struct iio_trigger *trig) > -{ > - struct hts221_hw *hw =3D iio_priv(iio_dev); > - > - return hw->trig =3D=3D trig ? 0 : -EINVAL; > -} > - > static const struct iio_info hts221_info =3D { > .read_raw =3D hts221_read_raw, > .write_raw =3D hts221_write_raw, > .read_avail =3D hts221_read_avail, > - .validate_trigger =3D hts221_validate_trigger, > }; > =20 > static const unsigned long hts221_scan_masks[] =3D {0x3, 0x0}; >=20 > --=20 > 2.56.1 >=20 --BZDVsvLQaMe1OKwC Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCaw0yCgAKCRA6cBh0uS2t rJj/AQDBO+dpZWLyu8rf+Z+46ABLNIgWXakElpXXzloqkRvzTAEA82B56cGMbKmi U11ALA00hJdnDx4yeRsnaMWFiLYdBwE= =wHzK -----END PGP SIGNATURE----- --BZDVsvLQaMe1OKwC--