From patchwork Sat Nov 27 17:49:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 73284 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 0BFE9B70B0 for ; Sun, 28 Nov 2010 04:49:39 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753118Ab0K0Rte (ORCPT ); Sat, 27 Nov 2010 12:49:34 -0500 Received: from server19320154104.serverpool.info ([193.201.54.104]:32782 "EHLO hauke-m.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752706Ab0K0Rtd (ORCPT ); Sat, 27 Nov 2010 12:49:33 -0500 Received: from localhost (localhost [127.0.0.1]) by hauke-m.de (Postfix) with ESMTP id E1BE587AA; Sat, 27 Nov 2010 18:49:31 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at hauke-m.de Received: from hauke-m.de ([127.0.0.1]) by localhost (hauke-m.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zW9Zgpt7Uurr; Sat, 27 Nov 2010 18:49:28 +0100 (CET) Received: from localhost.localdomain (host-091-097-248-055.ewe-ip-backbone.de [91.97.248.55]) by hauke-m.de (Postfix) with ESMTPSA id 4C67A8799; Sat, 27 Nov 2010 18:49:28 +0100 (CET) From: Hauke Mehrtens To: mb@bu3sch.de Cc: netdev@vger.kernel.org, Hauke Mehrtens , Bernhard Loos Subject: [PATCH] ssb: Add sysfs attributes to ssb devices Date: Sat, 27 Nov 2010 18:49:26 +0100 Message-Id: <1290880166-2092-1-git-send-email-hauke@hauke-m.de> X-Mailer: git-send-email 1.7.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Make it possible to read out the attributes, till now only show on dmesg, through sysfs. This patch was some time in OpenWrt. Signed-off-by: Bernhard Loos Signed-off-by: Hauke Mehrtens --- drivers/ssb/main.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-) diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c index c68b3dc..3918d2c 100644 --- a/drivers/ssb/main.c +++ b/drivers/ssb/main.c @@ -383,6 +383,35 @@ static int ssb_device_uevent(struct device *dev, struct kobj_uevent_env *env) ssb_dev->id.revision); } +#define ssb_config_attr(attrib, field, format_string) \ +static ssize_t \ +attrib##_show(struct device *dev, struct device_attribute *attr, char *buf) \ +{ \ + return sprintf(buf, format_string, dev_to_ssb_dev(dev)->field); \ +} + +ssb_config_attr(core_num, core_index, "%u\n") +ssb_config_attr(coreid, id.coreid, "0x%04x\n") +ssb_config_attr(vendor, id.vendor, "0x%04x\n") +ssb_config_attr(revision, id.revision, "%u\n") +ssb_config_attr(irq, irq, "%u\n") +static ssize_t +name_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%s\n", + ssb_core_name(dev_to_ssb_dev(dev)->id.coreid)); +} + +static struct device_attribute ssb_device_attrs[] = { + __ATTR_RO(name), + __ATTR_RO(core_num), + __ATTR_RO(coreid), + __ATTR_RO(vendor), + __ATTR_RO(revision), + __ATTR_RO(irq), + __ATTR_NULL, +}; + static struct bus_type ssb_bustype = { .name = "ssb", .match = ssb_bus_match, @@ -392,6 +421,7 @@ static struct bus_type ssb_bustype = { .suspend = ssb_device_suspend, .resume = ssb_device_resume, .uevent = ssb_device_uevent, + .dev_attrs = ssb_device_attrs, }; static void ssb_buses_lock(void)