Commit 30c6a0e8 authored by Rolf Eike Beer's avatar Rolf Eike Beer Committed by Deepak Saxena

[PATCH] PCI Express Hotplug: remove useless kmalloc casts

The result of kmalloc does not need to be casted, it is a void * which can be
assigned to any pointer variable. Also avoid code duplication in one if
statement.
parent 2e36dd6b
...@@ -391,7 +391,7 @@ do_pre_bridge_resource_split(struct pci_resource **head, ...@@ -391,7 +391,7 @@ do_pre_bridge_resource_split(struct pci_resource **head,
/* this one isn't an aligned length, so we'll make a new entry /* this one isn't an aligned length, so we'll make a new entry
* and split it up. * and split it up.
*/ */
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); split_node = kmalloc(sizeof(struct pci_resource), GFP_KERNEL);
if (!split_node) if (!split_node)
return NULL; return NULL;
...@@ -415,15 +415,14 @@ do_pre_bridge_resource_split(struct pci_resource **head, ...@@ -415,15 +415,14 @@ do_pre_bridge_resource_split(struct pci_resource **head,
/* Now unlink it */ /* Now unlink it */
if (*head == node) { if (*head == node) {
*head = node->next; *head = node->next;
node->next = NULL;
} else { } else {
prevnode = *head; prevnode = *head;
while (prevnode->next != node) while (prevnode->next != node)
prevnode = prevnode->next; prevnode = prevnode->next;
prevnode->next = node->next; prevnode->next = node->next;
node->next = NULL;
} }
node->next = NULL;
return node; return node;
} }
...@@ -524,7 +523,8 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size ...@@ -524,7 +523,8 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
if ((node->length - (temp_dword - node->base)) < size) if ((node->length - (temp_dword - node->base)) < size)
continue; continue;
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); split_node = kmalloc(sizeof(struct pci_resource),
GFP_KERNEL);
if (!split_node) if (!split_node)
return NULL; return NULL;
...@@ -543,7 +543,8 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size ...@@ -543,7 +543,8 @@ static struct pci_resource *get_io_resource(struct pci_resource **head, u32 size
if (node->length > size) { if (node->length > size) {
/* this one is longer than we need /* this one is longer than we need
so we'll make a new entry and split it up */ so we'll make a new entry and split it up */
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); split_node = kmalloc(sizeof(struct pci_resource),
GFP_KERNEL);
if (!split_node) if (!split_node)
return NULL; return NULL;
...@@ -624,7 +625,8 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz ...@@ -624,7 +625,8 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
if ((max->length - (temp_dword - max->base)) < size) if ((max->length - (temp_dword - max->base)) < size)
continue; continue;
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); split_node = kmalloc(sizeof(struct pci_resource),
GFP_KERNEL);
if (!split_node) if (!split_node)
return NULL; return NULL;
...@@ -642,7 +644,8 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz ...@@ -642,7 +644,8 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
if ((max->base + max->length) & (size - 1)) { if ((max->base + max->length) & (size - 1)) {
/* this one isn't end aligned properly at the top /* this one isn't end aligned properly at the top
so we'll make a new entry and split it up */ so we'll make a new entry and split it up */
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); split_node = kmalloc(sizeof(struct pci_resource),
GFP_KERNEL);
if (!split_node) if (!split_node)
return NULL; return NULL;
...@@ -663,7 +666,8 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz ...@@ -663,7 +666,8 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
for ( i = 0; max_size[i] > size; i++) { for ( i = 0; max_size[i] > size; i++) {
if (max->length > max_size[i]) { if (max->length > max_size[i]) {
split_node = (struct pci_resource *) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); split_node = kmalloc(sizeof(struct pci_resource),
GFP_KERNEL);
if (!split_node) if (!split_node)
break; /* return NULL; */ break; /* return NULL; */
split_node->base = max->base + max_size[i]; split_node->base = max->base + max_size[i];
...@@ -738,7 +742,8 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size) ...@@ -738,7 +742,8 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
if ((node->length - (temp_dword - node->base)) < size) if ((node->length - (temp_dword - node->base)) < size)
continue; continue;
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); split_node = kmalloc(sizeof(struct pci_resource),
GFP_KERNEL);
if (!split_node) if (!split_node)
return NULL; return NULL;
...@@ -758,7 +763,8 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size) ...@@ -758,7 +763,8 @@ static struct pci_resource *get_resource(struct pci_resource **head, u32 size)
dbg("%s: too big\n", __FUNCTION__); dbg("%s: too big\n", __FUNCTION__);
/* this one is longer than we need /* this one is longer than we need
so we'll make a new entry and split it up */ so we'll make a new entry and split it up */
split_node = (struct pci_resource*) kmalloc(sizeof(struct pci_resource), GFP_KERNEL); split_node = kmalloc(sizeof(struct pci_resource),
GFP_KERNEL);
if (!split_node) if (!split_node)
return NULL; return NULL;
...@@ -876,7 +882,7 @@ struct pci_func *pciehp_slot_create(u8 busnumber) ...@@ -876,7 +882,7 @@ struct pci_func *pciehp_slot_create(u8 busnumber)
struct pci_func *new_slot; struct pci_func *new_slot;
struct pci_func *next; struct pci_func *next;
dbg("%s: busnumber %x\n", __FUNCTION__, busnumber); dbg("%s: busnumber %x\n", __FUNCTION__, busnumber);
new_slot = (struct pci_func *) kmalloc(sizeof(struct pci_func), GFP_KERNEL); new_slot = kmalloc(sizeof(struct pci_func), GFP_KERNEL);
if (new_slot == NULL) if (new_slot == NULL)
return new_slot; return new_slot;
...@@ -1452,7 +1458,7 @@ static int update_slot_info(struct slot *slot) ...@@ -1452,7 +1458,7 @@ static int update_slot_info(struct slot *slot)
/* char buffer[SLOT_NAME_SIZE]; */ /* char buffer[SLOT_NAME_SIZE]; */
int result; int result;
info = kmalloc (sizeof (struct hotplug_slot_info), GFP_KERNEL); info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
if (!info) if (!info)
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