From: Mark Brown <broonie@kernel.org>
To: Flora Fu <flora.fu@mediatek.com>
Cc: Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
Pawel Moll <pawel.moll@arm.com>,
Ian Campbell <ijc+devicetree@hellion.org.uk>,
Kumar Gala <galak@codeaurora.org>,
Russell King <linux@arm.linux.org.uk>,
Samuel Ortiz <sameo@linux.intel.com>,
Lee Jones <lee.jones@linaro.org>,
Liam Girdwood <lgirdwood@gmail.com>,
Grant Likely <grant.likely@linaro.org>,
"Joe.C" <yingjoe.chen@mediatek.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Vladimir Murzin <vladimir.murzin@arm.com>,
Ashwin Chaugule <ashwin.chaugule@linaro.org>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
srv_heupstream@mediatek.com, Sascha Hauer <kernel@pengutronix.de>,
Eddie Huang <eddie.huang@mediatek.com>,
Dongdong Cheng <dongdong.cheng@mediatek.com>
Subject: Re: [PATCH 3/7] regulator: MT6397: Add support for MT6397 regulator
Date: Mon, 17 Nov 2014 23:40:12 +0000 [thread overview]
Message-ID: <20141117234012.GE22111@sirena.org.uk> (raw)
In-Reply-To: <1416210027-5562-4-git-send-email-flora.fu@mediatek.com>
[-- Attachment #1: Type: text/plain, Size: 2765 bytes --]
On Mon, Nov 17, 2014 at 03:40:23PM +0800, Flora Fu wrote:
This looks mostly good but there are a few fairly straightfoward things:
> @@ -725,5 +725,11 @@ config REGULATOR_WM8994
> This driver provides support for the voltage regulators on the
> WM8994 CODEC.
>
> +config REGULATOR_MT6397
> + tristate "MediaTek MT6397 PMIC"
> + depends on MFD_MT6397
> + help
> + This driver provides support for the voltage regulators on the MediaTek MT6397 PMIC.
> +
> endif
Keep this and the Makefile sorted.
> +static int mt6397_buck_set_voltage_sel(struct regulator_dev *rdev, unsigned sel)
> +{
> + vosel = info->buck_conf.vosel_reg;
> + voselon = info->buck_conf.voselon_reg;
> + vosel_mask = info->buck_conf.vosel_mask;
Please use the standard way of specifying data even if you can't use the
standard function.
> +
> + ret = regmap_update_bits(rdev->regmap, vosel, vosel_mask, sel);
> + if (ret != 0) {
> + dev_err(&rdev->dev, "Failed to update vosel: %d\n", ret);
> + return ret;
> + }
> +
> + ret = regmap_update_bits(rdev->regmap, voselon, vosel_mask, sel);
> + if (ret != 0) {
> + dev_err(&rdev->dev, "Failed to update vosel_on: %d\n", ret);
> + return ret;
> + }
> + return 0;
You should add comments here explaining what's going on - it's very
strange to have to write the same value to two different registers and
the names of the registers look suspicously like this is something to do
with a suspend mode...
Missing blank line before the return too.
> +static int mt6397_buck_get_voltage_sel(struct regulator_dev *rdev)
> +{
You could use the regmap based helper for this.
> +static int mt6397_ldo_set_voltage_sel(struct regulator_dev *rdev, unsigned sel)
> +{
The LDO operations appear to be identical to the standard regmap
helpers, please use them.
> + if (is_fixed)
> + return 0;
You should use the standard fixed voltage regulator support rather than
> +static int mt6397_regulator_is_enabled(struct regulator_dev *rdev)
> +{
Again this looks like it should be using helpers.
> +#define MT6397_REGULATOR_OF_MATCH(_name, _id) \
> +[MT6397_ID_##_id] = { \
> + .name = #_name, \
> + .driver_data = &mt6397_regulators[MT6397_ID_##_id], \
> +}
Define regulators_node and of_match in the regulator desc and you can
remove both this table and all your DT matching code in the driver, the
core will handle it for you.
> + if ((reg_value & 0xFF) == MT6397_REGULATOR_ID91) {
> + j = MT6397_ID_VCAMIO;
> + mt6397_regulator_matches[j].init_data->constraints.min_uV =
> + 1000000;
> + mt6397_regulators[j].desc.volt_table = ldo_volt_table5_v2;
> + }
Use a switch statement, that way other variants can be added more
easily.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2014-11-17 23:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1416210027-5562-1-git-send-email-flora.fu@mediatek.com>
[not found] ` <1416210027-5562-5-git-send-email-flora.fu@mediatek.com>
2014-11-17 23:31 ` [PATCH 4/7] dt-bindings: Add document for MT6397 MFD Mark Brown
[not found] ` <1416210027-5562-4-git-send-email-flora.fu@mediatek.com>
2014-11-17 23:40 ` Mark Brown [this message]
[not found] ` <1416553771.19764.51.camel@mtksdaap41>
2014-11-21 10:16 ` [PATCH 3/7] regulator: MT6397: Add support for MT6397 regulator Mark Brown
[not found] ` <1416210027-5562-3-git-send-email-flora.fu@mediatek.com>
2014-11-18 11:46 ` [PATCH 2/7] mfd: MT6397: Add regmap for MT8135 and MT6397 SoC Lee Jones
2014-11-18 13:46 ` Sascha Hauer
2014-11-19 17:04 ` Lee Jones
2014-11-20 9:19 ` Sascha Hauer
2014-11-20 10:38 ` Lee Jones
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=20141117234012.GE22111@sirena.org.uk \
--to=broonie@kernel.org \
--cc=ashwin.chaugule@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=devicetree@vger.kernel.org \
--cc=dongdong.cheng@mediatek.com \
--cc=eddie.huang@mediatek.com \
--cc=flora.fu@mediatek.com \
--cc=galak@codeaurora.org \
--cc=grant.likely@linaro.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=kernel@pengutronix.de \
--cc=lee.jones@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mark.rutland@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=sameo@linux.intel.com \
--cc=srv_heupstream@mediatek.com \
--cc=vladimir.murzin@arm.com \
--cc=yingjoe.chen@mediatek.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
Powered by JetHome