diff mbox series

[v1,2/4] media: ipu3-cio2: Convert to use software_node_register_node_group()

Message ID 20221118185617.33908-2-andriy.shevchenko@linux.intel.com
State Superseded
Headers show
Series [v1,1/4] media: ipu3-cio2: Don't dereference fwnode handle | expand

Commit Message

Andy Shevchenko Nov. 18, 2022, 6:56 p.m. UTC
The currently used software_node_register_nodes() is going to
be removed. Prepare driver by switchich to new API.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/media/pci/intel/ipu3/cio2-bridge.c | 21 ++++++++++++++++++---
 drivers/media/pci/intel/ipu3/cio2-bridge.h |  5 +++--
 2 files changed, 21 insertions(+), 5 deletions(-)

Comments

Dan Scally Nov. 21, 2022, 10:19 a.m. UTC | #1
Hi Andy

On 18/11/2022 18:56, Andy Shevchenko wrote:
> The currently used software_node_register_nodes() is going to
> be removed. Prepare driver by switchich to new API.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---


Also looks good to me:

Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>

>   drivers/media/pci/intel/ipu3/cio2-bridge.c | 21 ++++++++++++++++++---
>   drivers/media/pci/intel/ipu3/cio2-bridge.h |  5 +++--
>   2 files changed, 21 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.c b/drivers/media/pci/intel/ipu3/cio2-bridge.c
> index 18974a72e94a..dfefe0d8aa95 100644
> --- a/drivers/media/pci/intel/ipu3/cio2-bridge.c
> +++ b/drivers/media/pci/intel/ipu3/cio2-bridge.c
> @@ -195,6 +195,19 @@ static void cio2_bridge_init_swnode_names(struct cio2_sensor *sensor)
>   		 SWNODE_GRAPH_ENDPOINT_NAME_FMT, 0); /* And endpoint 0 */
>   }
>   
> +static void cio2_bridge_init_swnode_group(struct cio2_sensor *sensor)
> +{
> +	struct software_node *nodes = sensor->swnodes;
> +
> +	sensor->group[SWNODE_SENSOR_HID] = &nodes[SWNODE_SENSOR_HID];
> +	sensor->group[SWNODE_SENSOR_PORT] = &nodes[SWNODE_SENSOR_PORT];
> +	sensor->group[SWNODE_SENSOR_ENDPOINT] = &nodes[SWNODE_SENSOR_ENDPOINT];
> +	sensor->group[SWNODE_CIO2_PORT] = &nodes[SWNODE_CIO2_PORT];
> +	sensor->group[SWNODE_CIO2_ENDPOINT] = &nodes[SWNODE_CIO2_ENDPOINT];
> +	if (sensor->ssdb.vcmtype)
> +		sensor->group[SWNODE_VCM] =  &nodes[SWNODE_VCM];
> +}
> +
>   static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge,
>   						  struct cio2_sensor *sensor)
>   {
> @@ -219,6 +232,8 @@ static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge,
>   	if (sensor->ssdb.vcmtype)
>   		nodes[SWNODE_VCM] =
>   			NODE_VCM(cio2_vcm_types[sensor->ssdb.vcmtype - 1]);
> +
> +	cio2_bridge_init_swnode_group(sensor);
>   }
>   
>   static void cio2_bridge_instantiate_vcm_i2c_client(struct cio2_sensor *sensor)
> @@ -252,7 +267,7 @@ static void cio2_bridge_unregister_sensors(struct cio2_bridge *bridge)
>   
>   	for (i = 0; i < bridge->n_sensors; i++) {
>   		sensor = &bridge->sensors[i];
> -		software_node_unregister_nodes(sensor->swnodes);
> +		software_node_unregister_node_group(sensor->group);
>   		ACPI_FREE(sensor->pld);
>   		acpi_dev_put(sensor->adev);
>   		i2c_unregister_device(sensor->vcm_i2c_client);
> @@ -310,7 +325,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
>   		cio2_bridge_create_fwnode_properties(sensor, bridge, cfg);
>   		cio2_bridge_create_connection_swnodes(bridge, sensor);
>   
> -		ret = software_node_register_nodes(sensor->swnodes);
> +		ret = software_node_register_node_group(sensor->group);
>   		if (ret)
>   			goto err_free_pld;
>   
> @@ -337,7 +352,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
>   	return 0;
>   
>   err_free_swnodes:
> -	software_node_unregister_nodes(sensor->swnodes);
> +	software_node_unregister_node_group(sensor->group);
>   err_free_pld:
>   	ACPI_FREE(sensor->pld);
>   err_put_adev:
> diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.h b/drivers/media/pci/intel/ipu3/cio2-bridge.h
> index 4418cbd08208..b93b749c65bd 100644
> --- a/drivers/media/pci/intel/ipu3/cio2-bridge.h
> +++ b/drivers/media/pci/intel/ipu3/cio2-bridge.h
> @@ -117,8 +117,9 @@ struct cio2_sensor {
>   	struct acpi_device *adev;
>   	struct i2c_client *vcm_i2c_client;
>   
> -	/* SWNODE_COUNT + 1 for terminating empty node */
> -	struct software_node swnodes[SWNODE_COUNT + 1];
> +	/* SWNODE_COUNT + 1 for terminating NULL */
> +	const struct software_node *group[SWNODE_COUNT + 1];
> +	struct software_node swnodes[SWNODE_COUNT];
>   	struct cio2_node_names node_names;
>   
>   	struct cio2_sensor_ssdb ssdb;
Hans de Goede Nov. 21, 2022, 10:22 a.m. UTC | #2
Hi Dan,

On 11/21/22 11:19, Dan Scally wrote:
> Hi Andy
> 
> On 18/11/2022 18:56, Andy Shevchenko wrote:
>> The currently used software_node_register_nodes() is going to
>> be removed. Prepare driver by switchich to new API.
>>
>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> ---
> 
> 
> Also looks good to me:
> 
> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>

Any chance you can also give this series a test run on an IPU3 device to
ensure that it does not cause regressions ?

Regards,

Hans



> 
>>   drivers/media/pci/intel/ipu3/cio2-bridge.c | 21 ++++++++++++++++++---
>>   drivers/media/pci/intel/ipu3/cio2-bridge.h |  5 +++--
>>   2 files changed, 21 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.c b/drivers/media/pci/intel/ipu3/cio2-bridge.c
>> index 18974a72e94a..dfefe0d8aa95 100644
>> --- a/drivers/media/pci/intel/ipu3/cio2-bridge.c
>> +++ b/drivers/media/pci/intel/ipu3/cio2-bridge.c
>> @@ -195,6 +195,19 @@ static void cio2_bridge_init_swnode_names(struct cio2_sensor *sensor)
>>            SWNODE_GRAPH_ENDPOINT_NAME_FMT, 0); /* And endpoint 0 */
>>   }
>>   +static void cio2_bridge_init_swnode_group(struct cio2_sensor *sensor)
>> +{
>> +    struct software_node *nodes = sensor->swnodes;
>> +
>> +    sensor->group[SWNODE_SENSOR_HID] = &nodes[SWNODE_SENSOR_HID];
>> +    sensor->group[SWNODE_SENSOR_PORT] = &nodes[SWNODE_SENSOR_PORT];
>> +    sensor->group[SWNODE_SENSOR_ENDPOINT] = &nodes[SWNODE_SENSOR_ENDPOINT];
>> +    sensor->group[SWNODE_CIO2_PORT] = &nodes[SWNODE_CIO2_PORT];
>> +    sensor->group[SWNODE_CIO2_ENDPOINT] = &nodes[SWNODE_CIO2_ENDPOINT];
>> +    if (sensor->ssdb.vcmtype)
>> +        sensor->group[SWNODE_VCM] =  &nodes[SWNODE_VCM];
>> +}
>> +
>>   static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge,
>>                             struct cio2_sensor *sensor)
>>   {
>> @@ -219,6 +232,8 @@ static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge,
>>       if (sensor->ssdb.vcmtype)
>>           nodes[SWNODE_VCM] =
>>               NODE_VCM(cio2_vcm_types[sensor->ssdb.vcmtype - 1]);
>> +
>> +    cio2_bridge_init_swnode_group(sensor);
>>   }
>>     static void cio2_bridge_instantiate_vcm_i2c_client(struct cio2_sensor *sensor)
>> @@ -252,7 +267,7 @@ static void cio2_bridge_unregister_sensors(struct cio2_bridge *bridge)
>>         for (i = 0; i < bridge->n_sensors; i++) {
>>           sensor = &bridge->sensors[i];
>> -        software_node_unregister_nodes(sensor->swnodes);
>> +        software_node_unregister_node_group(sensor->group);
>>           ACPI_FREE(sensor->pld);
>>           acpi_dev_put(sensor->adev);
>>           i2c_unregister_device(sensor->vcm_i2c_client);
>> @@ -310,7 +325,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
>>           cio2_bridge_create_fwnode_properties(sensor, bridge, cfg);
>>           cio2_bridge_create_connection_swnodes(bridge, sensor);
>>   -        ret = software_node_register_nodes(sensor->swnodes);
>> +        ret = software_node_register_node_group(sensor->group);
>>           if (ret)
>>               goto err_free_pld;
>>   @@ -337,7 +352,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
>>       return 0;
>>     err_free_swnodes:
>> -    software_node_unregister_nodes(sensor->swnodes);
>> +    software_node_unregister_node_group(sensor->group);
>>   err_free_pld:
>>       ACPI_FREE(sensor->pld);
>>   err_put_adev:
>> diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.h b/drivers/media/pci/intel/ipu3/cio2-bridge.h
>> index 4418cbd08208..b93b749c65bd 100644
>> --- a/drivers/media/pci/intel/ipu3/cio2-bridge.h
>> +++ b/drivers/media/pci/intel/ipu3/cio2-bridge.h
>> @@ -117,8 +117,9 @@ struct cio2_sensor {
>>       struct acpi_device *adev;
>>       struct i2c_client *vcm_i2c_client;
>>   -    /* SWNODE_COUNT + 1 for terminating empty node */
>> -    struct software_node swnodes[SWNODE_COUNT + 1];
>> +    /* SWNODE_COUNT + 1 for terminating NULL */
>> +    const struct software_node *group[SWNODE_COUNT + 1];
>> +    struct software_node swnodes[SWNODE_COUNT];
>>       struct cio2_node_names node_names;
>>         struct cio2_sensor_ssdb ssdb;
>
Andy Shevchenko Nov. 21, 2022, 10:27 a.m. UTC | #3
On Mon, Nov 21, 2022 at 11:22:17AM +0100, Hans de Goede wrote:
> On 11/21/22 11:19, Dan Scally wrote:
> > On 18/11/2022 18:56, Andy Shevchenko wrote:
> >> The currently used software_node_register_nodes() is going to
> >> be removed. Prepare driver by switchich to new API.

> > Also looks good to me:
> > 
> > Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>

Thank you!

> Any chance you can also give this series a test run on an IPU3 device to
> ensure that it does not cause regressions ?

Yes, it would be really appreciated!
Hans de Goede Nov. 21, 2022, 2:40 p.m. UTC | #4
Hi,

On 11/21/22 15:32, Dan Scally wrote:
> Hi Andy and Hans
> 
> On 21/11/2022 10:27, Andy Shevchenko wrote:
>> On Mon, Nov 21, 2022 at 11:22:17AM +0100, Hans de Goede wrote:
>>> On 11/21/22 11:19, Dan Scally wrote:
>>>> On 18/11/2022 18:56, Andy Shevchenko wrote:
>>>>> The currently used software_node_register_nodes() is going to
>>>>> be removed. Prepare driver by switchich to new API.
>>>> Also looks good to me:
>>>>
>>>> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
>> Thank you!
>>
>>> Any chance you can also give this series a test run on an IPU3 device to
>>> ensure that it does not cause regressions ?
>> Yes, it would be really appreciated!
> 
> All seems fine (including the kunit test) - you can add
> 
> 
> Tested-by: Daniel Scally <dan.scally@ideasonboard.com>

Great, thank you!

Regards,

Hans
diff mbox series

Patch

diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.c b/drivers/media/pci/intel/ipu3/cio2-bridge.c
index 18974a72e94a..dfefe0d8aa95 100644
--- a/drivers/media/pci/intel/ipu3/cio2-bridge.c
+++ b/drivers/media/pci/intel/ipu3/cio2-bridge.c
@@ -195,6 +195,19 @@  static void cio2_bridge_init_swnode_names(struct cio2_sensor *sensor)
 		 SWNODE_GRAPH_ENDPOINT_NAME_FMT, 0); /* And endpoint 0 */
 }
 
