All of lore.kernel.org
 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 v5 06/11] platform/x86/amd/hsmp: Restructure sysfs group creation
Date: Wed, 24 Jan 2024 14:34:15 +0200 (EET)	[thread overview]
Message-ID: <c826d19f-5f84-012a-cd58-a620783f75f7@linux.intel.com> (raw)
In-Reply-To: <20240106022532.1746932-6-suma.hegde@amd.com>

[-- Attachment #1: Type: text/plain, Size: 3782 bytes --]

On Sat, 6 Jan 2024, Suma Hegde wrote:

> Split the creation of array of attribute groups and array of attributes
> into different functions. This will ease the ACPI support.
> 
> Signed-off-by: Suma Hegde <suma.hegde@amd.com>
> Signed-off-by: Naveen Krishna Chatradhi <nchatrad@amd.com>
> ---
> Changes since v4:
> New patch, generated after splitting 6th patch in v4 series
> 
>  drivers/platform/x86/amd/hsmp.c | 44 ++++++++++++++++++---------------
>  1 file changed, 24 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/platform/x86/amd/hsmp.c b/drivers/platform/x86/amd/hsmp.c
> index 0bf94e2bd022..cf8e8d155155 100644
> --- a/drivers/platform/x86/amd/hsmp.c
> +++ b/drivers/platform/x86/amd/hsmp.c
> @@ -442,49 +442,53 @@ static int hsmp_init_metric_tbl_bin_attr(struct bin_attribute **hattrs, u16 sock
>  /* One bin sysfs for metrics table*/
>  #define NUM_HSMP_ATTRS		1
>  
> -static int hsmp_create_sysfs_interface(void)
> +static int hsmp_create_attr_list(struct attribute_group *attr_grp,
> +				 struct device *dev, u16 sock_ind)
>  {
> -	const struct attribute_group **hsmp_attr_grps;
>  	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);
> +	if (!hsmp_bin_attrs)
> +		return -ENOMEM;
> +
> +	attr_grp->bin_attrs = hsmp_bin_attrs;
> +
> +	return hsmp_init_metric_tbl_bin_attr(hsmp_bin_attrs, sock_ind);
> +}
> +
> +static int hsmp_create_sysfs_interface(struct device *dev)
> +{
> +	const struct attribute_group **hsmp_attr_grps;
>  	struct attribute_group *attr_grp;
> -	int ret;
>  	u16 i;
>  
>  	/* String formatting is currently limited to u8 sockets */
>  	if (WARN_ON(plat_dev.num_sockets > U8_MAX))
>  		return -ERANGE;
>  
> -	hsmp_attr_grps = devm_kzalloc(plat_dev.sock[0].dev, sizeof(struct attribute_group *) *
> +	hsmp_attr_grps = devm_kzalloc(dev, sizeof(struct attribute_group *) *
>  				      (plat_dev.num_sockets + 1), GFP_KERNEL);
>  	if (!hsmp_attr_grps)
>  		return -ENOMEM;
>  
>  	/* Create a sysfs directory for each socket */
>  	for (i = 0; i < plat_dev.num_sockets; i++) {
> -		attr_grp = devm_kzalloc(plat_dev.sock[i].dev, sizeof(struct attribute_group),
> +		attr_grp = devm_kzalloc(dev, sizeof(struct attribute_group),
>  					GFP_KERNEL);
>  		if (!attr_grp)
>  			return -ENOMEM;
>  
>  		snprintf(plat_dev.sock[i].name, HSMP_ATTR_GRP_NAME_SIZE, "socket%u", (u8)i);
> -		attr_grp->name = plat_dev.sock[i].name;
> -
> -		/* Null terminated list of attributes */
> -		hsmp_bin_attrs = devm_kzalloc(plat_dev.sock[i].dev, sizeof(struct bin_attribute *) *
> -					      (NUM_HSMP_ATTRS + 1), GFP_KERNEL);
> -		if (!hsmp_bin_attrs)
> -			return -ENOMEM;
> -
> -		attr_grp->bin_attrs		= hsmp_bin_attrs;
> +		attr_grp->name			= plat_dev.sock[i].name;
>  		attr_grp->is_bin_visible	= hsmp_is_sock_attr_visible;
>  		hsmp_attr_grps[i]		= attr_grp;
>  
> -		/* Now create the leaf nodes */
> -		ret = hsmp_init_metric_tbl_bin_attr(hsmp_bin_attrs, i);
> -		if (ret)
> -			return ret;
> +		hsmp_create_attr_list(attr_grp, dev, i);
>  	}
> -	return devm_device_add_groups(plat_dev.sock[0].dev, hsmp_attr_grps);
> +
> +	return devm_device_add_groups(dev, hsmp_attr_grps);
>  }
>  
>  static int hsmp_cache_proto_ver(void)
> @@ -561,7 +565,7 @@ static int hsmp_pltdrv_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> -	ret = hsmp_create_sysfs_interface();
> +	ret = hsmp_create_sysfs_interface(&pdev->dev);
>  	if (ret)
>  		dev_err(&pdev->dev, "Failed to create HSMP sysfs interface\n");
>  
> 

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>


-- 
 i.

  reply	other threads:[~2024-01-24 12:34 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-06  2:25 [PATCH v5 01/11] platform/x86/amd/hsmp: Move hsmp_test to probe Suma Hegde
2024-01-06  2:25 ` [PATCH v5 02/11] platform/x86/amd/hsmp: Cache pci_dev in struct hsmp_socket Suma Hegde
2024-01-06  2:25 ` [PATCH v5 03/11] platform/x86/amd/hsmp: Create static func to handle platdev Suma Hegde
2024-01-06  2:25 ` [PATCH v5 04/11] platform/x86/amd/hsmp: Define a struct to hold mailbox regs Suma Hegde
2024-01-06  2:25 ` [PATCH v5 05/11] platform/x86/amd/hsmp: Move dev from platdev to hsmp_socket Suma Hegde
2024-01-06  2:25 ` [PATCH v5 06/11] platform/x86/amd/hsmp: Restructure sysfs group creation Suma Hegde
2024-01-24 12:34   ` Ilpo Järvinen [this message]
2024-01-06  2:25 ` [PATCH v5 07/11] platform/x86/amd/hsmp: Add support for ACPI based probing Suma Hegde
2024-01-24 13:02   ` Ilpo Järvinen
2024-01-06  2:25 ` [PATCH v5 08/11] platform/x86/amd/hsmp: Non-ACPI support for AMD F1A_M00~0Fh Suma Hegde
2024-01-06  2:25 ` [PATCH v5 09/11] platform/x86/amd/hsmp: Check num_sockets against MAX_AMD_SOCKETS Suma Hegde
2024-01-06  2:25 ` [PATCH v5 10/11] platform/x86/amd/hsmp: Change devm_kzalloc() to devm_kcalloc() Suma Hegde
2024-01-24 12:29   ` Ilpo Järvinen
2024-01-25 12:33   ` Ilpo Järvinen
2024-01-29 12:44     ` Ilpo Järvinen
2024-01-29 13:24       ` Hegde, Suma
2024-01-31 10:32         ` Ilpo Järvinen
2024-02-06  6:38           ` Hegde, Suma
2024-02-06  9:04             ` Ilpo Järvinen
2024-02-06  9:46               ` Hegde, Suma
2024-01-06  2:25 ` [PATCH v5 11/11] platform/x86/amd/hsmp: Remove extra parenthesis and add a space Suma Hegde
2024-01-24 12:25   ` Ilpo Järvinen

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=c826d19f-5f84-012a-cd58-a620783f75f7@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.