linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: minyard@acm.org
To: openipmi-developer@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, Jean Delvare <jdelvare@suse.de>
Cc: Corey Minyard <cminyard@mvista.com>, Andy Lutomirski <luto@kernel.org>
Subject: [PATCH v3 2/5] dmi: Add a DMI firmware node and handling
Date: Wed, 27 Apr 2016 08:04:17 -0500	[thread overview]
Message-ID: <1461762260-32454-3-git-send-email-minyard@acm.org> (raw)
In-Reply-To: <1461762260-32454-1-git-send-email-minyard@acm.org>

From: Corey Minyard <cminyard@mvista.com>

This is so that an IPMI platform device can be created from a
DMI firmware entry.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Cc: Jean Delvare <jdelvare@suse.de>
Cc: Andy Lutomirski <luto@kernel.org>
Tested-by: Andy Lutomirski <luto@kernel.org>
---
 drivers/firmware/dmi_scan.c | 16 ++++++++++------
 include/linux/dmi.h         | 14 ++++++++++++++
 include/linux/fwnode.h      |  1 +
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index da471b2..5519b4f 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -242,6 +242,12 @@ static void __init dmi_save_type(const struct dmi_header *dm, int slot,
 	dmi_ident[slot] = s;
 }
 
+static void __init dmi_devices_list_add(struct dmi_device *dev)
+{
+	dev->fwnode.type = FWNODE_DMI;
+	list_add(&dev->list, &dmi_devices);
+}
+
 static void __init dmi_save_one_device(int type, const char *name)
 {
 	struct dmi_device *dev;
@@ -257,8 +263,7 @@ static void __init dmi_save_one_device(int type, const char *name)
 	dev->type = type;
 	strcpy((char *)(dev + 1), name);
 	dev->name = (char *)(dev + 1);
-	dev->device_data = NULL;
-	list_add(&dev->list, &dmi_devices);
+	dmi_devices_list_add(dev);
 }
 
 static void __init dmi_save_devices(const struct dmi_header *dm)
@@ -293,9 +298,8 @@ static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm)
 
 		dev->type = DMI_DEV_TYPE_OEM_STRING;
 		dev->name = devname;
-		dev->device_data = NULL;
 
-		list_add(&dev->list, &dmi_devices);
+		dmi_devices_list_add(dev);
 	}
 }
 
@@ -318,7 +322,7 @@ static void __init dmi_save_ipmi_device(const struct dmi_header *dm)
 	dev->name = "IPMI controller";
 	dev->device_data = data;
 
-	list_add_tail(&dev->list, &dmi_devices);
+	dmi_devices_list_add(dev);
 }
 
 static void __init dmi_save_dev_pciaddr(int instance, int segment, int bus,
@@ -345,7 +349,7 @@ static void __init dmi_save_dev_pciaddr(int instance, int segment, int bus,
 	dev->dev.name = (char *)&dev[1];
 	dev->dev.device_data = dev;
 
-	list_add(&dev->dev.list, &dmi_devices);
+	dmi_devices_list_add(&dev->dev);
 }
 
 static void __init dmi_save_extended_devices(const struct dmi_header *dm)
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index a930a4d..c8dd5b8 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -4,6 +4,7 @@
 #include <linux/list.h>
 #include <linux/kobject.h>
 #include <linux/mod_devicetable.h>
+#include <linux/fwnode.h>
 
 /* enum dmi_field is in mod_devicetable.h */
 
@@ -80,6 +81,7 @@ struct dmi_header {
 
 struct dmi_device {
 	struct list_head list;
+	struct fwnode_handle fwnode;
 	int type;
 	const char *name;
 	void *device_data;	/* Type specific data */
@@ -113,6 +115,18 @@ extern int dmi_walk(void (*decode)(const struct dmi_header *, void *),
 extern bool dmi_match(enum dmi_field f, const char *str);
 extern void dmi_memdev_name(u16 handle, const char **bank, const char **device);
 
+static inline bool is_dmi_fwnode(struct fwnode_handle *fwnode)
+{
+	return fwnode && fwnode->type == FWNODE_DMI;
+}
+
+static inline struct dmi_device *to_dmi_device(struct fwnode_handle *fwnode)
+{
+	if (is_dmi_fwnode(fwnode))
+		return container_of(fwnode, struct dmi_device, fwnode);
+	return NULL;
+}
+
 #else
 
 static inline int dmi_check_system(const struct dmi_system_id *list) { return 0; }
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 8516717..8690de2 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -19,6 +19,7 @@ enum fwnode_type {
 	FWNODE_ACPI_DATA,
 	FWNODE_PDATA,
 	FWNODE_IRQCHIP,
+	FWNODE_DMI,
 };
 
 struct fwnode_handle {
-- 
2.7.4

  parent reply	other threads:[~2016-04-27 13:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-27 13:04 [PATCH v3 0/5] dmi: Rework to get IPMI autoloading from DMI tables minyard
2016-04-27 13:04 ` [PATCH v3 1/5] dmi: remove const from return of dmi_find_device minyard
2016-05-17 16:44   ` Andy Lutomirski
2016-05-17 19:11     ` [Openipmi-developer] " Corey Minyard
2016-04-27 13:04 ` minyard [this message]
2016-04-27 13:04 ` [PATCH v3 3/5] dmi: Add IPMI DMI scanning to the DMI code minyard
2016-04-27 13:04 ` [PATCH v3 4/5] dmi: Add IPMI DMI devices as platform devices minyard
2016-04-27 13:04 ` [PATCH v3 5/5] ipmi: Convert DMI handling over to a platform device minyard
2016-09-07 22:37 ` [Openipmi-developer] [PATCH v3 0/5] dmi: Rework to get IPMI autoloading from DMI tables Corey Minyard

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=1461762260-32454-3-git-send-email-minyard@acm.org \
    --to=minyard@acm.org \
    --cc=cminyard@mvista.com \
    --cc=jdelvare@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=openipmi-developer@lists.sourceforge.net \
    /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).