drivers/wifi: Remove unnecessary data structure copy
[coreboot2.git] / src / vendorcode / google / dsm_calib.c
bloba245b8040345771f018ac373c3a1931f0c6cb882
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <console/console.h>
4 #include <drivers/vpd/vpd.h>
5 #include <stdint.h>
6 #include <string.h>
7 #include <types.h>
8 #include "dsm_calib.h"
10 #define DSM_BUF_LEN 128
11 #define DSM_PREFIX "dsm_calib_"
13 enum cb_err get_dsm_calibration_from_key(const char *key, uint64_t *value)
15 static char buf[DSM_BUF_LEN];
16 char *ret;
17 long value_from_vpd;
19 if (strncmp(key, DSM_PREFIX, strlen(DSM_PREFIX))) {
20 printk(BIOS_ERR, "got invalid dsm_calib key: %s\n", key);
21 return CB_ERR;
24 ret = vpd_gets(key, buf, DSM_BUF_LEN, VPD_RO);
25 if (!ret) {
26 printk(BIOS_ERR, "failed to find key in VPD: %s\n", key);
27 return CB_ERR;
30 value_from_vpd = atol(buf);
31 if (value_from_vpd <= 0) {
32 printk(BIOS_ERR, "got invalid dsm_calib from VPD: %ld\n", value_from_vpd);
33 return CB_ERR;
36 *value = value_from_vpd;
38 return CB_SUCCESS;