Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp399223rwb; Sat, 1 Oct 2022 01:26:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6AUD3WKC41NIl8SsxSUaMKWuLVE+m0XrG003v0578aI6unfdpIz3hitjUEbMSh9/z/1NyM X-Received: by 2002:a05:6402:401b:b0:453:f519:94ad with SMTP id d27-20020a056402401b00b00453f51994admr11189771eda.144.1664612811890; Sat, 01 Oct 2022 01:26:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664612811; cv=none; d=google.com; s=arc-20160816; b=rvzX0MoErht80x9gIhVqj0YWKqv2u0DPYyoPGAkJU5ZmmoHtPZ4ek0niJsNu/zmNAf gdrKne/Ve3tny2M/0SAJikrqDGiON9snh3nWJfff04jR5/IhKIIOhQUfnQ6MHHyvxTH7 l8/lZroTgGczKCfXLQrjAsy4muedwSCRD7R8AYk7H1erhxTVvJfPWB1QKI2VSncPX1Nt HL3Yx3Y5enz6wSaVARW6411tEdrDH8z2aS/MpRxVrvg23/sPf1sDaWYZhsdIjwr823GC WezDNZP9viYcPiF9MGP4UM5EzGLxNdJJoRaw8yM+LwyFI1AokhVKowxO7SMgN4lk9aur 8xgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=HugR/NLJXFQfozYZ66e+YMwVjhph0I2XzzQk2oljY3o=; b=PiomxeQlC7Jsr8NpZ8NNOEFwFJauU/+9X1g4zkXIo1hmx0kuy974GRPaWtUhyUhFn6 YK2GUTXZ0i8H4ogSDx8gZ3y6yKuQaYS+BaSMc3j2Qqp8/d1ikHXodD6MA23eN8z9lsXW 3YV/D2+g9HHWqUvhZ4/WWsL2t7/Ye8vvSPk3/ChCdn8g7234g4O/LofwrBtTXBKxwEJG ZH9K9RLsk/yvCgCve6KQa8ja2C5lCBrz1y0Pg4+nSviZSP9sOD4N34YYw22vuq6N2ETU m3E3MhcvJZwiXjKll5+/pgATv30vLXpUPSfNzU4wktRH+7wEceIeumlWoMjf90u/qP75 b8LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=K6XnEKHh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k21-20020aa7d8d5000000b00456f739cf5bsi3212657eds.470.2022.10.01.01.26.20; Sat, 01 Oct 2022 01:26:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=K6XnEKHh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229592AbiJAHoN (ORCPT + 99 others); Sat, 1 Oct 2022 03:44:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbiJAHoL (ORCPT ); Sat, 1 Oct 2022 03:44:11 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 563BF153A7C; Sat, 1 Oct 2022 00:44:10 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id a2so10002506lfb.6; Sat, 01 Oct 2022 00:44:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=HugR/NLJXFQfozYZ66e+YMwVjhph0I2XzzQk2oljY3o=; b=K6XnEKHhkISLsNnZ+PqmRwXwEmcNFDlHFiGA32RcsPN4yXexBh2371BaDigsOMFxLd dFCJhUMeJAdxOIOVI3jQghfhUIedvxuYMFmXQ8T/912KnMtyCmhCueNpYGiGwsR8lmXX Dex7gYU68FzQlAc9yU05Dv/syh0K6+m9AxLZcjsQBnSiq5Xj9PTA+jFqEtRyRBBZN0Ji 1CfWA8YEmCxiZ1LnaX3VEkb9LeedEp4ydqBj7dlBmqerdlbL1VfM+nAlQEIbC4OP1ZT+ yxELqRVbO3Z4w3hcmSG4La44+oHgAbHVGl5aYtJL0NnGHOJaqey3P0Y5ydhDc1I4oxj6 3Q3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=HugR/NLJXFQfozYZ66e+YMwVjhph0I2XzzQk2oljY3o=; b=OWLTjMHAreTX4es+rk7DD9qLoG3zkPmWK20KCQO91O6StnKxG3Pn62AqIXKuHNZIF5 T0wscS2pO+7E7y740de/F85sdWNNl0FeNxso4kEfZ4aO4smfDepRCbb5OeHfy9hy1w5T opCpuPqwCMeZ/uyXfTcEk840+VMuovco2bL28cw7xXpi3eushda8WUOyT7eppBb0Ss58 RlgPU8+tZMonl/6ubMZRRIlBuhhJYyk9pq8wzVm1rNZXVSg3oxaY/Ony9cLNZ2ViR8OM DPaZTDvzIoU3xbTIRhdc02eyQmQaSwrg912h1fXtpSoBdlCMXCZb8eRpOrlyNE7oVXiH AD/Q== X-Gm-Message-State: ACrzQf3+qUmKvevoeyPKtKtqeDlSNCifPt2RM00CxaTZzf10p7g77545 mex0mVJroSQfmXWUzeOqhCI= X-Received: by 2002:a05:6512:31c8:b0:49c:db9d:bb97 with SMTP id j8-20020a05651231c800b0049cdb9dbb97mr4300336lfe.12.1664610248572; Sat, 01 Oct 2022 00:44:08 -0700 (PDT) Received: from dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi (dc75zzyyyyyyyyyyyyyyt-3.rev.dnainternet.fi. [2001:14ba:16f3:4a00::1]) by smtp.gmail.com with ESMTPSA id h19-20020a056512221300b00498f67cbfa9sm671086lfu.22.2022.10.01.00.44.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Oct 2022 00:44:07 -0700 (PDT) Date: Sat, 1 Oct 2022 10:44:01 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Cc: Cosmin Tanislav , Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , Eugen Hristev , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Benson Leung , Guenter Roeck , Alexandru Ardelean , Srinivas Pandruvada , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Nathan Chancellor , Miquel Raynal , Matti Vaittinen , Miaoqian Lin , Paul Cercueil , Mihail Chindris , Gwendal Grignou , Douglas Anderson , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chrome-platform@lists.linux.dev Subject: [RFT PATCH v2 1/2] iio: Add IIO_STATIC_CONST_DEVICE_ATTR Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xd5zRoFn41p0ColK" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --xd5zRoFn41p0ColK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Add IIO_STATIC_CONST_DEVICE_ATTR macro for creating an read-only iio_dev_attr which returns constant value. This macro is intended to be used when replacing the IIO_CONST_ATTR - attributes for triggered buffers because the triggered buffer attributes must be of type iio_dev_attr. Signed-off-by: Matti Vaittinen --- include/linux/iio/sysfs.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/iio/sysfs.h b/include/linux/iio/sysfs.h index e51fba66de4b..de5bb125815c 100644 --- a/include/linux/iio/sysfs.h +++ b/include/linux/iio/sysfs.h @@ -97,6 +97,17 @@ struct iio_const_attr { =3D { .string =3D _string, \ .dev_attr =3D __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)} =20 +#define IIO_STATIC_CONST_DEVICE_ATTR(_name, _string) \ + static ssize_t iio_const_dev_attr_show_##_name( \ + struct device *dev, \ + struct device_attribute *attr, \ + char *buf) \ + { \ + return sysfs_emit(buf, "%s\n", _string); \ + } \ + static IIO_DEVICE_ATTR(_name, 0444, \ + iio_const_dev_attr_show_##_name, NULL, 0) + /* Generic attributes of onetype or another */ =20 /** --=20 2.37.3 --=20 Matti Vaittinen, Linux device drivers ROHM Semiconductors, Finland SWDC Kiviharjunlenkki 1E 90220 OULU FINLAND ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~ Simon says - in Latin please. ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~ Thanks to Simon Glass for the translation =3D]=20 --xd5zRoFn41p0ColK Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmM378EACgkQeFA3/03a ocXKeAf9HN002m865SDcUlmLtg0aCs/YoUrIHeUs903yq/3AedvqFTck32PpJzs5 l5Lg7yVnTVBJchAdezzNQghJuAcWqQZsoO1qT9HF+dTumrTM46zJ/vs87li1wWIP hPMyaxcuCUyaKPTXEPYawiAihAChYcurB7bm1VLwjtoI9f9kSAYMvNIerfXi11v/ /T1kipzgSUv79MaojvGw5iYNbkcrMhi9+rZXegQl+YiicZ7dEtjHhI6o1SifTzmT oV5x77T3dFww7/P25HfYhWyvfCPTTPuiRmzS6sHpH0H4PbFPhel9ULa2xHtr/NCy qfQUs3ugjSq+s3gwzpehS6cAtte2GA== =DkLa -----END PGP SIGNATURE----- --xd5zRoFn41p0ColK--