mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab.ca>
To: Pantelis Antoniou <pantelis.antoniou@konsulko.com>
Cc: Rob Herring <robherring2@gmail.com>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Matt Porter <matt.porter@linaro.org>,
	Koen Kooi <koen@dominion.thruhere.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alison Chaiken <Alison_Chaiken@mentor.com>,
	Dinh Nguyen <dinh.linux@gmail.com>, Jan Lubbe <jluebbe@lasnet.de>,
	Alexander Sverdlin <alexander.sverdlin@nsn.com>,
	Michael Stickel <ms@mycable.de>,
	Guenter Roeck <linux@roeck-us.net>,
	Dirk Behme <dirk.behme@gmail.com>,
	Alan Tull <delicious.quinoa@gmail.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Michael Bohan <mbohan@codeaurora.org>,
	Ionut Nicu <ioan.nicu.ext@nsn.com>,
	Michal Simek <monstr@monstr.eu>,
	Matt Ranostay <mranostay@gmail.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Pete Popov <pete.popov@konsulko.com>,
	Dan Malek <dan.malek@konsulko.com>,
	Georgi Vlaev <georgi.vlaev@konsulko.com>,
	Pantelis Antoniou <pantelis.antoniou@konsulko.com>,
	Pantelis Antoniou <panto@antoniou-consulting.com>
Subject: Re: [PATCH 4/5] of: Add old prop argument on OF_RECONFIG_UPDATE_PROPERTY
Date: Wed, 05 Nov 2014 20:01:29 +0000	[thread overview]
Message-ID: <20141105200129.B4438C41C40@trevor.secretlab.ca> (raw)
In-Reply-To: <1414528433-9650-5-git-send-email-pantelis.antoniou@konsulko.com>

On Tue, 28 Oct 2014 22:33:52 +0200
, Pantelis Antoniou <pantelis.antoniou@konsulko.com>
 wrote:
> The notifier now includes the old_prop argument when updating
> properties, propagate this API to changeset internals while
> also retaining the old behaviour of retrieving the old_property
> when NULL is passed.
> 
> Signed-off-by: Pantelis Antoniou <pantelis.antoniou@konsulko.com>

I'm still fuzzy on the need for this patch. Is this just an optimization
so that the property doesn't get looked up twice? Or is there a reason
when the oldprop really needs to be passed in explicitly?

g.

