diff mbox series

[2/8] platform/surface: aggregator: Add platform handler pointer to device

Message ID 20241025193055.2235-3-mario.limonciello@amd.com (mailing list archive)
State Superseded, archived
Headers show
Series Add support for binding ACPI platform profile to multiple drivers | expand

Commit Message

Mario Limonciello Oct. 25, 2024, 7:30 p.m. UTC
To be able to reference the platform handler in remove, add
a pointer to `struct ssam_device`.

Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/platform/surface/surface_platform_profile.c | 1 +
 include/linux/surface_aggregator/device.h           | 2 ++
 2 files changed, 3 insertions(+)

Comments

Hans de Goede Oct. 26, 2024, 10:06 a.m. UTC | #1
Hi,

On 25-Oct-24 9:30 PM, Mario Limonciello wrote:
> To be able to reference the platform handler in remove, add
> a pointer to `struct ssam_device`.
> 
> Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <hdegoede@redhat.com>

Regards,

Hans


> ---
>  drivers/platform/surface/surface_platform_profile.c | 1 +
>  include/linux/surface_aggregator/device.h           | 2 ++
>  2 files changed, 3 insertions(+)
> 
> diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
> index 61aa488a80eb5..958afd7bce223 100644
> --- a/drivers/platform/surface/surface_platform_profile.c
> +++ b/drivers/platform/surface/surface_platform_profile.c
> @@ -210,6 +210,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev)
>  		return -ENOMEM;
>  
>  	tpd->sdev = sdev;
> +	sdev->tpd = tpd;
>  
>  	tpd->handler.name = "Surface Platform Profile";
>  	tpd->handler.profile_get = ssam_platform_profile_get;
> diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
> index 8cd8c38cf3f30..6a72b5bdc8782 100644
> --- a/include/linux/surface_aggregator/device.h
> +++ b/include/linux/surface_aggregator/device.h
> @@ -164,6 +164,7 @@ enum ssam_device_flags {
>   * @dev:   Driver model representation of the device.
>   * @ctrl:  SSAM controller managing this device.
>   * @uid:   UID identifying the device.
> + * @tpd:   Platform profile device data.
>   * @flags: Device state flags, see &enum ssam_device_flags.
>   */
>  struct ssam_device {
> @@ -171,6 +172,7 @@ struct ssam_device {
>  	struct ssam_controller *ctrl;
>  
>  	struct ssam_device_uid uid;
> +	struct ssam_platform_profile_device *tpd;
>  
>  	unsigned long flags;
>  };
Maximilian Luz Oct. 27, 2024, 11:10 p.m. UTC | #2
On 10/25/24 9:30 PM, Mario Limonciello wrote:
> To be able to reference the platform handler in remove, add
> a pointer to `struct ssam_device`.
> 
> Tested-by: Matthew Schwartz <matthew.schwartz@linux.dev>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>   drivers/platform/surface/surface_platform_profile.c | 1 +
>   include/linux/surface_aggregator/device.h           | 2 ++
>   2 files changed, 3 insertions(+)
> 
> diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
> index 61aa488a80eb5..958afd7bce223 100644
> --- a/drivers/platform/surface/surface_platform_profile.c
> +++ b/drivers/platform/surface/surface_platform_profile.c
> @@ -210,6 +210,7 @@ static int surface_platform_profile_probe(struct ssam_device *sdev)
>   		return -ENOMEM;
>   
>   	tpd->sdev = sdev;
> +	sdev->tpd = tpd;
>   
>   	tpd->handler.name = "Surface Platform Profile";
>   	tpd->handler.profile_get = ssam_platform_profile_get;
> diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
> index 8cd8c38cf3f30..6a72b5bdc8782 100644
> --- a/include/linux/surface_aggregator/device.h
> +++ b/include/linux/surface_aggregator/device.h
> @@ -164,6 +164,7 @@ enum ssam_device_flags {
>    * @dev:   Driver model representation of the device.
>    * @ctrl:  SSAM controller managing this device.
>    * @uid:   UID identifying the device.
> + * @tpd:   Platform profile device data.
>    * @flags: Device state flags, see &enum ssam_device_flags.
>    */
>   struct ssam_device {
> @@ -171,6 +172,7 @@ struct ssam_device {
>   	struct ssam_controller *ctrl;
>   
>   	struct ssam_device_uid uid;
> +	struct ssam_platform_profile_device *tpd;

Do we really need to introduce a new field in the main SSAM device struct? I
only had time for a brief look, but IIUC you could just use ssam_device_set_drvdata()
and ssam_device_get_drvdata().

>   	unsigned long flags;
>   };

Best regards,
Max
diff mbox series

Patch

diff --git a/drivers/platform/surface/surface_platform_profile.c b/drivers/platform/surface/surface_platform_profile.c
index 61aa488a80eb5..958afd7bce223 100644
--- a/drivers/platform/surface/surface_platform_profile.c
+++ b/drivers/platform/surface/surface_platform_profile.c
@@ -210,6 +210,7 @@  static int surface_platform_profile_probe(struct ssam_device *sdev)
 		return -ENOMEM;
 
 	tpd->sdev = sdev;
+	sdev->tpd = tpd;
 
 	tpd->handler.name = "Surface Platform Profile";
 	tpd->handler.profile_get = ssam_platform_profile_get;
diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h
index 8cd8c38cf3f30..6a72b5bdc8782 100644
--- a/include/linux/surface_aggregator/device.h
+++ b/include/linux/surface_aggregator/device.h
@@ -164,6 +164,7 @@  enum ssam_device_flags {
  * @dev:   Driver model representation of the device.
  * @ctrl:  SSAM controller managing this device.
  * @uid:   UID identifying the device.
+ * @tpd:   Platform profile device data.
  * @flags: Device state flags, see &enum ssam_device_flags.
  */
 struct ssam_device {
@@ -171,6 +172,7 @@  struct ssam_device {
 	struct ssam_controller *ctrl;
 
 	struct ssam_device_uid uid;
+	struct ssam_platform_profile_device *tpd;
 
 	unsigned long flags;
 };