From: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
To: linux-kernel@vger.kernel.org, ard.biesheuvel@linaro.org
Cc: dmidecode-devel@nongnu.org, grant.likely@linaro.org,
leif.lindholm@linaro.org, matt.fleming@intel.com,
Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Subject: [Patch v2 2/2] firmware: dmi-sysfs: add SMBIOS entry point area attribute
Date: Mon, 26 Jan 2015 15:28:38 +0200 [thread overview]
Message-ID: <1422278918-31477-3-git-send-email-ivan.khoronzhuk@linaro.org> (raw)
In-Reply-To: <1422278918-31477-1-git-send-email-ivan.khoronzhuk@linaro.org>
There are situations when code needs to access SMBIOS entry table
area, but cannot use /dev/mem for this. As the table format is
consistent only for a version, and can be changed, use binary
attribute to give access to raw SMBIOS entry table area.
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
drivers/firmware/dmi-sysfs.c | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/drivers/firmware/dmi-sysfs.c b/drivers/firmware/dmi-sysfs.c
index e0f1cb3..61b6a38 100644
--- a/drivers/firmware/dmi-sysfs.c
+++ b/drivers/firmware/dmi-sysfs.c
@@ -29,6 +29,8 @@
#define MAX_ENTRY_TYPE 255 /* Most of these aren't used, but we consider
the top entry type is only 8 bits */
+static const u8 *smbios_raw_header;
+
struct dmi_sysfs_entry {
struct dmi_header dh;
struct kobject kobj;
@@ -646,9 +648,37 @@ static void cleanup_entry_list(void)
}
}
+static ssize_t smbios_entry_area_raw_read(struct file *filp,
+ struct kobject *kobj,
+ struct bin_attribute *bin_attr,
+ char *buf, loff_t pos, size_t count)
+{
+ ssize_t size;
+
+ size = bin_attr->size;
+
+ if (size > pos)
+ size -= pos;
+ else
+ return 0;
+
+ if (count < size)
+ size = count;
+
+ memcpy(buf, &smbios_raw_header[pos], size);
+
+ return size;
+}
+
+static struct bin_attribute smbios_raw_area_attr = {
+ .read = smbios_entry_area_raw_read,
+ .attr = {.name = "smbios_raw_header", .mode = 0400},
+};
+
static int __init dmi_sysfs_init(void)
{
int error = -ENOMEM;
+ int size;
int val;
/* Set up our directory */
@@ -669,6 +699,18 @@ static int __init dmi_sysfs_init(void)
goto err;
}
+ smbios_raw_header = dmi_get_smbios_entry_area(&size);
+ if (!smbios_raw_header) {
+ pr_debug("dmi-sysfs: SMBIOS raw data is not available.\n");
+ error = -ENODATA;
+ goto err;
+ }
+
+ /* Create the raw binary file to access the entry area */
+ smbios_raw_area_attr.size = size;
+ if (sysfs_create_bin_file(dmi_kobj, &smbios_raw_area_attr))
+ goto err;
+
pr_debug("dmi-sysfs: loaded.\n");
return 0;
--
1.9.1
next prev parent reply other threads:[~2015-01-26 13:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-26 13:28 [Patch v2 0/2] firmware: dmi-sysfs: add SMBIOS entry point area raw attribute Ivan Khoronzhuk
2015-01-26 13:28 ` [Patch v2 1/2] firmware: dmi_scan: add symbol to get SMBIOS entry area Ivan Khoronzhuk
2015-01-26 13:32 ` Ard Biesheuvel
2015-01-26 13:28 ` Ivan Khoronzhuk [this message]
2015-01-26 13:34 ` [Patch v2 2/2] firmware: dmi-sysfs: add SMBIOS entry point area attribute Ard Biesheuvel
2015-01-27 11:35 ` [Patch v2 0/2] firmware: dmi-sysfs: add SMBIOS entry point area raw attribute Matt Fleming
2015-01-27 16:23 ` Grant Likely
2015-01-27 18:13 ` Ivan Khoronzhuk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1422278918-31477-3-git-send-email-ivan.khoronzhuk@linaro.org \
--to=ivan.khoronzhuk@linaro.org \
--cc=ard.biesheuvel@linaro.org \
--cc=dmidecode-devel@nongnu.org \
--cc=grant.likely@linaro.org \
--cc=leif.lindholm@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matt.fleming@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).