linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cristian Marussi <cristian.marussi@arm.com>
To: Sudeep Holla <sudeep.holla@arm.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 01/15] firmware: arm_scmi: Add support for multiple device per protocol
Date: Tue, 10 Dec 2019 17:02:58 +0000	[thread overview]
Message-ID: <3d3a3b53-dc2e-bcac-66c6-9537ffaf7be1@arm.com> (raw)
In-Reply-To: <20191210145345.11616-2-sudeep.holla@arm.com>

Hi Sudeep,

On 10/12/2019 14:53, Sudeep Holla wrote:
> Currently only one scmi device is created for each protocol enumerated.
> However, there is requirement to make use of some procotols by multiple
> kernel subsystems/frameworks. One such example is SCMI PERFORMANCE
> protocol which can be used by both cpufreq and devfreq drivers.
> Similarly, SENSOR protocol may be used by hwmon and iio subsystems,
> and POWER protocol may be used by genpd and regulator drivers.
> 
> In order to achieve that, let us extend the scmi bus to match based
> not only protocol id but also the scmi device name if one is available.
> 
> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
> ---
>  drivers/firmware/arm_scmi/bus.c    | 20 +++++++++++++++++---
>  drivers/firmware/arm_scmi/driver.c |  6 +++---
>  include/linux/scmi_protocol.h      |  5 ++++-
>  3 files changed, 24 insertions(+), 7 deletions(-)
> 

Looks good to me.

Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>

Cheers

Cristian

> diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c
> index 7a30952b463d..3714e6307b05 100644
> --- a/drivers/firmware/arm_scmi/bus.c
> +++ b/drivers/firmware/arm_scmi/bus.c
> @@ -28,8 +28,12 @@ scmi_dev_match_id(struct scmi_device *scmi_dev, struct scmi_driver *scmi_drv)
>  		return NULL;
> 
>  	for (; id->protocol_id; id++)
> -		if (id->protocol_id == scmi_dev->protocol_id)
> -			return id;
> +		if (id->protocol_id == scmi_dev->protocol_id) {
> +			if (!id->name)
> +				return id;
> +			else if (!strcmp(id->name, scmi_dev->name))
> +				return id;
> +		}
> 
>  	return NULL;
>  }
> @@ -125,7 +129,8 @@ static void scmi_device_release(struct device *dev)
>  }
> 
>  struct scmi_device *
> -scmi_device_create(struct device_node *np, struct device *parent, int protocol)
> +scmi_device_create(struct device_node *np, struct device *parent, int protocol,
> +		   const char *name)
>  {
>  	int id, retval;
>  	struct scmi_device *scmi_dev;
> @@ -134,8 +139,15 @@ scmi_device_create(struct device_node *np, struct device *parent, int protocol)
>  	if (!scmi_dev)
>  		return NULL;
> 
> +	scmi_dev->name = kstrdup_const(name ?: "unknown", GFP_KERNEL);
> +	if (!scmi_dev->name) {
> +		kfree(scmi_dev);
> +		return NULL;
> +	}
> +
>  	id = ida_simple_get(&scmi_bus_id, 1, 0, GFP_KERNEL);
>  	if (id < 0) {
> +		kfree_const(scmi_dev->name);
>  		kfree(scmi_dev);
>  		return NULL;
>  	}
> @@ -154,6 +166,7 @@ scmi_device_create(struct device_node *np, struct device *parent, int protocol)
> 
>  	return scmi_dev;
>  put_dev:
> +	kfree_const(scmi_dev->name);
>  	put_device(&scmi_dev->dev);
>  	ida_simple_remove(&scmi_bus_id, id);
>  	return NULL;
> @@ -161,6 +174,7 @@ scmi_device_create(struct device_node *np, struct device *parent, int protocol)
> 
>  void scmi_device_destroy(struct scmi_device *scmi_dev)
>  {
> +	kfree_const(scmi_dev->name);
>  	scmi_handle_put(scmi_dev->handle);
>  	ida_simple_remove(&scmi_bus_id, scmi_dev->id);
>  	device_unregister(&scmi_dev->dev);
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index 3eb0382491ce..dee7ce3bd815 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -803,11 +803,11 @@ scmi_mbox_txrx_setup(struct scmi_info *info, struct device *dev, int prot_id)
> 
>  static inline void
>  scmi_create_protocol_device(struct device_node *np, struct scmi_info *info,
> -			    int prot_id)
> +			    int prot_id, const char *name)
>  {
>  	struct scmi_device *sdev;
> 
> -	sdev = scmi_device_create(np, info->dev, prot_id);
> +	sdev = scmi_device_create(np, info->dev, prot_id, name);
>  	if (!sdev) {
>  		dev_err(info->dev, "failed to create %d protocol device\n",
>  			prot_id);
> @@ -892,7 +892,7 @@ static int scmi_probe(struct platform_device *pdev)
>  			continue;
>  		}
> 
> -		scmi_create_protocol_device(child, info, prot_id);
> +		scmi_create_protocol_device(child, info, prot_id, NULL);
>  	}
> 
>  	return 0;
> diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
> index 881fea47c83d..5c873a59b387 100644
> --- a/include/linux/scmi_protocol.h
> +++ b/include/linux/scmi_protocol.h
> @@ -257,6 +257,7 @@ enum scmi_std_protocol {
>  struct scmi_device {
>  	u32 id;
>  	u8 protocol_id;
> +	const char *name;
>  	struct device dev;
>  	struct scmi_handle *handle;
>  };
> @@ -264,11 +265,13 @@ struct scmi_device {
>  #define to_scmi_dev(d) container_of(d, struct scmi_device, dev)
> 
>  struct scmi_device *
> -scmi_device_create(struct device_node *np, struct device *parent, int protocol);
> +scmi_device_create(struct device_node *np, struct device *parent, int protocol,
> +		   const char *name);
>  void scmi_device_destroy(struct scmi_device *scmi_dev);
> 
>  struct scmi_device_id {
>  	u8 protocol_id;
> +	const char *name;
>  };
> 
>  struct scmi_driver {
> --
> 2.17.1
> 


  reply	other threads:[~2019-12-10 17:03 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-10 14:53 [PATCH 00/15] " Sudeep Holla
2019-12-10 14:53 ` [PATCH 01/15] " Sudeep Holla
2019-12-10 17:02   ` Cristian Marussi [this message]
2019-12-10 14:53 ` [PATCH 02/15] firmware: arm_scmi: Skip scmi mbox channel setup for addtional devices Sudeep Holla
2019-12-10 17:33   ` Cristian Marussi
2019-12-10 14:53 ` [PATCH 03/15] firmware: arm_scmi: Skip protocol initialisation for additional devices Sudeep Holla
2019-12-10 18:14   ` Cristian Marussi
2019-12-10 14:53 ` [PATCH 04/15] firmware: arm_scmi: Add names to scmi devices created Sudeep Holla
2019-12-10 18:26   ` Cristian Marussi
2019-12-10 14:53 ` [PATCH 05/15] firmware: arm_scmi: Add versions and identifier attributes using dev_groups Sudeep Holla
2019-12-11 13:21   ` Cristian Marussi
2019-12-10 14:53 ` [PATCH 06/15] firmware: arm_scmi: Update scmi_prot_init_fn_t to use device instead of handle Sudeep Holla
2019-12-11 17:34   ` Cristian Marussi
2019-12-10 14:53 ` [PATCH 07/15] firmware: arm_scmi: Stash version in protocol init functions Sudeep Holla
2019-12-11 17:35   ` Cristian Marussi
2019-12-10 14:53 ` [PATCH 08/15] firmware: arm_scmi: Add and initialise protocol version to scmi_device structure Sudeep Holla
2019-12-11 18:06   ` Cristian Marussi
2019-12-12 12:15     ` Sudeep Holla
2019-12-10 14:53 ` [PATCH 09/15] firmware: arm_scmi: Add scmi protocol version and id device attributes Sudeep Holla
2019-12-11 18:08   ` Cristian Marussi
2019-12-10 14:53 ` [PATCH 10/15] firmware: arm_scmi: Drop logging individual scmi protocol version Sudeep Holla
2019-12-11 18:09   ` Cristian Marussi
2019-12-10 14:53 ` [PATCH 11/15] firmware: arm_scmi: Match scmi device by both name and protocol id Sudeep Holla
2019-12-11 18:09   ` Cristian Marussi
2019-12-11 18:10   ` Cristian Marussi
2019-12-10 14:53 ` [PATCH 12/15] clk: scmi: " Sudeep Holla
2019-12-24  7:49   ` Stephen Boyd
2019-12-10 14:53 ` [PATCH 13/15] cpufreq: " Sudeep Holla
2019-12-11  2:39   ` Viresh Kumar
2019-12-11 10:13     ` Sudeep Holla
2019-12-11 10:30       ` Viresh Kumar
2019-12-10 14:53 ` [PATCH 14/15] hwmon: (scmi-hwmon) " Sudeep Holla
2019-12-10 18:06   ` Guenter Roeck
2019-12-10 18:20     ` Sudeep Holla
2019-12-10 14:53 ` [PATCH 15/15] reset: reset-scmi: " Sudeep Holla
2019-12-11  9:51   ` Philipp Zabel
2019-12-11 15:28     ` Sudeep Holla

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=3d3a3b53-dc2e-bcac-66c6-9537ffaf7be1@arm.com \
    --to=cristian.marussi@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sudeep.holla@arm.com \
    --subject='Re: [PATCH 01/15] firmware: arm_scmi: Add support for multiple device per protocol' \
    /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

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox