public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
To: Richard Fitzgerald
	<rf-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
Cc: lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org>,
	alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org,
	patches-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org,
	linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Marc Zyngier <marc.zyngier-5wv7dgnIgG8@public.gmane.org>
Subject: Re: [PATCH v2 09/18] irqchip: Add driver for Cirrus Logic Madera codecs
Date: Wed, 10 May 2017 17:03:46 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1705101634390.1979@nanos> (raw)
In-Reply-To: <1493050124-5970-10-git-send-email-rf-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>

On Mon, 24 Apr 2017, Richard Fitzgerald wrote:
> +
> +struct madera_irq_priv {
> +	struct device *dev;
> +	int irq;
> +	struct regmap_irq_chip_data *irq_data;
> +	struct madera *madera;

Please write your struct definitions in a tabular fashion:

struct madera_irq_priv {
	struct device			*dev;
	int				irq;
	struct regmap_irq_chip_data	*irq_data;
	struct madera			*madera;

> +};
> +
> +static const struct regmap_irq madera_irqs[MADERA_NUM_IRQ] = {
> +	[MADERA_IRQ_FLL1_LOCK] =  { .reg_offset = 0,
> +				    .mask = MADERA_FLL1_LOCK_EINT1 },
> +	[MADERA_IRQ_FLL2_LOCK] =  { .reg_offset = 0,
> +				    .mask = MADERA_FLL2_LOCK_EINT1 },
> +	[MADERA_IRQ_FLL3_LOCK] =  { .reg_offset = 0,
> +				    .mask = MADERA_FLL3_LOCK_EINT1 },
> +	[MADERA_IRQ_FLLAO_LOCK] = { .reg_offset = 0,
> +				    .mask = MADERA_FLLAO_LOCK_EINT1 },
> +
> +	[MADERA_IRQ_MICDET1] = { .reg_offset = 4,
> +				 .mask = MADERA_MICDET1_EINT1 },
> +	[MADERA_IRQ_MICDET2] = { .reg_offset = 4,
> +				 .mask = MADERA_MICDET2_EINT1 },
> +	[MADERA_IRQ_HPDET] =   { .reg_offset = 4,
> +				 .mask = MADERA_HPDET_EINT1 },
> +
> +	[MADERA_IRQ_MICD_CLAMP_RISE] = { .reg_offset = 5,
> +					 .mask = MADERA_MICD_CLAMP_RISE_EINT1 },

This is hard to read, makes my eyes hurt and takes way too many lines.

#define REGMAP_IRQ(_irq, _off, _mask)                    	\
        [MADERA_IRQ_##_irq] = { .reg_offset = (_off),	 	\
			    	.mask = MADERA_##_irq_EINT1) }

static const struct regmap_irq madera_irqs[MADERA_NUM_IRQ] = {
	REGMAP_IRQ(FLL1_LOCK,		0),
	REGMAP_IRQ(FLL2_LOCK,		0),
	....
	REGMAP_IRQ(MICD_CLAMP_RISE,	5),

Hmm?

> +
> +static const struct regmap_irq_chip madera_irq = {
> +	.name = "madera IRQ",

Again. Tabluar fashion, please.

> +	.status_base = MADERA_IRQ1_STATUS_2,
> +	.mask_base = MADERA_IRQ1_MASK_2,
> +	.ack_base = MADERA_IRQ1_STATUS_2,
> +	.runtime_pm = true, /* codec must be resumed to read IRQ status */

Please do not use tail comments. Aside of that this comment is superfluous.

> +	.num_regs = 32,
> +	.irqs = madera_irqs,
> +	.num_irqs = ARRAY_SIZE(madera_irqs),
> +};
> +
> +static int madera_map_irq(struct madera *madera, int irq)
> +{
> +	struct madera_irq_priv *priv = dev_get_drvdata(madera->irq_dev);
> +
> +	if (irq < 0)
> +		return irq;

Why would irq be < 0 ?

> +
> +	if (!madera->irq_dev)
> +		return -ENOENT;
> +
> +	return regmap_irq_get_virq(priv->irq_data, irq);
> +}

> +static int madera_irq_probe(struct platform_device *pdev)
> +{
> +	struct madera *madera = dev_get_drvdata(pdev->dev.parent);
> +	struct madera_irq_priv *priv;
> +	struct irq_data *irq_data;
> +	unsigned int irq_flags = madera->pdata.irqchip.irq_flags;
> +	int ret;
> +
> +	dev_dbg(&pdev->dev, "probe\n");
> +
> +	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
> +	if (!priv)
> +		return -ENOMEM;
> +
> +	priv->dev = &pdev->dev;
> +	priv->madera = madera;
> +	priv->irq = madera->irq;
> +
> +	/* Read the flags from the interrupt controller if not specified */
> +	if (!irq_flags) {
> +		irq_data = irq_get_irq_data(priv->irq);
> +		if (!irq_data) {
> +			dev_err(priv->dev, "Invalid IRQ: %d\n", priv->irq);
> +			return -EINVAL;
> +		}
> +
> +		irq_flags = irqd_get_trigger_type(irq_data);
> +		if (irq_flags == IRQ_TYPE_NONE)
> +			irq_flags = IRQF_TRIGGER_LOW; /* Device default */

Please do not use tail comments. They are horrible to parse and disturb the
reading flow.

> +	}
> +
> +	if (irq_flags & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)) {
> +		dev_err(priv->dev,
> +			"Host interrupt not level-triggered\n");
> +		return -EINVAL;
> +	}
> +
> +	if (irq_flags & IRQF_TRIGGER_HIGH) {
> +		ret = regmap_update_bits(madera->regmap, MADERA_IRQ1_CTRL,
> +					 MADERA_IRQ_POL_MASK, 0);
> +		if (ret) {
> +			dev_err(priv->dev,
> +				"Failed to set IRQ polarity: %d\n", ret);
> +			return ret;
> +		}
> +	}

What makes sure that the hardware is NOT set to TRIGGER_HIGH when you want
to have TRIGGER_LOW?

> +static struct platform_driver madera_irq_driver = {
> +	.probe = madera_irq_probe,

Tabular layout please

> +	.remove = madera_irq_remove,
> +	.driver = {
> +		.name	= "madera-irq",
> +		.pm = &madera_irq_pm_ops,
> +	}
> +};
> +

Pointless newline

> +module_platform_driver(madera_irq_driver);
> +

> --- /dev/null
> +++ b/include/linux/irqchip/irq-madera-pdata.h
> @@ -0,0 +1,19 @@
> +
> +struct madera_irqchip_pdata {
> +	/** Mode for primary IRQ (defaults to active low) */

If you want to document your structs, then please use proper kerneldoc
style.

> +	unsigned int irq_flags;
> +};

Thanks,

	tglx
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-05-10 15:03 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-24 16:08 [PATCH v2 00/18] Add support for Cirrus Logic CS47L35/L85/L90/L91 codecs Richard Fitzgerald
2017-04-24 16:08 ` [PATCH v2 01/18] mfd: madera: Add register definitions for Cirrus Logic Madera codecs Richard Fitzgerald
     [not found]   ` <1493050124-5970-2-git-send-email-rf-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2017-05-23  7:20     ` Lee Jones
2017-07-13  8:02   ` Lee Jones
2017-07-13 10:05     ` Mark Brown
2017-07-13 12:44       ` Richard Fitzgerald
     [not found]         ` <1499949850.4826.88.camel-WeElTRBN8n0bEPBeyYQi64iQ8/zYDDdY1BehtkLrGTY@public.gmane.org>
2017-07-13 13:03           ` Mark Brown
2017-07-14 11:50             ` Richard Fitzgerald
2017-07-14 12:06               ` [alsa-devel] " Takashi Iwai
2017-04-24 16:08 ` [PATCH v2 02/18] mfd: madera: Add common support " Richard Fitzgerald
     [not found]   ` <1493050124-5970-3-git-send-email-rf-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2017-05-22 17:39     ` Lee Jones
2017-04-24 16:08 ` [PATCH v2 03/18] dt-bindings: mfd: Add bindings " Richard Fitzgerald
2017-04-28 18:07   ` Rob Herring
2017-05-22 17:40   ` Lee Jones
2017-04-24 16:08 ` [PATCH v2 04/18] mfd: madera: Register map tables for Cirrus Logic CS47L35 Richard Fitzgerald
     [not found]   ` <1493050124-5970-5-git-send-email-rf-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2017-05-23  7:22     ` Lee Jones
2017-04-24 16:08 ` [PATCH v2 05/18] mfd: madera: Register map tables for Cirrus Logic CS47L85 Richard Fitzgerald
     [not found]   ` <1493050124-5970-6-git-send-email-rf-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2017-05-23  7:23     ` Lee Jones
     [not found] ` <1493050124-5970-1-git-send-email-rf-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2017-04-24 16:08   ` [PATCH v2 06/18] mfd: madera: Register map tables for Cirrus Logic CS47L90/91 Richard Fitzgerald
2017-05-23  7:24     ` Lee Jones
2017-04-24 16:08   ` [PATCH v2 07/18] regulator: arizona-micsupp: Add support for Cirrus Logic Madera codecs Richard Fitzgerald
     [not found]     ` <1493050124-5970-8-git-send-email-rf-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2017-04-28 18:07       ` Rob Herring
2017-04-24 16:08   ` [PATCH v2 10/18] pinctrl: madera: Add driver " Richard Fitzgerald
2017-04-25  9:41     ` Linus Walleij
2017-04-25 10:26       ` Richard Fitzgerald
2017-04-28  7:39     ` Linus Walleij
2017-05-20 20:06       ` Paul Gortmaker
2017-04-24 16:08   ` [PATCH v2 14/18] ASoC: madera: Add common support " Richard Fitzgerald
2017-04-24 16:08   ` [PATCH v2 15/18] dt-bindings: sound: Add bindings " Richard Fitzgerald
2017-04-25 15:52     ` Mark Brown
2017-04-25 16:27       ` Richard Fitzgerald
2017-05-14 10:04         ` Mark Brown
2017-04-28 18:06       ` Rob Herring
2017-04-24 16:08 ` [PATCH v2 08/18] regulator: arizona-ldo1: Add support " Richard Fitzgerald
2017-04-24 16:08 ` [PATCH v2 09/18] irqchip: Add driver " Richard Fitzgerald
     [not found]   ` <1493050124-5970-10-git-send-email-rf-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2017-05-10 15:03     ` Thomas Gleixner [this message]
2017-04-24 16:08 ` [PATCH v2 11/18] dt-bindings: pinctrl: Add bindings " Richard Fitzgerald
2017-04-25  9:35   ` Linus Walleij
     [not found]   ` <1493050124-5970-12-git-send-email-rf-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2017-04-28 18:16     ` Rob Herring
2017-04-24 16:08 ` [PATCH v2 12/18] gpio: madera: Support Cirrus Logic Madera class codecs Richard Fitzgerald
     [not found]   ` <1493050124-5970-13-git-send-email-rf-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2017-04-25 14:13     ` Linus Walleij
2017-04-25 14:44       ` Richard Fitzgerald
2017-04-28  7:46         ` Linus Walleij
2017-04-28  7:44   ` Linus Walleij
2017-04-24 16:08 ` [PATCH v2 13/18] dt-bindings: gpio: Add bindings for GPIO on Cirrus Logic Madera codecs Richard Fitzgerald
2017-04-25  9:42   ` Linus Walleij
2017-04-28 18:17   ` Rob Herring
2017-04-24 16:08 ` [PATCH v2 16/18] ASoC: cs47l35: Add codec driver for Cirrus Logic CS47L35 Richard Fitzgerald
2017-04-24 16:08 ` [PATCH v2 17/18] ASoC: cs47l85: Add codec driver for Cirrus Logic CS47L85 Richard Fitzgerald
2017-04-24 16:08 ` [PATCH v2 18/18] ASoC: cs47l90: Add codec driver for Cirrus Logic CS47L90 Richard Fitzgerald

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=alpine.DEB.2.20.1705101634390.1979@nanos \
    --to=tglx-hfztesqfncyowbw4kg4ksq@public.gmane.org \
    --cc=alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org \
    --cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=gnurou-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org \
    --cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-gpio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=marc.zyngier-5wv7dgnIgG8@public.gmane.org \
    --cc=patches-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
    --cc=rf-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@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