Skip to content

Commit

Permalink
of/sparc: convert various prom_* functions to use phandle
Browse files Browse the repository at this point in the history
Rather than passing around ints everywhere, use the
phandle type where appropriate for the various functions
that talk to the PROM.

Signed-off-by: Andres Salomon <[email protected]>
Acked-by: David S. Miller <[email protected]>
Signed-off-by: Grant Likely <[email protected]>
  • Loading branch information
dilinger authored and glikely committed Oct 9, 2010
1 parent 4e13efc commit 8d12556
Show file tree
Hide file tree
Showing 23 changed files with 157 additions and 144 deletions.
3 changes: 2 additions & 1 deletion arch/sparc/include/asm/floppy_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ static struct linux_prom_registers fd_regs[2];
static int sun_floppy_init(void)
{
char state[128];
int tnode, fd_node, num_regs;
phandle tnode, fd_node;
int num_regs;
struct resource r;

use_virtual_dma = 1;
Expand Down
16 changes: 9 additions & 7 deletions arch/sparc/include/asm/openprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#define LINUX_OPPROM_MAGIC 0x10010407

#ifndef __ASSEMBLY__
#include <linux/of.h>

/* V0 prom device operations. */
struct linux_dev_v0_funcs {
int (*v0_devopen)(char *device_str);
Expand All @@ -26,7 +28,7 @@ struct linux_dev_v0_funcs {

/* V2 and later prom device operations. */
struct linux_dev_v2_funcs {
int (*v2_inst2pkg)(int d); /* Convert ihandle to phandle */
phandle (*v2_inst2pkg)(int d); /* Convert ihandle to phandle */
char * (*v2_dumb_mem_alloc)(char *va, unsigned sz);
void (*v2_dumb_mem_free)(char *va, unsigned sz);

Expand Down Expand Up @@ -168,12 +170,12 @@ struct linux_romvec {

/* Routines for traversing the prom device tree. */
struct linux_nodeops {
int (*no_nextnode)(int node);
int (*no_child)(int node);
int (*no_proplen)(int node, const char *name);
int (*no_getprop)(int node, const char *name, char *val);
int (*no_setprop)(int node, const char *name, char *val, int len);
char * (*no_nextprop)(int node, char *name);
phandle (*no_nextnode)(phandle node);
phandle (*no_child)(phandle node);
int (*no_proplen)(phandle node, const char *name);
int (*no_getprop)(phandle node, const char *name, char *val);
int (*no_setprop)(phandle node, const char *name, char *val, int len);
char * (*no_nextprop)(phandle node, char *name);
};

/* More fun PROM structures for device probing. */
Expand Down
44 changes: 22 additions & 22 deletions arch/sparc/include/asm/oplib_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ extern unsigned int prom_rev, prom_prev;
/* Root node of the prom device tree, this stays constant after
* initialization is complete.
*/
extern int prom_root_node;
extern phandle prom_root_node;

/* Pointer to prom structure containing the device tree traversal
* and usage utility functions. Only prom-lib should use these,
Expand Down Expand Up @@ -178,82 +178,82 @@ extern void prom_putsegment(int context, unsigned long virt_addr,
/* PROM device tree traversal functions... */

/* Get the child node of the given node, or zero if no child exists. */
extern int prom_getchild(int parent_node);
extern phandle prom_getchild(phandle parent_node);

/* Get the next sibling node of the given node, or zero if no further
* siblings exist.
*/
extern int prom_getsibling(int node);
extern phandle prom_getsibling(phandle node);

/* Get the length, at the passed node, of the given property type.
* Returns -1 on error (ie. no such property at this node).
*/
extern int prom_getproplen(int thisnode, const char *property);
extern int prom_getproplen(phandle thisnode, const char *property);

/* Fetch the requested property using the given buffer. Returns
* the number of bytes the prom put into your buffer or -1 on error.
*/
extern int __must_check prom_getproperty(int thisnode, const char *property,
extern int __must_check prom_getproperty(phandle thisnode, const char *property,
char *prop_buffer, int propbuf_size);

/* Acquire an integer property. */
extern int prom_getint(int node, char *property);
extern int prom_getint(phandle node, char *property);

/* Acquire an integer property, with a default value. */
extern int prom_getintdefault(int node, char *property, int defval);
extern int prom_getintdefault(phandle node, char *property, int defval);

/* Acquire a boolean property, 0=FALSE 1=TRUE. */
extern int prom_getbool(int node, char *prop);
extern int prom_getbool(phandle node, char *prop);

/* Acquire a string property, null string on error. */
extern void prom_getstring(int node, char *prop, char *buf, int bufsize);
extern void prom_getstring(phandle node, char *prop, char *buf, int bufsize);

/* Does the passed node have the given "name"? YES=1 NO=0 */
extern int prom_nodematch(int thisnode, char *name);
extern int prom_nodematch(phandle thisnode, char *name);

/* Search all siblings starting at the passed node for "name" matching
* the given string. Returns the node on success, zero on failure.
*/
extern int prom_searchsiblings(int node_start, char *name);
extern phandle prom_searchsiblings(phandle node_start, char *name);

/* Return the first property type, as a string, for the given node.
* Returns a null string on error.
*/
extern char *prom_firstprop(int node, char *buffer);
extern char *prom_firstprop(phandle node, char *buffer);

/* Returns the next property after the passed property for the given
* node. Returns null string on failure.
*/
extern char *prom_nextprop(int node, char *prev_property, char *buffer);
extern char *prom_nextprop(phandle node, char *prev_property, char *buffer);

/* Returns phandle of the path specified */
extern int prom_finddevice(char *name);
extern phandle prom_finddevice(char *name);

/* Returns 1 if the specified node has given property. */
extern int prom_node_has_property(int node, char *property);
extern int prom_node_has_property(phandle node, char *property);

/* Set the indicated property at the given node with the passed value.
* Returns the number of bytes of your value that the prom took.
*/
extern int prom_setprop(int node, const char *prop_name, char *prop_value,
extern int prom_setprop(phandle node, const char *prop_name, char *prop_value,
int value_size);

extern int prom_pathtoinode(char *path);
extern int prom_inst2pkg(int);
extern phandle prom_pathtoinode(char *path);
extern phandle prom_inst2pkg(int);

/* Dorking with Bus ranges... */

/* Apply promlib probes OBIO ranges to registers. */
extern void prom_apply_obio_ranges(struct linux_prom_registers *obioregs, int nregs);

/* Apply ranges of any prom node (and optionally parent node as well) to registers. */
extern void prom_apply_generic_ranges(int node, int parent,
extern void prom_apply_generic_ranges(phandle node, phandle parent,
struct linux_prom_registers *sbusregs, int nregs);

/* CPU probing helpers. */
int cpu_find_by_instance(int instance, int *prom_node, int *mid);
int cpu_find_by_mid(int mid, int *prom_node);
int cpu_get_hwmid(int prom_node);
int cpu_find_by_instance(int instance, phandle *prom_node, int *mid);
int cpu_find_by_mid(int mid, phandle *prom_node);
int cpu_get_hwmid(phandle prom_node);

extern spinlock_t prom_lock;

Expand Down
39 changes: 20 additions & 19 deletions arch/sparc/include/asm/oplib_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ extern char prom_version[];
/* Root node of the prom device tree, this stays constant after
* initialization is complete.
*/
extern int prom_root_node;
extern phandle prom_root_node;

/* PROM stdin and stdout */
extern int prom_stdin, prom_stdout;

/* /chosen node of the prom device tree, this stays constant after
* initialization is complete.
*/
extern int prom_chosen_node;
extern phandle prom_chosen_node;

/* Helper values and strings in arch/sparc64/kernel/head.S */
extern const char prom_peer_name[];
Expand Down Expand Up @@ -218,68 +218,69 @@ extern void prom_unmap(unsigned long size, unsigned long vaddr);
/* PROM device tree traversal functions... */

/* Get the child node of the given node, or zero if no child exists. */
extern int prom_getchild(int parent_node);
extern phandle prom_getchild(phandle parent_node);

/* Get the next sibling node of the given node, or zero if no further
* siblings exist.
*/
extern int prom_getsibling(int node);
extern phandle prom_getsibling(phandle node);

/* Get the length, at the passed node, of the given property type.
* Returns -1 on error (ie. no such property at this node).
*/
extern int prom_getproplen(int thisnode, const char *property);
extern int prom_getproplen(phandle thisnode, const char *property);

/* Fetch the requested property using the given buffer. Returns
* the number of bytes the prom put into your buffer or -1 on error.
*/
extern int prom_getproperty(int thisnode, const char *property,
extern int prom_getproperty(phandle thisnode, const char *property,
char *prop_buffer, int propbuf_size);

/* Acquire an integer property. */
extern int prom_getint(int node, const char *property);
extern int prom_getint(phandle node, const char *property);

/* Acquire an integer property, with a default value. */
extern int prom_getintdefault(int node, const char *property, int defval);
extern int prom_getintdefault(phandle node, const char *property, int defval);

/* Acquire a boolean property, 0=FALSE 1=TRUE. */
extern int prom_getbool(int node, const char *prop);
extern int prom_getbool(phandle node, const char *prop);

/* Acquire a string property, null string on error. */
extern void prom_getstring(int node, const char *prop, char *buf, int bufsize);
extern void prom_getstring(phandle node, const char *prop, char *buf,
int bufsize);

/* Does the passed node have the given "name"? YES=1 NO=0 */
extern int prom_nodematch(int thisnode, const char *name);
extern int prom_nodematch(phandle thisnode, const char *name);

/* Search all siblings starting at the passed node for "name" matching
* the given string. Returns the node on success, zero on failure.
*/
extern int prom_searchsiblings(int node_start, const char *name);
extern phandle prom_searchsiblings(phandle node_start, const char *name);

/* Return the first property type, as a string, for the given node.
* Returns a null string on error. Buffer should be at least 32B long.
*/
extern char *prom_firstprop(int node, char *buffer);
extern char *prom_firstprop(phandle node, char *buffer);

/* Returns the next property after the passed property for the given
* node. Returns null string on failure. Buffer should be at least 32B long.
*/
extern char *prom_nextprop(int node, const char *prev_property, char *buffer);
extern char *prom_nextprop(phandle node, const char *prev_property, char *buf);

/* Returns 1 if the specified node has given property. */
extern int prom_node_has_property(int node, const char *property);
extern int prom_node_has_property(phandle node, const char *property);

/* Returns phandle of the path specified */
extern int prom_finddevice(const char *name);
extern phandle prom_finddevice(const char *name);

/* Set the indicated property at the given node with the passed value.
* Returns the number of bytes of your value that the prom took.
*/
extern int prom_setprop(int node, const char *prop_name, char *prop_value,
extern int prom_setprop(phandle node, const char *prop_name, char *prop_value,
int value_size);

extern int prom_pathtoinode(const char *path);
extern int prom_inst2pkg(int);
extern phandle prom_pathtoinode(const char *path);
extern phandle prom_inst2pkg(int);
extern int prom_service_exists(const char *service_name);
extern void prom_sun4v_guest_soft_state(void);

Expand Down
4 changes: 2 additions & 2 deletions arch/sparc/kernel/auxio_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static DEFINE_SPINLOCK(auxio_lock);

void __init auxio_probe(void)
{
int node, auxio_nd;
phandle node, auxio_nd;
struct linux_prom_registers auxregs[1];
struct resource r;

Expand Down Expand Up @@ -113,7 +113,7 @@ volatile unsigned char * auxio_power_register = NULL;
void __init auxio_power_probe(void)
{
struct linux_prom_registers regs;
int node;
phandle node;
struct resource r;

/* Attempt to find the sun4m power control node. */
Expand Down
4 changes: 2 additions & 2 deletions arch/sparc/kernel/btext.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static unsigned char *dispDeviceBase __force_data;

static unsigned char vga_font[cmapsz];

static int __init btext_initialize(unsigned int node)
static int __init btext_initialize(phandle node)
{
unsigned int width, height, depth, pitch;
unsigned long address = 0;
Expand Down Expand Up @@ -309,7 +309,7 @@ static struct console btext_console = {

int __init btext_find_display(void)
{
unsigned int node;
phandle node;
char type[32];
int ret;

Expand Down
23 changes: 12 additions & 11 deletions arch/sparc/kernel/devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ static char *cpu_mid_prop(void)
return "mid";
}

static int check_cpu_node(int nd, int *cur_inst,
int (*compare)(int, int, void *), void *compare_arg,
int *prom_node, int *mid)
static int check_cpu_node(phandle nd, int *cur_inst,
int (*compare)(phandle, int, void *), void *compare_arg,
phandle *prom_node, int *mid)
{
if (!compare(nd, *cur_inst, compare_arg)) {
if (prom_node)
Expand All @@ -51,8 +51,8 @@ static int check_cpu_node(int nd, int *cur_inst,
return -ENODEV;
}

static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg,
int *prom_node, int *mid)
static int __cpu_find_by(int (*compare)(phandle, int, void *),
void *compare_arg, phandle *prom_node, int *mid)
{
struct device_node *dp;
int cur_inst;
Expand All @@ -71,7 +71,7 @@ static int __cpu_find_by(int (*compare)(int, int, void *), void *compare_arg,
return -ENODEV;
}

static int cpu_instance_compare(int nd, int instance, void *_arg)
static int cpu_instance_compare(phandle nd, int instance, void *_arg)
{
int desired_instance = (int) _arg;

Expand All @@ -80,13 +80,13 @@ static int cpu_instance_compare(int nd, int instance, void *_arg)
return -ENODEV;
}

int cpu_find_by_instance(int instance, int *prom_node, int *mid)
int cpu_find_by_instance(int instance, phandle *prom_node, int *mid)
{
return __cpu_find_by(cpu_instance_compare, (void *)instance,
prom_node, mid);
}

static int cpu_mid_compare(int nd, int instance, void *_arg)
static int cpu_mid_compare(phandle nd, int instance, void *_arg)
{
int desired_mid = (int) _arg;
int this_mid;
Expand All @@ -98,7 +98,7 @@ static int cpu_mid_compare(int nd, int instance, void *_arg)
return -ENODEV;
}

int cpu_find_by_mid(int mid, int *prom_node)
int cpu_find_by_mid(int mid, phandle *prom_node)
{
return __cpu_find_by(cpu_mid_compare, (void *)mid,
prom_node, NULL);
Expand All @@ -108,7 +108,7 @@ int cpu_find_by_mid(int mid, int *prom_node)
* address (0-3). This gives us the true hardware mid, which might have
* some other bits set. On 4d hardware and software mids are the same.
*/
int cpu_get_hwmid(int prom_node)
int cpu_get_hwmid(phandle prom_node)
{
return prom_getintdefault(prom_node, cpu_mid_prop(), -ENODEV);
}
Expand All @@ -119,7 +119,8 @@ void __init device_scan(void)

#ifndef CONFIG_SMP
{
int err, cpu_node;
phandle cpu_node;
int err;
err = cpu_find_by_instance(0, &cpu_node, NULL);
if (err) {
/* Probably a sun4e, Sun is trying to trick us ;-) */
Expand Down
4 changes: 2 additions & 2 deletions arch/sparc/kernel/pcic.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ int __init pcic_probe(void)
struct linux_prom_registers regs[PROMREG_MAX];
struct linux_pbm_info* pbm;
char namebuf[64];
int node;
phandle node;
int err;

if (pcic0_up) {
Expand Down Expand Up @@ -440,7 +440,7 @@ static int __devinit pdev_to_pnode(struct linux_pbm_info *pbm,
{
struct linux_prom_pci_registers regs[PROMREG_MAX];
int err;
int node = prom_getchild(pbm->prom_node);
phandle node = prom_getchild(pbm->prom_node);

while(node) {
err = prom_getproperty(node, "reg",
Expand Down
Loading

0 comments on commit 8d12556

Please sign in to comment.