Files
system76-coreboot/src/vendorcode/google/chromeos/wrdd.c
Patrick Georgi 6b5bc77c9b treewide: Remove "this file is part of" lines
Stefan thinks they don't add value.

Command used:
sed -i -e '/file is part of /d' $(git grep "file is part of " |egrep ":( */\*.*\*/\$|#|;#|-- | *\* )" | cut -d: -f1 |grep -v crossgcc |grep -v gcov | grep -v /elf.h |grep -v nvramtool)

The exceptions are for:
 - crossgcc (patch file)
 - gcov (imported from gcc)
 - elf.h (imported from GNU's libc)
 - nvramtool (more complicated header)

The removed lines are:
-       fmt.Fprintln(f, "/* This file is part of the coreboot project. */")
-# This file is part of a set of unofficial pre-commit hooks available
-/* This file is part of coreboot */
-# This file is part of msrtool.
-/* This file is part of msrtool. */
- * This file is part of ncurses, designed to be appended after curses.h.in
-/* This file is part of pgtblgen. */
- * This file is part of the coreboot project.
- /* This file is part of the coreboot project. */
-#  This file is part of the coreboot project.
-# This file is part of the coreboot project.
-## This file is part of the coreboot project.
--- This file is part of the coreboot project.
-/* This file is part of the coreboot project */
-/* This file is part of the coreboot project. */
-;## This file is part of the coreboot project.
-# This file is part of the coreboot project. It originated in the
- * This file is part of the coreinfo project.
-## This file is part of the coreinfo project.
- * This file is part of the depthcharge project.
-/* This file is part of the depthcharge project. */
-/* This file is part of the ectool project. */
- * This file is part of the GNU C Library.
- * This file is part of the libpayload project.
-## This file is part of the libpayload project.
-/* This file is part of the Linux kernel. */
-## This file is part of the superiotool project.
-/* This file is part of the superiotool project */
-/* This file is part of uio_usbdebug */

Change-Id: I82d872b3b337388c93d5f5bf704e9ee9e53ab3a9
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/41194
Reviewed-by: HAOUAS Elyes <ehaouas@noos.fr>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2020-05-11 17:11:40 +00:00

72 lines
2.0 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only */
#include <console/console.h>
#include <cpu/cpu.h>
#include <types.h>
#include <string.h>
#include <wrdd.h>
#include <drivers/vpd/vpd.h>
#define CROS_VPD_REGION_NAME "region"
/*
* wrdd_domain_value is ISO 3166-2
* ISO 3166-2 code consists of two parts, separated by a hyphen
* The first part is the ISO 3166-1 alpha-2 code of the country;
* The second part is a string of up to three alphanumeric characters
*/
#define VARIANT_SEPARATOR '.'
struct wrdd_code_value_pair {
const char *code;
u16 value;
};
/* Retrieve the regulatory domain information from VPD and
* return it as an uint16.
* WARNING: if domain information is not found in the VPD,
* this function will fall back to the default value
*/
uint16_t wifi_regulatory_domain(void)
{
static struct wrdd_code_value_pair wrdd_table[] = {
{
/* Indonesia
* Alpha-2 code 'ID'
* Full name 'the Republic of Indonesia'
* Alpha-3 code 'IDN'
* Numeric code '360'
*/
.code = "id",
.value = WRDD_REGULATORY_DOMAIN_INDONESIA
}
};
const char *wrdd_domain_key = CROS_VPD_REGION_NAME;
int i;
struct wrdd_code_value_pair *p;
/* wrdd_domain_value is ISO 3166-2 */
char wrdd_domain_code[7];
char *separator;
/* If not found for any reason fall backto the default value */
if (!vpd_gets(wrdd_domain_key, wrdd_domain_code,
ARRAY_SIZE(wrdd_domain_code), VPD_ANY)) {
printk(BIOS_DEBUG,
"Error: Could not locate '%s' in VPD\n", wrdd_domain_key);
return WRDD_DEFAULT_REGULATORY_DOMAIN;
}
printk(BIOS_DEBUG, "Found '%s'='%s' in VPD\n",
wrdd_domain_key, wrdd_domain_code);
separator = memchr(wrdd_domain_code, VARIANT_SEPARATOR,
ARRAY_SIZE(wrdd_domain_code));
if (separator) {
*separator = '\0';
}
for (i = 0; i < ARRAY_SIZE(wrdd_table); i++) {
p = &wrdd_table[i];
if (strncmp(p->code, wrdd_domain_code,
ARRAY_SIZE(wrdd_domain_code)) == 0)
return p->value;
}
return WRDD_DEFAULT_REGULATORY_DOMAIN;
}