Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752449AbbGWIBU (ORCPT ); Thu, 23 Jul 2015 04:01:20 -0400 Received: from down.free-electrons.com ([37.187.137.238]:49070 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751323AbbGWIBJ (ORCPT ); Thu, 23 Jul 2015 04:01:09 -0400 Date: Thu, 23 Jul 2015 10:01:01 +0200 From: Boris Brezillon To: Lee Jones Cc: Cyrille Pitchen , 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 Message-ID: <20150723100101.7290242b@bbrezillon> In-Reply-To: <20150723073217.GT3061@x1> References: <7639e02fc2b16dc20b19fbe3bbbb986b0f3b9887.1437558598.git.cyrille.pitchen@atmel.com> <20150723073217.GT3061@x1> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2054 Lines: 65 Hi Lee, On Thu, 23 Jul 2015 08:32:17 +0100 Lee Jones 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/