x86/CPU: Rename struct cpuid_read_output to struct cpuid_output

There's no CPUID "write" operation so there's no need to have
a cpuid_read_output thing - cpuid_output is perfectly clear. And
shortens the code just fine.

Remove the funky function signature line breaks while at it.

No functional changes.

Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20260805025323.GCanKlox0DF7Gwhpf1@fat_crate.local
This commit is contained in:
Borislav Petkov (AMD) 2026-08-04 18:53:41 -07:00
parent cb1e042a32
commit 6cc3a72caa
2 changed files with 29 additions and 33 deletions

View File

@ -11,14 +11,14 @@
#include "cpuid_parser.h"
/* Clear a single CPUID table entry */
static void cpuid_clear(const struct cpuid_parse_entry *e, const struct cpuid_read_output *output)
static void cpuid_clear(const struct cpuid_parse_entry *e, const struct cpuid_output *out)
{
struct cpuid_regs *regs = output->regs;
struct cpuid_regs *regs = out->regs;
for (int i = 0; i < e->maxcnt; i++, regs++)
memset(regs, 0, sizeof(*regs));
memset(output->info, 0, sizeof(*output->info));
memset(out->info, 0, sizeof(*out->info));
}
/*
@ -29,12 +29,11 @@ static void cpuid_clear(const struct cpuid_parse_entry *e, const struct cpuid_re
* Default CPUID read function
* Satisfies the requirements stated at 'struct cpuid_parse_entry'->read().
*/
static void
cpuid_read_generic(const struct cpuid_parse_entry *e, const struct cpuid_read_output *output)
static void cpuid_read_generic(const struct cpuid_parse_entry *e, const struct cpuid_output *out)
{
struct cpuid_regs *regs = output->regs;
struct cpuid_regs *regs = out->regs;
for (int i = 0; i < e->maxcnt; i++, regs++, output->info->nr_entries++)
for (int i = 0; i < e->maxcnt; i++, regs++, out->info->nr_entries++)
cpuid_read_subleaf(e->leaf, e->subleaf + i, regs);
}
@ -60,15 +59,14 @@ static unsigned int cpuid_range_max_leaf(const struct cpuid_table *t, unsigned i
}
}
static void
__cpuid_reset_table(struct cpuid_table *t, const struct cpuid_parse_entry entries[],
unsigned int nr_entries, unsigned int start, unsigned int end, bool fill)
static void __cpuid_reset_table(struct cpuid_table *t, const struct cpuid_parse_entry entries[],
unsigned int nr_entries, unsigned int start, unsigned int end, bool fill)
{
const struct cpuid_parse_entry *entry = entries;
unsigned int range = CPUID_RANGE(start);
for (unsigned int i = 0; i < nr_entries; i++, entry++) {
struct cpuid_read_output output = {
struct cpuid_output out = {
.regs = cpuid_table_regs_p(t, entry->regs_offs),
.info = cpuid_table_info_p(t, entry->info_offs),
};
@ -76,14 +74,14 @@ __cpuid_reset_table(struct cpuid_table *t, const struct cpuid_parse_entry entrie
if (entry->leaf < start || entry->leaf > end)
continue;
cpuid_clear(entry, &output);
cpuid_clear(entry, &out);
/*
* Read the range's anchor leaf unconditionally so that the cached
* maximum valid leaf value is available for the remaining entries.
*/
if (fill && (entry->leaf == range || entry->leaf <= cpuid_range_max_leaf(t, range)))
entry->read(entry, &output);
entry->read(entry, &out);
}
}
@ -91,22 +89,20 @@ __cpuid_reset_table(struct cpuid_table *t, const struct cpuid_parse_entry entrie
* Zero all cached CPUID entries within [@start-@end] range. This is needed when
* certain operations like MSR writes induce changes to the CPU's CPUID layout.
*/
static void
__cpuid_zero_table(struct cpuid_table *t, const struct cpuid_parse_entry entries[],
unsigned int nr_entries, unsigned int start, unsigned int end)
static void __cpuid_zero_table(struct cpuid_table *t, const struct cpuid_parse_entry entries[],
unsigned int nr_entries, unsigned int start, unsigned int end)
{
__cpuid_reset_table(t, entries, nr_entries, start, end, false);
}
static void
__cpuid_fill_table(struct cpuid_table *t, const struct cpuid_parse_entry entries[],
unsigned int nr_entries, unsigned int start, unsigned int end)
static void __cpuid_fill_table(struct cpuid_table *t, const struct cpuid_parse_entry entries[],
unsigned int nr_entries, unsigned int start, unsigned int end)
{
__cpuid_reset_table(t, entries, nr_entries, start, end, true);
}
static void
cpuid_fill_table(struct cpuid_table *t, const struct cpuid_parse_entry entries[], unsigned int nr_entries)
static void cpuid_fill_table(struct cpuid_table *t, const struct cpuid_parse_entry entries[],
unsigned int nr_entries)
{
static const struct {
unsigned int start;
@ -127,8 +123,8 @@ static void __cpuid_scan_cpu_full(struct cpuinfo_x86 *c)
cpuid_fill_table(table, cpuid_parse_entries, nr_entries);
}
static void
__cpuid_scan_cpu_partial(struct cpuinfo_x86 *c, unsigned int start_leaf, unsigned int end_leaf)
static void __cpuid_scan_cpu_partial(struct cpuinfo_x86 *c, unsigned int start_leaf,
unsigned int end_leaf)
{
unsigned int nr_entries = ARRAY_SIZE(cpuid_parse_entries);
struct cpuid_table *table = &c->cpuid;

View File

@ -35,21 +35,21 @@
* Translation of compile time offsets to generic runtime pointers:
*/
static inline struct cpuid_regs *
cpuid_table_regs_p(const struct cpuid_table *t, unsigned long regs_offset)
static inline struct cpuid_regs *cpuid_table_regs_p(const struct cpuid_table *t,
unsigned long regs_offset)
{
return (struct cpuid_regs *)((unsigned long)(&t->leaves) + regs_offset);
}
static inline struct leaf_parse_info *
cpuid_table_info_p(const struct cpuid_table *t, unsigned long info_offset)
static inline struct leaf_parse_info *cpuid_table_info_p(const struct cpuid_table *t,
unsigned long info_offset)
{
return (struct leaf_parse_info *)((unsigned long)(&t->leaves) + info_offset);
}
/**
* struct cpuid_read_output - Output of a CPUID read operation
* @regs: Pointer to an array of CPUID outputs, where each array element covers the
* struct cpuid_output - Output of a CPUID operation
* @regs: Pointer to an array of CPUID results, where each array element covers the
* full EAX->EDX output range.
* @info: Pointer to query info; for saving the number of filled elements at @regs.
*
@ -59,7 +59,7 @@ cpuid_table_info_p(const struct cpuid_table *t, unsigned long info_offset)
*
* See struct cpuid_parse_entry.read().
*/
struct cpuid_read_output {
struct cpuid_output {
struct cpuid_regs *regs;
struct leaf_parse_info *info;
};
@ -74,8 +74,8 @@ struct cpuid_read_output {
* passed to cpuid_table_info_p().
* @maxcnt: Maximum number of output storage entries available for the CPUID query.
* @read: Read function for this entry. It must save the parsed CPUID output to the passed
* 'struct cpuid_read_output'->regs array of size >= @maxcnt. It must set
* 'struct cpuid_read_output'->info.nr_entries to the number of CPUID output entries
* 'struct cpuid_output'->regs array of size >= @maxcnt. It must set
* 'struct cpuid_output'->info.nr_entries to the number of CPUID output entries
* parsed and filled. A generic implementation is provided at cpuid_read_generic().
*/
struct cpuid_parse_entry {
@ -84,7 +84,7 @@ struct cpuid_parse_entry {
unsigned int regs_offs;
unsigned int info_offs;
unsigned int maxcnt;
void (*read)(const struct cpuid_parse_entry *e, const struct cpuid_read_output *o);
void (*read)(const struct cpuid_parse_entry *e, const struct cpuid_output *o);
};
#define __CPUID_PARSE_ENTRY(_leaf, _subleaf, _suffix, _reader_fn) \