From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1762461AbdDSLzh (ORCPT ); Wed, 19 Apr 2017 07:55:37 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:58046 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760547AbdDSLze (ORCPT ); Wed, 19 Apr 2017 07:55:34 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org AAA7861150 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vivek.gautam@codeaurora.org Subject: Re: [PATCH V3 2/4] reset: Add APIs to manage array of resets To: Philipp Zabel References: <1492514488-27385-1-git-send-email-vivek.gautam@codeaurora.org> <1492514488-27385-3-git-send-email-vivek.gautam@codeaurora.org> <1492597912.2970.65.camel@pengutronix.de> Cc: swarren@wwwdotorg.org, balbi@kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-usb@vger.kernel.org, thierry.reding@gmail.com, gregkh@linuxfoundation.org, linux-arm-msm@vger.kernel.org From: Vivek Gautam Message-ID: Date: Wed, 19 Apr 2017 17:25:28 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1492597912.2970.65.camel@pengutronix.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Philipp, On 04/19/2017 04:01 PM, Philipp Zabel wrote: > 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 >> Signed-off-by: Vivek Gautam >> --- >> 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. I assumed that the user will call _assert in case of failure, driver removal or may be suspend, and thought that we may not care even if the _assert failed. But i see now that we also care about the (de)assert count, so that the shared resets are handled properly. Will add the core to deassert the already asserted resets in error case. Thanks > >> + } >> + >> + 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. Yea, like this one. Best Regards Vivek > > regards > Philipp > -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project