devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel-+ZI9xUNit7I@public.gmane.org>
To: Vadim Pasternak <vadimp-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Cc: lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	j.anaszewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org,
	rpurdie-Fm38FmjxZ/leoWH0uzbU5w@public.gmane.org,
	linux-leds-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	jiri-rHqAuBHg3fBzbRFIqnYvSA@public.gmane.org
Subject: Re: [patch v1 1/2] mfd: Add Mellanox regmap core driver
Date: Wed, 26 Jul 2017 13:18:46 +0200	[thread overview]
Message-ID: <20170726111846.GB6033@amd> (raw)
In-Reply-To: <1501001499-21971-2-git-send-email-vadimp-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 3530 bytes --]

Hi!

> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mfd/mellanox,mlxreg-core
> @@ -0,0 +1,347 @@
> +Mellanox programmable device control.
> +-------------------------------------
> +This binding defines the device control interface over I2C bus for Mellanox BMC
> +based switches.

You'll need to cc dt maintainers here.

> +Required properties:
> +- compatible = "mellanox,mlxreg-i2c",
> +	       "mellanox,mlxreg-i2c-16",
> +	       "mellanox,mlxreg-core";
> +- #address-cells : must be 1;
> +- #size-cells : must be 0;
> +- reg : I2C address;

> +			cpu_watchdog {
> +				reg = <0x1d>;
> +				mask = <0xef>;
> +			};
> +
> +			cpu_kernel_panic {
> +				reg = <0x1d>;
> +				mask = <0xef>;
> +			};
> +			bmc_warm_reset {
> +				reg = <0x71>;
> +				mask = <0xfe>;
> +			};

Extra newline.

> +static ssize_t mlxreg_core_attr_show(struct device *dev,
> +				     struct device_attribute *attr,
> +				     char *buf)
> +{
> +	struct mlxreg_core_priv_data *priv = dev_get_drvdata(dev);
> +	int index = to_sensor_dev_attr_2(attr)->index;
> +	int nr = to_sensor_dev_attr_2(attr)->nr;
> +	struct mlxreg_core_data *data;
> +	u32 regval = 0;
> +	int ret;
> +
> +	switch (nr) {
> +	case MLXREG_CORE_ATTR_PSU:
> +	case MLXREG_CORE_ATTR_FAN:
> +		/* Bit = 0 : item is functional. */
> +		ret = regmap_read(priv->regmap,
> +				  priv->item[mlxreg_core_grp[nr].type]->reg,
> +				  &regval);
> +		if (ret)
> +			goto access_error;
> +
> +		regval = !!!(regval & BIT(mlxreg_core_get_pos(priv,
> +					  &mlxreg_core_grp[nr],

Uff. You really really mean it. But one ! should be enough.

> +static int
> +mlxreg_core_add_attr_group(struct mlxreg_core_priv_data *priv,
> +			   struct mlxreg_core_grp *grp, int id)
> +{
> +	struct mlxreg_core_data *data = priv->item[grp->type]->data;
> +	int i;
> +
> +	/* Skip group with negative access value. */
> +	if (grp->access < 0)
> +		return id;
> +
> +	priv->item[grp->type]->ind = id;
> +	for (i = 0; i < priv->item[grp->type]->count; i++, id++, data++) {
> +		priv->mlxreg_core_attr[id] =
> +				&priv->mlxreg_core_dev_attr[id].dev_attr.attr;
> +		if (grp->use_grp_name)
> +			priv->mlxreg_core_attr[id]->name =
> +				devm_kasprintf(priv->dev, GFP_KERNEL,
> +					       "%s%u", grp->name, id %
> +						priv->item[grp->type]->count
> +						+ 1);
> +		else
> +			priv->mlxreg_core_attr[id]->name =
> +				devm_kasprintf(priv->dev, GFP_KERNEL,
> +					       data->label);

Is it really neccessary to dynamically generate it? Static table could
be simpler...

> +static void
> +mlxreg_core_work_helper(struct mlxreg_core_priv_data *priv,
> +			struct mlxreg_core_item *item, u8 is_inverse,
> +			u16 off, u32 mask, u32 *cache)
> +{
> +	struct mlxreg_core_data *data;
> +	u32 asserted, regval, bit;
> +	int ret;
> +
> +	/*
> +	 * Validate if item related to received signal type is valid.
> +	 * It should never happen, excepted the situation when some
> +	 * piece of hardware is broken. In such situation just produce
> +	 * error message and return. Caller must continue to handle the
> +	 * signals from other devices if any.
> +	 */
> +	if (unlikely(!item)) {
> +		dev_err(priv->dev, "False signal is received: register at offset 0x%02x, mask 0x%02x.\n",
> +			off, mask);

Slightly too long line.

Thanks,
									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  parent reply	other threads:[~2017-07-26 11:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25 16:51 [patch v1 0/2] Introduce support for mlxreg mfd core and I2C drivers Vadim Pasternak
2017-07-25 16:51 ` [patch v1 1/2] mfd: Add Mellanox regmap core driver Vadim Pasternak
     [not found]   ` <1501001499-21971-2-git-send-email-vadimp-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-07-26 11:18     ` Pavel Machek [this message]
2017-07-26 11:28       ` Jiri Pirko
2017-07-26 11:42         ` Pavel Machek
2017-07-26 17:18       ` Vadim Pasternak
     [not found]         ` <AM4PR05MB3330F7C7913391C906CB2069A2B90-n5Jp0YuYvM1LPiJj6BpYmdqRiQSDpxhJvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2017-07-26 18:25           ` Pavel Machek
2017-07-25 16:51 ` [patch v1 2/2] mfd: Add Mellanox regmap I2C driver Vadim Pasternak
     [not found]   ` <1501001499-21971-3-git-send-email-vadimp-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2017-07-26 11:19     ` Pavel Machek

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=20170726111846.GB6033@amd \
    --to=pavel-+zi9xunit7i@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=j.anaszewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org \
    --cc=jiri-rHqAuBHg3fBzbRFIqnYvSA@public.gmane.org \
    --cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-leds-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=rpurdie-Fm38FmjxZ/leoWH0uzbU5w@public.gmane.org \
    --cc=vadimp-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).