Commit c4f5ee08 authored by Rolf Eike Beer's avatar Rolf Eike Beer Committed by Greg Kroah-Hartman

[PATCH] PCI Hotplug: Remove unneeded kmalloc casts from ibmphp_pci.c

this patch removes some unneeded casts from ibmphp_pci.c that cast the result
of kmalloc to some pointer type. It also uses "sizeof(*result)" instead of
"sizeof(type_of_result)".
Signed-off-by: default avatarRolf Eike Beer <eike-hotplug@sf-tec.de>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 1f37d545
...@@ -164,7 +164,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) ...@@ -164,7 +164,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
cleanup_count = 6; cleanup_count = 6;
goto error; goto error;
} }
newfunc = (struct pci_func *) kmalloc (sizeof (struct pci_func), GFP_KERNEL); newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
if (!newfunc) { if (!newfunc) {
err ("out of system memory\n"); err ("out of system memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -203,7 +203,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) ...@@ -203,7 +203,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
flag = FALSE; flag = FALSE;
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
if (func->devices[i]) { if (func->devices[i]) {
newfunc = (struct pci_func *) kmalloc (sizeof (struct pci_func), GFP_KERNEL); newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
if (!newfunc) { if (!newfunc) {
err ("out of system memory\n"); err ("out of system memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -232,7 +232,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) ...@@ -232,7 +232,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
} }
} }
newfunc = (struct pci_func *) kmalloc (sizeof (struct pci_func), GFP_KERNEL); newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
if (!newfunc) { if (!newfunc) {
err ("out of system memory\n"); err ("out of system memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -279,7 +279,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno) ...@@ -279,7 +279,7 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
if (func->devices[i]) { if (func->devices[i]) {
debug ("inside for loop, device is %x\n", i); debug ("inside for loop, device is %x\n", i);
newfunc = (struct pci_func *) kmalloc (sizeof (struct pci_func), GFP_KERNEL); newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
if (!newfunc) { if (!newfunc) {
err (" out of system memory\n"); err (" out of system memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -459,7 +459,7 @@ static int configure_device (struct pci_func *func) ...@@ -459,7 +459,7 @@ static int configure_device (struct pci_func *func)
ibmphp_add_resource (pfmem[count]); ibmphp_add_resource (pfmem[count]);
func->pfmem[count] = pfmem[count]; func->pfmem[count] = pfmem[count];
} else { } else {
mem_tmp = kmalloc (sizeof (struct resource_node), GFP_KERNEL); mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL);
if (!mem_tmp) { if (!mem_tmp) {
err ("out of system memory\n"); err ("out of system memory\n");
kfree (pfmem[count]); kfree (pfmem[count]);
...@@ -724,7 +724,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) ...@@ -724,7 +724,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
ibmphp_add_resource (bus_pfmem[count]); ibmphp_add_resource (bus_pfmem[count]);
func->pfmem[count] = bus_pfmem[count]; func->pfmem[count] = bus_pfmem[count];
} else { } else {
mem_tmp = kmalloc (sizeof (struct resource_node), GFP_KERNEL); mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL);
if (!mem_tmp) { if (!mem_tmp) {
err ("out of system memory\n"); err ("out of system memory\n");
retval = -ENOMEM; retval = -ENOMEM;
...@@ -836,7 +836,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) ...@@ -836,7 +836,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
flag_io = TRUE; flag_io = TRUE;
} else { } else {
debug ("it wants %x IO behind the bridge\n", amount_needed->io); debug ("it wants %x IO behind the bridge\n", amount_needed->io);
io = kmalloc (sizeof (struct resource_node), GFP_KERNEL); io = kmalloc(sizeof(*io), GFP_KERNEL);
if (!io) { if (!io) {
err ("out of system memory\n"); err ("out of system memory\n");
...@@ -860,7 +860,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) ...@@ -860,7 +860,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
flag_mem = TRUE; flag_mem = TRUE;
} else { } else {
debug ("it wants %x memory behind the bridge\n", amount_needed->mem); debug ("it wants %x memory behind the bridge\n", amount_needed->mem);
mem = kmalloc (sizeof (struct resource_node), GFP_KERNEL); mem = kmalloc(sizeof(*mem), GFP_KERNEL);
if (!mem) { if (!mem) {
err ("out of system memory\n"); err ("out of system memory\n");
retval = -ENOMEM; retval = -ENOMEM;
...@@ -883,7 +883,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) ...@@ -883,7 +883,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
flag_pfmem = TRUE; flag_pfmem = TRUE;
} else { } else {
debug ("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem); debug ("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem);
pfmem = kmalloc (sizeof (struct resource_node), GFP_KERNEL); pfmem = kmalloc(sizeof(*pfmem), GFP_KERNEL);
if (!pfmem) { if (!pfmem) {
err ("out of system memory\n"); err ("out of system memory\n");
retval = -ENOMEM; retval = -ENOMEM;
...@@ -899,7 +899,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) ...@@ -899,7 +899,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
ibmphp_add_resource (pfmem); ibmphp_add_resource (pfmem);
flag_pfmem = TRUE; flag_pfmem = TRUE;
} else { } else {
mem_tmp = kmalloc (sizeof (struct resource_node), GFP_KERNEL); mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL);
if (!mem_tmp) { if (!mem_tmp) {
err ("out of system memory\n"); err ("out of system memory\n");
retval = -ENOMEM; retval = -ENOMEM;
...@@ -931,7 +931,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno) ...@@ -931,7 +931,7 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
*/ */
bus = ibmphp_find_res_bus (sec_number); bus = ibmphp_find_res_bus (sec_number);
if (!bus) { if (!bus) {
bus = kmalloc (sizeof (struct bus_node), GFP_KERNEL); bus = kmalloc(sizeof(*bus), GFP_KERNEL);
if (!bus) { if (!bus) {
err ("out of system memory\n"); err ("out of system memory\n");
retval = -ENOMEM; retval = -ENOMEM;
...@@ -1107,7 +1107,7 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno) ...@@ -1107,7 +1107,7 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno)
}; };
struct res_needed *amount; struct res_needed *amount;
amount = kmalloc (sizeof (struct res_needed), GFP_KERNEL); amount = kmalloc(sizeof(*amount), GFP_KERNEL);
if (amount == NULL) if (amount == NULL)
return NULL; return NULL;
memset (amount, 0, sizeof (struct res_needed)); memset (amount, 0, sizeof (struct res_needed));
...@@ -1680,7 +1680,7 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r ...@@ -1680,7 +1680,7 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
list_add (&bus->bus_list, &cur_bus->bus_list); list_add (&bus->bus_list, &cur_bus->bus_list);
} }
if (io) { if (io) {
io_range = kmalloc (sizeof (struct range_node), GFP_KERNEL); io_range = kmalloc(sizeof(*io_range), GFP_KERNEL);
if (!io_range) { if (!io_range) {
err ("out of system memory\n"); err ("out of system memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -1693,7 +1693,7 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r ...@@ -1693,7 +1693,7 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
bus->rangeIO = io_range; bus->rangeIO = io_range;
} }
if (mem) { if (mem) {
mem_range = kmalloc (sizeof (struct range_node), GFP_KERNEL); mem_range = kmalloc(sizeof(*mem_range), GFP_KERNEL);
if (!mem_range) { if (!mem_range) {
err ("out of system memory\n"); err ("out of system memory\n");
return -ENOMEM; return -ENOMEM;
...@@ -1706,7 +1706,7 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r ...@@ -1706,7 +1706,7 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
bus->rangeMem = mem_range; bus->rangeMem = mem_range;
} }
if (pfmem) { if (pfmem) {
pfmem_range = kmalloc (sizeof (struct range_node), GFP_KERNEL); pfmem_range = kmalloc(sizeof(*pfmem_range), GFP_KERNEL);
if (!pfmem_range) { if (!pfmem_range) {
err ("out of system memory\n"); err ("out of system memory\n");
return -ENOMEM; return -ENOMEM;
......
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