devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Lee Jones <lee.jones@linaro.org>
Cc: Cyrille Pitchen <cyrille.pitchen@atmel.com>,
	nicolas.ferre@atmel.com, alexandre.belloni@free-electrons.com,
	sameo@linux.intel.com, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, robh+dt@kernel.org,
	pawel.moll@arm.com, mark.rutland@arm.com,
	ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v6 2/2] mfd: atmel-flexcom: add a driver for Atmel Flexible Serial Communication Unit
Date: Thu, 23 Jul 2015 10:01:01 +0200	[thread overview]
Message-ID: <20150723100101.7290242b@bbrezillon> (raw)
In-Reply-To: <20150723073217.GT3061@x1>

Hi Lee,

On Thu, 23 Jul 2015 08:32:17 +0100
Lee Jones <lee.jones@linaro.org> wrote:

> On Wed, 22 Jul 2015, Cyrille Pitchen wrote:
> > +	for_each_child_of_node(np, child) {
> > +		const char *compatible;
> > +		int cplen;
> > +
> > +		if (!of_device_is_available(child))
> > +			continue;
> > +
> > +		compatible = of_get_property(child, "compatible", &cplen);
> > +		if (!compatible || strlen(compatible) > cplen)
> > +			continue;
> > +
> > +		if (strstr(compatible, "-usart")) {
> > +			opmode = FLEX_MR_OPMODE_USART;
> > +			break;
> > +		}
> > +
> > +		if (strstr(compatible, "-spi")) {
> > +			opmode = FLEX_MR_OPMODE_SPI;
> > +			break;
> > +		}
> > +
> > +		if (strstr(compatible, "-i2c")) {
> > +			opmode = FLEX_MR_OPMODE_TWI;
> > +			break;
> > +		}
> > +	}
> 
> From what I understand Flexcom is a wrapper which can sit above any
> number of SPI, I2C and/or UART devices.  Devices which you don't
> really have any control over (source code wise).  So wouldn't it be
> better to match on the details you do have control over i.e. the node
> name, rather than the compatible string?
> 
> I would personally match on of_find_node_by_name() to future-proof
> your implementation.

Actually, I think using compatible strings is more future-proof than
using the node names, because nothing in the DT bindings doc enforce the
node name, and usually what we use to attach a node to a specific
driver is the compatible string (this one is specified in the bindings
doc).

Regarding the implementation itself, I would match the child node with
an of_device_id table rather than trying to find a specific substring
in the compatible string, but I think that's only a matter of taste.

Best Regards,

Boris

-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

  reply	other threads:[~2015-07-23  8:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-22 10:23 [PATCH v6 0/2] mfd: flexcom: add a driver for Flexcom Cyrille Pitchen
2015-07-22 10:23 ` [PATCH v6 1/2] mfd: devicetree: add bindings for Atmel Flexcom Cyrille Pitchen
     [not found]   ` <bfff43813c2dc0a265bb644a87dcdd5fe58fc3e3.1437558598.git.cyrille.pitchen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2015-07-23  7:35     ` Lee Jones
2015-07-22 10:23 ` [PATCH v6 2/2] mfd: atmel-flexcom: add a driver for Atmel Flexible Serial Communication Unit Cyrille Pitchen
2015-07-23  7:32   ` Lee Jones
2015-07-23  8:01     ` Boris Brezillon [this message]
2015-07-23  9:13       ` Lee Jones
2015-07-23 12:50         ` Boris Brezillon
2015-07-23 16:42           ` Cyrille Pitchen
2015-07-24 10:16             ` 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=20150723100101.7290242b@bbrezillon \
    --to=boris.brezillon@free-electrons.com \
    --cc=alexandre.belloni@free-electrons.com \
    --cc=cyrille.pitchen@atmel.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=nicolas.ferre@atmel.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sameo@linux.intel.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;
as well as URLs for NNTP newsgroup(s).