linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
To: Michael Bringmann <mwb@linux.vnet.ibm.com>,
	linuxppc-dev@lists.ozlabs.org
Cc: John Allen <jallen@linux.vnet.ibm.com>,
	Tyrel Datwyler <tyreld@linux.vnet.ibm.com>,
	Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Subject: Re: [RFC v4 2/4] hotplug/drcinfo: Provide parser with callback
Date: Tue, 22 May 2018 16:02:26 -0500	[thread overview]
Message-ID: <516edea6-8554-cdc6-db6d-9f6661e65ec4@linux.vnet.ibm.com> (raw)
In-Reply-To: <2e2261b4-c0b3-3b6d-d649-541bc8802546@linux.vnet.ibm.com>

On 05/22/2018 11:37 AM, Michael Bringmann wrote:
> This patch provides a common parse function for the ibm,drc-info
> property that can be modified by a callback function.  The caller
> provides a pointer to the function and a pointer to their unique
> data, and the parser provides the current lmb set from the struct.
> The callback function may return codes indicating that the parsing
> is complete, or should continue, along with an error code that may
> be returned to the caller.
> 
> Signed-off-by: Michael Bringmann <mwb@linux.vnet.ibm.com>
> Fixes: 3f38000eda48 ("powerpc/firmware: Add definitions for new drc-info firmwar
> e feature" -- end of patch series applied to powerpc next)
> ---
> Changes in V4:
>   -- Update code to account for latest kernel checkins.
>   -- Rebased to 4.17-rc5 kernel
>   -- Some patch cleanup including file combination
> ---
>  arch/powerpc/include/asm/prom.h             |    7 +++++
>  arch/powerpc/platforms/pseries/of_helpers.c |   37 +++++++++++++++++++++++++++
>  2 files changed, 44 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
> index b04c5ce..2e947b3 100644
> --- a/arch/powerpc/include/asm/prom.h
> +++ b/arch/powerpc/include/asm/prom.h
> @@ -94,6 +94,13 @@ struct of_drc_info {
>  extern int of_read_drc_info_cell(struct property **prop,
>  			const __be32 **curval, struct of_drc_info *data);
> 
> +extern int drc_info_parser(struct device_node *dn,
> +			int (*usercb)(struct of_drc_info *drc,
> +					void *data,
> +					void *optional_data,

The optional_data parameter to the callback routine doesn't seem to be used.

-Nathan

> +					int *ret_code),
> +			char *opt_drc_type,
> +			void *data);
> 
>  /*
>   * There are two methods for telling firmware what our capabilities are.
> diff --git a/arch/powerpc/platforms/pseries/of_helpers.c b/arch/powerpc/platforms/pseries/of_helpers.c
> index 11b2ef1..a588ee6 100644
> --- a/arch/powerpc/platforms/pseries/of_helpers.c
> +++ b/arch/powerpc/platforms/pseries/of_helpers.c
> @@ -6,6 +6,9 @@
>  #include <asm/prom.h>
> 
>  #include "of_helpers.h"
> +#include "pseries.h"
> +
> +#define	MAX_DRC_NAME_LEN 64
> 
>  /**
>   * pseries_of_derive_parent - basically like dirname(1)
> @@ -87,3 +90,37 @@ int of_read_drc_info_cell(struct property **prop, const __be32 **curval,
>  	return 0;
>  }
>  EXPORT_SYMBOL(of_read_drc_info_cell);
> +
> +int drc_info_parser(struct device_node *dn,
> +		int (*usercb)(struct of_drc_info *drc,
> +				void *data,
> +				void *optional_data,
> +				int *ret_code),
> +		char *opt_drc_type,
> +		void *data)
> +{
> +	struct property *info;
> +	unsigned int entries;
> +	struct of_drc_info drc;
> +	const __be32 *value;
> +	int j, done = 0, ret_code = -EINVAL;
> +
> +	info = of_find_property(dn, "ibm,drc-info", NULL);
> +	if (info == NULL)
> +		return -EINVAL;
> +
> +	value = info->value;
> +	entries = of_read_number(value++, 1);
> +
> +	for (j = 0, done = 0; (j < entries) && (!done); j++) {
> +		of_read_drc_info_cell(&info, &value, &drc);
> +
> +		if (opt_drc_type && strcmp(opt_drc_type, drc.drc_type))
> +			continue;
> +
> +		done = usercb(&drc, data, NULL, &ret_code);
> +	}
> +
> +	return ret_code;
> +}
> +EXPORT_SYMBOL(drc_info_parser);
> 

  reply	other threads:[~2018-05-22 21:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-22 16:36 [RFC v4 0/4] powerpc/drcinfo: Fix bugs 'ibm,drc-info' property Michael Bringmann
2018-05-22 16:37 ` [RFC v4 1/4] hotplug/drcinfo: Simplify parse ibm,drc-info structs Michael Bringmann
2018-05-22 20:32   ` [RFC v4 1/4] hotplug/drcinfo: Simplify parse ibm, drc-info structs Nathan Fontenot
2018-05-22 16:37 ` [RFC v4 2/4] hotplug/drcinfo: Provide parser with callback Michael Bringmann
2018-05-22 21:02   ` Nathan Fontenot [this message]
2018-05-23  0:42     ` Michael Bringmann
2018-05-22 21:23   ` Nathan Fontenot
2018-05-23  0:59     ` Michael Bringmann
2018-05-22 16:37 ` [RFC v4 3/4] hotplug/drcinfo: Fix hot-add CPU issues Michael Bringmann
2018-05-22 21:31   ` Nathan Fontenot
2018-05-23  1:14     ` Michael Bringmann
2018-05-22 16:37 ` [RFC v4 4/4] hotplug/drcinfo: Code cleanup for devices Michael Bringmann
2018-05-22 21:39   ` Nathan Fontenot
2018-05-23  1:29     ` Michael Bringmann

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=516edea6-8554-cdc6-db6d-9f6661e65ec4@linux.vnet.ibm.com \
    --to=nfont@linux.vnet.ibm.com \
    --cc=jallen@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mwb@linux.vnet.ibm.com \
    --cc=tlfalcon@linux.vnet.ibm.com \
    --cc=tyreld@linux.vnet.ibm.com \
    /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;
as well as URLs for NNTP newsgroup(s).