+static void cio2_bridge_init_swnode_group(struct cio2_sensor *sensor)
+{
+	struct software_node *nodes = sensor->swnodes;
+
+	sensor->group[SWNODE_SENSOR_HID] = &nodes[SWNODE_SENSOR_HID];
+	sensor->group[SWNODE_SENSOR_PORT] = &nodes[SWNODE_SENSOR_PORT];
+	sensor->group[SWNODE_SENSOR_ENDPOINT] = &nodes[SWNODE_SENSOR_ENDPOINT];
+	sensor->group[SWNODE_CIO2_PORT] = &nodes[SWNODE_CIO2_PORT];
+	sensor->group[SWNODE_CIO2_ENDPOINT] = &nodes[SWNODE_CIO2_ENDPOINT];
+	if (sensor->ssdb.vcmtype)
+		sensor->group[SWNODE_VCM] =  &nodes[SWNODE_VCM];
+}
+
 static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge,
 						  struct cio2_sensor *sensor)
 {
@@ -219,6 +232,8 @@  static void cio2_bridge_create_connection_swnodes(struct cio2_bridge *bridge,
 	if (sensor->ssdb.vcmtype)
 		nodes[SWNODE_VCM] =
 			NODE_VCM(cio2_vcm_types[sensor->ssdb.vcmtype - 1]);
+
+	cio2_bridge_init_swnode_group(sensor);
 }
 
 static void cio2_bridge_instantiate_vcm_i2c_client(struct cio2_sensor *sensor)
@@ -252,7 +267,7 @@  static void cio2_bridge_unregister_sensors(struct cio2_bridge *bridge)
 
 	for (i = 0; i < bridge->n_sensors; i++) {
 		sensor = &bridge->sensors[i];
-		software_node_unregister_nodes(sensor->swnodes);
+		software_node_unregister_node_group(sensor->group);
 		ACPI_FREE(sensor->pld);
 		acpi_dev_put(sensor->adev);
 		i2c_unregister_device(sensor->vcm_i2c_client);
@@ -310,7 +325,7 @@  static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
 		cio2_bridge_create_fwnode_properties(sensor, bridge, cfg);
 		cio2_bridge_create_connection_swnodes(bridge, sensor);
 
-		ret = software_node_register_nodes(sensor->swnodes);
+		ret = software_node_register_node_group(sensor->group);
 		if (ret)
 			goto err_free_pld;
 
@@ -337,7 +352,7 @@  static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
 	return 0;
 
 err_free_swnodes:
-	software_node_unregister_nodes(sensor->swnodes);
+	software_node_unregister_node_group(sensor->group);
 err_free_pld:
 	ACPI_FREE(sensor->pld);
 err_put_adev:
diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.h b/drivers/media/pci/intel/ipu3/cio2-bridge.h
index 4418cbd08208..b93b749c65bd 100644
--- a/drivers/media/pci/intel/ipu3/cio2-bridge.h
+++ b/drivers/media/pci/intel/ipu3/cio2-bridge.h
@@ -117,8 +117,9 @@  struct cio2_sensor {
 	struct acpi_device *adev;
 	struct i2c_client *vcm_i2c_client;
 
-	/* SWNODE_COUNT + 1 for terminating empty node */
-	struct software_node swnodes[SWNODE_COUNT + 1];
+	/* SWNODE_COUNT + 1 for terminating NULL */
+	const struct software_node *group[SWNODE_COUNT + 1];
+	struct software_node swnodes[SWNODE_COUNT];
 	struct cio2_node_names node_names;
 
 	struct cio2_sensor_ssdb ssdb;