public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
	Mark Brown <broonie@kernel.org>,
	Mike Turquette <mturquette@linaro.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Alessandro Zummo <a.zummo@towertech.it>,
	Kukjin Kim <kgene.kim@samsung.com>,
	Doug Anderson <dianders@chromium.org>,
	Olof Johansson <olof@lixom.net>,
	Sjoerd Simons <sjoerd.simons@collabora.co.uk>,
	Daniel Stone <daniels@collabora.com>,
	Tomeu Vizoso <tomeu.vizoso@collabora.com>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Yadwinder Singh Brar <yadi.brar01@gmail.com>,
	linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
	linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 07/14] mfd: Add driver for Maxim 77802 Power Management IC
Date: Tue, 1 Jul 2014 16:15:19 +0100	[thread overview]
Message-ID: <20140701151519.GM27971@lee--X1> (raw)
In-Reply-To: <1403806546-31122-8-git-send-email-javier.martinez@collabora.co.uk>

On Thu, 26 Jun 2014, Javier Martinez Canillas wrote:

> Maxim MAX77802 is a power management chip that contains 10 high
> efficiency Buck regulators, 32 Low-dropout (LDO) regulators used
> to power up application processors and peripherals, a 2-channel
> 32kHz clock outputs, a Real-Time-Clock (RTC) and a I2C interface
> to program the individual regulators, clocks outputs and the RTC.
> 
> This patch adds the core support for MAX77802 PMIC and is based
> on a driver added by Simon Glass to the Chrome OS kernel 3.8 tree.
> 
> Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> Tested-by: Naveen Krishna Chatradhi <ch.naveen@samsung.com>
> ---
> 
> Changes since v4:
>  - Use consistent expressions when checking for NULL values.
>    Suggested by Krzysztof Kozlowski.
>  - Remove unused defines. Suggested by Krzysztof Kozlowski.
>  - Explain why IRQ is disabled on suspend. Suggested by Krzysztof Kozlowski.
> 
> Changes since v3:
>  - Remove unnecessary OOM error message since the mm subsystem already logs it. 
> 
> Changes since v2:
>  - Split the DT binding docs in a separate patch and improve the documentation.
>    Suggested by Mark Brown.
>  - Add all the devices in the MFD driver instead of doing in separate patches.
>    Suggested by Mark Brown.
> 
> Changes since v1:
>  - Convert max77{686,802} to regmap irq API and get rid of max77{686,802}-irq.c
>    Suggested by Krzysztof Kozlowski.
>  - Don't protect max77802 mfd_cells using Kconfig options since mfd core omits
>    devices that don't match. Suggested by Lee Jones.
>  - Change mfd driver to be tristate instead of boolean. Suggested by Mark Brown.
>  - Change binding "voltage-regulators" property to "regulators" to be consistent
>    with other PMIC drivers. Suggested by Mark Brown.
>  - Use regulators node names instead of the deprecated "regulator-compatible"
>    property. Suggested by Mark Brown.
>  - Use the new descriptor-based GPIO interface instead of the deprecated
>    integer based GPIO one. Suggested by Mark Brown.
>  - Remove the type parameter from i2c_device_id table since was not used.
>  - Fix device not found error message and remove unneeded device found message.
> 
>  drivers/mfd/Kconfig                  |  14 ++
>  drivers/mfd/Makefile                 |   1 +
>  drivers/mfd/max77802.c               | 366 ++++++++++++++++++++++++++++++++++

I don't think this needs it's own, brand new file.  You can just as
easy slot the enablement into max77686, which I suggest you do.

>  include/linux/mfd/max77802-private.h | 307 +++++++++++++++++++++++++++++
>  include/linux/mfd/max77802.h         | 121 ++++++++++++
>  5 files changed, 809 insertions(+)
>  create mode 100644 drivers/mfd/max77802.c
>  create mode 100644 include/linux/mfd/max77802-private.h
>  create mode 100644 include/linux/mfd/max77802.h

[...]

> +#ifdef CONFIG_OF
> +static struct of_device_id max77802_pmic_dt_match[] = {
> +	{.compatible = "maxim,max77802", .data = NULL},

Space before .compatible.

No need to set .data to NULL, just omit it.

> +	{},
> +};
> +
> +static void max77802_dt_parse_dvs_gpio(struct device *dev,
> +				       struct max77802_platform_data *pd,
> +				       struct device_node *np)

No need to overload these parameters by passing np, you can extract it
from dev.  Same goes for pd if you populate platform_data _before_
calling this function.

