X86 platform drivers
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Suma Hegde <suma.hegde@amd.com>
Cc: platform-driver-x86@vger.kernel.org,
	Hans de Goede <hdegoede@redhat.com>,
	 Naveen Krishna Chatradhi <nchatrad@amd.com>
Subject: Re: [PATCH v4 9/9] platform/x86/amd/hsmp: Change devm_kzalloc() to devm_kcalloc()
Date: Fri, 5 Jan 2024 11:37:58 +0200 (EET)	[thread overview]
Message-ID: <29f4398-7c7a-528f-c13e-d7875f544e6b@linux.intel.com> (raw)
In-Reply-To: <20240105074618.1667898-10-suma.hegde@amd.com>

On Fri, 5 Jan 2024, Suma Hegde wrote:

> Use the standard array allocation variant of devm memory allocation
> APIs.
> 
> Also remove extra parenthesis around hsmp_get_tbl_dram_base()
> and add a space in a comment.
> 
> Signed-off-by: Suma Hegde <suma.hegde@amd.com>
> Reviewed-by: Naveen Krishna Chatradhi <nchatrad@amd.com>
> ---
> Changes since v3:
> New patch, based on Ilpos review comments and additional cosmetic changes.
> 
>  drivers/platform/x86/amd/hsmp.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/platform/x86/amd/hsmp.c b/drivers/platform/x86/amd/hsmp.c
> index 99bebb0ca5a9..f2247885c547 100644
> --- a/drivers/platform/x86/amd/hsmp.c
> +++ b/drivers/platform/x86/amd/hsmp.c
> @@ -643,12 +643,12 @@ static int hsmp_init_metric_tbl_bin_attr(struct bin_attribute **hattrs, u16 sock
>  	hattrs[0]		= hattr;
>  
>  	if (plat_dev.proto_ver == HSMP_PROTO_VER6)
> -		return (hsmp_get_tbl_dram_base(sock_ind));
> +		return hsmp_get_tbl_dram_base(sock_ind);
>  	else
>  		return 0;
>  }
>  
> -/* One bin sysfs for metrics table*/
> +/* One bin sysfs for metrics table */
>  #define NUM_HSMP_ATTRS		1
>  
>  static int hsmp_create_attr_list(struct attribute_group *attr_grp,

Please put these two into own change.

> @@ -657,8 +657,9 @@ static int hsmp_create_attr_list(struct attribute_group *attr_grp,
>  	struct bin_attribute **hsmp_bin_attrs;
>  
>  	/* Null terminated list of attributes */
> -	hsmp_bin_attrs = devm_kzalloc(dev, sizeof(struct bin_attribute *) *
> -				      (NUM_HSMP_ATTRS + 1), GFP_KERNEL);
> +	hsmp_bin_attrs = devm_kcalloc(dev, NUM_HSMP_ATTRS + 1,
> +				      sizeof(struct bin_attribute *),

While at it, it's better to match these sizeof()s with destination 
variable using sizeof(*hsmp_bin_attrs) construct.

> +				      GFP_KERNEL);
>  	if (!hsmp_bin_attrs)
>  		return -ENOMEM;
>  
> @@ -673,8 +674,9 @@ static int hsmp_create_non_acpi_sysfs_if(struct device *dev)
>  	struct attribute_group *attr_grp;
>  	u16 i;
>  
> -	hsmp_attr_grps = devm_kzalloc(dev, sizeof(struct attribute_group *) *
> -				      (plat_dev.num_sockets + 1), GFP_KERNEL);
> +	hsmp_attr_grps = devm_kcalloc(dev, plat_dev.num_sockets + 1,
> +				      sizeof(struct attribute_group *),
> +				      GFP_KERNEL);
>  	if (!hsmp_attr_grps)
>  		return -ENOMEM;
>  
> @@ -804,8 +806,8 @@ static int hsmp_pltdrv_probe(struct platform_device *pdev)
>  	 * on each probe.
>  	 */
>  	if (!plat_dev.is_probed) {
> -		plat_dev.sock = devm_kzalloc(&pdev->dev,
> -					     (plat_dev.num_sockets * sizeof(struct hsmp_socket)),
> +		plat_dev.sock = devm_kcalloc(&pdev->dev, plat_dev.num_sockets,
> +					     sizeof(struct hsmp_socket),
>  					     GFP_KERNEL);
>  		if (!plat_dev.sock)
>  			return -ENOMEM;
> 

-- 
 i.


      reply	other threads:[~2024-01-05  9:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-05  7:46 [PATCH v4 0/9] Add ACPI probing support for HSMP Suma Hegde
2024-01-05  7:46 ` [PATCH v4 1/9] platform/x86/amd/hsmp: Move hsmp_test to probe Suma Hegde
2024-01-05  7:46 ` [PATCH v4 2/9] platform/x86/amd/hsmp: Cache pci_dev in struct hsmp_socket Suma Hegde
2024-01-05  7:46 ` [PATCH v4 3/9] platform/x86/amd/hsmp: Create static func to handle platdev Suma Hegde
2024-01-05  7:46 ` [PATCH v4 4/9] platform/x86/amd/hsmp: Define a struct to hold mailbox regs Suma Hegde
2024-01-05  7:46 ` [PATCH v4 5/9] platform/x86/amd/hsmp: Move dev from platdev to hsmp_socket Suma Hegde
2024-01-05  7:46 ` [PATCH v4 6/9] platform/x86/amd/hsmp: Add support for ACPI based probing Suma Hegde
2024-01-05  9:31   ` Ilpo Järvinen
2024-01-06  2:11     ` Hegde, Suma
2024-01-05  7:46 ` [PATCH v4 7/9] platform/x86/amd/hsmp: Non-ACPI support for AMD F1A_M00~0Fh Suma Hegde
2024-01-05  7:46 ` [PATCH v4 8/9] platform/x86/amd/hsmp: Check num_sockets against MAX_AMD_SOCKETS Suma Hegde
2024-01-05  9:36   ` Ilpo Järvinen
2024-01-05  7:46 ` [PATCH v4 9/9] platform/x86/amd/hsmp: Change devm_kzalloc() to devm_kcalloc() Suma Hegde
2024-01-05  9:37   ` Ilpo Järvinen [this message]

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=29f4398-7c7a-528f-c13e-d7875f544e6b@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=hdegoede@redhat.com \
    --cc=nchatrad@amd.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=suma.hegde@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