Skip to content

Commit e7df728

Browse files
Ahmed S. DarwishIngo Molnar
authored andcommitted
x86/cpuid: Rename cpuid_get_leaf_0x2_regs() to cpuid_leaf_0x2()
Rename the CPUID(0x2) register accessor function: cpuid_get_leaf_0x2_regs(regs) to: cpuid_leaf_0x2(regs) for consistency with other <cpuid/api.h> accessors that return full CPUID registers outputs like: cpuid_leaf(regs) cpuid_subleaf(regs) In the same vein, rename the CPUID(0x2) iteration macro: for_each_leaf_0x2_entry() to: for_each_cpuid_0x2_desc() to include "cpuid" in the macro name, and since what is iterated upon is CPUID(0x2) cache and TLB "descriptos", not "entries". Prefix an underscore to that iterator macro parameters, so that the newly renamed 'desc' parameter do not get mixed with "union leaf_0x2_regs :: desc[]" in the macro's implementation. Adjust all the affected call-sites accordingly. While at it, use "CPUID(0x2)" instead of "CPUID leaf 0x2" as this is the recommended style. No change in functionality intended. Signed-off-by: Ahmed S. Darwish <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Andrew Cooper <[email protected]> Cc: John Ogness <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent 2f924ca commit e7df728

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

arch/x86/include/asm/cpuid/api.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,17 @@ static inline u32 hypervisor_cpuid_base(const char *sig, u32 leaves)
216216
*/
217217

218218
/**
219-
* cpuid_get_leaf_0x2_regs() - Return sanitized leaf 0x2 register output
219+
* cpuid_leaf_0x2() - Return sanitized CPUID(0x2) register output
220220
* @regs: Output parameter
221221
*
222-
* Query CPUID leaf 0x2 and store its output in @regs. Force set any
222+
* Query CPUID(0x2) and store its output in @regs. Force set any
223223
* invalid 1-byte descriptor returned by the hardware to zero (the NULL
224224
* cache/TLB descriptor) before returning it to the caller.
225225
*
226-
* Use for_each_leaf_0x2_entry() to iterate over the register output in
226+
* Use for_each_cpuid_0x2_desc() to iterate over the register output in
227227
* parsed form.
228228
*/
229-
static inline void cpuid_get_leaf_0x2_regs(union leaf_0x2_regs *regs)
229+
static inline void cpuid_leaf_0x2(union leaf_0x2_regs *regs)
230230
{
231231
cpuid_leaf(0x2, regs);
232232

@@ -251,34 +251,34 @@ static inline void cpuid_get_leaf_0x2_regs(union leaf_0x2_regs *regs)
251251
}
252252

253253
/**
254-
* for_each_leaf_0x2_entry() - Iterator for parsed leaf 0x2 descriptors
255-
* @regs: Leaf 0x2 register output, returned by cpuid_get_leaf_0x2_regs()
256-
* @__ptr: u8 pointer, for macro internal use only
257-
* @entry: Pointer to parsed descriptor information at each iteration
254+
* for_each_cpuid_0x2_desc() - Iterator for parsed CPUID(0x2) descriptors
255+
* @_regs: CPUID(0x2) register output, as returned by cpuid_leaf_0x2()
256+
* @_ptr: u8 pointer, for macro internal use only
257+
* @_desc: Pointer to the parsed CPUID(0x2) descriptor at each iteration
258258
*
259-
* Loop over the 1-byte descriptors in the passed leaf 0x2 output registers
260-
* @regs. Provide the parsed information for each descriptor through @entry.
259+
* Loop over the 1-byte descriptors in the passed CPUID(0x2) output registers
260+
* @_regs. Provide the parsed information for each descriptor through @_desc.
261261
*
262-
* To handle cache-specific descriptors, switch on @entry->c_type. For TLB
263-
* descriptors, switch on @entry->t_type.
262+
* To handle cache-specific descriptors, switch on @_desc->c_type. For TLB
263+
* descriptors, switch on @_desc->t_type.
264264
*
265265
* Example usage for cache descriptors::
266266
*
267-
* const struct leaf_0x2_table *entry;
267+
* const struct leaf_0x2_table *desc;
268268
* union leaf_0x2_regs regs;
269269
* u8 *ptr;
270270
*
271-
* cpuid_get_leaf_0x2_regs(&regs);
272-
* for_each_leaf_0x2_entry(regs, ptr, entry) {
273-
* switch (entry->c_type) {
271+
* cpuid_leaf_0x2(&regs);
272+
* for_each_cpuid_0x2_desc(regs, ptr, desc) {
273+
* switch (desc->c_type) {
274274
* ...
275275
* }
276276
* }
277277
*/
278-
#define for_each_leaf_0x2_entry(regs, __ptr, entry) \
279-
for (__ptr = &(regs).desc[1]; \
280-
__ptr < &(regs).desc[16] && (entry = &cpuid_0x2_table[*__ptr]); \
281-
__ptr++)
278+
#define for_each_cpuid_0x2_desc(_regs, _ptr, _desc) \
279+
for (_ptr = &(_regs).desc[1]; \
280+
_ptr < &(_regs).desc[16] && (_desc = &cpuid_0x2_table[*_ptr]); \
281+
_ptr++)
282282

283283
/*
284284
* CPUID(0x80000006) parsing:

arch/x86/kernel/cpu/cacheinfo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ static void intel_cacheinfo_0x2(struct cpuinfo_x86 *c)
388388
if (c->cpuid_level < 2)
389389
return;
390390

391-
cpuid_get_leaf_0x2_regs(&regs);
392-
for_each_leaf_0x2_entry(regs, ptr, entry) {
391+
cpuid_leaf_0x2(&regs);
392+
for_each_cpuid_0x2_desc(regs, ptr, entry) {
393393
switch (entry->c_type) {
394394
case CACHE_L1_INST: l1i += entry->c_size; break;
395395
case CACHE_L1_DATA: l1d += entry->c_size; break;

arch/x86/kernel/cpu/intel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,8 @@ static void intel_detect_tlb(struct cpuinfo_x86 *c)
716716
if (c->cpuid_level < 2)
717717
return;
718718

719-
cpuid_get_leaf_0x2_regs(&regs);
720-
for_each_leaf_0x2_entry(regs, ptr, entry)
719+
cpuid_leaf_0x2(&regs);
720+
for_each_cpuid_0x2_desc(regs, ptr, entry)
721721
intel_tlb_lookup(entry);
722722
}
723723

0 commit comments

Comments
 (0)