Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1626002

Re: [PATCH V3 2/4] reset: Add APIs to manage array of resets

From Philipp Zabel <p.zabel@pengutronix.de>
Newsgroups linux.kernel
Subject Re: [PATCH V3 2/4] reset: Add APIs to manage array of resets
Date 2017-04-19 12:40 +0200
Message-ID <txVbI-2kv-11@gated-at.bofh.it> (permalink)
References <txzux-5A7-3@gated-at.bofh.it> <txzux-5A7-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, 2017-04-18 at 16:51 +0530, Vivek Gautam wrote:
> Many devices may want to request a bunch of resets
> and control them. So it's better to manage them as an
> array. Add APIs to _get(), _assert(), and _deassert()
> an array of reset_control.

Thanks! This looks good to me, one small issue below.

> Cc: Philipp Zabel <p.zabel@pengutronix.de>
> Signed-off-by: Vivek Gautam <vivek.gautam@codeaurora.org>
> ---
>  drivers/reset/core.c  | 177 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/reset.h |  93 ++++++++++++++++++++++++++
>  2 files changed, 270 insertions(+)
> 
> diff --git a/drivers/reset/core.c b/drivers/reset/core.c
> index f0a06a7aca93..54bd3be5e7a4 100644
> --- a/drivers/reset/core.c
> +++ b/drivers/reset/core.c
> @@ -488,3 +488,180 @@ int of_reset_control_get_count(struct device_node *node)
>  	return count;
>  }
>  EXPORT_SYMBOL_GPL(of_reset_control_get_count);
> +
> +/**
> + * APIs to manage an array of reset controls.
> + */
> +/**
> + * reset_control_array_assert: assert a list of resets
> + *
> + * @resets: reset control array holding info about the list of resets
> + *
> + * This API doesn't guarantee that the reset lines controlled by
> + * the reset array are asserted in any particular order.
> + *
> + * Returns 0 on success or error number on failure.
> + */
> +int reset_control_array_assert(struct reset_control_array *resets)
> +{
> +	int ret, i;
> +
> +	if (!resets)
> +		return 0;
> +
> +	if (IS_ERR(resets))
> +		return -EINVAL;
> +
> +	for (i = 0; i < resets->num_rstcs; i++) {
> +		ret = reset_control_assert(resets->rstc[i]);
> +		if (ret)
> +			return ret;

This should try to deassert the already asserted resets in the error
case.

> +	}
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(reset_control_array_assert);
> +
> +/**
> + * reset_control_array_deassert: deassert a list of resets
> + *
> + * @resets: reset control array holding info about the list of resets
> + *
> + * This API doesn't guarantee that the reset lines controlled by
> + * the reset array are deasserted in any particular order.
> + *
> + * Returns 0 on success or error number on failure.
> + */
> +int reset_control_array_deassert(struct reset_control_array *resets)
> +{
> +	int ret, i;
> +
> +	if (!resets)
> +		return 0;
> +
> +	if (IS_ERR(resets))
> +		return -EINVAL;
> +
> +	for (i = 0; i < resets->num_rstcs; i++) {
> +		ret = reset_control_deassert(resets->rstc[i]);
> +		if (ret)
> +			goto err;
> +	}
> +
> +	return 0;
> +
> +err:
> +	while (i--)
> +		reset_control_assert(resets->rstc[i]);
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(reset_control_array_deassert);

As this already does.

regards
Philipp

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH V3 0/4] reset: APIs to manage a list of resets Vivek Gautam <vivek.gautam@codeaurora.org> - 2017-04-18 13:30 +0200
  [PATCH V3 2/4] reset: Add APIs to manage array of resets Vivek Gautam <vivek.gautam@codeaurora.org> - 2017-04-18 13:30 +0200
    Re: [PATCH V3 2/4] reset: Add APIs to manage array of resets Philipp Zabel <p.zabel@pengutronix.de> - 2017-04-19 12:40 +0200
      Re: [PATCH V3 2/4] reset: Add APIs to manage array of resets Vivek Gautam <vivek.gautam@codeaurora.org> - 2017-04-19 14:00 +0200
  [PATCH V3 1/4] reset: Add API to count number of reset available with device Vivek Gautam <vivek.gautam@codeaurora.org> - 2017-04-18 13:30 +0200
    Re: [PATCH V3 1/4] reset: Add API to count number of reset  available with device Philipp Zabel <p.zabel@pengutronix.de> - 2017-04-19 12:30 +0200
      Re: [PATCH V3 1/4] reset: Add API to count number of reset available  with device Vivek Gautam <vivek.gautam@codeaurora.org> - 2017-04-19 13:50 +0200
  [PATCH V3 4/4] soc/tegra: pmc: Use the new reset APIs to manage reset controllers Vivek Gautam <vivek.gautam@codeaurora.org> - 2017-04-18 13:30 +0200
    Re: [PATCH V3 4/4] soc/tegra: pmc: Use the new reset APIs to manage  reset controllers Philipp Zabel <p.zabel@pengutronix.de> - 2017-04-19 12:50 +0200
    Re: [PATCH V3 4/4] soc/tegra: pmc: Use the new reset APIs to manage  reset controllers Jon Hunter <jonathanh@nvidia.com> - 2017-04-24 14:50 +0200
  [PATCH V3 3/4] usb: dwc3: of-simple: Add support to get resets for the device Vivek Gautam <vivek.gautam@codeaurora.org> - 2017-04-18 13:30 +0200
    Re: [PATCH V3 3/4] usb: dwc3: of-simple: Add support to get resets  for the device Philipp Zabel <p.zabel@pengutronix.de> - 2017-04-19 12:40 +0200
      Re: [PATCH V3 3/4] usb: dwc3: of-simple: Add support to get resets  for the device Vivek Gautam <vivek.gautam@codeaurora.org> - 2017-04-19 14:10 +0200

csiph-web