Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Naveen Krishna Chatradhi <nchatrad@amd.com>
Cc: linux-hwmon@vger.kernel.org, naveenkrishna.ch@gmail.com,
	Akshay Gupta <Akshay.Gupta@amd.com>
Subject: Re: [PATCH v2 1/4] hwmon: amd_energy: Move label out of accumulation structure
Date: Tue, 29 Sep 2020 22:03:47 -0700	[thread overview]
Message-ID: <20200930050347.GA193415@roeck-us.net> (raw)
In-Reply-To: <20200929105322.8919-2-nchatrad@amd.com>

On Tue, Sep 29, 2020 at 04:23:19PM +0530, Naveen Krishna Chatradhi wrote:
> From: Akshay Gupta <Akshay.Gupta@amd.com>
> 
> At present, core & socket labels are defined in struct sensor_accumulator
> This patch moves it to the amd_energy_data structure, which will
> help in calling memset on struct sensor_accumulator to optimize the code.
> 
> Signed-off-by: Akshay Gupta <Akshay.Gupta@amd.com>

Series applied.

Thanks,
Guenter

> ---
> Changes since v1:
> None
> 
>  drivers/hwmon/amd_energy.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/hwmon/amd_energy.c b/drivers/hwmon/amd_energy.c
> index 29603742c858..9580a16185b8 100644
> --- a/drivers/hwmon/amd_energy.c
> +++ b/drivers/hwmon/amd_energy.c
> @@ -35,7 +35,6 @@
>  struct sensor_accumulator {
>  	u64 energy_ctr;
>  	u64 prev_value;
> -	char label[10];
>  };
>  
>  struct amd_energy_data {
> @@ -52,6 +51,7 @@ struct amd_energy_data {
>  	int nr_cpus;
>  	int nr_socks;
>  	int core_id;
> +	char (*label)[10];
>  };
>  
>  static int amd_energy_read_labels(struct device *dev,
> @@ -61,7 +61,7 @@ static int amd_energy_read_labels(struct device *dev,
>  {
>  	struct amd_energy_data *data = dev_get_drvdata(dev);
>  
> -	*str = data->accums[channel].label;
> +	*str = data->label[channel];
>  	return 0;
>  }
>  
> @@ -253,6 +253,7 @@ static int amd_create_sensor(struct device *dev,
>  	struct sensor_accumulator *accums;
>  	int i, num_siblings, cpus, sockets;
>  	u32 *s_config;
> +	char (*label_l)[10];
>  
>  	/* Identify the number of siblings per core */
>  	num_siblings = ((cpuid_ebx(0x8000001e) >> 8) & 0xff) + 1;
> @@ -276,21 +277,25 @@ static int amd_create_sensor(struct device *dev,
>  	if (!accums)
>  		return -ENOMEM;
>  
> +	label_l = devm_kcalloc(dev, cpus + sockets,
> +			       sizeof(*label_l), GFP_KERNEL);
> +	if (!label_l)
> +		return -ENOMEM;
> +
>  	info->type = type;
>  	info->config = s_config;
>  
>  	data->nr_cpus = cpus;
>  	data->nr_socks = sockets;
>  	data->accums = accums;
> +	data->label = label_l;
>  
>  	for (i = 0; i < cpus + sockets; i++) {
>  		s_config[i] = config;
>  		if (i < cpus)
> -			scnprintf(accums[i].label, 10,
> -				  "Ecore%03u", i);
> +			scnprintf(label_l[i], 10, "Ecore%03u", i);
>  		else
> -			scnprintf(accums[i].label, 10,
> -				  "Esocket%u", (i - cpus));
> +			scnprintf(label_l[i], 10, "Esocket%u", (i - cpus));
>  	}
>  
>  	return 0;

  reply	other threads:[~2020-09-30  5:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29 10:53 [PATCH v2 0/4] hwmon: improvements to amd_energy driver Naveen Krishna Chatradhi
2020-09-29 10:53 ` [PATCH v2 1/4] hwmon: amd_energy: Move label out of accumulation structure Naveen Krishna Chatradhi
2020-09-30  5:03   ` Guenter Roeck [this message]
2020-09-29 10:53 ` [PATCH v2 2/4] hwmon: amd_energy: optimize accumulation interval Naveen Krishna Chatradhi
2020-09-29 10:53 ` [PATCH v2 3/4] hwmon: amd_energy: Improve the accumulation logic Naveen Krishna Chatradhi
2020-09-29 10:53 ` [PATCH v2 4/4] hwmon: (amd_energy) Update driver documentation Naveen Krishna Chatradhi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200930050347.GA193415@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=Akshay.Gupta@amd.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=naveenkrishna.ch@gmail.com \
    --cc=nchatrad@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox