Commit e90d1cdd authored by Bob Breuer's avatar Bob Breuer Committed by David S. Miller

[SPARC]: Check prom_getproperty return value.

Errors should not be ignored, so add __must_check
tag to this function as well.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4cd74f1d
......@@ -53,7 +53,8 @@ void __init auxio_probe(void)
#endif
}
}
prom_getproperty(auxio_nd, "reg", (char *) auxregs, sizeof(auxregs));
if(prom_getproperty(auxio_nd, "reg", (char *) auxregs, sizeof(auxregs)) <= 0)
return;
prom_apply_obio_ranges(auxregs, 0x1);
/* Map the register both read and write */
r.flags = auxregs[0].which_io & 0xF;
......@@ -121,7 +122,8 @@ void __init auxio_power_probe(void)
return;
/* Map the power control register. */
prom_getproperty(node, "reg", (char *)&regs, sizeof(regs));
if (prom_getproperty(node, "reg", (char *)&regs, sizeof(regs)) <= 0)
return;
prom_apply_obio_ranges(&regs, 1);
memset(&r, 0, sizeof(r));
r.flags = regs.which_io & 0xF;
......
......@@ -53,13 +53,12 @@ static void __init display_system_type(unsigned char machtype)
for (i = 0; i < NUM_SUN_MACHINES; i++) {
if(Sun_Machines[i].id_machtype == machtype) {
if (machtype != (SM_SUN4M_OBP | 0x00))
if (machtype != (SM_SUN4M_OBP | 0x00) ||
prom_getproperty(prom_root_node, "banner-name",
sysname, sizeof(sysname)) <= 0)
printk("TYPE: %s\n", Sun_Machines[i].name);
else {
prom_getproperty(prom_root_node, "banner-name",
sysname, sizeof(sysname));
else
printk("TYPE: %s\n", sysname);
}
return;
}
}
......
......@@ -217,13 +217,18 @@ void __init sun4c_init_IRQ(void)
panic("Cannot find /interrupt-enable node");
/* Depending on the "address" property is bad news... */
prom_getproperty(ie_node, "reg", (char *) int_regs, sizeof(int_regs));
memset(&phyres, 0, sizeof(struct resource));
phyres.flags = int_regs[0].which_io;
phyres.start = int_regs[0].phys_addr;
interrupt_enable = (char *) sbus_ioremap(&phyres, 0,
int_regs[0].reg_size, "sun4c_intr");
interrupt_enable = NULL;
if (prom_getproperty(ie_node, "reg", (char *) int_regs,
sizeof(int_regs)) != -1) {
memset(&phyres, 0, sizeof(struct resource));
phyres.flags = int_regs[0].which_io;
phyres.start = int_regs[0].phys_addr;
interrupt_enable = (char *) sbus_ioremap(&phyres, 0,
int_regs[0].reg_size, "sun4c_intr");
}
}
if (!interrupt_enable)
panic("Cannot map interrupt_enable");
BTFIXUPSET_CALL(sbint_to_irq, sun4c_sbint_to_irq, BTFIXUPCALL_NORM);
BTFIXUPSET_CALL(enable_irq, sun4c_enable_irq, BTFIXUPCALL_NORM);
......
......@@ -52,13 +52,15 @@ iounit_init(int sbi_node, int io_node, struct sbus_bus *sbus)
iounit->rotor[1] = IOUNIT_BMAP2_START;
iounit->rotor[2] = IOUNIT_BMAPM_START;
prom_getproperty(sbi_node, "reg", (void *) iommu_promregs,
sizeof(iommu_promregs));
prom_apply_generic_ranges(io_node, 0, iommu_promregs, 3);
memset(&r, 0, sizeof(r));
r.flags = iommu_promregs[2].which_io;
r.start = iommu_promregs[2].phys_addr;
xpt = (iopte_t *) sbus_ioremap(&r, 0, PAGE_SIZE * 16, "XPT");
xpt = NULL;
if(prom_getproperty(sbi_node, "reg", (void *) iommu_promregs,
sizeof(iommu_promregs)) != -1) {
prom_apply_generic_ranges(io_node, 0, iommu_promregs, 3);
memset(&r, 0, sizeof(r));
r.flags = iommu_promregs[2].which_io;
r.start = iommu_promregs[2].phys_addr;
xpt = (iopte_t *) sbus_ioremap(&r, 0, PAGE_SIZE * 16, "XPT");
}
if(!xpt) panic("Cannot map External Page Table.");
sbus->iommu = (struct iommu_struct *)iounit;
......
......@@ -71,14 +71,16 @@ iommu_init(int iommund, struct sbus_bus *sbus)
prom_printf("Unable to allocate iommu structure\n");
prom_halt();
}
prom_getproperty(iommund, "reg", (void *) iommu_promregs,
sizeof(iommu_promregs));
memset(&r, 0, sizeof(r));
r.flags = iommu_promregs[0].which_io;
r.start = iommu_promregs[0].phys_addr;
iommu->regs = (struct iommu_regs *)
sbus_ioremap(&r, 0, PAGE_SIZE * 3, "iommu_regs");
if(!iommu->regs) {
iommu->regs = NULL;
if (prom_getproperty(iommund, "reg", (void *) iommu_promregs,
sizeof(iommu_promregs)) != -1) {
memset(&r, 0, sizeof(r));
r.flags = iommu_promregs[0].which_io;
r.start = iommu_promregs[0].phys_addr;
iommu->regs = (struct iommu_regs *)
sbus_ioremap(&r, 0, PAGE_SIZE * 3, "iommu_regs");
}
if (!iommu->regs) {
prom_printf("Cannot map IOMMU registers\n");
prom_halt();
}
......
......@@ -511,7 +511,8 @@ void __init sun4c_probe_memerr_reg(void)
node = prom_searchsiblings(prom_root_node, "memory-error");
if (!node)
return;
prom_getproperty(node, "reg", (char *)regs, sizeof(regs));
if (prom_getproperty(node, "reg", (char *)regs, sizeof(regs)) <= 0)
return;
/* hmm I think regs[0].which_io is zero here anyways */
sun4c_memerr_reg = ioremap(regs[0].phys_addr, regs[0].reg_size);
}
......
......@@ -111,6 +111,7 @@ prom_query_input_device(void)
int st_p;
char propb[64];
char *p;
int propl;
switch(prom_vers) {
case PROM_V0:
......@@ -139,14 +140,16 @@ prom_query_input_device(void)
if(strncmp(propb, "serial", sizeof("serial")))
return PROMDEV_I_UNK;
}
prom_getproperty(prom_root_node, "stdin-path", propb, sizeof(propb));
p = propb;
while(*p) p++; p -= 2;
if(p[0] == ':') {
if(p[1] == 'a')
return PROMDEV_ITTYA;
else if(p[1] == 'b')
return PROMDEV_ITTYB;
propl = prom_getproperty(prom_root_node, "stdin-path", propb, sizeof(propb));
if(propl > 2) {
p = propb;
while(*p) p++; p -= 2;
if(p[0] == ':') {
if(p[1] == 'a')
return PROMDEV_ITTYA;
else if(p[1] == 'b')
return PROMDEV_ITTYB;
}
}
return PROMDEV_I_UNK;
}
......@@ -179,7 +182,7 @@ prom_query_output_device(void)
restore_current();
spin_unlock_irqrestore(&prom_lock, flags);
propl = prom_getproperty(st_p, "device_type", propb, sizeof(propb));
if (propl >= 0 && propl == sizeof("display") &&
if (propl == sizeof("display") &&
strncmp("display", propb, sizeof("display")) == 0)
{
return PROMDEV_OSCREEN;
......@@ -188,16 +191,20 @@ prom_query_output_device(void)
if(propl >= 0 &&
strncmp("serial", propb, sizeof("serial")) != 0)
return PROMDEV_O_UNK;
prom_getproperty(prom_root_node, "stdout-path", propb, sizeof(propb));
if(strncmp(propb, con_name_jmc, CON_SIZE_JMC) == 0)
propl = prom_getproperty(prom_root_node, "stdout-path",
propb, sizeof(propb));
if(propl == CON_SIZE_JMC &&
strncmp(propb, con_name_jmc, CON_SIZE_JMC) == 0)
return PROMDEV_OTTYA;
p = propb;
while(*p) p++; p -= 2;
if(p[0]==':') {
if(p[1] == 'a')
return PROMDEV_OTTYA;
else if(p[1] == 'b')
return PROMDEV_OTTYB;
if(propl > 2) {
p = propb;
while(*p) p++; p-= 2;
if(p[0]==':') {
if(p[1] == 'a')
return PROMDEV_OTTYA;
else if(p[1] == 'b')
return PROMDEV_OTTYB;
}
}
} else {
switch(*romvec->pv_stdin) {
......
......@@ -312,8 +312,8 @@ static int sun_floppy_init(void)
}
/* The sun4m lets us know if the controller is actually usable. */
if(sparc_cpu_model == sun4m) {
prom_getproperty(fd_node, "status", state, sizeof(state));
if(sparc_cpu_model == sun4m &&
prom_getproperty(fd_node, "status", state, sizeof(state)) != -1) {
if(!strcmp(state, "disabled")) {
goto no_sun_fdc;
}
......
......@@ -10,6 +10,7 @@
#include <asm/openprom.h>
#include <linux/spinlock.h>
#include <linux/compiler.h>
/* The master romvec pointer... */
extern struct linux_romvec *romvec;
......@@ -244,8 +245,8 @@ extern int prom_getproplen(int thisnode, 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, char *property,
char *prop_buffer, int propbuf_size);
extern int __must_check prom_getproperty(int thisnode, char *property,
char *prop_buffer, int propbuf_size);
/* Acquire an integer property. */
extern int prom_getint(int node, char *property);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment