mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Holger Assmann <h.assmann@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] mfd: regulator: initial support for pca9450
Date: Wed, 26 Jul 2023 11:40:21 +0200	[thread overview]
Message-ID: <20230726094021.GG18491@pengutronix.de> (raw)
In-Reply-To: <20230724075258.1840671-1-h.assmann@pengutronix.de>

Hi Holger,

On Mon, Jul 24, 2023 at 09:52:58AM +0200, Holger Assmann wrote:
> +++ b/drivers/mfd/pca9450.c
> @@ -0,0 +1,106 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (C) 2023 Holger Assmann, Pengutronix
> + */
> +
> +#include <common.h>
> +#include <driver.h>
> +#include <errno.h>
> +#include <i2c/i2c.h>
> +#include <init.h>
> +#include <mfd/pca9450.h>
> +#include <of.h>
> +#include <regmap.h>
> +#include <reset_source.h>
> +
> +#define REASON_PMIC_RST		0x10
> +#define REASON_PWON		0x80
> +#define REASON_SW_RST		0x20
> +#define REASON_WDOG		0x40

Please sort these defines by register bit.

> +
> +static const struct regmap_config pca9450_regmap_i2c_config = {
> +	.reg_bits = 8,
> +	.val_bits = 8,
> +	.max_register = 0x2E,
> +};
> +
> +static int pca9450_get_reset_source(struct device *dev, struct regmap *map)
> +{
> +	enum reset_src_type type;
> +	int reg;
> +	int ret;
> +
> +	ret = regmap_read(map, PCA9450_PWRON_STAT, &reg);
> +	if (ret)
> +		return ret;
> +	
> +	switch (reg) {
> +		case REASON_PWON:
> +			dev_dbg(dev, "Power ON triggered by PMIC_ON_REQ.\n");
> +			type = RESET_POR;
> +			break;
> +		case REASON_WDOG:
> +			dev_dbg(dev, "Detected cold reset by WDOGB pin\n");
> +			type = RESET_WDG;
> +			break;
> +		case REASON_SW_RST:
> +			dev_dbg(dev, "Detected cold reset by SW_RST\n");
> +			type = RESET_RST;
> +			break;
> +		case REASON_PMIC_RST:
> +			dev_dbg(dev, "Detected cold reset by PMIC_RST_B\n");
> +			type = RESET_EXT;
> +			break;
> +		default:
> +			dev_warn(dev, "Could not determine reset reason.\n");
> +			type = RESET_UKWN;
> +	}

Coding style is to align the 'case' directly under 'switch'.

> +
> +	reset_source_set_device(dev, type);
> +
> +	return 0;
> +};
> +	

There are some trailing whitespaces here and elsewhere.

Otherwise looks good.

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      reply	other threads:[~2023-07-26  9:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-24  7:52 Holger Assmann
2023-07-26  9:40 ` Sascha Hauer [this message]

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=20230726094021.GG18491@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=h.assmann@pengutronix.de \
    /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