From patchwork Sat Oct 1 07:44:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matti Vaittinen X-Patchwork-Id: 12996427 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 B5DD1C4332F for ; Sat, 1 Oct 2022 07:45:14 +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: In-Reply-To:MIME-Version:References: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:List-Owner; bh=qHIpIdFqQXfpJZn44CWQtMT6uCcNhYbfP1anUk0nXt0=; b=IISxmw1RBycQg3HLisDGX4zsLu 5P3dSaMQQfZYXAjDeqAQPX4AAXmu3Kl8z8TGUypuMLbaCysi4BAGxzhExg0WYmSVMgL9yo6pdOJ9/ 7fM2RIO2ysBXwvP81Vz3yw4oq0N+z0UnkmTGKN22LJNchcHP7WGiHTtFw9itGLRmRIZICozD6Z9qn Y9NkEt3f957F8e3tVBxOrtHK6awvjNQBpPQ/wk9JheLj3I2hEQL7rjJvzhJqpGYp1SA4bndYzFAyy YdkPJFUxoe6KLU4GvzysGWBZ8EkcYoLF+9MGx9KN6jaFmcWPLm94C74MtIzPOrlcY9e+A7n+wdvOB CQQnn4yA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oeXAT-00Db6e-MZ; Sat, 01 Oct 2022 07:44:13 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oeXAR-00Db5Y-5K for linux-arm-kernel@lists.infradead.org; Sat, 01 Oct 2022 07:44:12 +0000 Received: by mail-lf1-x12e.google.com with SMTP id a2so10002507lfb.6 for ; Sat, 01 Oct 2022 00:44:09 -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=MtulKYFxPi57DlcuapDl/7bbRVKy36WRtA9bb/M/2b5dukL5x8LWAAj1R0UPEBMujn mb7GglNNaMMK1x1uk86isnH6AgATbpjeEzShfGBKlU25+bHVzTEhupwTyfVTvgXssink Pb0X74+94o+l0YrCQ7XeZfUqs6zafZlv74B/mTZ9uMHDzvFOIPr7OJG1y5AdjafTEbyT ZzBi81y5eWmQnvFsrJl9g7HXcS3i0KEaebv4rlq9RgP6TGlOyHAT87Kz8jEQ3dOz0qV2 qAVEnp94u2go0Lle2LxVADgETmA1hIknyqHLkW7DMMMFBLlAKTC8r1NYpjrGP69+zdAE Isdg== X-Gm-Message-State: ACrzQf0/lqXDtFGnnjD2vYnqGqg0hEDXsA5h1rOZzB6Y00P2QqYrNQjD PHQFXgxmK29zOwvMrn4NANg= X-Google-Smtp-Source: AMsMyM4ByumW4JDxNyG8DNIURZfGCkHffICG/1xi8XrU8oXss1j1HhVqLqIYRmLyvTOVMP0tUbbdZA== 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 Subject: [RFT PATCH v2 1/2] iio: Add IIO_STATIC_CONST_DEVICE_ATTR Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221001_004411_226515_988164A1 X-CRM114-Status: GOOD ( 14.58 ) 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 , linux-iio@vger.kernel.org, Srinivas Pandruvada , Gwendal Grignou , Paul Cercueil , Miquel Raynal , Guenter Roeck , chrome-platform@lists.linux.dev, Lars-Peter Clausen , Miaoqian Lin , Uwe =?iso-8859-1?q?Kleine-K=F6nig?= , Alexandru Ardelean , Mihail Chindris , Michael Hennerich , Matti Vaittinen , Cosmin Tanislav , Nathan Chancellor , Benson Leung , linux-arm-kernel@lists.infradead.org, Douglas Anderson , linux-kernel@vger.kernel.org, Eugen Hristev , Claudiu Beznea , Jonathan Cameron Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 { = { .string = _string, \ .dev_attr = __ATTR(_name, S_IRUGO, iio_read_const_attr, NULL)} +#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 */ /**