linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean Delvare <jdelvare@suse.de>
To: Linux I2C <linux-i2c@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Cc: Wolfram Sang <wsa@the-dreams.de>
Subject: [PATCH 2/4] firmware: dmi: Add dmi_memdev_handle
Date: Mon, 18 Nov 2019 10:26:06 +0100	[thread overview]
Message-ID: <20191118102606.6dbccfdf@endymion> (raw)
In-Reply-To: <20191118102410.78cd8e6e@endymion>

Add a utility function dmi_memdev_handle() which returns the DMI
handle associated with a given memory slot. This will allow kernel
drivers to iterate over the memory slots.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
 drivers/firmware/dmi_scan.c |   16 ++++++++++++++++
 include/linux/dmi.h         |    2 ++
 2 files changed, 18 insertions(+)

--- linux-5.3.orig/drivers/firmware/dmi_scan.c	2019-10-10 11:33:02.871034637 +0200
+++ linux-5.3/drivers/firmware/dmi_scan.c	2019-10-10 11:45:37.275549638 +0200
@@ -1151,3 +1151,19 @@ u8 dmi_memdev_type(u16 handle)
 	return 0x0;	/* Not a valid value */
 }
 EXPORT_SYMBOL_GPL(dmi_memdev_type);
+
+/**
+ *	dmi_memdev_handle - get the DMI handle of a memory slot
+ *	@slot: slot number
+ *
+ *	Return the DMI handle associated with a given memory slot, or %0xFFFF
+ *      if there is no such slot.
+ */
+u16 dmi_memdev_handle(int slot)
+{
+	if (dmi_memdev && slot >= 0 && slot < dmi_memdev_nr)
+		return dmi_memdev[slot].handle;
+
+	return 0xffff;	/* Not a valid value */
+}
+EXPORT_SYMBOL_GPL(dmi_memdev_handle);
--- linux-5.3.orig/include/linux/dmi.h	2019-10-10 11:33:02.871034637 +0200
+++ linux-5.3/include/linux/dmi.h	2019-10-10 11:34:46.146337207 +0200
@@ -114,6 +114,7 @@ extern bool dmi_match(enum dmi_field f,
 extern void dmi_memdev_name(u16 handle, const char **bank, const char **device);
 extern u64 dmi_memdev_size(u16 handle);
 extern u8 dmi_memdev_type(u16 handle);
+extern u16 dmi_memdev_handle(int slot);
 
 #else
 
@@ -144,6 +145,7 @@ static inline void dmi_memdev_name(u16 h
 		const char **device) { }
 static inline u64 dmi_memdev_size(u16 handle) { return ~0ul; }
 static inline u8 dmi_memdev_type(u16 handle) { return 0x0; }
+static inline u16 dmi_memdev_handle(int slot) { return 0xffff; }
 static inline const struct dmi_system_id *
 	dmi_first_match(const struct dmi_system_id *list) { return NULL; }
 


-- 
Jean Delvare
SUSE L3 Support

  parent reply	other threads:[~2019-11-18  9:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-18  9:24 [PATCH 0/4 v2] Instantiate SPD EEPROMs at boot on x86 Jean Delvare
2019-11-18  9:25 ` [PATCH 1/4] firmware: dmi: Remember the memory type Jean Delvare
2019-11-18  9:26 ` Jean Delvare [this message]
2019-11-18  9:27 ` [PATCH 3/4 v2] i2c: smbus: Add a way to instantiate SPD EEPROMs automatically Jean Delvare
2019-11-18  9:28 ` [PATCH 4/4 v2] i2c: i801: Instantiate " Jean Delvare
  -- strict thread matches above, loose matches on Subject: below --
2019-10-14  9:36 [PATCH 0/4] Instantiate SPD EEPROMs at boot on x86 Jean Delvare
2019-10-14  9:38 ` [PATCH 2/4] firmware: dmi: Add dmi_memdev_handle Jean Delvare

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=20191118102606.6dbccfdf@endymion \
    --to=jdelvare@suse.de \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wsa@the-dreams.de \
    /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).