Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755458Ab3GKAiW (ORCPT ); Wed, 10 Jul 2013 20:38:22 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:56619 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755409Ab3GKAg0 (ORCPT ); Wed, 10 Jul 2013 20:36:26 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: oliver+list@schinagl.nl, linux@roeck-us.net, khali@linux-fr.org, Greg Kroah-Hartman Subject: [PATCH v2 3/7] sysfs.h: add BIN_ATTR macro Date: Wed, 10 Jul 2013 17:36:01 -0700 Message-Id: <1373502965-1683-4-git-send-email-gregkh@linuxfoundation.org> X-Mailer: git-send-email 1.8.3.rc0.20.gb99dd2e In-Reply-To: <1373502965-1683-1-git-send-email-gregkh@linuxfoundation.org> References: <1373486714-14531-1-git-send-email-gregkh@linuxfoundation.org> <1373502965-1683-1-git-send-email-gregkh@linuxfoundation.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1264 Lines: 36 This makes it easier to create static binary attributes, which is needed in a number of drivers, instead of "open coding" them. Signed-off-by: Greg Kroah-Hartman --- include/linux/sysfs.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index f62ff01..d50a96b 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -132,6 +132,15 @@ struct bin_attribute { */ #define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr) +/* macro to create static binary attributes easier */ +#define BIN_ATTR(_name, _mode, _read, _write, _size) \ +struct bin_attribute bin_attr_##_name = { \ + .attr = {.name = __stringify(_name), .mode = _mode }, \ + .read = _read, \ + .write = _write, \ + .size = _size, \ +} + struct sysfs_ops { ssize_t (*show)(struct kobject *, struct attribute *,char *); ssize_t (*store)(struct kobject *,struct attribute *,const char *, size_t); -- 1.8.3.rc0.20.gb99dd2e -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/