> +{
> +	int i;
> +
> +	/*
> +	 * NOTE: we don't consider GPIO errors fatal; board may have some lines
> +	 * directly pulled high or low and thus doesn't specify them.
> +	 */
> +	for (i = 0; i < ARRAY_SIZE(pd->buck_gpio_dvs); i++)
> +		pd->buck_gpio_dvs[i] =
> +			devm_gpiod_get_index(dev, "max77802,pmic-buck-dvs", i);
> +
> +	for (i = 0; i < ARRAY_SIZE(pd->buck_gpio_selb); i++)
> +		pd->buck_gpio_selb[i] =
> +			devm_gpiod_get_index(dev, "max77802,pmic-buck-selb", i);
> +}
> +
> +static struct max77802_platform_data *max77802_i2c_parse_dt_pdata(struct device
> +								  *dev)
> +{
> +	struct device_node *np = dev->of_node;
> +	struct max77802_platform_data *pd;
> +
> +	pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
> +	if (!pd)
> +		return NULL;
> +
> +	/* Read default index and ignore errors, since default is 0 */
> +	of_property_read_u32(np, "max77802,pmic-buck-default-dvs-idx",
> +			     &pd->buck_default_idx);
> +
> +	max77802_dt_parse_dvs_gpio(dev, pd, np);
> +
> +	dev->platform_data = pd;
> +	return pd;
> +}
> +#else
> +static struct max77802_platform_data *max77802_i2c_parse_dt_pdata(struct device
> +								  *dev)
> +{
> +	return 0;
> +}
> +#endif

No need for dummy functions.

Use if (IS_ENABLED(CONFIG_OF) && i2c->dev.of_node) instead.

> +static int max77802_i2c_probe(struct i2c_client *i2c,
> +			      const struct i2c_device_id *id)
> +{
> +	struct max77802_dev *max77802 = NULL;
> +	struct max77802_platform_data *pdata = dev_get_platdata(&i2c->dev);
> +	unsigned int data;
> +	int ret = 0;
> +
> +	if (i2c->dev.of_node)
> +		pdata = max77802_i2c_parse_dt_pdata(&i2c->dev);

DT should not over-rule platform data.  If the driver supports pdata
and it's present, it should over-rule DT.

> +	if (!pdata) {
> +		dev_err(&i2c->dev, "No platform data found.\n");
> +		return -EIO;

-EIO is not the correct error code here.  Either -EINVAL or -ENODEV
would be better.

> +	}
> +
> +	max77802 = devm_kzalloc(&i2c->dev, sizeof(struct max77802_dev),
> +				GFP_KERNEL);
> +	if (max77802 == NULL)

if (!max77802)

> +		return -ENOMEM;
> +
> +	i2c_set_clientdata(i2c, max77802);
> +
> +	max77802->dev = &i2c->dev;
> +	max77802->i2c = i2c;
> +	max77802->type = id->driver_data;
> +
> +	max77802->wakeup = pdata->wakeup;
> +	max77802->irq = i2c->irq;
> +
> +	max77802->regmap = devm_regmap_init_i2c(i2c, &max77802_regmap_config);
> +	if (IS_ERR(max77802->regmap)) {
> +		ret = PTR_ERR(max77802->regmap);
> +		dev_err(max77802->dev, "Failed to allocate register map: %d\n",
> +			ret);
> +		return ret;
> +	}
> +
> +	if (regmap_read(max77802->regmap,
> +			 MAX77802_REG_DEVICE_ID, &data) < 0) {
> +		dev_err(max77802->dev,
> +			"device not found on this channel\n");
> +		return -ENODEV;
> +	}

The return values for all other calls are first placed into a variable
and _then_ evaluated.  For consistency can you do the same here
please?

> +	ret = regmap_add_irq_chip(max77802->regmap, max77802->irq,
> +				  IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
> +				  IRQF_SHARED, 0, &max77802_irq_chip,
> +				  &max77802->irq_data);
> +	if (ret != 0) {

if (ret)

> +		dev_err(&i2c->dev, "failed to add PMIC irq chip: %d\n", ret);
> +		return ret;
> +	}

'\n'

[...]

> +static struct i2c_driver max77802_i2c_driver = {
> +	.driver = {
> +		   .name = "max77802",
> +		   .owner = THIS_MODULE,
> +		   .pm = &max77802_pm,
> +		   .of_match_table = of_match_ptr(max77802_pmic_dt_match),

This tabbing is off.

> +	},
> +	.probe = max77802_i2c_probe,
> +	.remove = max77802_i2c_remove,
> +	.id_table = max77802_i2c_id,
> +};
> +
> +static int __init max77802_i2c_init(void)
> +{
> +	return i2c_add_driver(&max77802_i2c_driver);
> +}
> +/* init early so consumer devices can complete system boot */
> +subsys_initcall(max77802_i2c_init);
> +
> +static void __exit max77802_i2c_exit(void)
> +{
> +	i2c_del_driver(&max77802_i2c_driver);
> +}
> +module_exit(max77802_i2c_exit);

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2014-07-01 15:15 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-26 18:15 [PATCH v5 00/14] Add Maxim 77802 PMIC support Javier Martinez Canillas
2014-06-26 18:15 ` [PATCH v5 01/14] mfd: max77686: Convert to use regmap_irq Javier Martinez Canillas
2014-06-26 18:15 ` [PATCH v5 02/14] mfd: max77686: Allow the max77686 rtc to wakeup the system Javier Martinez Canillas
2014-06-27  9:21   ` Lee Jones
2014-06-27  9:32     ` Javier Martinez Canillas
2014-06-26 18:15 ` [PATCH v5 03/14] clk: max77686: Add DT include for MAX77686 PMIC clock Javier Martinez Canillas
2014-06-27  7:48   ` Andreas Färber
2014-06-27  7:53     ` Javier Martinez Canillas
2014-06-27  8:26       ` Andreas Färber
     [not found]         ` <53AD2AB7.1090000-l3A5Bk7waGM@public.gmane.org>
2014-06-27  8:54           ` Javier Martinez Canillas
     [not found]   ` <1403806546-31122-4-git-send-email-javier.martinez-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
2014-07-01 17:30     ` Mike Turquette
2014-06-26 18:15 ` [PATCH v5 04/14] clk: max77686: Improve Maxim 77686 PMIC clocks binding Javier Martinez Canillas
     [not found]   ` <1403806546-31122-5-git-send-email-javier.martinez-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
2014-07-01 17:29     ` Mike Turquette
2014-07-02 10:17       ` Javier Martinez Canillas
2014-07-02 15:21         ` Mike Turquette
2014-06-26 18:15 ` [PATCH v5 05/14] clk: Add generic driver for Maxim PMIC clocks Javier Martinez Canillas
2014-06-30  4:01   ` Yadwinder Singh Brar
2014-06-30 10:58     ` Javier Martinez Canillas
     [not found]       ` <53B142F1.1050407-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
2014-06-30 11:35         ` Russell King - ARM Linux
2014-06-30 16:00           ` Javier Martinez Canillas
2014-07-01 17:26     ` Mike Turquette
2014-07-02 10:13       ` Javier Martinez Canillas
2014-07-02 10:19         ` Krzysztof Kozlowski
2014-06-26 18:15 ` [PATCH v5 06/14] clk: max77686: Convert to the generic max clock driver Javier Martinez Canillas
2014-06-26 18:15 ` [PATCH v5 07/14] mfd: Add driver for Maxim 77802 Power Management IC Javier Martinez Canillas
2014-07-01 15:15   ` Lee Jones [this message]
2014-07-01 15:55     ` Javier Martinez Canillas
2014-06-26 18:15 ` [PATCH v5 08/14] mfd: max77802: Add DT binding documentation Javier Martinez Canillas
2014-06-27  8:06   ` Andreas Färber
2014-06-27  8:50     ` Javier Martinez Canillas
2014-06-26 18:15 ` [PATCH v5 09/14] regmap: Add regmap_reg_copy function Javier Martinez Canillas
2014-06-26 18:15 ` [PATCH v5 10/14] regulator: Add driver for Maxim 77802 PMIC regulators Javier Martinez Canillas
2014-06-27  9:26   ` Lee Jones
2014-06-27  9:42     ` Javier Martinez Canillas
2014-06-26 18:15 ` [PATCH v5 11/14] clk: Add driver for Maxim 77802 PMIC clocks Javier Martinez Canillas
2014-06-26 18:15 ` [PATCH v5 12/14] clk: max77802: Add DT binding documentation Javier Martinez Canillas
     [not found]   ` <1403806546-31122-13-git-send-email-javier.martinez-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
2014-06-27  7:52     ` Andreas Färber
2014-06-27  7:55       ` Javier Martinez Canillas
2014-06-26 18:15 ` [PATCH v5 13/14] rtc: Add driver for Maxim 77802 PMIC Real-Time-Clock Javier Martinez Canillas
2014-06-26 18:15 ` [PATCH v5 14/14] ARM: dts: Add max77802 to exynos5420-peach-pit and exynos5800-peach-pi Javier Martinez Canillas
2014-07-02  9:20   ` Tushar Behera
2014-07-02  9:22     ` Javier Martinez Canillas

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=20140701151519.GM27971@lee--X1 \
    --to=lee.jones@linaro.org \
    --cc=a.zummo@towertech.it \
    --cc=broonie@kernel.org \
    --cc=daniels@collabora.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dianders@chromium.org \
    --cc=javier.martinez@collabora.co.uk \
    --cc=k.kozlowski@samsung.com \
    --cc=kgene.kim@samsung.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=mturquette@linaro.org \
    --cc=olof@lixom.net \
    --cc=sameo@linux.intel.com \
    --cc=sjoerd.simons@collabora.co.uk \
    --cc=tomeu.vizoso@collabora.com \
    --cc=yadi.brar01@gmail.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