Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1190699

Re: [PATCH v6 2/2] mfd: atmel-flexcom: add a driver for Atmel Flexible Serial Communication Unit

From Boris Brezillon <boris.brezillon@free-electrons.com>
Newsgroups linux.kernel
Subject Re: [PATCH v6 2/2] mfd: atmel-flexcom: add a driver for Atmel Flexible Serial Communication Unit
Date 2015-07-23 10:10 +0200
Message-ID <pPjJM-Qs-7@gated-at.bofh.it> (permalink)
References <pOZrJ-43B-23@gated-at.bofh.it> <pOZrJ-43B-29@gated-at.bofh.it> <pPjgJ-8uV-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH v6 2/2] mfd: atmel-flexcom: add a driver for Atmel  Flexible Serial Communication Unit Lee Jones <lee.jones@linaro.org> - 2015-07-23 09:40 +0200
  Re: [PATCH v6 2/2] mfd: atmel-flexcom: add a driver for Atmel  Flexible Serial Communication Unit Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-07-23 10:10 +0200
    Re: [PATCH v6 2/2] mfd: atmel-flexcom: add a driver for Atmel  Flexible Serial Communication Unit Boris Brezillon <boris.brezillon@free-electrons.com> - 2015-07-23 15:00 +0200
      Re: [PATCH v6 2/2] mfd: atmel-flexcom: add a driver for Atmel  Flexible Serial Communication Unit Lee Jones <lee.jones@linaro.org> - 2015-07-24 12:20 +0200

csiph-web