alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [alsa-devel] [PATCH] firmware: vpd: Add an interface to read VPD value
@ 2019-10-07  7:16 Cheng-Yi Chiang
  2019-10-07  8:03 ` Tzung-Bi Shih
  0 siblings, 1 reply; 11+ messages in thread
From: Cheng-Yi Chiang @ 2019-10-07  7:16 UTC (permalink / raw)
  To: linux-kernel
  Cc: alsa-devel, tzungbi, Greg Kroah-Hartman, Stephen Boyd,
	Hung-Te Lin, Mark Brown, Sean Paul, dgreid, Guenter Roeck,
	Cheng-Yi Chiang

Add an interface for other driver to query VPD value.
This will be used for ASoC machine driver to query calibration
data stored in VPD for smart amplifier speaker resistor
calibration.

Signed-off-by: Cheng-Yi Chiang <cychiang@chromium.org>
---
 drivers/firmware/google/vpd.c              | 16 ++++++++++++++++
 include/linux/firmware/google/google_vpd.h | 18 ++++++++++++++++++
 2 files changed, 34 insertions(+)
 create mode 100644 include/linux/firmware/google/google_vpd.h

diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c
index db0812263d46..71e9d2da63be 100644
--- a/drivers/firmware/google/vpd.c
+++ b/drivers/firmware/google/vpd.c
@@ -65,6 +65,22 @@ static ssize_t vpd_attrib_read(struct file *filp, struct kobject *kobp,
 				       info->bin_attr.size);
 }
 
+int vpd_attribute_read_value(bool ro, const char *key,
+			     char **value, u32 value_len)
+{
+	struct vpd_attrib_info *info;
+	struct vpd_section *sec = ro ? &ro_vpd : &rw_vpd;
+
+	list_for_each_entry(info, &sec->attribs, list) {
+		if (strcmp(info->key, key) == 0) {
+			*value = kstrndup(info->value, value_len, GFP_KERNEL);
+			return 0;
+		}
+	}
+	return -EINVAL;
+}
+EXPORT_SYMBOL(vpd_attribute_read_value);
+
 /*
  * vpd_section_check_key_name()
  *
diff --git a/include/linux/firmware/google/google_vpd.h b/include/linux/firmware/google/google_vpd.h
new file mode 100644
index 000000000000..6f1160f28af8
--- /dev/null
+++ b/include/linux/firmware/google/google_vpd.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Google VPD interface.
+ *
+ * Copyright 2019 Google Inc.
+ */
+
+/* Interface for reading VPD value on Chrome platform. */
+
+#ifndef __GOOGLE_VPD_H
+#define __GOOGLE_VPD_H
+
+#include <linux/types.h>
+
+int vpd_attribute_read_value(bool ro, const char *key,
+			     char **value, u32 value_len);
+
+#endif  /* __GOOGLE_VPD_H */
-- 
2.23.0.581.g78d2f28ef7-goog

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-10-14  3:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-07  7:16 [alsa-devel] [PATCH] firmware: vpd: Add an interface to read VPD value Cheng-Yi Chiang
2019-10-07  8:03 ` Tzung-Bi Shih
2019-10-07  8:52   ` Cheng-yi Chiang
2019-10-07 12:27   ` Guenter Roeck
2019-10-07 13:58     ` Cheng-yi Chiang
2019-10-07 15:35       ` Stephen Boyd
2019-10-07 18:50         ` Cheng-yi Chiang
2019-10-08 15:14           ` Stephen Boyd
2019-10-09 13:37             ` Mark Brown
2019-10-09 14:05             ` Srinivas Kandagatla
2019-10-14  3:21               ` Cheng-yi Chiang

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).