Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1250935ybk; Thu, 14 May 2020 04:30:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwW6Ed4yLB6GBVckaRh2gRtBAijUkW0N8YmWgNno9JbhLYzwJxutzHBXlgd+q/o7HQRwiad X-Received: by 2002:a17:906:74c:: with SMTP id z12mr3532180ejb.87.1589455821878; Thu, 14 May 2020 04:30:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589455821; cv=none; d=google.com; s=arc-20160816; b=QOhrtTlfP9c4ZN6n6W5mtvkVuwNuiGO6fE93jwgMQx7Iwwm1ucLW7y/q/oX5Z5V9Ur zdbA/3IEpRFzZaWp5yCFWWi+OL0EZ80E+FMj20AS/TVUIEn74czyUu6hGyljPqBwtNmd tGOSJycfThOK19ZfLMc8y65eVorYeyWqSBtZnO+8XEjpydZRtTkJ0Fl4KvgOICRYsd5a T7QycOfZTDq3zJkJp8h/VYOdvKaNsEHuquLxeP/ykwVZb+oehetcIre64YoQ77Cfv7M7 Ls3TIBeVl/PrVUDiUQGhdhwmT6LlEeoQS5h4rdv+m36BmhPZPKytAXakyTTWlED2dbsI JhOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=wxAs+mvRFMkQC0sck5MS5WhqTOyvJuovj78EsreUtvE=; b=S0/0XQExUTCxXds1bZB4U68U7tSQMLRq5XyrvUyOlaZ7d6zilj7uMU2nIke20usuNu FcnOup7iLlWX0skmkp5a9mzpx28j0gqfKbpR15tcmZAkMDSqRfpxaHXHx7ECj9Yt7AhF KnmsqQvrQn9ZwqUzint6p1bjMdLblJNAfHNbb0bl+sjaQUuLODRf9bnEiigqjf9KqWMe 8QiWukxmkzsXq7VA6erDAcM0gQjDnrmGPDR/R1LSfw1p3m/ZZaaDf5bO37vDiaya+GyP GPmY3TeViiWw6u4FwHboT97wBF5FZGOlTqA/SAJLngFwxMlesqeFurvreI4spzNcrIoR hGrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FDvaNrZJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d20si1333974edx.529.2020.05.14.04.29.57; Thu, 14 May 2020 04:30:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FDvaNrZJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726492AbgENL14 (ORCPT + 99 others); Thu, 14 May 2020 07:27:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726051AbgENL14 (ORCPT ); Thu, 14 May 2020 07:27:56 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5DF5C061A0C for ; Thu, 14 May 2020 04:27:55 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id c3so2005586otr.12 for ; Thu, 14 May 2020 04:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wxAs+mvRFMkQC0sck5MS5WhqTOyvJuovj78EsreUtvE=; b=FDvaNrZJJwmbPiapmx88pMKzanvUHC7BTHIvMPe6B5SRaYMqaQWdQVHWUzKT+CHWUO IPI6jehEtsu0MvskmpriRki1/VVhuWa2lsxgeLpPE7ZS8EWWrQif51SMiqmU1yHqtGJM 6bRy5vuz/HsIlMA7dBfSMddHzP681WpZ3lOPsOAzBtSVfjWxRh+ijCUQwrlwc4KkTRYX jD2GmDreLZ9kOPcjPIeoO58EFtYAxQQcULnBjInpLJv/yor8X2t278Rdl8YDRBz5nLdX S2xUG1+EBMvAZsS/mbUm6DSjxNvARM92lDxzTsBdL2WqA5oI2dzXTWMEpCHuE6qJYR1r 9BZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wxAs+mvRFMkQC0sck5MS5WhqTOyvJuovj78EsreUtvE=; b=UnlZWITwcvNmKamnlyimsrkFt1GidsCigVgcyypCBPJTmsgRvbRdi3er6h9t2CaEcn uzpGoo88I49qTghxmI66pqR7JvFhUi8Iti2mxZocDgIfJCZ0WkDFiK2wHML3EpjLQDAW WkxiEbe2nLvy2m8N2pQ6l1n3Ei032SFEP6tJKpjmA6AbkbXp5sHa992wBiIIQ/+xgruE qILPYUAgmwKowaJgv+2WPSs37iPrCSEBTw8kZYNHp/MdI4CZI+9iTmeXKxuQyUGBI1/2 U8W5GDI9+6EVTCvqIM7zSLpVoT/ic62qdXiUrhrcbvnJ9YWkqBC7xYiUaw5KWfRcKuez kaEw== X-Gm-Message-State: AOAM531vfeU/7R3mCffpD1QKpQS7ZKIsDn0R43EZjFi1C7zp8JRHgQQo xYaq0upNdnFrOOntwnRIFdbY9kKxOshdGSQIHujGv6gq0ci1MQ== X-Received: by 2002:a9d:e93:: with SMTP id 19mr3159324otj.371.1589455675094; Thu, 14 May 2020 04:27:55 -0700 (PDT) MIME-Version: 1.0 References: <20200508204200.13481-1-sumit.semwal@linaro.org> <20200508204200.13481-4-sumit.semwal@linaro.org> <20200511103937.GC8216@sirena.org.uk> In-Reply-To: <20200511103937.GC8216@sirena.org.uk> From: Sumit Semwal Date: Thu, 14 May 2020 16:57:43 +0530 Message-ID: Subject: Re: [v2 3/4] regulator: qcom: Add labibb driver To: Mark Brown Cc: agross@kernel.org, Bjorn Andersson , lgirdwood@gmail.com, robh+dt@kernel.org, Nisha Kumari , linux-arm-msm@vger.kernel.org, LKML , devicetree@vger.kernel.org, kgunda@codeaurora.org, Rajendra Nayak Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Mark, Thank you for your review comments! On Mon, 11 May 2020 at 16:09, Mark Brown wrote: > > On Sat, May 09, 2020 at 02:11:59AM +0530, Sumit Semwal wrote: > > > + ret = regmap_bulk_read(reg->regmap, reg->base + > > + REG_LABIBB_STATUS1, &val, 1); > > + if (ret < 0) { > > + dev_err(reg->dev, "Read register failed ret = %d\n", ret); > > + return ret; > > + } > > Why a bulk read of a single register? Right, will change. > > > +static int _check_enabled_with_retries(struct regulator_dev *rdev, > > + int retries, int enabled) > > +{ > > This is not retrying, this is polling to see if the regulator actually > enabled. Yes, will update accordingly. > > > +static int qcom_labibb_regulator_enable(struct regulator_dev *rdev) > > +{ > > > + ret = _check_enabled_with_retries(rdev, retries, 1); > > + if (ret < 0) { > > + dev_err(reg->dev, "retries exhausted: enable %s regulator\n", > > + reg->desc.name); > > + return ret; > > + } > > If this is useful factor it out into a helper or the core, other devices > also have status bits saying if the regulator is enabled. It looks like > this may be mainly trying to open code something like enable_time, with > possibly some issues where the time taken to enable varies a lot. > Makes sense; I am not terribly familiar with the regulator core and helpers, so let me look and refactor accordingly. > > + if (ret) > > + return 0; > > + > > + > > + dev_err(reg->dev, "Can't enable %s\n", reg->desc.name); > > + return -EINVAL; > > Return the actual error code (the logic here is quite convoluted). Will try to simplify. > > > + ret = regulator_disable_regmap(rdev); > > + > > + if (ret < 0) { > > You have lots of blank lines between operations and checking their > return codes? > will correct that. > > + ret = _check_enabled_with_retries(rdev, retries, 0); > > + if (ret < 0) { > > + dev_err(reg->dev, "retries exhausted: disable %s regulator\n", > > + reg->desc.name); > > + return ret; > > + } > > Similarly to the enable path, but is this one about off_on_delay rather > than enable_time? Got it. Let me look deeper. > > > + if (reg_data->type == QCOM_LAB_TYPE) { > > + reg = &labibb->lab; > > + reg->desc.enable_mask = LAB_ENABLE_CTL_MASK; > > + } else { > > + reg = &labibb->ibb; > > + reg->desc.enable_mask = IBB_ENABLE_CTL_MASK; > > + } > > Write a switch statement so this is extensible. I can change over to switch, though in the current set of downstream code I've seen, it doesn't look that it would get extended. But I guess there isn't any harm in moving over to switch. Will do. Best, Sumit.