Re: [PATCH v3 4/6] acpi: Break out nesting for hmat_parse_locality()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 15 Jun 2023 14:24:07 -0700
Dave Jiang <dave.jiang@xxxxxxxxx> wrote:

> Refactor hmat_parse_locality() to break up the deep nesting of the
> function.
> 
> Suggested-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
> Signed-off-by: Dave Jiang <dave.jiang@xxxxxxxxx>

Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>

> ---
>  drivers/acpi/numa/hmat.c |   32 ++++++++++++++++++++------------
>  1 file changed, 20 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/acpi/numa/hmat.c b/drivers/acpi/numa/hmat.c
> index e2ab1cce0add..cb240f5233fe 100644
> --- a/drivers/acpi/numa/hmat.c
> +++ b/drivers/acpi/numa/hmat.c
> @@ -320,11 +320,28 @@ static __init void hmat_add_locality(struct acpi_hmat_locality *hmat_loc)
>  	}
>  }
>  
> +static __init void hmat_update_target(unsigned int tgt_pxm, unsigned int init_pxm,
> +				      u8 mem_hier, u8 type, u32 value)
> +{
> +	struct memory_target *target = find_mem_target(tgt_pxm);
> +
> +	if (mem_hier != ACPI_HMAT_MEMORY)
> +		return;
> +
> +	if (target && target->processor_pxm == init_pxm) {
> +		hmat_update_target_access(target, type, value,
> +					  NODE_ACCESS_CLASS_0);
> +		/* If the node has a CPU, update access 1 */
> +		if (node_state(pxm_to_node(init_pxm), N_CPU))
> +			hmat_update_target_access(target, type, value,
> +						  NODE_ACCESS_CLASS_1);
> +	}
> +}
> +
>  static __init int hmat_parse_locality(union acpi_subtable_headers *header,
>  				      const unsigned long end)
>  {
>  	struct acpi_hmat_locality *hmat_loc = (void *)header;
> -	struct memory_target *target;
>  	unsigned int init, targ, total_size, ipds, tpds;
>  	u32 *inits, *targs, value;
>  	u16 *entries;
> @@ -365,17 +382,8 @@ static __init int hmat_parse_locality(union acpi_subtable_headers *header,
>  				inits[init], targs[targ], value,
>  				hmat_data_type_suffix(type));
>  
> -			if (mem_hier == ACPI_HMAT_MEMORY) {
> -				target = find_mem_target(targs[targ]);
> -				if (target && target->processor_pxm == inits[init]) {
> -					hmat_update_target_access(target, type, value,
> -								  NODE_ACCESS_CLASS_0);
> -					/* If the node has a CPU, update access 1 */
> -					if (node_state(pxm_to_node(inits[init]), N_CPU))
> -						hmat_update_target_access(target, type, value,
> -									  NODE_ACCESS_CLASS_1);
> -				}
> -			}
> +			hmat_update_target(targs[targ], inits[init],
> +					   mem_hier, type, value);
>  		}
>  	}
>  
> 
> 
> 




[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux