2022-05-01 18:36:48

by Frank Rowand

[permalink] [raw]
Subject: [PATCH 1/3] of: overlay: add entry to of_overlay_action_name[]

From: Frank Rowand <[email protected]>

The values of enum of_overlay_notify_action are used to index into
array of_overlay_action_name. Add an entry to of_overlay_action_name
for the value recently added to of_overlay_notify_action.

Array of_overlay_action_name[] is moved into include/linux/of.h
adjacent to enum of_overlay_notify_action to make the connection
between the two more obvious if either is modified in the future.

The only use of of_overlay_action_name is for error reporting in
overlay_notify(). All callers of overlay_notify() report the same
error, but with fewer details. Remove the redundant error reports
in the callers.

Fixes: 067c098766c6 ("of: overlay: rework overlay apply and remove kfree()s")
Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Frank Rowand <[email protected]>
---
drivers/of/overlay.c | 27 +++++----------------------
include/linux/of.h | 13 +++++++++++++
2 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
index 64588bff99ce..48c240b06d3b 100644
--- a/drivers/of/overlay.c
+++ b/drivers/of/overlay.c
@@ -152,13 +152,6 @@ int of_overlay_notifier_unregister(struct notifier_block *nb)
}
EXPORT_SYMBOL_GPL(of_overlay_notifier_unregister);

-static char *of_overlay_action_name[] = {
- "pre-apply",
- "post-apply",
- "pre-remove",
- "post-remove",
-};
-
static int overlay_notify(struct overlay_changeset *ovcs,
enum of_overlay_notify_action action)
{
@@ -180,7 +173,7 @@ static int overlay_notify(struct overlay_changeset *ovcs,
if (ret) {
ret = notifier_to_errno(ret);
pr_err("overlay changeset %s notifier error %d, target: %pOF\n",
- of_overlay_action_name[action], ret, nd.target);
+ of_overlay_action_name(action), ret, nd.target);
return ret;
}
}
@@ -927,10 +920,8 @@ static int of_overlay_apply(struct overlay_changeset *ovcs)
goto out;

ret = overlay_notify(ovcs, OF_OVERLAY_PRE_APPLY);
- if (ret) {
- pr_err("overlay changeset pre-apply notify error %d\n", ret);
+ if (ret)
goto out;
- }

ret = build_changeset(ovcs);
if (ret)
@@ -953,12 +944,9 @@ static int of_overlay_apply(struct overlay_changeset *ovcs)
/* notify failure is not fatal, continue */

ret_tmp = overlay_notify(ovcs, OF_OVERLAY_POST_APPLY);
- if (ret_tmp) {
- pr_err("overlay changeset post-apply notify error %d\n",
- ret_tmp);
+ if (ret_tmp)
if (!ret)
ret = ret_tmp;
- }

out:
pr_debug("%s() err=%d\n", __func__, ret);
@@ -1194,10 +1182,8 @@ int of_overlay_remove(int *ovcs_id)
}

ret = overlay_notify(ovcs, OF_OVERLAY_PRE_REMOVE);
- if (ret) {
- pr_err("overlay changeset pre-remove notify error %d\n", ret);
+ if (ret)
goto err_unlock;
- }

ret_apply = 0;
ret = __of_changeset_revert_entries(&ovcs->cset, &ret_apply);
@@ -1220,12 +1206,9 @@ int of_overlay_remove(int *ovcs_id)
* OF_OVERLAY_POST_REMOVE returns an error.
*/
ret_tmp = overlay_notify(ovcs, OF_OVERLAY_POST_REMOVE);
- if (ret_tmp) {
- pr_err("overlay changeset post-remove notify error %d\n",
- ret_tmp);
+ if (ret_tmp)
if (!ret)
ret = ret_tmp;
- }

free_overlay_changeset(ovcs);

diff --git a/include/linux/of.h b/include/linux/of.h
index 17741eee0ca4..f0a5d6b10c5a 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -1550,6 +1550,19 @@ enum of_overlay_notify_action {
OF_OVERLAY_POST_REMOVE,
};

+static inline char *of_overlay_action_name(enum of_overlay_notify_action action)
+{
+ static char *of_overlay_action_name[] = {
+ "init",
+ "pre-apply",
+ "post-apply",
+ "pre-remove",
+ "post-remove",
+ };
+
+ return of_overlay_action_name[action];
+}
+
struct of_overlay_notify_data {
struct device_node *overlay;
struct device_node *target;
--
Frank Rowand <[email protected]>


2022-05-02 23:33:31

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH 1/3] of: overlay: add entry to of_overlay_action_name[]

On Sat, Apr 30, 2022 at 07:05:41PM -0500, [email protected] wrote:
> From: Frank Rowand <[email protected]>
>
> The values of enum of_overlay_notify_action are used to index into
> array of_overlay_action_name. Add an entry to of_overlay_action_name
> for the value recently added to of_overlay_notify_action.
>
> Array of_overlay_action_name[] is moved into include/linux/of.h
> adjacent to enum of_overlay_notify_action to make the connection
> between the two more obvious if either is modified in the future.
>
> The only use of of_overlay_action_name is for error reporting in
> overlay_notify(). All callers of overlay_notify() report the same
> error, but with fewer details. Remove the redundant error reports
> in the callers.
>
> Fixes: 067c098766c6 ("of: overlay: rework overlay apply and remove kfree()s")
> Reported-by: Dan Carpenter <[email protected]>
> Signed-off-by: Frank Rowand <[email protected]>
> ---
> drivers/of/overlay.c | 27 +++++----------------------
> include/linux/of.h | 13 +++++++++++++
> 2 files changed, 18 insertions(+), 22 deletions(-)

This isn't applying for me.

Rob

2022-05-03 00:22:30

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH 1/3] of: overlay: add entry to of_overlay_action_name[]

On Mon, May 2, 2022 at 1:17 PM Frank Rowand <[email protected]> wrote:
>
> On 5/2/22 12:00, Rob Herring wrote:
> > On Sat, Apr 30, 2022 at 07:05:41PM -0500, [email protected] wrote:
> >> From: Frank Rowand <[email protected]>
> >>
> >> The values of enum of_overlay_notify_action are used to index into
> >> array of_overlay_action_name. Add an entry to of_overlay_action_name
> >> for the value recently added to of_overlay_notify_action.
> >>
> >> Array of_overlay_action_name[] is moved into include/linux/of.h
> >> adjacent to enum of_overlay_notify_action to make the connection
> >> between the two more obvious if either is modified in the future.
> >>
> >> The only use of of_overlay_action_name is for error reporting in
> >> overlay_notify(). All callers of overlay_notify() report the same
> >> error, but with fewer details. Remove the redundant error reports
> >> in the callers.
> >>
> >> Fixes: 067c098766c6 ("of: overlay: rework overlay apply and remove kfree()s")
> >> Reported-by: Dan Carpenter <[email protected]>
> >> Signed-off-by: Frank Rowand <[email protected]>
> >> ---
> >> drivers/of/overlay.c | 27 +++++----------------------
> >> include/linux/of.h | 13 +++++++++++++
> >> 2 files changed, 18 insertions(+), 22 deletions(-)
> >
> > This isn't applying for me.
>
> Weird, patch can apply it, but 'git am' does not work. I see that when
> I try that on your dt/next branch.
>
> The problem seems to be that I did not create the series on top of
> dt/next: 5f756a2eaa44 of: overlay: do not break notify on NOTIFY_{OK|STOP}.

It should be more than just that. It was also not any base I have in
my tree, so 'git am' wouldn't try a 3-way merge either.

> I have rebased the series on top of that patch and am sending v2.

Thanks.

Rob

2022-05-03 00:43:57

by Frank Rowand

[permalink] [raw]
Subject: Re: [PATCH 1/3] of: overlay: add entry to of_overlay_action_name[]

On 5/2/22 12:00, Rob Herring wrote:
> On Sat, Apr 30, 2022 at 07:05:41PM -0500, [email protected] wrote:
>> From: Frank Rowand <[email protected]>
>>
>> The values of enum of_overlay_notify_action are used to index into
>> array of_overlay_action_name. Add an entry to of_overlay_action_name
>> for the value recently added to of_overlay_notify_action.
>>
>> Array of_overlay_action_name[] is moved into include/linux/of.h
>> adjacent to enum of_overlay_notify_action to make the connection
>> between the two more obvious if either is modified in the future.
>>
>> The only use of of_overlay_action_name is for error reporting in
>> overlay_notify(). All callers of overlay_notify() report the same
>> error, but with fewer details. Remove the redundant error reports
>> in the callers.
>>
>> Fixes: 067c098766c6 ("of: overlay: rework overlay apply and remove kfree()s")
>> Reported-by: Dan Carpenter <[email protected]>
>> Signed-off-by: Frank Rowand <[email protected]>
>> ---
>> drivers/of/overlay.c | 27 +++++----------------------
>> include/linux/of.h | 13 +++++++++++++
>> 2 files changed, 18 insertions(+), 22 deletions(-)
>
> This isn't applying for me.

Weird, patch can apply it, but 'git am' does not work. I see that when
I try that on your dt/next branch.

The problem seems to be that I did not create the series on top of
dt/next: 5f756a2eaa44 of: overlay: do not break notify on NOTIFY_{OK|STOP}.

I have rebased the series on top of that patch and am sending v2.

-Frank


>
> Rob

2022-05-03 01:08:16

by Frank Rowand

[permalink] [raw]
Subject: Re: [PATCH 1/3] of: overlay: add entry to of_overlay_action_name[]

On 5/2/22 13:29, Rob Herring wrote:
> On Mon, May 2, 2022 at 1:17 PM Frank Rowand <[email protected]> wrote:
>>
>> On 5/2/22 12:00, Rob Herring wrote:
>>> On Sat, Apr 30, 2022 at 07:05:41PM -0500, [email protected] wrote:
>>>> From: Frank Rowand <[email protected]>
>>>>
>>>> The values of enum of_overlay_notify_action are used to index into
>>>> array of_overlay_action_name. Add an entry to of_overlay_action_name
>>>> for the value recently added to of_overlay_notify_action.
>>>>
>>>> Array of_overlay_action_name[] is moved into include/linux/of.h
>>>> adjacent to enum of_overlay_notify_action to make the connection
>>>> between the two more obvious if either is modified in the future.
>>>>
>>>> The only use of of_overlay_action_name is for error reporting in
>>>> overlay_notify(). All callers of overlay_notify() report the same
>>>> error, but with fewer details. Remove the redundant error reports
>>>> in the callers.
>>>>
>>>> Fixes: 067c098766c6 ("of: overlay: rework overlay apply and remove kfree()s")
>>>> Reported-by: Dan Carpenter <[email protected]>
>>>> Signed-off-by: Frank Rowand <[email protected]>
>>>> ---
>>>> drivers/of/overlay.c | 27 +++++----------------------
>>>> include/linux/of.h | 13 +++++++++++++
>>>> 2 files changed, 18 insertions(+), 22 deletions(-)
>>>
>>> This isn't applying for me.
>>
>> Weird, patch can apply it, but 'git am' does not work. I see that when
>> I try that on your dt/next branch.
>>
>> The problem seems to be that I did not create the series on top of
>> dt/next: 5f756a2eaa44 of: overlay: do not break notify on NOTIFY_{OK|STOP}.
>
> It should be more than just that. It was also not any base I have in
> my tree, so 'git am' wouldn't try a 3-way merge either.

That was the only thing patch mentioned when it applied successfully,
a little bit of fuzz around the few lines in that patch. I thought
it a little weird that 'git am' didn't handle that, but it was easy
enough to rebase instead of debugging git.

>
>> I have rebased the series on top of that patch and am sending v2.
>
> Thanks.

I just now tried the v2 series emails on top of your dt/next and 'git am'
is happy with it.

>
> Rob