Skip to content

Commit

Permalink
[POWERPC] Constify & voidify get_property()
Browse files Browse the repository at this point in the history
Now that get_property() returns a void *, there's no need to cast its
return value. Also, treat the return value as const, so we can
constify get_property later.

powerpc core changes.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
jk-ozlabs authored and paulusmack committed Jul 31, 2006
1 parent 4288b92 commit a7f67bd
Show file tree
Hide file tree
Showing 24 changed files with 239 additions and 238 deletions.
24 changes: 12 additions & 12 deletions arch/powerpc/kernel/btext.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,35 +158,35 @@ int btext_initialize(struct device_node *np)
{
unsigned int width, height, depth, pitch;
unsigned long address = 0;
u32 *prop;
const u32 *prop;

prop = (u32 *)get_property(np, "linux,bootx-width", NULL);
prop = get_property(np, "linux,bootx-width", NULL);
if (prop == NULL)
prop = (u32 *)get_property(np, "width", NULL);
prop = get_property(np, "width", NULL);
if (prop == NULL)
return -EINVAL;
width = *prop;
prop = (u32 *)get_property(np, "linux,bootx-height", NULL);
prop = get_property(np, "linux,bootx-height", NULL);
if (prop == NULL)
prop = (u32 *)get_property(np, "height", NULL);
prop = get_property(np, "height", NULL);
if (prop == NULL)
return -EINVAL;
height = *prop;
prop = (u32 *)get_property(np, "linux,bootx-depth", NULL);
prop = get_property(np, "linux,bootx-depth", NULL);
if (prop == NULL)
prop = (u32 *)get_property(np, "depth", NULL);
prop = get_property(np, "depth", NULL);
if (prop == NULL)
return -EINVAL;
depth = *prop;
pitch = width * ((depth + 7) / 8);
prop = (u32 *)get_property(np, "linux,bootx-linebytes", NULL);
prop = get_property(np, "linux,bootx-linebytes", NULL);
if (prop == NULL)
prop = (u32 *)get_property(np, "linebytes", NULL);
prop = get_property(np, "linebytes", NULL);
if (prop)
pitch = *prop;
if (pitch == 1)
pitch = 0x1000;
prop = (u32 *)get_property(np, "address", NULL);
prop = get_property(np, "address", NULL);
if (prop)
address = *prop;

Expand Down Expand Up @@ -214,11 +214,11 @@ int btext_initialize(struct device_node *np)

int __init btext_find_display(int allow_nonstdout)
{
char *name;
const char *name;
struct device_node *np = NULL;
int rc = -ENODEV;

name = (char *)get_property(of_chosen, "linux,stdout-path", NULL);
name = get_property(of_chosen, "linux,stdout-path", NULL);
if (name != NULL) {
np = of_find_node_by_path(name);
if (np != NULL) {
Expand Down
6 changes: 3 additions & 3 deletions arch/powerpc/kernel/ibmebus.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, ibmebusdev_show_name,
NULL);

static struct ibmebus_dev* __devinit ibmebus_register_device_common(
struct ibmebus_dev *dev, char *name)
struct ibmebus_dev *dev, const char *name)
{
int err = 0;

Expand All @@ -194,10 +194,10 @@ static struct ibmebus_dev* __devinit ibmebus_register_device_node(
struct device_node *dn)
{
struct ibmebus_dev *dev;
char *loc_code;
const char *loc_code;
int length;

loc_code = (char *)get_property(dn, "ibm,loc-code", NULL);
loc_code = get_property(dn, "ibm,loc-code", NULL);
if (!loc_code) {
printk(KERN_WARNING "%s: node %s missing 'ibm,loc-code'\n",
__FUNCTION__, dn->name ? dn->name : "<unknown>");
Expand Down
35 changes: 18 additions & 17 deletions arch/powerpc/kernel/legacy_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,17 @@ static int __init add_legacy_port(struct device_node *np, int want_index,
phys_addr_t taddr, unsigned long irq,
upf_t flags, int irq_check_parent)
{
u32 *clk, *spd, clock = BASE_BAUD * 16;
const u32 *clk, *spd;
u32 clock = BASE_BAUD * 16;
int index;

/* get clock freq. if present */
clk = (u32 *)get_property(np, "clock-frequency", NULL);
clk = get_property(np, "clock-frequency", NULL);
if (clk && *clk)
clock = *clk;

/* get default speed if present */
spd = (u32 *)get_property(np, "current-speed", NULL);
spd = get_property(np, "current-speed", NULL);

/* If we have a location index, then try to use it */
if (want_index >= 0 && want_index < MAX_LEGACY_SERIAL_PORTS)
Expand Down Expand Up @@ -113,7 +114,7 @@ static int __init add_legacy_soc_port(struct device_node *np,
struct device_node *soc_dev)
{
u64 addr;
u32 *addrp;
const u32 *addrp;
upf_t flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_SHARE_IRQ;

/* We only support ports that have a clock frequency properly
Expand All @@ -140,15 +141,15 @@ static int __init add_legacy_soc_port(struct device_node *np,
static int __init add_legacy_isa_port(struct device_node *np,
struct device_node *isa_brg)
{
u32 *reg;
char *typep;
const u32 *reg;
const char *typep;
int index = -1;
u64 taddr;

DBG(" -> add_legacy_isa_port(%s)\n", np->full_name);

/* Get the ISA port number */
reg = (u32 *)get_property(np, "reg", NULL);
reg = get_property(np, "reg", NULL);
if (reg == NULL)
return -1;

Expand All @@ -159,7 +160,7 @@ static int __init add_legacy_isa_port(struct device_node *np,
/* Now look for an "ibm,aix-loc" property that gives us ordering
* if any...
*/
typep = (char *)get_property(np, "ibm,aix-loc", NULL);
typep = get_property(np, "ibm,aix-loc", NULL);

/* If we have a location index, then use it */
if (typep && *typep == 'S')
Expand All @@ -184,7 +185,7 @@ static int __init add_legacy_pci_port(struct device_node *np,
struct device_node *pci_dev)
{
u64 addr, base;
u32 *addrp;
const u32 *addrp;
unsigned int flags;
int iotype, index = -1, lindex = 0;

Expand Down Expand Up @@ -223,7 +224,7 @@ static int __init add_legacy_pci_port(struct device_node *np,
* we get to their "reg" property
*/
if (np != pci_dev) {
u32 *reg = (u32 *)get_property(np, "reg", NULL);
const u32 *reg = get_property(np, "reg", NULL);
if (reg && (*reg < 4))
index = lindex = *reg;
}
Expand Down Expand Up @@ -281,13 +282,13 @@ static void __init setup_legacy_serial_console(int console)
void __init find_legacy_serial_ports(void)
{
struct device_node *np, *stdout = NULL;
char *path;
const char *path;
int index;

DBG(" -> find_legacy_serial_port()\n");

/* Now find out if one of these is out firmware console */
path = (char *)get_property(of_chosen, "linux,stdout-path", NULL);
path = get_property(of_chosen, "linux,stdout-path", NULL);
if (path != NULL) {
stdout = of_find_node_by_path(path);
if (stdout)
Expand Down Expand Up @@ -487,8 +488,8 @@ static int __init check_legacy_serial_console(void)
{
struct device_node *prom_stdout = NULL;
int speed = 0, offset = 0;
char *name;
u32 *spd;
const char *name;
const u32 *spd;

DBG(" -> check_legacy_serial_console()\n");

Expand All @@ -509,7 +510,7 @@ static int __init check_legacy_serial_console(void)
}
/* We are getting a weird phandle from OF ... */
/* ... So use the full path instead */
name = (char *)get_property(of_chosen, "linux,stdout-path", NULL);
name = get_property(of_chosen, "linux,stdout-path", NULL);
if (name == NULL) {
DBG(" no linux,stdout-path !\n");
return -ENODEV;
Expand All @@ -521,12 +522,12 @@ static int __init check_legacy_serial_console(void)
}
DBG("stdout is %s\n", prom_stdout->full_name);

name = (char *)get_property(prom_stdout, "name", NULL);
name = get_property(prom_stdout, "name", NULL);
if (!name) {
DBG(" stdout package has no name !\n");
goto not_found;
}
spd = (u32 *)get_property(prom_stdout, "current-speed", NULL);
spd = get_property(prom_stdout, "current-speed", NULL);
if (spd)
speed = *spd;

Expand Down
11 changes: 5 additions & 6 deletions arch/powerpc/kernel/lparcfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,11 @@ static int pseries_lparcfg_data(struct seq_file *m, void *v)
int partition_potential_processors;
int partition_active_processors;
struct device_node *rtas_node;
int *lrdrp = NULL;
const int *lrdrp = NULL;

rtas_node = find_path_device("/rtas");
if (rtas_node)
lrdrp = (int *)get_property(rtas_node, "ibm,lrdr-capacity",
NULL);
lrdrp = get_property(rtas_node, "ibm,lrdr-capacity", NULL);

if (lrdrp == NULL) {
partition_potential_processors = vdso_data->processorCount;
Expand Down Expand Up @@ -519,7 +518,8 @@ static int lparcfg_data(struct seq_file *m, void *v)
const char *model = "";
const char *system_id = "";
const char *tmp;
unsigned int *lp_index_ptr, lp_index = 0;
const unsigned int *lp_index_ptr;
unsigned int lp_index = 0;

seq_printf(m, "%s %s \n", MODULE_NAME, MODULE_VERS);

Expand All @@ -539,8 +539,7 @@ static int lparcfg_data(struct seq_file *m, void *v)
if (firmware_has_feature(FW_FEATURE_ISERIES))
system_id += 4;
}
lp_index_ptr = (unsigned int *)
get_property(rootdn, "ibm,partition-no", NULL);
lp_index_ptr = get_property(rootdn, "ibm,partition-no", NULL);
if (lp_index_ptr)
lp_index = *lp_index_ptr;
}
Expand Down
10 changes: 4 additions & 6 deletions arch/powerpc/kernel/machine_kexec_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ int default_machine_kexec_prepare(struct kimage *image)
unsigned long begin, end; /* limits of segment */
unsigned long low, high; /* limits of blocked memory range */
struct device_node *node;
unsigned long *basep;
unsigned int *sizep;
const unsigned long *basep;
const unsigned int *sizep;

if (!ppc_md.hpte_clear_all)
return -ENOENT;
Expand Down Expand Up @@ -74,10 +74,8 @@ int default_machine_kexec_prepare(struct kimage *image)
/* We also should not overwrite the tce tables */
for (node = of_find_node_by_type(NULL, "pci"); node != NULL;
node = of_find_node_by_type(node, "pci")) {
basep = (unsigned long *)get_property(node, "linux,tce-base",
NULL);
sizep = (unsigned int *)get_property(node, "linux,tce-size",
NULL);
basep = get_property(node, "linux,tce-base", NULL);
sizep = get_property(node, "linux,tce-size", NULL);
if (basep == NULL || sizep == NULL)
continue;

Expand Down
39 changes: 21 additions & 18 deletions arch/powerpc/kernel/pci_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,12 +633,12 @@ pcibios_alloc_controller(void)
static void
make_one_node_map(struct device_node* node, u8 pci_bus)
{
int *bus_range;
const int *bus_range;
int len;

if (pci_bus >= pci_bus_count)
return;
bus_range = (int *) get_property(node, "bus-range", &len);
bus_range = get_property(node, "bus-range", &len);
if (bus_range == NULL || len < 2 * sizeof(int)) {
printk(KERN_WARNING "Can't get bus-range for %s, "
"assuming it starts at 0\n", node->full_name);
Expand All @@ -648,13 +648,13 @@ make_one_node_map(struct device_node* node, u8 pci_bus)

for (node=node->child; node != 0;node = node->sibling) {
struct pci_dev* dev;
unsigned int *class_code, *reg;
const unsigned int *class_code, *reg;

class_code = (unsigned int *) get_property(node, "class-code", NULL);
class_code = get_property(node, "class-code", NULL);
if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
(*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS))
continue;
reg = (unsigned int *)get_property(node, "reg", NULL);
reg = get_property(node, "reg", NULL);
if (!reg)
continue;
dev = pci_find_slot(pci_bus, ((reg[0] >> 8) & 0xff));
Expand All @@ -669,7 +669,7 @@ pcibios_make_OF_bus_map(void)
{
int i;
struct pci_controller* hose;
u8* of_prop_map;
struct property *map_prop;

pci_to_OF_bus_map = (u8*)kmalloc(pci_bus_count, GFP_KERNEL);
if (!pci_to_OF_bus_map) {
Expand All @@ -691,9 +691,12 @@ pcibios_make_OF_bus_map(void)
continue;
make_one_node_map(node, hose->first_busno);
}
of_prop_map = get_property(find_path_device("/"), "pci-OF-bus-map", NULL);
if (of_prop_map)
memcpy(of_prop_map, pci_to_OF_bus_map, pci_bus_count);
map_prop = of_find_property(find_path_device("/"),
"pci-OF-bus-map", NULL);
if (map_prop) {
BUG_ON(pci_bus_count > map_prop->length);
memcpy(map_prop->value, pci_to_OF_bus_map, pci_bus_count);
}
#ifdef DEBUG
printk("PCI->OF bus map:\n");
for (i=0; i<pci_bus_count; i++) {
Expand All @@ -712,7 +715,7 @@ scan_OF_pci_childs(struct device_node* node, pci_OF_scan_iterator filter, void*
struct device_node* sub_node;

for (; node != 0;node = node->sibling) {
unsigned int *class_code;
const unsigned int *class_code;

if (filter(node, data))
return node;
Expand All @@ -722,7 +725,7 @@ scan_OF_pci_childs(struct device_node* node, pci_OF_scan_iterator filter, void*
* a fake root for all functions of a multi-function device,
* we go down them as well.
*/
class_code = (unsigned int *) get_property(node, "class-code", NULL);
class_code = get_property(node, "class-code", NULL);
if ((!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI &&
(*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) &&
strcmp(node->name, "multifunc-device"))
Expand All @@ -737,10 +740,10 @@ scan_OF_pci_childs(struct device_node* node, pci_OF_scan_iterator filter, void*
static int
scan_OF_pci_childs_iterator(struct device_node* node, void* data)
{
unsigned int *reg;
const unsigned int *reg;
u8* fdata = (u8*)data;

reg = (unsigned int *) get_property(node, "reg", NULL);
reg = get_property(node, "reg", NULL);
if (reg && ((reg[0] >> 8) & 0xff) == fdata[1]
&& ((reg[0] >> 16) & 0xff) == fdata[0])
return 1;
Expand Down Expand Up @@ -841,7 +844,7 @@ find_OF_pci_device_filter(struct device_node* node, void* data)
int
pci_device_from_OF_node(struct device_node* node, u8* bus, u8* devfn)
{
unsigned int *reg;
const unsigned int *reg;
struct pci_controller* hose;
struct pci_dev* dev = NULL;

Expand All @@ -854,7 +857,7 @@ pci_device_from_OF_node(struct device_node* node, u8* bus, u8* devfn)
if (!scan_OF_pci_childs(((struct device_node*)hose->arch_data)->child,
find_OF_pci_device_filter, (void *)node))
return -ENODEV;
reg = (unsigned int *) get_property(node, "reg", NULL);
reg = get_property(node, "reg", NULL);
if (!reg)
return -ENODEV;
*bus = (reg[0] >> 16) & 0xff;
Expand Down Expand Up @@ -885,8 +888,8 @@ pci_process_bridge_OF_ranges(struct pci_controller *hose,
struct device_node *dev, int primary)
{
static unsigned int static_lc_ranges[256] __initdata;
unsigned int *dt_ranges, *lc_ranges, *ranges, *prev;
unsigned int size;
const unsigned int *dt_ranges;
unsigned int *lc_ranges, *ranges, *prev, size;
int rlen = 0, orig_rlen;
int memno = 0;
struct resource *res;
Expand All @@ -897,7 +900,7 @@ pci_process_bridge_OF_ranges(struct pci_controller *hose,
* that can have more than 3 ranges, fortunately using contiguous
* addresses -- BenH
*/
dt_ranges = (unsigned int *) get_property(dev, "ranges", &rlen);
dt_ranges = get_property(dev, "ranges", &rlen);
if (!dt_ranges)
return;
/* Sanity check, though hopefully that never happens */
Expand Down
Loading

0 comments on commit a7f67bd

Please sign in to comment.