From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2836CC433FE for ; Fri, 30 Sep 2022 10:55:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type:Cc: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: MIME-Version:Message-ID:Subject:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=dVZ/RFKSMmgxoM/ewOEkUFtSeRbpaZN/+dOIKwVRBu8=; b=DAF egoCoTJ16l5WbjftCXj38oUiv4FS9P/p92RpdlpUaq42IQl8PSOkCLcRx5dfP3u8g6MHFnuJgWcny m/yWzFo4aQUM5ksEMsV0bkJbn0p9K0j97Nes3MzUH7Znjis19aoLY4KUk5meDInhnHZadondIM5wX Fbuckg5KMTZ5GZdtciWKtqCUzm75k35ejzYKWgp8H87buNaG1mjXmQ86X+bZCcsJT2ET47VCAOizE bxtwf4RNUrTVFVBbJQcPd3H28aeieVa7h8BA9anGfeS1TghsUQVkzLt0gMW7XA6isv3DwvY01X8ej JH5WSV6to5HmeAmmfClUOxabi3NtF9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oeDf4-008h9i-Rr; Fri, 30 Sep 2022 10:54:30 +0000 Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oeDf2-008h8r-3P for linux-arm-kernel@lists.infradead.org; Fri, 30 Sep 2022 10:54:29 +0000 Received: by mail-lf1-x12c.google.com with SMTP id s6so6283948lfo.7 for ; Fri, 30 Sep 2022 03:54:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date; bh=vt4anCeshQmpiBAIkV+85GsPhIKG979bY2xHCX0TUWI=; b=Wa+S+q8QyCffEYBzox4w4HqnuUEYeyAkthi5BEHLLCnyCWTL4PHBMGJW4BLsWMW8Xx gcysaVyAizRveM48sYPDkQXlxV5fZXbPEbwdIWPtb/ukp2ICABCeRHWcTK2idn8rhVUQ cAyBK20q5Hn7qmzgZ8YLq+zf1khAr4dV0ZQ59GqOshhVYPi5qCYa0hT63BOGsJPfCuDO XB1PAcA/mubqnYvDqC5Hc0X+b/eOySLFWSMxYdaEQB/bzpWbH/RjeBSgfEz8ICp80HaJ +Is23YZsiEB+Mm+pWlgTA+uaPIEl06FxWJ/HzTCW7xlaomssg3xbQqJ8kbLsUSk+lR19 KECA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=vt4anCeshQmpiBAIkV+85GsPhIKG979bY2xHCX0TUWI=; b=ff5eG3zSYzkWbQr59tn3HJ8sRfA565jQ4uFNdASBLBt3pvlFUUln9EjuxYQetjc0aY I88EQEd5p+vFnB5tjEyVmZydkfvJY+R6jwVfj63k3s3/EtQoueM4QjJfZeQzBSqWB3zt yPY1rqiKI6I5C96cTI+dx8ERJgl/HS9rUOL+IjhkBIVlmVjD6Uzjqp/EPAjdqyY6M9EV 7GEV/4sQP7kecj9y2stOGPrI/sINzUv0XFmtHiQZSsBZH191pi6/Xl7w7+4Sx7aZvVjb afnqLXkMztw0VWx5fzjWchTRRCUQ7BRl8gFoSdhzdK65rtlN1vrvhonLlOu531IP+PhZ bJsg== X-Gm-Message-State: ACrzQf06t/BlmWeT9gfpcz8pkgs1fDkWchBWaO5Ad/qv90SGwkhzRPc5 LIWUQ9MDzYp5zhBkRqUtcPU= X-Google-Smtp-Source: AMsMyM50tO3mQSdFG6Os81ZjoAEmNUS6e26q/o86wVvr0FXiZYyQ52RLD1uEmRsDyyrRPR686qpTWA== X-Received: by 2002:ac2:4945:0:b0:498:eb8d:e283 with SMTP id o5-20020ac24945000000b00498eb8de283mr3210641lfi.192.1664535265313; Fri, 30 Sep 2022 03:54:25 -0700 (PDT) Received: from fedora ([213.255.186.46]) by smtp.gmail.com with ESMTPSA id u1-20020a056512128100b0049b8c0571e5sm258565lfs.113.2022.09.30.03.54.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 03:54:24 -0700 (PDT) Date: Fri, 30 Sep 2022 13:54:08 +0300 From: Matti Vaittinen To: Matti Vaittinen , Matti Vaittinen Subject: [PATCH 1/2] iio: Add IIO_STATIC_CONST_DEVICE_ATTR Message-ID: <57fa292756e187d104249f39a655ae736cbcaa76.1664534676.git.mazziesaccount@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220930_035428_161754_496E0B29 X-CRM114-Status: GOOD ( 17.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Lars-Peter Clausen , Michael Hennerich , Matti Vaittinen , Cosmin Tanislav , Miquel Raynal , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Miaoqian Lin , Srinivas Pandruvada , Eugen Hristev , Alexandru Ardelean , Mihail Chindris , Claudiu Beznea , Jonathan Cameron Content-Type: multipart/mixed; boundary="===============8666953026334836366==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============8666953026334836366== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="2YvFr+H0AS5yMMpx" Content-Disposition: inline --2YvFr+H0AS5yMMpx 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 --- I am not thrilled about how keyword 'static' is handled here but in my calendar this day seems to be called the day of the developer without working ideas. Feel free to suggest something if you guys have more luck with ideas. :) And I still think this macro is better than adding the summy 'show' callback in each individual driver :/ 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 --2YvFr+H0AS5yMMpx Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIx+f8wZb28fLKEhTeFA3/03aocUFAmM2yr4ACgkQeFA3/03a ocV+IQf+KnlB/0pYgeZf3Rc8bquy7j39FdT601xZPf43MK3TyyP6SaiPW1eRDLzo D4NP8eDYp4RO8ceMgzodKKNoKsDc7HTH/KGUmnc3Eo3SF7m7knL6peIXgB8mWbFx C44Nj4OINEnB+DshtqzBZjNCzICa2bUq7ZQ8Xb3Qi4OUuUrXZbrgQuYiU4kmoa9j UZ7VN+fiYurFa7/Fq8NYXNk4uNt/EtbA0J7wzzDfg5aplM0b4Qz2d8d4By26mXUm H1ik3qMvxMNfI3yMbRy1tVQry3CrHGdTEjZoCSxXp8yzlR+lsu2hH9HUhYuKvcUL joLoK0nBy7/Fm3k7yh606lQERdepMA== =sil0 -----END PGP SIGNATURE----- --2YvFr+H0AS5yMMpx-- --===============8666953026334836366== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============8666953026334836366==--