Re: [PATCH 1/2] lscpu-arm: Allow externally sourced model name.

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

 



Hi Paul,

On Fri, Jul 11, 2025 at 02:16:47PM -0700, Paul Benoit wrote:
> When there isn't an entry for the model name in the id_part table(s),
> attempt to get the machine name from /sys/bus/soc/devices/soc0/machine

How is it supposed to work on a system with multiple CPU types (more CPU  
models) if it reads all from the same path?

> +	/*
> +	 * If the Model name was not found in the lscpu 'id_part' tables, see
> +	 * if there is a Machine name associated with the SOC.  This name may
> +	 * have been set via either SOC specific support code, or obtained
> +	 * via an ARM SMC CC call into Trusted Firmware.
> +	 */
> +	if (!ct->modelname) {
> +		fd = ul_path_fopen(NULL, "r", _PATH_SOC_MACHINENAME);
> +		if (fd) {
> +			if (!fgets(machinename, sizeof(machinename), fd))
> +				machinename[0] = '\0';
> +			fclose(fd);
> +
> +			/* Replace newline with string terminator */
> +			for (i = 0; i < strlen(machinename); i++) {
> +				if (machinename[i] == '\n')
> +					machinename[i] = '\0';
> +			}
> +
> +			if (strnlen(machinename, sizeof(machinename)))
> +				ct->modelname = xstrdup(machinename);

    if (!ct->modelname)
        ul_path_read_string(NULL, &ct->modelname, _PATH_SOC_MACHINENAME);

This should be enough, it reads the string, removes \n and strdup()
the result.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com





[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux