From: Wolfram Sang <w.sang@pengutronix.de>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: [PATCH 2/8] powerpc/5200: Stop using device_type and port-number properties
Date: Thu, 29 Jan 2009 22:15:05 +0100 [thread overview]
Message-ID: <20090129211505.GB1406@pengutronix.de> (raw)
In-Reply-To: <20090121205512.31232.99373.stgit@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 4576 bytes --]
On Wed, Jan 21, 2009 at 01:55:13PM -0700, Grant Likely wrote:
> From: Grant Likely <grant.likely@secretlab.ca>
>
> There is no reason for the PSC UART driver or the Ethernet driver
> to require a device_type property. The compatible value is sufficient
> to uniquely identify the device. Remove it from the driver.
>
> The whole 'port-number' scheme for assigning numbers to PSC uarts was
> always rather half baked and just adds complexity. Remove it from the
> driver. After this patch is applied, PSC UART numbers are simply
> assigned from the order they are found in the device tree (just like
> all the other devices). Userspace can query sysfs to determine what
> ttyPSC number is assigned to each PSC instance.
>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
> CC: Wolfram Sang <w.sang@pengutronix.de>
I like it. One more optimization below, but it's also good for now...
Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>
> ---
>
> drivers/net/fec_mpc52xx.c | 6 +++---
> drivers/serial/mpc52xx_uart.c | 38 ++++++++++----------------------------
> 2 files changed, 13 insertions(+), 31 deletions(-)
>
>
> diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
> index cd8e98b..049b0a7 100644
> --- a/drivers/net/fec_mpc52xx.c
> +++ b/drivers/net/fec_mpc52xx.c
> @@ -1123,9 +1123,9 @@ static int mpc52xx_fec_of_resume(struct of_device *op)
> #endif
>
> static struct of_device_id mpc52xx_fec_match[] = {
> - { .type = "network", .compatible = "fsl,mpc5200b-fec", },
> - { .type = "network", .compatible = "fsl,mpc5200-fec", },
> - { .type = "network", .compatible = "mpc5200-fec", },
> + { .compatible = "fsl,mpc5200b-fec", },
> + { .compatible = "fsl,mpc5200-fec", },
> + { .compatible = "mpc5200-fec", },
> { }
> };
>
> diff --git a/drivers/serial/mpc52xx_uart.c b/drivers/serial/mpc52xx_uart.c
> index 0c3a2ab..d73d7da 100644
> --- a/drivers/serial/mpc52xx_uart.c
> +++ b/drivers/serial/mpc52xx_uart.c
> @@ -50,8 +50,8 @@
> /* OF Platform device Usage :
> *
> * This driver is only used for PSCs configured in uart mode. The device
> - * tree will have a node for each PSC in uart mode w/ device_type = "serial"
> - * and "mpc52xx-psc-uart" in the compatible string
> + * tree will have a node for each PSC with "mpc52xx-psc-uart" in the compatible
> + * list.
> *
> * By default, PSC devices are enumerated in the order they are found. However
> * a particular PSC number can be forces by adding 'device_no = <port#>'
> @@ -1212,30 +1212,18 @@ mpc52xx_uart_of_resume(struct of_device *op)
> #endif
>
> static void
> -mpc52xx_uart_of_assign(struct device_node *np, int idx)
> +mpc52xx_uart_of_assign(struct device_node *np)
> {
> - int free_idx = -1;
> int i;
>
> - /* Find the first free node */
> + /* Find the first free PSC number */
> for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) {
> if (mpc52xx_uart_nodes[i] == NULL) {
> - free_idx = i;
> - break;
> + of_node_get(np);
> + mpc52xx_uart_nodes[i] = np;
> + return;
> }
> }
> -
> - if ((idx < 0) || (idx >= MPC52xx_PSC_MAXNUM))
> - idx = free_idx;
> -
> - if (idx < 0)
> - return; /* No free slot; abort */
> -
> - of_node_get(np);
> - /* If the slot is already occupied, then swap slots */
> - if (mpc52xx_uart_nodes[idx] && (free_idx != -1))
> - mpc52xx_uart_nodes[free_idx] = mpc52xx_uart_nodes[idx];
> - mpc52xx_uart_nodes[idx] = np;
> }
>
> static void
> @@ -1243,23 +1231,17 @@ mpc52xx_uart_of_enumerate(void)
> {
> static int enum_done;
> struct device_node *np;
> - const unsigned int *devno;
> const struct of_device_id *match;
> int i;
>
> if (enum_done)
> return;
>
> - for_each_node_by_type(np, "serial") {
> + /* Assign index to each PSC in device tree */
> + for_each_matching_node(np, mpc52xx_uart_of_match) {
> match = of_match_node(mpc52xx_uart_of_match, np);
> - if (!match)
> - continue;
> -
> psc_ops = match->data;
> -
> - /* Is a particular device number requested? */
> - devno = of_get_property(np, "port-number", NULL);
> - mpc52xx_uart_of_assign(np, devno ? *devno : -1);
> + mpc52xx_uart_of_assign(np);
> }
>
> enum_done = 1;
>
You could drop the for-loop which follows here and put its dev_dbg into
uart_of_assign when a node was found. Would also get rid of 'i' here.
Regards,
Wolfram
--
Dipl.-Ing. Wolfram Sang | http://www.pengutronix.de
Pengutronix - Linux Solutions for Science and Industry
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2009-01-29 21:15 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-21 20:55 [PATCH 1/8] powerpc/5200: update device tree binding documentation Grant Likely
2009-01-21 20:55 ` [PATCH 2/8] powerpc/5200: Stop using device_type and port-number properties Grant Likely
2009-01-21 21:13 ` Juergen Beisert
2009-01-22 4:46 ` Grant Likely
2009-01-29 21:15 ` Wolfram Sang [this message]
2009-01-21 20:55 ` [PATCH 3/8] powerpc/5200: Trim cruft from device trees Grant Likely
2009-01-29 21:21 ` Wolfram Sang
2009-01-21 20:55 ` [PATCH 4/8] powerpc/5200: Add support for the Media5200 board from Freescale Grant Likely
2009-01-21 20:55 ` [PATCH 5/8] powerpc/5200: Don't specify IRQF_SHARED in PSC UART driver Grant Likely
2009-01-29 21:24 ` Wolfram Sang
2009-01-21 20:55 ` [PATCH 6/8] powerpc/5200: Remove pr_debug() from hot paths in irq driver Grant Likely
2009-01-29 21:29 ` Wolfram Sang
2009-01-21 20:55 ` [PATCH 7/8] powerpc/5200: Refactor mpc5200 interrupt controller driver Grant Likely
2009-01-25 20:06 ` Wolfgang Grandegger
2009-01-26 0:22 ` Grant Likely
2009-01-26 6:26 ` Wolfgang Denk
2009-01-26 8:31 ` Wolfgang Grandegger
2009-01-26 17:58 ` Matt Sealey
2009-01-26 9:22 ` Wolfram Sang
2009-01-27 17:52 ` Matt Sealey
2009-01-27 17:54 ` Grant Likely
2009-01-29 21:33 ` Wolfram Sang
2009-01-21 20:55 ` [PATCH 8/8] powerpc/5200: Rework GPT driver to also be an IRQ controller Grant Likely
2009-01-27 12:23 ` Wolfram Sang
2009-01-25 19:48 ` [PATCH 1/8] powerpc/5200: update device tree binding documentation Wolfram Sang
2009-01-26 1:46 ` Grant Likely
2009-01-26 9:26 ` Wolfram Sang
2009-01-27 16:25 ` Grant Likely
2009-01-27 18:00 ` Matt Sealey
2009-01-27 18:06 ` Grant Likely
2009-01-29 21:09 ` Wolfram Sang
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=20090129211505.GB1406@pengutronix.de \
--to=w.sang@pengutronix.de \
--cc=grant.likely@secretlab.ca \
--cc=linuxppc-dev@ozlabs.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;
as well as URLs for NNTP newsgroup(s).