summaryrefslogtreecommitdiff
path: root/src/soc/intel
diff options
context:
space:
mode:
authorElyes Haouas <ehaouas@noos.fr>2022-09-13 10:03:44 +0200
committerFelix Held <felix-coreboot@felixheld.de>2022-09-15 13:03:28 +0000
commitf1ba7d6c8f844110c2bc05fa26e4cea9038672db (patch)
treef6e3d0da0391ae5d797deaf7db276f2a32e2114f /src/soc/intel
parent3de12533184ea13198de6c02fd83e331a894b075 (diff)
soc/intel/xeon_sp: Use "if (!ptr)" in preference to "if (ptr == NULL)"
Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Change-Id: I664f5b7d354b0d9a7144c25604ae4efbdd9ba9a9 Reviewed-on: https://review.coreboot.org/c/coreboot/+/67593 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Jonathan Zhang <jonzhang@fb.com>
Diffstat (limited to 'src/soc/intel')
-rw-r--r--src/soc/intel/xeon_sp/chip_common.c24
-rw-r--r--src/soc/intel/xeon_sp/cpx/romstage.c8
-rw-r--r--src/soc/intel/xeon_sp/cpx/soc_util.c4
-rw-r--r--src/soc/intel/xeon_sp/memmap.c4
-rw-r--r--src/soc/intel/xeon_sp/nb_acpi.c4
-rw-r--r--src/soc/intel/xeon_sp/skx/chip.c2
-rw-r--r--src/soc/intel/xeon_sp/skx/cpu.c2
-rw-r--r--src/soc/intel/xeon_sp/skx/hob_display.c6
-rw-r--r--src/soc/intel/xeon_sp/skx/soc_util.c2
-rw-r--r--src/soc/intel/xeon_sp/util.c10
10 files changed, 33 insertions, 33 deletions
diff --git a/src/soc/intel/xeon_sp/chip_common.c b/src/soc/intel/xeon_sp/chip_common.c
index 1c1715fb5c..0cddec1564 100644
--- a/src/soc/intel/xeon_sp/chip_common.c
+++ b/src/soc/intel/xeon_sp/chip_common.c
@@ -91,7 +91,7 @@ void xeonsp_pci_domain_scan_bus(struct device *dev)
printk(BIOS_SPEW, "%s:%s scanning buses under device %s\n",
__FILE__, __func__, dev_path(dev));
- while (link != NULL) {
+ while (link) {
if (link->secondary == 0) { // scan only PSTACK buses
struct device *d;
for (d = link->children; d; d = d->sibling)
@@ -171,7 +171,7 @@ static void add_res_to_stack(struct stack_dev_resource **root,
{
struct stack_dev_resource *cur = *root;
while (cur) {
- if (cur->align == res->align || cur->next == NULL) /* equal or last record */
+ if (cur->align == res->align || !cur->next) /* equal or last record */
break;
else if (cur->align > res->align) {
if (cur->next->align < res->align) /* need to insert new record here */
@@ -192,7 +192,7 @@ static void add_res_to_stack(struct stack_dev_resource **root,
if (!cur) {
*root = nr; /* head node */
} else if (cur->align > nr->align) {
- if (cur->next == NULL) {
+ if (!cur->next) {
cur->next = nr;
} else {
nr->next = cur->next;
@@ -206,20 +206,20 @@ static void add_res_to_stack(struct stack_dev_resource **root,
nr = cur;
}
- assert(nr != NULL && nr->align == res->align);
+ assert(nr && nr->align == res->align);
struct pci_resource *npr = malloc(sizeof(struct pci_resource));
- if (npr == NULL)
+ if (!npr)
die("%s: out of memory.\n", __func__);
npr->res = res;
npr->dev = dev;
npr->next = NULL;
- if (nr->children == NULL) {
+ if (!nr->children) {
nr->children = npr;
} else {
struct pci_resource *pr = nr->children;
- while (pr->next != NULL)
+ while (pr->next)
pr = pr->next;
pr->next = npr;
}
@@ -343,7 +343,7 @@ static void assign_stack_resources(struct iiostack_resource *stack_list,
/* get IIO stack for this bus */
stack = find_stack_for_bus(stack_list, bus->secondary);
- assert(stack != NULL);
+ assert(stack);
/* Assign resources to bridge */
for (curdev = bus->children; curdev; curdev = curdev->sibling)
@@ -473,7 +473,7 @@ void xeonsp_pci_domain_set_resources(struct device *dev)
xeonsp_pci_domain_read_resources(dev);
struct bus *link = dev->link_list;
- while (link != NULL) {
+ while (link) {
assign_resources(link);
link = link->next;
}
@@ -499,7 +499,7 @@ void attach_iio_stacks(struct device *dev)
continue;
iiostack_bus = malloc(sizeof(struct bus));
- if (iiostack_bus == NULL)
+ if (!iiostack_bus)
die("%s: out of memory.\n", __func__);
memset(iiostack_bus, 0, sizeof(*iiostack_bus));
memcpy(iiostack_bus, dev->bus, sizeof(*iiostack_bus));
@@ -518,11 +518,11 @@ void attach_iio_stacks(struct device *dev)
printk(BIOS_WARNING, "IIO Stack device %s not visible\n",
dev_path(&dummy));
- if (dev->link_list == NULL) {
+ if (!dev->link_list) {
dev->link_list = iiostack_bus;
} else {
struct bus *nlink = dev->link_list;
- while (nlink->next != NULL)
+ while (nlink->next)
nlink = nlink->next;
nlink->next = iiostack_bus;
}
diff --git a/src/soc/intel/xeon_sp/cpx/romstage.c b/src/soc/intel/xeon_sp/cpx/romstage.c
index ad794c3b6f..efdce78ca9 100644
--- a/src/soc/intel/xeon_sp/cpx/romstage.c
+++ b/src/soc/intel/xeon_sp/cpx/romstage.c
@@ -48,9 +48,9 @@ static const struct SystemMemoryMapHob *get_system_memory_map(void)
memmap_addr = (const struct SystemMemoryMapHob **)
fsp_find_extension_hob_by_guid(mem_hob_guid, &hob_size);
/* hob_size is the size of the 8-byte address not the hob data */
- assert(memmap_addr != NULL && hob_size != 0);
+ assert(memmap_addr && hob_size != 0);
/* assert the pointer to the hob is not NULL */
- assert(*memmap_addr != NULL);
+ assert(*memmap_addr);
return *memmap_addr;
}
@@ -85,14 +85,14 @@ void save_dimm_info(void)
uint32_t vdd_voltage;
hob = get_system_memory_map();
- assert(hob != NULL);
+ assert(hob);
/*
* Allocate CBMEM area for DIMM information used to populate SMBIOS
* table 17
*/
mem_info = cbmem_add(CBMEM_ID_MEMINFO, sizeof(*mem_info));
- if (mem_info == NULL) {
+ if (!mem_info) {
printk(BIOS_ERR, "CBMEM entry for DIMM info missing\n");
return;
}
diff --git a/src/soc/intel/xeon_sp/cpx/soc_util.c b/src/soc/intel/xeon_sp/cpx/soc_util.c
index ed239766b4..cd1e06d290 100644
--- a/src/soc/intel/xeon_sp/cpx/soc_util.c
+++ b/src/soc/intel/xeon_sp/cpx/soc_util.c
@@ -18,9 +18,9 @@ const struct SystemMemoryMapHob *get_system_memory_map(void)
memmap_addr = (const struct SystemMemoryMapHob **)
fsp_find_extension_hob_by_guid(mem_hob_guid, &hob_size);
/* hob_size is the size of the 8-byte address not the hob data */
- assert(memmap_addr != NULL && hob_size != 0);
+ assert(memmap_addr && hob_size != 0);
/* assert the pointer to the hob is not NULL */
- assert(*memmap_addr != NULL);
+ assert(*memmap_addr);
return *memmap_addr;
}
diff --git a/src/soc/intel/xeon_sp/memmap.c b/src/soc/intel/xeon_sp/memmap.c
index b640c2ddfe..c256484034 100644
--- a/src/soc/intel/xeon_sp/memmap.c
+++ b/src/soc/intel/xeon_sp/memmap.c
@@ -59,7 +59,7 @@ union dpr_register txt_get_chipset_dpr(void)
dpr.raw = 0;
- if (dev == NULL) {
+ if (!dev) {
printk(BIOS_ERR, "BUS 0: Unable to find VTD PCI dev");
return dpr;
}
@@ -76,7 +76,7 @@ union dpr_register txt_get_chipset_dpr(void)
uint8_t bus = ri->BusBase;
dev = VTD_DEV(bus);
- if (dev == NULL) {
+ if (!dev) {
printk(BIOS_ERR, "BUS %x: Unable to find VTD PCI dev\n", bus);
dpr.raw = 0;
return dpr;
diff --git a/src/soc/intel/xeon_sp/nb_acpi.c b/src/soc/intel/xeon_sp/nb_acpi.c
index 0519d4451b..b3e4575f4d 100644
--- a/src/soc/intel/xeon_sp/nb_acpi.c
+++ b/src/soc/intel/xeon_sp/nb_acpi.c
@@ -46,7 +46,7 @@ static unsigned int get_srat_memory_entries(acpi_srat_mem_t *srat_mem)
unsigned int mmap_index;
memory_map = get_system_memory_map();
- assert(memory_map != NULL);
+ assert(memory_map);
printk(BIOS_DEBUG, "memory_map: %p\n", memory_map);
mmap_index = 0;
@@ -332,7 +332,7 @@ static unsigned long acpi_create_rmrr(unsigned long current)
ptr = cbmem_find(CBMEM_ID_STORAGE_DATA);
if (!ptr) {
ptr = cbmem_add(CBMEM_ID_STORAGE_DATA, size);
- assert(ptr != NULL);
+ assert(ptr);
memset(ptr, 0, size);
}
diff --git a/src/soc/intel/xeon_sp/skx/chip.c b/src/soc/intel/xeon_sp/skx/chip.c
index 92f2afa099..78507879d1 100644
--- a/src/soc/intel/xeon_sp/skx/chip.c
+++ b/src/soc/intel/xeon_sp/skx/chip.c
@@ -78,7 +78,7 @@ void platform_fsp_silicon_init_params_cb(FSPS_UPD *silupd)
microcode_file = cbfs_map("cpu_microcode_blob.bin", &microcode_len);
- if ((microcode_file != NULL) && (microcode_len != 0)) {
+ if ((microcode_file) && (microcode_len != 0)) {
/* Update CPU Microcode patch base address/size */
silupd->FspsConfig.PcdCpuMicrocodePatchBase =
(uint32_t)microcode_file;
diff --git a/src/soc/intel/xeon_sp/skx/cpu.c b/src/soc/intel/xeon_sp/skx/cpu.c
index 027e9bbcd3..d2e4af1cd9 100644
--- a/src/soc/intel/xeon_sp/skx/cpu.c
+++ b/src/soc/intel/xeon_sp/skx/cpu.c
@@ -61,7 +61,7 @@ static void xeon_sp_core_init(struct device *cpu)
printk(BIOS_INFO, "%s dev: %s, cpu: %d, apic_id: 0x%x\n",
__func__, dev_path(cpu), cpu_index(), cpu->path.apic.apic_id);
- assert(chip_config != NULL);
+ assert(chip_config);
/* set MSR_PKG_CST_CONFIG_CONTROL - scope per core*/
msr.hi = 0;
diff --git a/src/soc/intel/xeon_sp/skx/hob_display.c b/src/soc/intel/xeon_sp/skx/hob_display.c
index 4f9636d380..efe1038dfb 100644
--- a/src/soc/intel/xeon_sp/skx/hob_display.c
+++ b/src/soc/intel/xeon_sp/skx/hob_display.c
@@ -37,7 +37,7 @@ void soc_display_hob(const struct hob_header *hob)
const struct hob_resource *res;
res = fsp_hob_header_to_resource(hob);
- assert(res != NULL);
+ assert(res);
printk(BIOS_DEBUG, "\tResource type: 0x%x, attribute: 0x%x, addr: 0x%08llx, len: 0x%08llx\n",
res->type, res->attribute_type, res->addr, res->length);
printk(BIOS_DEBUG, "\tOwner GUID: ");
@@ -57,7 +57,7 @@ void soc_display_memmap_hob(void)
size_t hob_size = 0;
const struct SystemMemoryMapHob *hob =
fsp_find_extension_hob_by_guid(fsp_hob_memmap_guid, &hob_size);
- assert(hob != NULL && hob_size != 0);
+ assert(hob && hob_size != 0);
printk(BIOS_DEBUG, "===================== MEMORY MAP HOB DATA =====================\n");
printk(BIOS_DEBUG, "hob: %p, hob_size: 0x%zx, SystemMemoryMapHob size: 0x%zx, "
@@ -90,7 +90,7 @@ void soc_display_iio_universal_data_hob(void)
size_t hob_size = 0;
const IIO_UDS *hob = fsp_find_extension_hob_by_guid(fsp_hob_iio_uds_guid, &hob_size);
- assert(hob != NULL && hob_size != 0);
+ assert(hob && hob_size != 0);
printk(BIOS_DEBUG, "===================== IIO_UDS HOB DATA =====================\n");
diff --git a/src/soc/intel/xeon_sp/skx/soc_util.c b/src/soc/intel/xeon_sp/skx/soc_util.c
index cc8db642b8..3258007f1c 100644
--- a/src/soc/intel/xeon_sp/skx/soc_util.c
+++ b/src/soc/intel/xeon_sp/skx/soc_util.c
@@ -50,7 +50,7 @@ const struct SystemMemoryMapHob *get_system_memory_map(void)
const struct SystemMemoryMapHob *memmap_addr;
memmap_addr = fsp_find_extension_hob_by_guid(mem_hob_guid, &hob_size);
- assert(memmap_addr != NULL && hob_size != 0);
+ assert(memmap_addr && hob_size != 0);
return memmap_addr;
}
diff --git a/src/soc/intel/xeon_sp/util.c b/src/soc/intel/xeon_sp/util.c
index 42957044bb..818dd78fc8 100644
--- a/src/soc/intel/xeon_sp/util.c
+++ b/src/soc/intel/xeon_sp/util.c
@@ -92,11 +92,11 @@ const IIO_UDS *get_iio_uds(void)
static const IIO_UDS *hob;
const uint8_t fsp_hob_iio_universal_data_guid[16] = FSP_HOB_IIO_UNIVERSAL_DATA_GUID;
- if (hob != NULL)
+ if (hob)
return hob;
hob = fsp_find_extension_hob_by_guid(fsp_hob_iio_universal_data_guid, &hob_size);
- assert(hob != NULL && hob_size != 0);
+ assert(hob && hob_size != 0);
return hob;
}
@@ -150,11 +150,11 @@ static void get_core_thread_bits(uint32_t *core_bits, uint32_t *thread_bits)
static void get_cpu_info_from_apicid(uint32_t apicid, uint32_t core_bits, uint32_t thread_bits,
uint8_t *package, uint8_t *core, uint8_t *thread)
{
- if (package != NULL)
+ if (package)
*package = (apicid >> (thread_bits + core_bits));
- if (core != NULL)
+ if (core)
*core = (uint32_t)((apicid >> thread_bits) & ~((~0) << core_bits));
- if (thread != NULL)
+ if (thread)
*thread = (uint32_t)(apicid & ~((~0) << thread_bits));
}