From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8D422D0618 for ; Wed, 14 Jan 2026 12:19:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768393187; cv=none; b=DqOcHtY89NZY9oyYtm6zeCiEPWatBM15B5ouVYBCgsAi2SmPyJjjx3bq4K39AEMVAR4uiUTH8yeVaCIaYWkNOZbGMOLyLVSZ4QyRq+/uPN+LZ0rJOVKsQGAQVDQVzYQcD64vTN3Ohc0BCMckfY0vJqw5jVMsEkLHAeQ0hvP8j6E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768393187; c=relaxed/simple; bh=Ul9uRDIuNAEZD7yUfXJ+ahp5uEknivcplS5wg/nPt7I=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=o1umcNM4AusWYpjUC6ai70g8Bx8aMEM/Orwj1P7De10P0RBYKgsm+XiSH2ztQp9eNoNi9nCLdSXnzxL9j6bruV/GNSYASiY+SKR5+0dSF6OqvS/9EziFWfG/uYj5y+LUCYLG0m0gJWyheNZ3oNlcu+UyQ298xP1t4agcB64av3g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JTk3dYSS; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JTk3dYSS" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-47795f6f5c0so54103255e9.1 for ; Wed, 14 Jan 2026 04:19:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768393184; x=1768997984; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=76S1+zeUbIQhxKsOZuHnISrzUIHK4b1ifpotuDCkHKk=; b=JTk3dYSSjnezrKnrnnth3+CxtpQ0TLkVr5B41iZ5c1gB/wKJ/E7eWBjwVE3OEyIDJB jAm5r3j3GrPc3lqLjkWEqSCn5k8xJD7m2SEOPOlm+oeBrQjzYE1ZOZ3RKvV733sreOhC rQv1eMXzSIRlnLb3zst2LZ9vN4Mm+25rzZ73AIqsCWxK3VGaQVJKc7PI1D2XGTMSu57B /BE+PITPyegEFUKa6dusTTK7xlBMhRybn7cp9K9V5VevTjUTha1GiKCKYv+Q7OC8ImR5 r0D29fOEBiC9Wre5qM7gDA0zVYL6GhJ/4WvR7XrpPowl4468vu/yXGUs3x2hfslGcPfW lX5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768393184; x=1768997984; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=76S1+zeUbIQhxKsOZuHnISrzUIHK4b1ifpotuDCkHKk=; b=htnJZXimh5P9JXH4UJkOI1CWIEFhzoHcsrxxt97wX06qUGHUfrvuxqlZn2wTMKZahg DRhxK7rwqXXEVU0zMQEbgTFr5CERhDUv3ki8SuLEf6AGSVTPAOpErpDhVCpeUzNx8/W5 rVjZmPzxTnzpJcDwCaLOpb/kKkjE73uosNF82gs49h+cCYyfLaqOtqI47KtyH1ItIi5R TrODeLfOzrRihzr4cjKhTCw42wS694H+rYY4wawg0XpinOftnv2LBkGDgXjYOFjEvy+T ruYkfMINgnTrYHtBdGxnaskbelo6jYR/paYnR1OJEqPcNXftJ256eTLV/OP84b8tjKSG p+iA== X-Forwarded-Encrypted: i=1; AJvYcCUcjmHTGFfeiDScZO9IF2RV45/cJC3x274csJdvTe67kFsoqTUqTjHF+Gb53jvB3ljoLsILHacvQHWgN98=@vger.kernel.org X-Gm-Message-State: AOJu0Yzb+4NQAGllWLB4BQ/2YE8x9fTS5tTJLgt7h34KuqlNYh6pN8SV NfhV/5GQtesE0jIqN8+1k2Ho5uWJppMgBu111/s0E5QROSMLQXCT+opf X-Gm-Gg: AY/fxX5OqTRQsLzL8ETUux06sit3xcaY5ux1hJKXENy7GrMrdf68Cnxjy5pngQ/79wf j6q8AD7jjdfnTH5Ror9iUZTJM9Vna94uGiR5KWywHlxFtGD3FllIpUMZVehguQ0gQGTtlSQ3prq ujSrt1oCZ9G8n8SnDoyOMOZN504S60cIDy1xloFHFBox1dw41YXpPWIftDSg1RmMEafoZxvdQ+w yd2SSZ0r9FV1bBwsEko0yiHb7IJLEEMDPXBwsv9WS7iT6O+i+lzWHZYINe07XaGpOnH9oF+lYn2 XMAX6Dgpfov5odUT3H+uX4GMrfH1Q/YDSDCzfKGKbVT0U3yt1uf4o1+Y3eSJKZc4Vcu663Kkz6P SXOEAfLEF/IpaqN+zlAgQ03F5VgrpIwZa0G0IuNOwJ3SMuHuM06lh2DYJWZH5pwkpKDoC+udKqn s60d2dTsNndPP/+05LEhA= X-Received: by 2002:a05:600c:6287:b0:477:79f8:daa8 with SMTP id 5b1f17b1804b1-47ee3391744mr35341065e9.17.1768393183972; Wed, 14 Jan 2026 04:19:43 -0800 (PST) Received: from [192.168.1.187] ([161.230.67.253]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47ee55c5413sm28933635e9.6.2026.01.14.04.19.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jan 2026 04:19:43 -0800 (PST) Message-ID: Subject: Re: [PATCH v3 2/4] iio: industrialio-backend: support backend capabilities From: Nuno =?ISO-8859-1?Q?S=E1?= To: Tomas Melin , Michael Hennerich , Nuno Sa , Lars-Peter Clausen , Jonathan Cameron , David Lechner , Andy Shevchenko , Olivier Moysan Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 14 Jan 2026 12:20:26 +0000 In-Reply-To: <20260114-b4-ad9467-optional-backend-v3-2-d2c84979d010@vaisala.com> References: <20260114-b4-ad9467-optional-backend-v3-0-d2c84979d010@vaisala.com> <20260114-b4-ad9467-optional-backend-v3-2-d2c84979d010@vaisala.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Wed, 2026-01-14 at 10:45 +0000, Tomas Melin wrote: > Not all backends support the full set of capabilities provided by the > industrialio-backend framework. Capability bits can be used in frontends > and backends for checking for a certain feature set, or if using > related functions can be expected to fail. >=20 > Capability bits should be set by a compatible backend and provided when > registering the backend. >=20 > Signed-off-by: Tomas Melin > --- > =C2=A0drivers/iio/industrialio-backend.c | 17 +++++++++++++++++ > =C2=A0include/linux/iio/backend.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 | 17 +++++++++++++++++ > =C2=A02 files changed, 34 insertions(+) >=20 > diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industriali= o-backend.c > index 447b694d6d5f72dc6f018b1697fdb88e555bd61e..0a98fdd5df9db6cc233af819a= c5243ba8cd5266f 100644 > --- a/drivers/iio/industrialio-backend.c > +++ b/drivers/iio/industrialio-backend.c > @@ -56,6 +56,7 @@ struct iio_backend { > =C2=A0 void *priv; > =C2=A0 const char *name; > =C2=A0 unsigned int cached_reg_addr; > + u32 caps; > =C2=A0 /* > =C2=A0 * This index is relative to the frontend. Meaning that for > =C2=A0 * frontends with multiple backends, this will be the index of thi= s > @@ -774,6 +775,21 @@ int iio_backend_extend_chan_spec(struct iio_backend = *back, > =C2=A0} > =C2=A0EXPORT_SYMBOL_NS_GPL(iio_backend_extend_chan_spec, "IIO_BACKEND"); > =C2=A0 > +/** > + * iio_backend_has_caps - Check if backend has specific capabilities > + * @back: Backend device > + * @caps: Capabilities to check > + * > + * RETURNS: > + * Non-zero value if backend has all the requested capabilities, > + * 0 otherwise. > + */ > +int iio_backend_has_caps(struct iio_backend *back, u32 caps) > +{ > + return back->caps & caps; > +} > +EXPORT_SYMBOL_NS_GPL(iio_backend_has_caps, "IIO_BACKEND"); > + > =C2=A0static void iio_backend_release(void *arg) > =C2=A0{ > =C2=A0 struct iio_backend *back =3D arg; > @@ -1114,6 +1130,7 @@ int devm_iio_backend_register(struct device *dev, > =C2=A0 > =C2=A0 back->ops =3D info->ops; > =C2=A0 back->name =3D info->name; > + back->caps =3D info->caps; It would be nice to sanity check the registered backend here. If it adverti= ses some capability, then better to support the corresponding op. > =C2=A0 back->owner =3D dev->driver->owner; > =C2=A0 back->dev =3D dev; > =C2=A0 back->priv =3D priv; > diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h > index 7f815f3fed6ae34c65ffc579d5101020fc9bd336..8a0df8e980e910ac2d5398275= 963dc5adf077c8a 100644 > --- a/include/linux/iio/backend.h > +++ b/include/linux/iio/backend.h > @@ -84,6 +84,20 @@ enum iio_backend_filter_type { > =C2=A0 IIO_BACKEND_FILTER_TYPE_MAX > =C2=A0}; > =C2=A0 > +/** > + * enum iio_backend_capabilities - Backend capabilities > + * Backend capabilities can be used by frontends to check if a given > + * functionality is supported by the backend. Capabilities are loosely > + * coupled with operations, meaning that a capability requires certain > + * operations to be implemented by the backend. > + * @IIO_BACKEND_CAP_CALIBRATION: Backend supports calibration. Needs at = least > + * iodelay_set(), test_pattern_set() data_sample_trigger(), chan_status(= ) > + * and data_format_set() operations implemented. I would not be so explicit as the above. It is very specific to the ad9467 = process. There are other devices with other ways of calibrating the interface and I = don't want people to keep adding things into the comment. So it needs to be a bit more= generic and we should also be more explicit about it being about calibrating the da= ta interface. > + */ > +enum iio_backend_capabilities { > + IIO_BACKEND_CAP_CALIBRATION =3D BIT(0), > +}; > + > =C2=A0/** > =C2=A0 * struct iio_backend_ops - operations structure for an iio_backend > =C2=A0 * @enable: Enable backend. > @@ -179,10 +193,12 @@ struct iio_backend_ops { > =C2=A0 * struct iio_backend_info - info structure for an iio_backend > =C2=A0 * @name: Backend name. > =C2=A0 * @ops: Backend operations. > + * @caps: Backend capabilities. @see iio_backend_capabilities > =C2=A0 */ > =C2=A0struct iio_backend_info { > =C2=A0 const char *name; > =C2=A0 const struct iio_backend_ops *ops; > + u32 caps; > =C2=A0}; > =C2=A0 > =C2=A0int iio_backend_chan_enable(struct iio_backend *back, unsigned int = chan); > @@ -235,6 +251,7 @@ int iio_backend_read_raw(struct iio_backend *back, > =C2=A0 long mask); > =C2=A0int iio_backend_extend_chan_spec(struct iio_backend *back, > =C2=A0 struct iio_chan_spec *chan); > +int iio_backend_has_caps(struct iio_backend *back, u32 caps); Not what David suggested and I do agree with him FWIW. - Nuno S=C3=A1