> ---
>  drivers/of/dynamic.c  | 18 ++++++++++++++----
>  drivers/of/selftest.c |  2 +-
>  include/linux/of.h    | 20 +++++++++++++-------
>  3 files changed, 28 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
> index 8e8b614..9eb8528 100644
> --- a/drivers/of/dynamic.c
> +++ b/drivers/of/dynamic.c
> @@ -627,6 +627,7 @@ int of_changeset_revert(struct of_changeset *ocs)
>   * @action:	action to perform
>   * @np:		Pointer to device node
>   * @prop:	Pointer to property
> + * @old_prop:	Pointer to old property (if updating)
>   *
>   * On action being one of:
>   * + OF_RECONFIG_ATTACH_NODE
> @@ -637,10 +638,21 @@ int of_changeset_revert(struct of_changeset *ocs)
>   * Returns 0 on success, a negative error value in case of an error.
>   */
>  int of_changeset_action(struct of_changeset *ocs, unsigned long action,
> -		struct device_node *np, struct property *prop)
> +		struct device_node *np, struct property *prop,
> +		struct property *oldprop)
>  {
>  	struct of_changeset_entry *ce;
>  
> +	/* in case someone passed NULL as old_prop, find it */
> +	if (action == OF_RECONFIG_UPDATE_PROPERTY && prop && !oldprop) {
> +		oldprop = of_find_property(np, prop->name, NULL);
> +		if (!oldprop) {
> +			pr_err("%s: Failed to find old_prop for \"%s/%s\"\n",
> +					__func__, np->full_name, prop->name);
> +			return -EINVAL;
> +		}
> +	}
> +
>  	ce = kzalloc(sizeof(*ce), GFP_KERNEL);
>  	if (!ce) {
>  		pr_err("%s: Failed to allocate\n", __func__);
> @@ -650,9 +662,7 @@ int of_changeset_action(struct of_changeset *ocs, unsigned long action,
>  	ce->action = action;
>  	ce->np = of_node_get(np);
>  	ce->prop = prop;
> -
> -	if (action == OF_RECONFIG_UPDATE_PROPERTY && prop)
> -		ce->old_prop = of_find_property(np, prop->name, NULL);
> +	ce->old_prop = oldprop;
>  
>  	/* add it to the list */
>  	list_add_tail(&ce->node, &ocs->entries);
> diff --git a/drivers/of/selftest.c b/drivers/of/selftest.c
> index 7800127..16102fd 100644
> --- a/drivers/of/selftest.c
> +++ b/drivers/of/selftest.c
> @@ -427,7 +427,7 @@ static void __init of_selftest_changeset(void)
>  	selftest(!of_changeset_detach_node(&chgset, nremove), "fail remove node\n");
>  	selftest(!of_changeset_attach_node(&chgset, n21), "fail attach n21\n");
>  	selftest(!of_changeset_add_property(&chgset, parent, ppadd), "fail add prop\n");
> -	selftest(!of_changeset_update_property(&chgset, parent, ppupdate), "fail update prop\n");
> +	selftest(!of_changeset_update_property(&chgset, parent, ppupdate, NULL), "fail update prop\n");
>  	selftest(!of_changeset_remove_property(&chgset, parent, ppremove), "fail remove prop\n");
>  	mutex_lock(&of_mutex);
>  	selftest(!of_changeset_apply(&chgset), "apply failed\n");
> diff --git a/include/linux/of.h b/include/linux/of.h
> index 6545e7a..71d25aa 100644
> --- a/include/linux/of.h
> +++ b/include/linux/of.h
> @@ -830,36 +830,42 @@ extern int of_changeset_apply(struct of_changeset *ocs);
>  extern int of_changeset_revert(struct of_changeset *ocs);
>  extern int of_changeset_action(struct of_changeset *ocs,
>  		unsigned long action, struct device_node *np,
> -		struct property *prop);
> +		struct property *prop, struct property *old_prop);
>  
>  static inline int of_changeset_attach_node(struct of_changeset *ocs,
>  		struct device_node *np)
>  {
> -	return of_changeset_action(ocs, OF_RECONFIG_ATTACH_NODE, np, NULL);
> +	return of_changeset_action(ocs, OF_RECONFIG_ATTACH_NODE, np, NULL,
> +			NULL);
>  }
>  
>  static inline int of_changeset_detach_node(struct of_changeset *ocs,
>  		struct device_node *np)
>  {
> -	return of_changeset_action(ocs, OF_RECONFIG_DETACH_NODE, np, NULL);
> +	return of_changeset_action(ocs, OF_RECONFIG_DETACH_NODE, np, NULL,
> +			NULL);
>  }
>  
>  static inline int of_changeset_add_property(struct of_changeset *ocs,
>  		struct device_node *np, struct property *prop)
>  {
> -	return of_changeset_action(ocs, OF_RECONFIG_ADD_PROPERTY, np, prop);
> +	return of_changeset_action(ocs, OF_RECONFIG_ADD_PROPERTY, np, prop,
> +			NULL);
>  }
>  
>  static inline int of_changeset_remove_property(struct of_changeset *ocs,
>  		struct device_node *np, struct property *prop)
>  {
> -	return of_changeset_action(ocs, OF_RECONFIG_REMOVE_PROPERTY, np, prop);
> +	return of_changeset_action(ocs, OF_RECONFIG_REMOVE_PROPERTY, np, prop,
> +			NULL);
>  }
>  
>  static inline int of_changeset_update_property(struct of_changeset *ocs,
> -		struct device_node *np, struct property *prop)
> +		struct device_node *np, struct property *prop,
> +		struct property *old_prop)
>  {
> -	return of_changeset_action(ocs, OF_RECONFIG_UPDATE_PROPERTY, np, prop);
> +	return of_changeset_action(ocs, OF_RECONFIG_UPDATE_PROPERTY, np, prop,
> +			old_prop);
>  }
>  #endif
>  
> -- 
> 1.7.12
> 


  reply	other threads:[~2014-11-05 20:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-28 20:33 [PATCH 0/5] of: Resolver and dynamic updates Pantelis Antoniou
2014-10-28 20:33 ` [PATCH 1/5] of: resolver: Switch to new local fixups format Pantelis Antoniou
2014-10-28 20:33 ` [PATCH 2/5] of: testcases: Update with " Pantelis Antoniou
2014-10-28 20:33 ` [PATCH 3/5] of: Only call notifiers when node is attached Pantelis Antoniou
2014-11-05 21:39   ` Grant Likely
2014-11-06 12:33     ` Pantelis Antoniou
2014-11-06 12:47       ` Grant Likely
2014-10-28 20:33 ` [PATCH 4/5] of: Add old prop argument on OF_RECONFIG_UPDATE_PROPERTY Pantelis Antoniou
2014-11-05 20:01   ` Grant Likely [this message]
2014-11-05 20:08     ` Pantelis Antoniou
2014-11-06 12:46       ` Grant Likely
2014-11-06 13:14         ` Pantelis Antoniou
2014-10-28 20:33 ` [PATCH 5/5] of: of_reconfig_get_state_change() of notifier helper Pantelis Antoniou
2014-11-05 20:07   ` Grant Likely

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=20141105200129.B4438C41C40@trevor.secretlab.ca \
    --to=grant.likely@secretlab.ca \
    --cc=Alison_Chaiken@mentor.com \
    --cc=alexander.sverdlin@nsn.com \
    --cc=dan.malek@konsulko.com \
    --cc=delicious.quinoa@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dinh.linux@gmail.com \
    --cc=dirk.behme@gmail.com \
    --cc=georgi.vlaev@konsulko.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ioan.nicu.ext@nsn.com \
    --cc=jluebbe@lasnet.de \
    --cc=koen@dominion.thruhere.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=matt.porter@linaro.org \
    --cc=mbohan@codeaurora.org \
    --cc=monstr@monstr.eu \
    --cc=mranostay@gmail.com \
    --cc=ms@mycable.de \
    --cc=pantelis.antoniou@konsulko.com \
    --cc=panto@antoniou-consulting.com \
    --cc=pete.popov@konsulko.com \
    --cc=robherring2@gmail.com \
    --cc=s.hauer@pengutronix.de \
    --cc=swarren@wwwdotorg.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®