2022-11-21 15:48:21

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 1/4] media: ipu3-cio2: Don't dereference fwnode handle

Use acpi_fwnode_handle() instead of dereferencing an fwnode handle directly,
which is a better coding practice.

Signed-off-by: Andy Shevchenko <[email protected]>
Tested-by: Daniel Scally <[email protected]>
Acked-by: Heikki Krogerus <[email protected]>
Reviewed-by: Daniel Scally <[email protected]>
---
v2: added tags (Heikki, Daniel)

drivers/media/pci/intel/ipu3/cio2-bridge.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.c b/drivers/media/pci/intel/ipu3/cio2-bridge.c
index df6c94da2f6a..18974a72e94a 100644
--- a/drivers/media/pci/intel/ipu3/cio2-bridge.c
+++ b/drivers/media/pci/intel/ipu3/cio2-bridge.c
@@ -263,7 +263,7 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
struct cio2_bridge *bridge,
struct pci_dev *cio2)
{
- struct fwnode_handle *fwnode;
+ struct fwnode_handle *fwnode, *primary;
struct cio2_sensor *sensor;
struct acpi_device *adev;
acpi_status status;
@@ -322,7 +322,9 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
}

sensor->adev = acpi_dev_get(adev);
- adev->fwnode.secondary = fwnode;
+
+ primary = acpi_fwnode_handle(adev);
+ primary->secondary = fwnode;

cio2_bridge_instantiate_vcm_i2c_client(sensor);

--
2.35.1



2022-11-21 15:48:34

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 2/4] media: ipu3-cio2: Convert to use software_node_register_node_group()

The currently used software_node_register_nodes() is going to
be removed. Prepare driver by switching to a new API.

Signed-off-by: Andy Shevchenko <[email protected]>
Tested-by: Daniel Scally <[email protected]>
Acked-by: Heikki Krogerus <[email protected]>
Reviewed-by: Daniel Scally <[email protected]>
---
v2: added tags (Heikki, Daniel)

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;
--
2.35.1


2022-11-21 15:52:00

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v2 3/4] software node: Switch property entry test to a new API

Switch property entry test to use software_node_register_node_group() API.
The current one is going to be removed soon.

Signed-off-by: Andy Shevchenko <[email protected]>
Tested-by: Daniel Scally <[email protected]>
Acked-by: Heikki Krogerus <[email protected]>
---
v2: added tags (Heikki, Daniel)

drivers/base/test/property-entry-test.c | 30 ++++++++++++-------------
1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/drivers/base/test/property-entry-test.c b/drivers/base/test/property-entry-test.c
index 6071d5bc128c..dd2b606d76a3 100644
--- a/drivers/base/test/property-entry-test.c
+++ b/drivers/base/test/property-entry-test.c
@@ -405,20 +405,18 @@ static void pe_test_move_inline_str(struct kunit *test)
/* Handling of reference properties */
static void pe_test_reference(struct kunit *test)
{
- static const struct software_node nodes[] = {
- { .name = "1", },
- { .name = "2", },
- { }
- };
+ static const struct software_node node1 = { .name = "1" };
+ static const struct software_node node2 = { .name = "2" };
+ static const struct software_node *group[] = { &node1, &node2, NULL };

static const struct software_node_ref_args refs[] = {
- SOFTWARE_NODE_REFERENCE(&nodes[0]),
- SOFTWARE_NODE_REFERENCE(&nodes[1], 3, 4),
+ SOFTWARE_NODE_REFERENCE(&node1),
+ SOFTWARE_NODE_REFERENCE(&node2, 3, 4),
};

const struct property_entry entries[] = {
- PROPERTY_ENTRY_REF("ref-1", &nodes[0]),
- PROPERTY_ENTRY_REF("ref-2", &nodes[1], 1, 2),
+ PROPERTY_ENTRY_REF("ref-1", &node1),
+ PROPERTY_ENTRY_REF("ref-2", &node2, 1, 2),
PROPERTY_ENTRY_REF_ARRAY("ref-3", refs),
{ }
};
@@ -427,7 +425,7 @@ static void pe_test_reference(struct kunit *test)
struct fwnode_reference_args ref;
int error;

- error = software_node_register_nodes(nodes);
+ error = software_node_register_node_group(group);
KUNIT_ASSERT_EQ(test, error, 0);

node = fwnode_create_software_node(entries, NULL);
@@ -436,7 +434,7 @@ static void pe_test_reference(struct kunit *test)
error = fwnode_property_get_reference_args(node, "ref-1", NULL,
0, 0, &ref);
KUNIT_ASSERT_EQ(test, error, 0);
- KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &nodes[0]);
+ KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &node1);
KUNIT_EXPECT_EQ(test, ref.nargs, 0U);

/* wrong index */
@@ -447,7 +445,7 @@ static void pe_test_reference(struct kunit *test)
error = fwnode_property_get_reference_args(node, "ref-2", NULL,
1, 0, &ref);
KUNIT_ASSERT_EQ(test, error, 0);
- KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &nodes[1]);
+ KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &node2);
KUNIT_EXPECT_EQ(test, ref.nargs, 1U);
KUNIT_EXPECT_EQ(test, ref.args[0], 1LLU);

@@ -455,7 +453,7 @@ static void pe_test_reference(struct kunit *test)
error = fwnode_property_get_reference_args(node, "ref-2", NULL,
3, 0, &ref);
KUNIT_ASSERT_EQ(test, error, 0);
- KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &nodes[1]);
+ KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &node2);
KUNIT_EXPECT_EQ(test, ref.nargs, 3U);
KUNIT_EXPECT_EQ(test, ref.args[0], 1LLU);
KUNIT_EXPECT_EQ(test, ref.args[1], 2LLU);
@@ -470,14 +468,14 @@ static void pe_test_reference(struct kunit *test)
error = fwnode_property_get_reference_args(node, "ref-3", NULL,
0, 0, &ref);
KUNIT_ASSERT_EQ(test, error, 0);
- KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &nodes[0]);
+ KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &node1);
KUNIT_EXPECT_EQ(test, ref.nargs, 0U);

/* second reference in the array */
error = fwnode_property_get_reference_args(node, "ref-3", NULL,
2, 1, &ref);
KUNIT_ASSERT_EQ(test, error, 0);
- KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &nodes[1]);
+ KUNIT_EXPECT_PTR_EQ(test, to_software_node(ref.fwnode), &node2);
KUNIT_EXPECT_EQ(test, ref.nargs, 2U);
KUNIT_EXPECT_EQ(test, ref.args[0], 3LLU);
KUNIT_EXPECT_EQ(test, ref.args[1], 4LLU);
@@ -488,7 +486,7 @@ static void pe_test_reference(struct kunit *test)
KUNIT_EXPECT_NE(test, error, 0);

fwnode_remove_software_node(node);
- software_node_unregister_nodes(nodes);
+ software_node_unregister_node_group(group);
}

static struct kunit_case property_entry_test_cases[] = {
--
2.35.1


2022-11-23 18:28:05

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] media: ipu3-cio2: Don't dereference fwnode handle

+ Cc: Petr, Sergey

On Mon, Nov 21, 2022 at 05:27:01PM +0200, Andy Shevchenko wrote:
> Use acpi_fwnode_handle() instead of dereferencing an fwnode handle directly,
> which is a better coding practice.

It appears that this series depends on fd070e8ceb90 ("test_printf: Refactor
fwnode_pointer() to make it more readable") which is in PRINTK tree.

Sakari, Mauro, if you are okay to route this via that tree, can we get your
tags for that? Otherwise we need to postpone this till v6.2-rc1 (but I would
like to decrease the chances to appear a new user of the to be removed API).

--
With Best Regards,
Andy Shevchenko


2022-11-23 19:51:57

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] media: ipu3-cio2: Don't dereference fwnode handle

Dunno what happened to my previous reply to this. Okay, trying again...

+ Cc: Petr, Sergey

On Mon, Nov 21, 2022 at 05:27:01PM +0200, Andy Shevchenko wrote:
> Use acpi_fwnode_handle() instead of dereferencing an fwnode handle directly,
> which is a better coding practice.

It appears that this series depends on fd070e8ceb90 ("test_printf: Refactor
fwnode_pointer() to make it more readable") which is in PRINTK tree.

Sakari, Mauro, if you are okay to route this via that tree, can we get your
tags for that? Otherwise we need to postpone this till v6.2-rc1 (but I would
like to decrease the chances to appear a new user of the to be removed API).

Note, that Greg Acked v1 of the swnode patches (which are the same in v2).

--
With Best Regards,
Andy Shevchenko


2022-12-07 10:23:26

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] media: ipu3-cio2: Don't dereference fwnode handle

On Wed, Dec 07, 2022 at 09:02:49AM +0000, Sakari Ailus wrote:
> On Wed, Nov 23, 2022 at 09:10:58PM +0200, Andy Shevchenko wrote:
> > Dunno what happened to my previous reply to this. Okay, trying again...
> >
> > + Cc: Petr, Sergey
> >
> > On Mon, Nov 21, 2022 at 05:27:01PM +0200, Andy Shevchenko wrote:
> > > Use acpi_fwnode_handle() instead of dereferencing an fwnode handle directly,
> > > which is a better coding practice.
> >
> > It appears that this series depends on fd070e8ceb90 ("test_printf: Refactor
> > fwnode_pointer() to make it more readable") which is in PRINTK tree.
> >
> > Sakari, Mauro, if you are okay to route this via that tree, can we get your
> > tags for that? Otherwise we need to postpone this till v6.2-rc1 (but I would
> > like to decrease the chances to appear a new user of the to be removed API).
> >
> > Note, that Greg Acked v1 of the swnode patches (which are the same in v2).
>
> Sorry for the late reply. Feel free to do that if it's not too late, with:
>
> Acked-by: Sakari Ailus <[email protected]>

Thank you!
I think it's a bit late for printk tree to consume this. If it's the case
(Petr?) then I will submit a new version after v6.2-rc1 is out.

> I don't think the linkelihood for having a new user for this API is high.

--
With Best Regards,
Andy Shevchenko


2022-12-07 10:23:33

by Sakari Ailus

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] media: ipu3-cio2: Don't dereference fwnode handle

