prom_getproperty cleanups
Since I brought the subject up, I felt compelled to put some effort toward the cleanup. I have appended the cleanups for the asm-sparc and arch/sparc directories.
I noticed that Art Haas sent a patch for tree.c. I left my version in as an alternative and you can pick whichever one looks better.
Bob
include/asm-sparc/floppy.h +2 -2
@@ -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; }
include/asm-sparc/oplib.h +2 -2
@@ -244,8 +244,8 @@ extern int prom_getproplen(int thisnode,/* 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); +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);
arch/sparc/kernel/auxio.c +4 -2
@@ -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 *)®s,sizeof (regs)); +if (prom_getproperty (node,"reg" , (char *)®s,sizeof (regs)) <=0 ) +return ;prom_apply_obio_ranges (®s,1 );memset (&r,0 ,sizeof (r)); r.flags = regs.which_io &0xF ;
arch/sparc/kernel/idprom.c +4 -5
@@ -53,13 +53,12 @@ static void __init display_system_type(ufor (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 ; } }
arch/sparc/kernel/sun4c_irq.c +11 -6
@@ -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 );
Only in linux-2.6.10/arch/sparc/kernel: vmlinux.lds
arch/sparc/mm/iommu.c +10 -8
@@ -71,14 +71,16 @@ iommu_init(int iommund, struct sbus_busprom_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 (); }
arch/sparc/mm/io-unit.c +9 -7
@@ -52,13 +52,15 @@ iounit_init(int sbi_node, int io_node, s 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;
arch/sparc/mm/sun4c.c +2 -1
@@ -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); }
arch/sparc/prom/console.c +25 -18
68 lines not on this page · raw message
arch/sparc/prom/tree.c +5 -2
@@ -177,8 +177,11 @@ void prom_getstring(int node, char *propint prom_nodematch (int node,char *name) {static char namebuf[128 ]; -prom_getproperty (node,"name" , namebuf,sizeof (namebuf)); -if (strcmp (namebuf, name) =0 )return 1 ; +int len; + + len =prom_getproperty (node,"name" , namebuf,sizeof (namebuf)); +if (len !=-1 &&strcmp (namebuf, name) =0 ) +return 1 ;return 0 ; }
David S. Miller
maintainerQuoted 6 lines · On Sun, 06 Feb 2005 22:42:19 -0600 Bob Breuer <[email protected]> wrote:
Since I brought the subject up, I felt compelled to put some effort toward the cleanup. I have appended the cleanups for the asm-sparc and
arch/sparcdirectories.I noticed that Art Haas sent a patch for
tree.c. I left my version in as an alternative and you can pick whichever one looks better.
I put in Art's fix already, yes.
Can I ask you to do two things please?
1) Add include/linux/compiler.h to oplib.h, that is needed for the __must_check declaration.
2) Please include your patch as an attachment. Something in your mailer adds spaces to the beginning of lines of your patches so it always rejects when I try to apply.
Thanks.
Quoted 4 lines · David S. Miller
Can I ask you to do two things please?
1) Add
include/linux/compiler.htooplib.h, that is needed for the__must_checkdeclaration.
Ok, I've added it. Somehow everything I tested compiled fine without it.
Quoted 3 lines
2) Please include your patch as an attachment. Something in your mailer adds spaces to the beginning of lines of your patches so it always rejects when I try to apply.
Sorry about that, I didn't realize it was mangling them.
Updated patch is attached. The patch only cleans up the include/asm-sparc and arch/sparc directories.
If there is anything questionable or if you prefer patches to be done differently, just let me know.
Bob
include/asm-sparc/floppy.h +2 -2
@@ -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; }
include/asm-sparc/oplib.h +3 -2
@@ -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,/* 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); +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);
arch/sparc/kernel/auxio.c +4 -2
@@ -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 *)®s,sizeof (regs)); +if (prom_getproperty (node,"reg" , (char *)®s,sizeof (regs)) <=0 ) +return ;prom_apply_obio_ranges (®s,1 );memset (&r,0 ,sizeof (r)); r.flags = regs.which_io &0xF ;
arch/sparc/kernel/idprom.c +4 -5
@@ -53,13 +53,12 @@ static void __init display_system_type(ufor (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 ; } }
arch/sparc/kernel/sun4c_irq.c +11 -6
@@ -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 );
arch/sparc/mm/iommu.c +10 -8
@@ -71,14 +71,16 @@ iommu_init(int iommund, struct sbus_busprom_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 (); }
arch/sparc/mm/io-unit.c +9 -7
@@ -52,13 +52,15 @@ iounit_init(int sbi_node, int io_node, s 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;
arch/sparc/mm/sun4c.c +2 -1
@@ -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); }
arch/sparc/prom/console.c +25 -18
68 lines not on this page · raw message
Quoted 1 line · On Tue, 15 Feb 2005 20:37:23 -0600 Bob Breuer <[email protected]> wrote:
Somehow everything I tested compiled fine without it.
Right, some other header is bringing it in indirectly.
Quoted 2 lines
Updated patch is attached. The patch only cleans up the
include/asm-sparcandarch/sparcdirectories.
Applied. I made a minor modification, I retained the "extern" in the oplib.h header declaration. I don't know why you removed it.
Thanks Bob.