aboutsummaryrefslogtreecommitdiff
path: root/drivers/pci/hotplug
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r--drivers/pci/hotplug/acpiphp_glue.c14
-rw-r--r--drivers/pci/hotplug/cpci_hotplug_core.c9
-rw-r--r--drivers/pci/hotplug/cpqphp_core.c13
-rw-r--r--drivers/pci/hotplug/fakephp.c9
-rw-r--r--drivers/pci/hotplug/ibmphp_core.c6
-rw-r--r--drivers/pci/hotplug/ibmphp_ebda.c57
-rw-r--r--drivers/pci/hotplug/ibmphp_pci.c63
-rw-r--r--drivers/pci/hotplug/ibmphp_res.c33
-rw-r--r--drivers/pci/hotplug/pciehp_core.c13
-rw-r--r--drivers/pci/hotplug/rpaphp_slot.c9
10 files changed, 69 insertions, 157 deletions
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c
index cbd5893d198..c7e6387983d 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -143,10 +143,9 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
device = (adr >> 16) & 0xffff;
function = adr & 0xffff;
- newfunc = kmalloc(sizeof(struct acpiphp_func), GFP_KERNEL);
+ newfunc = kzalloc(sizeof(struct acpiphp_func), GFP_KERNEL);
if (!newfunc)
return AE_NO_MEMORY;
- memset(newfunc, 0, sizeof(struct acpiphp_func));
INIT_LIST_HEAD(&newfunc->sibling);
newfunc->handle = handle;
@@ -189,13 +188,12 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
}
if (!slot) {
- slot = kmalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
+ slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
if (!slot) {
kfree(newfunc);
return AE_NO_MEMORY;
}
- memset(slot, 0, sizeof(struct acpiphp_slot));
slot->bridge = bridge;
slot->device = device;
slot->sun = sun;
@@ -376,12 +374,10 @@ static void add_host_bridge(acpi_handle *handle, struct pci_bus *pci_bus)
{
struct acpiphp_bridge *bridge;
- bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
+ bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
if (bridge == NULL)
return;
- memset(bridge, 0, sizeof(struct acpiphp_bridge));
-
bridge->type = BRIDGE_TYPE_HOST;
bridge->handle = handle;
@@ -398,14 +394,12 @@ static void add_p2p_bridge(acpi_handle *handle, struct pci_dev *pci_dev)
{
struct acpiphp_bridge *bridge;
- bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
+ bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
if (bridge == NULL) {
err("out of memory\n");
return;
}
- memset(bridge, 0, sizeof(struct acpiphp_bridge));
-
bridge->type = BRIDGE_TYPE_P2P;
bridge->handle = handle;
diff --git a/drivers/pci/hotplug/cpci_hotplug_core.c b/drivers/pci/hotplug/cpci_hotplug_core.c
index 30af105271a..037ce4c9168 100644
--- a/drivers/pci/hotplug/cpci_hotplug_core.c
+++ b/drivers/pci/hotplug/cpci_hotplug_core.c
@@ -248,22 +248,19 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
* with the pci_hotplug subsystem.
*/
for (i = first; i <= last; ++i) {
- slot = kmalloc(sizeof (struct slot), GFP_KERNEL);
+ slot = kzalloc(sizeof (struct slot), GFP_KERNEL);
if (!slot)
goto error;
- memset(slot, 0, sizeof (struct slot));
hotplug_slot =
- kmalloc(sizeof (struct hotplug_slot), GFP_KERNEL);
+ kzalloc(sizeof (struct hotplug_slot), GFP_KERNEL);
if (!hotplug_slot)
goto error_slot;
- memset(hotplug_slot, 0, sizeof (struct hotplug_slot));
slot->hotplug_slot = hotplug_slot;
- info = kmalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL);
+ info = kzalloc(sizeof (struct hotplug_slot_info), GFP_KERNEL);
if (!info)
goto error_hpslot;
- memset(info, 0, sizeof (struct hotplug_slot_info));
hotplug_slot->info = info;
name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index 8626901daeb..9bc1deb8df5 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -347,26 +347,22 @@ static int ctrl_slot_setup(struct controller *ctrl,
slot_number = ctrl->first_slot;
while (number_of_slots) {
- slot = kmalloc(sizeof(*slot), GFP_KERNEL);
+ slot = kzalloc(sizeof(*slot), GFP_KERNEL);
if (!slot)
goto error;
- memset(slot, 0, sizeof(struct slot));
- slot->hotplug_slot = kmalloc(sizeof(*(slot->hotplug_slot)),
+ slot->hotplug_slot = kzalloc(sizeof(*(slot->hotplug_slot)),
GFP_KERNEL);
if (!slot->hotplug_slot)
goto error_slot;
hotplug_slot = slot->hotplug_slot;
- memset(hotplug_slot, 0, sizeof(struct hotplug_slot));
hotplug_slot->info =
- kmalloc(sizeof(*(hotplug_slot->info)),
+ kzalloc(sizeof(*(hotplug_slot->info)),
GFP_KERNEL);
if (!hotplug_slot->info)
goto error_hpslot;
hotplug_slot_info = hotplug_slot->info;
- memset(hotplug_slot_info, 0,
- sizeof(struct hotplug_slot_info));
hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
if (!hotplug_slot->name)
@@ -854,13 +850,12 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
goto err_disable_device;
}
- ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL);
+ ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL);
if (!ctrl) {
err("%s : out of memory\n", __FUNCTION__);
rc = -ENOMEM;
goto err_disable_device;
}
- memset(ctrl, 0, sizeof(struct controller));
rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsystem_deviceid);
if (rc) {
diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c
index 060d74775d7..71b80c23e8c 100644
--- a/drivers/pci/hotplug/fakephp.c
+++ b/drivers/pci/hotplug/fakephp.c
@@ -95,15 +95,13 @@ static int add_slot(struct pci_dev *dev)
struct hotplug_slot *slot;
int retval = -ENOMEM;
- slot = kmalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
+ slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
if (!slot)
goto error;
- memset(slot, 0, sizeof(*slot));
- slot->info = kmalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
+ slot->info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
if (!slot->info)
goto error_slot;
- memset(slot->info, 0, sizeof(struct hotplug_slot_info));
slot->info->power_status = 1;
slot->info->max_bus_speed = PCI_SPEED_UNKNOWN;
@@ -227,11 +225,10 @@ static void pci_rescan_bus(const struct pci_bus *bus)
{
unsigned int devfn;
struct pci_dev *dev;
- dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL);
+ dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL);
if (!dev)
return;
- memset(dev, 0, sizeof(dev));
dev->bus = (struct pci_bus*)bus;
dev->sysdata = bus->sysdata;
for (devfn = 0; devfn < 0x100; devfn += 8) {
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c
index dc59da675c0..45e2a0d9b59 100644
--- a/drivers/pci/hotplug/ibmphp_core.c
+++ b/drivers/pci/hotplug/ibmphp_core.c
@@ -1141,7 +1141,7 @@ static int enable_slot(struct hotplug_slot *hs)
goto error_power;
}
- slot_cur->func = kmalloc(sizeof(struct pci_func), GFP_KERNEL);
+ slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL);
if (!slot_cur->func) {
/* We cannot do update_slot_info here, since no memory for
* kmalloc n.e.ways, and update_slot_info allocates some */
@@ -1149,7 +1149,6 @@ static int enable_slot(struct hotplug_slot *hs)
rc = -ENOMEM;
goto error_power;
}
- memset(slot_cur->func, 0, sizeof(struct pci_func));
slot_cur->func->busno = slot_cur->bus;
slot_cur->func->device = slot_cur->device;
for (i = 0; i < 4; i++)
@@ -1252,13 +1251,12 @@ int ibmphp_do_disable_slot(struct slot *slot_cur)
if (slot_cur->func == NULL) {
/* We need this for fncs's that were there on bootup */
- slot_cur->func = kmalloc(sizeof(struct pci_func), GFP_KERNEL);
+ slot_cur->func = kzalloc(sizeof(struct pci_func), GFP_KERNEL);
if (!slot_cur->func) {
err("out of system memory\n");
rc = -ENOMEM;
goto error;
}
- memset(slot_cur->func, 0, sizeof(struct pci_func));
slot_cur->func->busno = slot_cur->bus;
slot_cur->func->device = slot_cur->device;
}
diff --git a/drivers/pci/hotplug/ibmphp_ebda.c b/drivers/pci/hotplug/ibmphp_ebda.c
index aea1187c73a..ba12034c5d3 100644
--- a/drivers/pci/hotplug/ibmphp_ebda.c
+++ b/drivers/pci/hotplug/ibmphp_ebda.c
@@ -72,13 +72,7 @@ static int ebda_rio_table (void);
static struct ebda_hpc_list * __init alloc_ebda_hpc_list (void)
{
- struct ebda_hpc_list *list;
-
- list = kmalloc (sizeof (struct ebda_hpc_list), GFP_KERNEL);
- if (!list)
- return NULL;
- memset (list, 0, sizeof (*list));
- return list;
+ return kzalloc(sizeof(struct ebda_hpc_list), GFP_KERNEL);
}
static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count)
@@ -87,21 +81,18 @@ static struct controller *alloc_ebda_hpc (u32 slot_count, u32 bus_count)
struct ebda_hpc_slot *slots;
struct ebda_hpc_bus *buses;
- controller = kmalloc (sizeof (struct controller), GFP_KERNEL);
+ controller = kzalloc(sizeof(struct controller), GFP_KERNEL);
if (!controller)
goto error;
- memset (controller, 0, sizeof (*controller));
- slots = kmalloc (sizeof (struct ebda_hpc_slot) * slot_count, GFP_KERNEL);
+ slots = kcalloc(slot_count, sizeof(struct ebda_hpc_slot), GFP_KERNEL);
if (!slots)
goto error_contr;
- memset (slots, 0, sizeof (*slots) * slot_count);
controller->slots = slots;
- buses = kmalloc (sizeof (struct ebda_hpc_bus) * bus_count, GFP_KERNEL);
+ buses = kcalloc(bus_count, sizeof(struct ebda_hpc_bus), GFP_KERNEL);
if (!buses)
goto error_slots;
- memset (buses, 0, sizeof (*buses) * bus_count);
controller->buses = buses;
return controller;
@@ -122,24 +113,12 @@ static void free_ebda_hpc (struct controller *controller)
static struct ebda_rsrc_list * __init alloc_ebda_rsrc_list (void)
{
- struct ebda_rsrc_list *list;
-
- list = kmalloc (sizeof (struct ebda_rsrc_list), GFP_KERNEL);
- if (!list)
- return NULL;
- memset (list, 0, sizeof (*list));
- return list;
+ return kzalloc(sizeof(struct ebda_rsrc_list), GFP_KERNEL);
}
static struct ebda_pci_rsrc *alloc_ebda_pci_rsrc (void)
{
- struct ebda_pci_rsrc *resource;
-
- resource = kmalloc (sizeof (struct ebda_pci_rsrc), GFP_KERNEL);
- if (!resource)
- return NULL;
- memset (resource, 0, sizeof (*resource));
- return resource;
+ return kzalloc(sizeof(struct ebda_pci_rsrc), GFP_KERNEL);
}
static void __init print_bus_info (void)
@@ -390,10 +369,9 @@ int __init ibmphp_access_ebda (void)
debug ("now enter io table ---\n");
debug ("rio blk id: %x\n", blk_id);
- rio_table_ptr = kmalloc (sizeof (struct rio_table_hdr), GFP_KERNEL);
+ rio_table_ptr = kzalloc(sizeof(struct rio_table_hdr), GFP_KERNEL);
if (!rio_table_ptr)
return -ENOMEM;
- memset (rio_table_ptr, 0, sizeof (struct rio_table_hdr) );
rio_table_ptr->ver_num = readb (io_mem + offset);
rio_table_ptr->scal_count = readb (io_mem + offset + 1);
rio_table_ptr->riodev_count = readb (io_mem + offset + 2);
@@ -445,10 +423,9 @@ static int __init ebda_rio_table (void)
// we do concern about rio details
for (i = 0; i < rio_table_ptr->riodev_count; i++) {
- rio_detail_ptr = kmalloc (sizeof (struct rio_detail), GFP_KERNEL);
+ rio_detail_ptr = kzalloc(sizeof(struct rio_detail), GFP_KERNEL);
if (!rio_detail_ptr)
return -ENOMEM;
- memset (rio_detail_ptr, 0, sizeof (struct rio_detail));
rio_detail_ptr->rio_node_id = readb (io_mem + offset);
rio_detail_ptr->bbar = readl (io_mem + offset + 1);
rio_detail_ptr->rio_type = readb (io_mem + offset + 5);
@@ -503,10 +480,9 @@ static int __init combine_wpg_for_chassis (void)
rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list);
opt_rio_ptr = search_opt_vg (rio_detail_ptr->chassis_num);
if (!opt_rio_ptr) {
- opt_rio_ptr = (struct opt_rio *) kmalloc (sizeof (struct opt_rio), GFP_KERNEL);
+ opt_rio_ptr = kzalloc(sizeof(struct opt_rio), GFP_KERNEL);
if (!opt_rio_ptr)
return -ENOMEM;
- memset (opt_rio_ptr, 0, sizeof (struct opt_rio));
opt_rio_ptr->rio_type = rio_detail_ptr->rio_type;
opt_rio_ptr->chassis_num = rio_detail_ptr->chassis_num;
opt_rio_ptr->first_slot_num = rio_detail_ptr->first_slot_num;
@@ -546,10 +522,9 @@ static int combine_wpg_for_expansion (void)
rio_detail_ptr = list_entry (list_head_ptr, struct rio_detail, rio_detail_list);
opt_rio_lo_ptr = search_opt_lo (rio_detail_ptr->chassis_num);
if (!opt_rio_lo_ptr) {
- opt_rio_lo_ptr = (struct opt_rio_lo *) kmalloc (sizeof (struct opt_rio_lo), GFP_KERNEL);
+ opt_rio_lo_ptr = kzalloc(sizeof(struct opt_rio_lo), GFP_KERNEL);
if (!opt_rio_lo_ptr)
return -ENOMEM;
- memset (opt_rio_lo_ptr, 0, sizeof (struct opt_rio_lo));
opt_rio_lo_ptr->rio_type = rio_detail_ptr->rio_type;
opt_rio_lo_ptr->chassis_num = rio_detail_ptr->chassis_num;
opt_rio_lo_ptr->first_slot_num = rio_detail_ptr->first_slot_num;
@@ -842,12 +817,11 @@ static int __init ebda_rsrc_controller (void)
bus_info_ptr2 = ibmphp_find_same_bus_num (slot_ptr->slot_bus_num);
if (!bus_info_ptr2) {
- bus_info_ptr1 = (struct bus_info *) kmalloc (sizeof (struct bus_info), GFP_KERNEL);
+ bus_info_ptr1 = kzalloc(sizeof(struct bus_info), GFP_KERNEL);
if (!bus_info_ptr1) {
rc = -ENOMEM;
goto error_no_hp_slot;
}
- memset (bus_info_ptr1, 0, sizeof (struct bus_info));
bus_info_ptr1->slot_min = slot_ptr->slot_num;
bus_info_ptr1->slot_max = slot_ptr->slot_num;
bus_info_ptr1->slot_count += 1;
@@ -946,19 +920,17 @@ static int __init ebda_rsrc_controller (void)
// register slots with hpc core as well as create linked list of ibm slot
for (index = 0; index < hpc_ptr->slot_count; index++) {
- hp_slot_ptr = kmalloc(sizeof(*hp_slot_ptr), GFP_KERNEL);
+ hp_slot_ptr = kzalloc(sizeof(*hp_slot_ptr), GFP_KERNEL);
if (!hp_slot_ptr) {
rc = -ENOMEM;
goto error_no_hp_slot;
}
- memset(hp_slot_ptr, 0, sizeof(*hp_slot_ptr));
- hp_slot_ptr->info = kmalloc (sizeof(struct hotplug_slot_info), GFP_KERNEL);
+ hp_slot_ptr->info = kzalloc(sizeof(struct hotplug_slot_info), GFP_KERNEL);
if (!hp_slot_ptr->info) {
rc = -ENOMEM;
goto error_no_hp_info;
}
- memset(hp_slot_ptr->info, 0, sizeof(struct hotplug_slot_info));
hp_slot_ptr->name = kmalloc(30, GFP_KERNEL);
if (!hp_slot_ptr->name) {
@@ -966,12 +938,11 @@ static int __init ebda_rsrc_controller (void)
goto error_no_hp_name;
}
- tmp_slot = kmalloc(sizeof(*tmp_slot), GFP_KERNEL);
+ tmp_slot = kzalloc(sizeof(*tmp_slot), GFP_KERNEL);
if (!tmp_slot) {
rc = -ENOMEM;
goto error_no_slot;
}
- memset(tmp_slot, 0, sizeof(*tmp_slot));
tmp_slot->flag = TRUE;
diff --git a/drivers/pci/hotplug/ibmphp_pci.c b/drivers/pci/hotplug/ibmphp_pci.c
index 155133fe5c1..97753ddcd85 100644
--- a/drivers/pci/hotplug/ibmphp_pci.c
+++ b/drivers/pci/hotplug/ibmphp_pci.c
@@ -164,12 +164,11 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
cleanup_count = 6;
goto error;
}
- newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
+ newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
if (!newfunc) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (newfunc, 0, sizeof (struct pci_func));
newfunc->busno = cur_func->busno;
newfunc->device = device;
cur_func->next = newfunc;
@@ -203,12 +202,11 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
flag = FALSE;
for (i = 0; i < 32; i++) {
if (func->devices[i]) {
- newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
+ newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
if (!newfunc) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (newfunc, 0, sizeof (struct pci_func));
newfunc->busno = sec_number;
newfunc->device = (u8) i;
for (j = 0; j < 4; j++)
@@ -232,12 +230,11 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
}
}
- newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
+ newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
if (!newfunc) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (newfunc, 0, sizeof (struct pci_func));
newfunc->busno = cur_func->busno;
newfunc->device = device;
for (j = 0; j < 4; j++)
@@ -279,12 +276,11 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
for (i = 0; i < 32; i++) {
if (func->devices[i]) {
debug ("inside for loop, device is %x\n", i);
- newfunc = kmalloc(sizeof(*newfunc), GFP_KERNEL);
+ newfunc = kzalloc(sizeof(*newfunc), GFP_KERNEL);
if (!newfunc) {
err (" out of system memory\n");
return -ENOMEM;
}
- memset (newfunc, 0, sizeof (struct pci_func));
newfunc->busno = sec_number;
newfunc->device = (u8) i;
for (j = 0; j < 4; j++)
@@ -405,13 +401,12 @@ static int configure_device (struct pci_func *func)
debug ("len[count] in IO %x, count %d\n", len[count], count);
- io[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!io[count]) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (io[count], 0, sizeof (struct resource_node));
io[count]->type = IO;
io[count]->busno = func->busno;
io[count]->devfunc = PCI_DEVFN(func->device, func->function);
@@ -444,12 +439,11 @@ static int configure_device (struct pci_func *func)
debug ("len[count] in PFMEM %x, count %d\n", len[count], count);
- pfmem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!pfmem[count]) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (pfmem[count], 0, sizeof (struct resource_node));
pfmem[count]->type = PFMEM;
pfmem[count]->busno = func->busno;
pfmem[count]->devfunc = PCI_DEVFN(func->device,
@@ -460,13 +454,12 @@ static int configure_device (struct pci_func *func)
ibmphp_add_resource (pfmem[count]);
func->pfmem[count] = pfmem[count];
} else {
- mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL);
+ mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
if (!mem_tmp) {
err ("out of system memory\n");
kfree (pfmem[count]);
return -ENOMEM;
}
- memset (mem_tmp, 0, sizeof (struct resource_node));
mem_tmp->type = MEM;
mem_tmp->busno = pfmem[count]->busno;
mem_tmp->devfunc = pfmem[count]->devfunc;
@@ -512,12 +505,11 @@ static int configure_device (struct pci_func *func)
debug ("len[count] in Mem %x, count %d\n", len[count], count);
- mem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!mem[count]) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (mem[count], 0, sizeof (struct resource_node));
mem[count]->type = MEM;
mem[count]->busno = func->busno;
mem[count]->devfunc = PCI_DEVFN(func->device,
@@ -677,14 +669,13 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
debug ("len[count] in IO = %x\n", len[count]);
- bus_io[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ bus_io[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!bus_io[count]) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (bus_io[count], 0, sizeof (struct resource_node));
bus_io[count]->type = IO;
bus_io[count]->busno = func->busno;
bus_io[count]->devfunc = PCI_DEVFN(func->device,
@@ -711,13 +702,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
debug ("len[count] in PFMEM = %x\n", len[count]);
- bus_pfmem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ bus_pfmem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!bus_pfmem[count]) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (bus_pfmem[count], 0, sizeof (struct resource_node));
bus_pfmem[count]->type = PFMEM;
bus_pfmem[count]->busno = func->busno;
bus_pfmem[count]->devfunc = PCI_DEVFN(func->device,
@@ -728,13 +718,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
ibmphp_add_resource (bus_pfmem[count]);
func->pfmem[count] = bus_pfmem[count];
} else {
- mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL);
+ mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
if (!mem_tmp) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (mem_tmp, 0, sizeof (struct resource_node));
mem_tmp->type = MEM;
mem_tmp->busno = bus_pfmem[count]->busno;
mem_tmp->devfunc = bus_pfmem[count]->devfunc;
@@ -770,13 +759,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
debug ("len[count] in Memory is %x\n", len[count]);
- bus_mem[count] = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ bus_mem[count] = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!bus_mem[count]) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (bus_mem[count], 0, sizeof (struct resource_node));
bus_mem[count]->type = MEM;
bus_mem[count]->busno = func->busno;
bus_mem[count]->devfunc = PCI_DEVFN(func->device,
@@ -841,14 +829,13 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
flag_io = TRUE;
} else {
debug ("it wants %x IO behind the bridge\n", amount_needed->io);
- io = kmalloc(sizeof(*io), GFP_KERNEL);
+ io = kzalloc(sizeof(*io), GFP_KERNEL);
if (!io) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (io, 0, sizeof (struct resource_node));
io->type = IO;
io->busno = func->busno;
io->devfunc = PCI_DEVFN(func->device, func->function);
@@ -865,13 +852,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
flag_mem = TRUE;
} else {
debug ("it wants %x memory behind the bridge\n", amount_needed->mem);
- mem = kmalloc(sizeof(*mem), GFP_KERNEL);
+ mem = kzalloc(sizeof(*mem), GFP_KERNEL);
if (!mem) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (mem, 0, sizeof (struct resource_node));
mem->type = MEM;
mem->busno = func->busno;
mem->devfunc = PCI_DEVFN(func->device, func->function);
@@ -888,13 +874,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
flag_pfmem = TRUE;
} else {
debug ("it wants %x pfmemory behind the bridge\n", amount_needed->pfmem);
- pfmem = kmalloc(sizeof(*pfmem), GFP_KERNEL);
+ pfmem = kzalloc(sizeof(*pfmem), GFP_KERNEL);
if (!pfmem) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (pfmem, 0, sizeof (struct resource_node));
pfmem->type = PFMEM;
pfmem->busno = func->busno;
pfmem->devfunc = PCI_DEVFN(func->device, func->function);
@@ -904,13 +889,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
ibmphp_add_resource (pfmem);
flag_pfmem = TRUE;
} else {
- mem_tmp = kmalloc(sizeof(*mem_tmp), GFP_KERNEL);
+ mem_tmp = kzalloc(sizeof(*mem_tmp), GFP_KERNEL);
if (!mem_tmp) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (mem_tmp, 0, sizeof (struct resource_node));
mem_tmp->type = MEM;
mem_tmp->busno = pfmem->busno;
mem_tmp->devfunc = pfmem->devfunc;
@@ -936,13 +920,12 @@ static int configure_bridge (struct pci_func **func_passed, u8 slotno)
*/
bus = ibmphp_find_res_bus (sec_number);
if (!bus) {
- bus = kmalloc(sizeof(*bus), GFP_KERNEL);
+ bus = kzalloc(sizeof(*bus), GFP_KERNEL);
if (!bus) {
err ("out of system memory\n");
retval = -ENOMEM;
goto error;
}
- memset (bus, 0, sizeof (struct bus_node));
bus->busno = sec_number;
debug ("b4 adding new bus\n");
rc = add_new_bus (bus, io, mem, pfmem, func->busno);
@@ -1111,10 +1094,9 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno)
};
struct res_needed *amount;
- amount = kmalloc(sizeof(*amount), GFP_KERNEL);
+ amount = kzalloc(sizeof(*amount), GFP_KERNEL);
if (amount == NULL)
return NULL;
- memset (amount, 0, sizeof (struct res_needed));
ibmphp_pci_bus->number = busno;
@@ -1672,12 +1654,11 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
list_add (&bus->bus_list, &cur_bus->bus_list);
}
if (io) {
- io_range = kmalloc(sizeof(*io_range), GFP_KERNEL);
+ io_range = kzalloc(sizeof(*io_range), GFP_KERNEL);
if (!io_range) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (io_range, 0, sizeof (struct range_node));
io_range->start = io->start;
io_range->end = io->end;
io_range->rangeno = 1;
@@ -1685,12 +1666,11 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
bus->rangeIO = io_range;
}
if (mem) {
- mem_range = kmalloc(sizeof(*mem_range), GFP_KERNEL);
+ mem_range = kzalloc(sizeof(*mem_range), GFP_KERNEL);
if (!mem_range) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (mem_range, 0, sizeof (struct range_node));
mem_range->start = mem->start;
mem_range->end = mem->end;
mem_range->rangeno = 1;
@@ -1698,12 +1678,11 @@ static int add_new_bus (struct bus_node *bus, struct resource_node *io, struct r
bus->rangeMem = mem_range;
}
if (pfmem) {
- pfmem_range = kmalloc(sizeof(*pfmem_range), GFP_KERNEL);
+ pfmem_range = kzalloc(sizeof(*pfmem_range), GFP_KERNEL);
if (!pfmem_range) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (pfmem_range, 0, sizeof (struct range_node));
pfmem_range->start = pfmem->start;
pfmem_range->end = pfmem->end;
pfmem_range->rangeno = 1;
diff --git a/drivers/pci/hotplug/ibmphp_res.c b/drivers/pci/hotplug/ibmphp_res.c
index 9c224c94d69..852a98bf07d 100644
--- a/drivers/pci/hotplug/ibmphp_res.c
+++ b/drivers/pci/hotplug/ibmphp_res.c
@@ -55,13 +55,12 @@ static struct bus_node * __init alloc_error_bus (struct ebda_pci_rsrc * curr, u8
return NULL;
}
- newbus = kmalloc (sizeof (struct bus_node), GFP_KERNEL);
+ newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL);
if (!newbus) {
err ("out of system memory\n");
return NULL;
}
- memset (newbus, 0, sizeof (struct bus_node));
if (flag)
newbus->busno = busno;
else
@@ -79,12 +78,11 @@ static struct resource_node * __init alloc_resources (struct ebda_pci_rsrc * cur
return NULL;
}
- rs = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ rs = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!rs) {
err ("out of system memory\n");
return NULL;
}
- memset (rs, 0, sizeof (struct resource_node));
rs->busno = curr->bus_num;
rs->devfunc = curr->dev_fun;
rs->start = curr->start_addr;
@@ -100,12 +98,11 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node
u8 num_ranges = 0;
if (first_bus) {
- newbus = kmalloc (sizeof (struct bus_node), GFP_KERNEL);
+ newbus = kzalloc(sizeof(struct bus_node), GFP_KERNEL);
if (!newbus) {
err ("out of system memory.\n");
return -ENOMEM;
}
- memset (newbus, 0, sizeof (struct bus_node));
newbus->busno = curr->bus_num;
} else {
newbus = *new_bus;
@@ -122,14 +119,13 @@ static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node
}
}
- newrange = kmalloc (sizeof (struct range_node), GFP_KERNEL);
+ newrange = kzalloc(sizeof(struct range_node), GFP_KERNEL);
if (!newrange) {
if (first_bus)
kfree (newbus);
err ("out of system memory\n");
return -ENOMEM;
}
- memset (newrange, 0, sizeof (struct range_node));
newrange->start = curr->start_addr;
newrange->end = curr->end_addr;
@@ -1705,12 +1701,11 @@ static int __init once_over (void)
bus_cur->firstPFMemFromMem = pfmem_cur;
- mem = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!mem) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (mem, 0, sizeof (struct resource_node));
mem->type = MEM;
mem->busno = pfmem_cur->busno;
mem->devfunc = pfmem_cur->devfunc;
@@ -1994,12 +1989,11 @@ static int __init update_bridge_ranges (struct bus_node **bus)
end_address |= (upper_io_end << 16);
if ((start_address) && (start_address <= end_address)) {
- range = kmalloc (sizeof (struct range_node), GFP_KERNEL);
+ range = kzalloc(sizeof(struct range_node), GFP_KERNEL);
if (!range) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (range, 0, sizeof (struct range_node));
range->start = start_address;
range->end = end_address + 0xfff;
@@ -2020,13 +2014,12 @@ static int __init update_bridge_ranges (struct bus_node **bus)
fix_resources (bus_sec);
if (ibmphp_find_resource (bus_cur, start_address, &io, IO)) {
- io = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ io = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!io) {
kfree (range);
err ("out of system memory\n");
return -ENOMEM;
}
- memset (io, 0, sizeof (struct resource_node));
io->type = IO;
io->busno = bus_cur->busno;
io->devfunc = ((device << 3) | (function & 0x7));
@@ -2045,12 +2038,11 @@ static int __init update_bridge_ranges (struct bus_node **bus)
if ((start_address) && (start_address <= end_address)) {
- range = kmalloc (sizeof (struct range_node), GFP_KERNEL);
+ range = kzalloc(sizeof(struct range_node), GFP_KERNEL);
if (!range) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (range, 0, sizeof (struct range_node));
range->start = start_address;
range->end = end_address + 0xfffff;
@@ -2072,13 +2064,12 @@ static int __init update_bridge_ranges (struct bus_node **bus)
fix_resources (bus_sec);
if (ibmphp_find_resource (bus_cur, start_address, &mem, MEM)) {
- mem = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ mem = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!mem) {
kfree (range);
err ("out of system memory\n");
return -ENOMEM;
}
- memset (mem, 0, sizeof (struct resource_node));
mem->type = MEM;
mem->busno = bus_cur->busno;
mem->devfunc = ((device << 3) | (function & 0x7));
@@ -2101,12 +2092,11 @@ static int __init update_bridge_ranges (struct bus_node **bus)
if ((start_address) && (start_address <= end_address)) {
- range = kmalloc (sizeof (struct range_node), GFP_KERNEL);
+ range = kzalloc(sizeof(struct range_node), GFP_KERNEL);
if (!range) {
err ("out of system memory\n");
return -ENOMEM;
}
- memset (range, 0, sizeof (struct range_node));
range->start = start_address;
range->end = end_address + 0xfffff;
@@ -2127,13 +2117,12 @@ static int __init update_bridge_ranges (struct bus_node **bus)
fix_resources (bus_sec);
if (ibmphp_find_resource (bus_cur, start_address, &pfmem, PFMEM)) {
- pfmem = kmalloc (sizeof (struct resource_node), GFP_KERNEL);
+ pfmem = kzalloc(sizeof(struct resource_node), GFP_KERNEL);
if (!pfmem) {
kfree (range);
err ("out of system memory\n");
return -ENOMEM;
}
- memset (pfmem, 0, sizeof (struct resource_node));
pfmem->type = PFMEM;
pfmem->busno = bus_cur->busno;
pfmem->devfunc = ((device << 3) | (function & 0x7));
diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
index 1e8506e0fd8..601cf9045b2 100644
--- a/drivers/pci/hotplug/pciehp_core.c
+++ b/drivers/pci/hotplug/pciehp_core.c
@@ -117,27 +117,23 @@ static int init_slots(struct controller *ctrl)
slot_number = ctrl->first_slot;
while (number_of_slots) {
- slot = kmalloc(sizeof(*slot), GFP_KERNEL);
+ slot = kzalloc(sizeof(*slot), GFP_KERNEL);
if (!slot)
goto error;
- memset(slot, 0, sizeof(struct slot));
slot->hotplug_slot =
- kmalloc(sizeof(*(slot->hotplug_slot)),
+ kzalloc(sizeof(*(slot->hotplug_slot)),
GFP_KERNEL);
if (!slot->hotplug_slot)
goto error_slot;
hotplug_slot = slot->hotplug_slot;
- memset(hotplug_slot, 0, sizeof(struct hotplug_slot));
hotplug_slot->info =
- kmalloc(sizeof(*(hotplug_slot->info)),
+ kzalloc(sizeof(*(hotplug_slot->info)),
GFP_KERNEL);
if (!hotplug_slot->info)
goto error_hpslot;
hotplug_slot_info = hotplug_slot->info;
- memset(hotplug_slot_info, 0,
- sizeof(struct hotplug_slot_info));
hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
if (!hotplug_slot->name)
goto error_info;
@@ -373,12 +369,11 @@ static int pciehp_probe(struct pcie_device *dev, const struct pcie_port_service_
u8 value;
struct pci_dev *pdev;
- ctrl = kmalloc(sizeof(*ctrl), GFP_KERNEL);
+ ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL);
if (!ctrl) {
err("%s : out of memory\n", __FUNCTION__);
goto err_out_none;
}
- memset(ctrl, 0, sizeof(struct controller));
pdev = dev->port;
ctrl->pci_dev = pdev;
diff --git a/drivers/pci/hotplug/rpaphp_slot.c b/drivers/pci/hotplug/rpaphp_slot.c
index 78943e064b5..b771196a654 100644
--- a/drivers/pci/hotplug/rpaphp_slot.c
+++ b/drivers/pci/hotplug/rpaphp_slot.c
@@ -84,19 +84,16 @@ struct slot *alloc_slot_struct(struct device_node *dn, int drc_index, char *drc_
{
struct slot *slot;
- slot = kmalloc(sizeof (struct slot), GFP_KERNEL);
+ slot = kzalloc(sizeof(struct slot), GFP_KERNEL);
if (!slot)
goto error_nomem;
- memset(slot, 0, sizeof (struct slot));
- slot->hotplug_slot = kmalloc(sizeof (struct hotplug_slot), GFP_KERNEL);
+ slot->hotplug_slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
if (!slot->hotplug_slot)
goto error_slot;
- memset(slot->hotplug_slot, 0, sizeof (struct hotplug_slot));
- slot->hotplug_slot->info = kmalloc(sizeof (struct hotplug_slot_info),
+ slot->hotplug_slot->info = kzalloc(sizeof(struct hotplug_slot_info),
GFP_KERNEL);
if (!slot->hotplug_slot->info)
goto error_hpslot;
- memset(slot->hotplug_slot->info, 0, sizeof (struct hotplug_slot_info));
slot->hotplug_slot->name = kmalloc(BUS_ID_SIZE + 1, GFP_KERNEL);
if (!slot->hotplug_slot->name)
goto error_info;