Hi Andy,

On Wed, Nov 23, 2022 at 09:10:58PM +0200, Andy Shevchenko wrote:
> Dunno what happened to my previous reply to this. Okay, trying again...
>
> + Cc: Petr, Sergey
>
> On Mon, Nov 21, 2022 at 05:27:01PM +0200, Andy Shevchenko wrote:
> > Use acpi_fwnode_handle() instead of dereferencing an fwnode handle directly,
> > which is a better coding practice.
>
> It appears that this series depends on fd070e8ceb90 ("test_printf: Refactor
> fwnode_pointer() to make it more readable") which is in PRINTK tree.
>
> Sakari, Mauro, if you are okay to route this via that tree, can we get your
> tags for that? Otherwise we need to postpone this till v6.2-rc1 (but I would
> like to decrease the chances to appear a new user of the to be removed API).
>
> Note, that Greg Acked v1 of the swnode patches (which are the same in v2).

Sorry for the late reply. Feel free to do that if it's not too late, with:

Acked-by: Sakari Ailus <[email protected]>

I don't think the linkelihood for having a new user for this API is high.

--
Kind regards,

Sakari Ailus

2022-12-07 14:18:37

by Sakari Ailus

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] media: ipu3-cio2: Don't dereference fwnode handle

On Wed, Dec 07, 2022 at 11:53:12AM +0200, Andy Shevchenko wrote:
> On Wed, Dec 07, 2022 at 09:02:49AM +0000, Sakari Ailus wrote:
> > On Wed, Nov 23, 2022 at 09:10:58PM +0200, Andy Shevchenko wrote:
> > > Dunno what happened to my previous reply to this. Okay, trying again...
> > >
> > > + Cc: Petr, Sergey
> > >
> > > On Mon, Nov 21, 2022 at 05:27:01PM +0200, Andy Shevchenko wrote:
> > > > Use acpi_fwnode_handle() instead of dereferencing an fwnode handle directly,
> > > > which is a better coding practice.
> > >
> > > It appears that this series depends on fd070e8ceb90 ("test_printf: Refactor
> > > fwnode_pointer() to make it more readable") which is in PRINTK tree.
> > >
> > > Sakari, Mauro, if you are okay to route this via that tree, can we get your
> > > tags for that? Otherwise we need to postpone this till v6.2-rc1 (but I would
> > > like to decrease the chances to appear a new user of the to be removed API).
> > >
> > > Note, that Greg Acked v1 of the swnode patches (which are the same in v2).
> >
> > Sorry for the late reply. Feel free to do that if it's not too late, with:
> >
> > Acked-by: Sakari Ailus <[email protected]>

I intended to add this applies to the set.

>
> Thank you!
> I think it's a bit late for printk tree to consume this. If it's the case
> (Petr?) then I will submit a new version after v6.2-rc1 is out.
>
> > I don't think the linkelihood for having a new user for this API is high.

--
Sakari Ailus

2022-12-08 10:45:51

by Petr Mladek

[permalink] [raw]
Subject: Re: [PATCH v2 1/4] media: ipu3-cio2: Don't dereference fwnode handle

On Wed 2022-12-07 11:53:12, Andy Shevchenko wrote:
> On Wed, Dec 07, 2022 at 09:02:49AM +0000, Sakari Ailus wrote:
> > On Wed, Nov 23, 2022 at 09:10:58PM +0200, Andy Shevchenko wrote:
> > > Dunno what happened to my previous reply to this. Okay, trying again...
> > >
> > > + Cc: Petr, Sergey
> > >
> > > On Mon, Nov 21, 2022 at 05:27:01PM +0200, Andy Shevchenko wrote:
> > > > Use acpi_fwnode_handle() instead of dereferencing an fwnode handle directly,
> > > > which is a better coding practice.
> > >
> > > It appears that this series depends on fd070e8ceb90 ("test_printf: Refactor
> > > fwnode_pointer() to make it more readable") which is in PRINTK tree.
> > >
> > > Sakari, Mauro, if you are okay to route this via that tree, can we get your
> > > tags for that? Otherwise we need to postpone this till v6.2-rc1 (but I would
> > > like to decrease the chances to appear a new user of the to be removed API).
> > >
> > > Note, that Greg Acked v1 of the swnode patches (which are the same in v2).
> >
> > Sorry for the late reply. Feel free to do that if it's not too late, with:
> >
> > Acked-by: Sakari Ailus <[email protected]>
>
> Thank you!
> I think it's a bit late for printk tree to consume this. If it's the case
> (Petr?) then I will submit a new version after v6.2-rc1 is out.

Yes, I am sorry but it is too late for the printk tree. I am going to
send the pull request for 6.2 today or tomorrow. Linus explicitly
asked to send the pull request early this time because the merge
window will be overlapping with the holidays.

On the positive side. There is a high chance that the changes from
the printk tree will be in the mainline early enough so that you
could manage to send this still during the merge window.

Best Regards,
Petr