Skip to content

Commit

Permalink
powerpc/5200: Stop using device_type and port-number properties
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Wolfram Sang <w.sang@pengutronix.de>
  • Loading branch information
Grant Likely committed Feb 3, 2009
1 parent b1792e3 commit 3b5ebf8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 31 deletions.
6 changes: 3 additions & 3 deletions drivers/net/fec_mpc52xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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", },
{ }
};

Expand Down
38 changes: 10 additions & 28 deletions drivers/serial/mpc52xx_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -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#>'
Expand Down Expand Up @@ -1212,54 +1212,36 @@ 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
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;
Expand Down

0 comments on commit 3b5ebf8

Please sign in to comment.