From mboxrd@z Thu Jan 1 00:00:00 1970 From: lee.jones@linaro.org (Lee Jones) Date: Thu, 23 Jul 2015 10:13:11 +0100 Subject: [PATCH v6 2/2] mfd: atmel-flexcom: add a driver for Atmel Flexible Serial Communication Unit In-Reply-To: <20150723100101.7290242b@bbrezillon> References: <7639e02fc2b16dc20b19fbe3bbbb986b0f3b9887.1437558598.git.cyrille.pitchen@atmel.com> <20150723073217.GT3061@x1> <20150723100101.7290242b@bbrezillon> Message-ID: <20150723091311.GX3061@x1> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Thu, 23 Jul 2015, Boris Brezillon wrote: > 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). I know what you're saying, but what if someone uses the Flexcom driver to wrap a different type of SPI driver where (for instance) the compatible string used is "-". Then we'd have to keep adding more lines here to accommodate. Whereas if we used the child node name which only pertains to _this_ driver, we would then have full control and know that (unless it Flexcom is used for a completely different type of serial controller) we wouldn't have to keep expanding the code to accommodate. > 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. You mean duplicate each of the supported device's compatible strings in this driver, then fetch the attributed of_match_device()->data value? -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lee Jones Subject: Re: [PATCH v6 2/2] mfd: atmel-flexcom: add a driver for Atmel Flexible Serial Communication Unit Date: Thu, 23 Jul 2015 10:13:11 +0100 Message-ID: <20150723091311.GX3061@x1> References: <7639e02fc2b16dc20b19fbe3bbbb986b0f3b9887.1437558598.git.cyrille.pitchen@atmel.com> <20150723073217.GT3061@x1> <20150723100101.7290242b@bbrezillon> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Content-Disposition: inline In-Reply-To: <20150723100101.7290242b@bbrezillon> Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Boris Brezillon Cc: Cyrille Pitchen , nicolas.ferre-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org, alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org, sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, pawel.moll-5wv7dgnIgG8@public.gmane.org, mark.rutland-5wv7dgnIgG8@public.gmane.org, ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org, galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: devicetree@vger.kernel.org On Thu, 23 Jul 2015, Boris Brezillon wrote: > Hi Lee, >=20 > On Thu, 23 Jul 2015 08:32:17 +0100 > Lee Jones wrote: >=20 > > 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 =3D of_get_property(child, "compatible", &cplen); > > > + if (!compatible || strlen(compatible) > cplen) > > > + continue; > > > + > > > + if (strstr(compatible, "-usart")) { > > > + opmode =3D FLEX_MR_OPMODE_USART; > > > + break; > > > + } > > > + > > > + if (strstr(compatible, "-spi")) { > > > + opmode =3D FLEX_MR_OPMODE_SPI; > > > + break; > > > + } > > > + > > > + if (strstr(compatible, "-i2c")) { > > > + opmode =3D FLEX_MR_OPMODE_TWI; > > > + break; > > > + } > > > + } > >=20 > > 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 no= de > > name, rather than the compatible string? > >=20 > > I would personally match on of_find_node_by_name() to future-proof > > your implementation. >=20 > 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 binding= s > doc). I know what you're saying, but what if someone uses the Flexcom driver to wrap a different type of SPI driver where (for instance) the compatible string used is "-". Then we'd have to keep adding more lines here to accommodate. Whereas if we used the child node name which only pertains to _this_ driver, we would then have full control and know that (unless it =46lexcom is used for a completely different type of serial controller) we wouldn't have to keep expanding the code to accommodate. > Regarding the implementation itself, I would match the child node wit= h > 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. You mean duplicate each of the supported device's compatible strings in this driver, then fetch the attributed of_match_device()->data value? --=20 Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org =E2=94=82 Open source software for ARM SoCs =46ollow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe devicetree" i= n the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752896AbbGWJNd (ORCPT ); Thu, 23 Jul 2015 05:13:33 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:37021 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752343AbbGWJNV (ORCPT ); Thu, 23 Jul 2015 05:13:21 -0400 Date: Thu, 23 Jul 2015 10:13:11 +0100 From: Lee Jones To: Boris Brezillon 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: <20150723091311.GX3061@x1> References: <7639e02fc2b16dc20b19fbe3bbbb986b0f3b9887.1437558598.git.cyrille.pitchen@atmel.com> <20150723073217.GT3061@x1> <20150723100101.7290242b@bbrezillon> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20150723100101.7290242b@bbrezillon> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 23 Jul 2015, Boris Brezillon wrote: > 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). I know what you're saying, but what if someone uses the Flexcom driver to wrap a different type of SPI driver where (for instance) the compatible string used is "-". Then we'd have to keep adding more lines here to accommodate. Whereas if we used the child node name which only pertains to _this_ driver, we would then have full control and know that (unless it Flexcom is used for a completely different type of serial controller) we wouldn't have to keep expanding the code to accommodate. > 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. You mean duplicate each of the supported device's compatible strings in this driver, then fetch the attributed of_match_device()->data value? -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog