Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4835892pxb; Tue, 28 Sep 2021 05:19:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNPck4xCAdL6HDgUjwOtnwPsvhRlNx8rlgRRqHk4fJDg4xNfFs09quC3mflv0idCz22W4M X-Received: by 2002:a17:907:2653:: with SMTP id ar19mr6268058ejc.431.1632831565312; Tue, 28 Sep 2021 05:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632831565; cv=none; d=google.com; s=arc-20160816; b=I4W4wTzx3avxsR6pyzQT0geWPEN7gBX2QhZf93XQNZIqCRJ/rPZh3CJl6nb82b4Omz CKTtgM1iCgNuzNs0HV8djMKOLEfrUSJg4/XPP1+es3BMAocW8nOXreRBoqyCSkh4NEh6 3aah4TMHlEkwensUN7hemha1ovVrxOSly31/GiYGyV+rIPMETzkIajaP9jdfxR0Dfdcn 7hcNv8Q55EaiO7fOJ1rIn25lN1Pde17WY+XEDVnbajstC3TozKMyL20ugqx16GGSmpGj m0giwa3LtYb8QDCRLOYMxBmd1TTtMN2Lx5exZR9IFfs8I8BnroXL4F6pgbmuW90F+5mE WYSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :sender:dkim-signature; bh=3YxpkI8yDoGtSj31ff3dv3bwdiRI/L0P/ZZXyQghP1k=; b=MX+J3YMZlBnCGs8bxuNhLnSmtsFRXd1+x2UNdv8fbvfNwoY/ZJ5cAGVwMBApu5lMz9 tHs+pXVI2R9/R/ulFQhdwl289H792ZHqnD7UqEsbf9HLXlfrCEt9+YztOWOTIA5vLAIc sAsJjBQz57AQHTYmvcMK2fR2iKchcoT+IqzzSnBZTHGKqK4gk8evGPdAp+Hqdx/qClq6 iQ0CipQ5Q1q5XsCZVp1et0h5SMkuBwn2nRU6Wj3el3Y69uyfUxpFA5Z4S3uDRfHQOtEE 8VasB/sHE+kESaxSP9XOXmA5/yp3CynfdRRknjEYk83pMTHB6enNHOSp+k86lNDG2Usd Hvlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b="kWtI/TXN"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n1si12373490ejx.273.2021.09.28.05.19.01; Tue, 28 Sep 2021 05:19:25 -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=@mg.codeaurora.org header.s=smtp header.b="kWtI/TXN"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240503AbhI1MS4 (ORCPT + 99 others); Tue, 28 Sep 2021 08:18:56 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:27568 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240528AbhI1MSz (ORCPT ); Tue, 28 Sep 2021 08:18:55 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1632831436; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=3YxpkI8yDoGtSj31ff3dv3bwdiRI/L0P/ZZXyQghP1k=; b=kWtI/TXNd1BjtNs+k9yu2cv8Xr0V0kbfl6k90hSh58w/rdfpZllwCJPZTIc2tIxXBk/hKbkU uuAmb1bIneiih6IcOPkCSzWUvP4CsfWsp5ocMgAtQwfycelARnxgfS+9Us15sA8daLS6Nm8c GJIOP7IEvBKwqBy+yJs27OiT8DQ= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n02.prod.us-east-1.postgun.com with SMTP id 615307b9713d5d6f96782ba2 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 28 Sep 2021 12:16:57 GMT Sender: skakit=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 97176C43639; Tue, 28 Sep 2021 12:16:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: skakit) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6BECDC43619; Tue, 28 Sep 2021 12:16:54 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 28 Sep 2021 17:46:54 +0530 From: skakit@codeaurora.org To: Mark Brown Cc: Andy Gross , Bjorn Andersson , Rob Herring , Lee Jones , Liam Girdwood , mka@chromium.org, swboyd@chromium.org, Das Srinagesh , David Collins , kgunda@codeaurora.org, Subbaraman Narayanamurthy , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/4] regulator: Add a regulator driver for the PM8008 PMIC In-Reply-To: <20210917153837.GB4700@sirena.org.uk> References: <1631875538-22473-1-git-send-email-skakit@codeaurora.org> <1631875538-22473-4-git-send-email-skakit@codeaurora.org> <20210917153837.GB4700@sirena.org.uk> Message-ID: X-Sender: skakit@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mark, Thanks for reviewing the changes! On 2021-09-17 21:08, Mark Brown wrote: > On Fri, Sep 17, 2021 at 04:15:37PM +0530, Satya Priya wrote: > >> +static int pm8008_regulator_is_enabled(struct regulator_dev *rdev) >> +{ >> + struct pm8008_regulator *pm8008_reg = rdev_get_drvdata(rdev); >> + int rc; >> + u8 reg; >> + >> + rc = pm8008_read(pm8008_reg->regmap, >> + LDO_ENABLE_REG(pm8008_reg->base), ®, 1); >> + if (rc < 0) { >> + pr_err("failed to read enable reg rc=%d\n", rc); >> + return rc; >> + } >> + >> + return !!(reg & ENABLE_BIT); >> +} > > This could just be regulator_is_enabled_regmap(). There's also a lot > of > instances in the driver where it's using pr_err() not dev_err() (and > similarly for the debug prints). > Okay, I'll use the helper regulator_is_enabled_regmap() here and remove this completely. >> + >> +static int pm8008_regulator_enable(struct regulator_dev *rdev) >> +{ >> + struct pm8008_regulator *pm8008_reg = rdev_get_drvdata(rdev); >> + int rc, current_uv, delay_us, delay_ms, retry_count = 10; >> + u8 reg; > > This is the regmap helper. > Okay, I'll use regulator_enable_regmap(). >> + /* >> + * Wait for the VREG_READY status bit to be set using a timeout >> delay >> + * calculated from the current commanded voltage. >> + */ >> + delay_us = STARTUP_DELAY_USEC >> + + DIV_ROUND_UP(current_uv, pm8008_reg->step_rate); >> + delay_ms = DIV_ROUND_UP(delay_us, 1000); > > Set poll_enable_time and implement get_status() then this will be > handled by the core. > Anyway I will be removing this API. >> +static int pm8008_regulator_disable(struct regulator_dev *rdev) >> +{ > > Use the regmap helper. > Ok, I'll use regulator_disable_regmap. >> + rc = pm8008_write_voltage(pm8008_reg, min_uv, max_uv); >> + if (rc < 0) >> + return rc; > > This is the only place where write_voltage() is called, may as well > just > inline it. > Okay. >> + init_voltage = -EINVAL; >> + of_property_read_u32(reg_node, "qcom,init-voltage", &init_voltage); > > Why does this property exist and if it's needed why is it specific to > this device? It looks like the device allows you to read the voltage > on > startup from the regmap. > I think it is not necessary, will remove it. >> + init_data = of_get_regulator_init_data(dev, reg_node, >> + &pm8008_reg->rdesc); >> + if (init_data == NULL) { >> + dev_err(dev, "%s: failed to get regulator data\n", name); >> + return -ENODATA; >> + } >> + if (!init_data->constraints.name) { >> + dev_err(dev, "%s: regulator name missing\n", name); >> + return -EINVAL; >> + } > > Just let the core find the init data for you, there is no reason to > insist on a system provided name - that is an entirely optional > property > for systems to use, there is no reason for a regulator driver to care. > OK, I will remove this if check. >> + init_data->constraints.input_uV = init_data->constraints.max_uV; >> + init_data->constraints.valid_ops_mask |= REGULATOR_CHANGE_STATUS >> + | REGULATOR_CHANGE_VOLTAGE; > > This is absolutely not something that a regulator driver should be > doing, the whole point with constraints is that they come from the > machine. > Okay I will remove this. >> +static int pm8008_parse_regulator(struct regmap *regmap, struct >> device *dev) >> +{ >> + int rc = 0; >> + const char *name; >> + struct device_node *child; >> + struct pm8008_regulator *pm8008_reg; >> + >> + /* parse each subnode and register regulator for regulator child */ >> + for_each_available_child_of_node(dev->of_node, child) { >> + pm8008_reg = devm_kzalloc(dev, sizeof(*pm8008_reg), GFP_KERNEL); >> + if (!pm8008_reg) > > You shouldn't be doing this, just unconditionally register all the > regulators supported by the chip. If they don't appear in the DT > that's > totally fine - it gives read only access which can be useful for > diagnostics. Okay will remove this check as well. -Satya Priya.