Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5afe806 authored by Eric Sesterhenn's avatar Eric Sesterhenn Committed by Greg Kroah-Hartman
Browse files

[PATCH] PCI: kzalloc() conversion in drivers/pci



this patch converts drivers/pci to kzalloc usage.
Compile tested with allyes config.

Signed-off-by: default avatarEric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7c8f25da
Loading
Loading
Loading
Loading
+4 −10
Original line number Original line Diff line number Diff line
@@ -143,10 +143,9 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
	device = (adr >> 16) & 0xffff;
	device = (adr >> 16) & 0xffff;
	function = adr & 0xffff;
	function = adr & 0xffff;


	newfunc = kmalloc(sizeof(struct acpiphp_func), GFP_KERNEL);
	newfunc = kzalloc(sizeof(struct acpiphp_func), GFP_KERNEL);
	if (!newfunc)
	if (!newfunc)
		return AE_NO_MEMORY;
		return AE_NO_MEMORY;
	memset(newfunc, 0, sizeof(struct acpiphp_func));


	INIT_LIST_HEAD(&newfunc->sibling);
	INIT_LIST_HEAD(&newfunc->sibling);
	newfunc->handle = handle;
	newfunc->handle = handle;
@@ -189,13 +188,12 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv)
		}
		}


	if (!slot) {
	if (!slot) {
		slot = kmalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
		slot = kzalloc(sizeof(struct acpiphp_slot), GFP_KERNEL);
		if (!slot) {
		if (!slot) {
			kfree(newfunc);
			kfree(newfunc);
			return AE_NO_MEMORY;
			return AE_NO_MEMORY;
		}
		}


		memset(slot, 0, sizeof(struct acpiphp_slot));
		slot->bridge = bridge;
		slot->bridge = bridge;
		slot->device = device;
		slot->device = device;
		slot->sun = sun;
		slot->sun = sun;
@@ -376,12 +374,10 @@ static void add_host_bridge(acpi_handle *handle, struct pci_bus *pci_bus)
{
{
	struct acpiphp_bridge *bridge;
	struct acpiphp_bridge *bridge;


	bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
	bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
	if (bridge == NULL)
	if (bridge == NULL)
		return;
		return;


	memset(bridge, 0, sizeof(struct acpiphp_bridge));

	bridge->type = BRIDGE_TYPE_HOST;
	bridge->type = BRIDGE_TYPE_HOST;
	bridge->handle = handle;
	bridge->handle = handle;


@@ -398,14 +394,12 @@ static void add_p2p_bridge(acpi_handle *handle, struct pci_dev *pci_dev)
{
{
	struct acpiphp_bridge *bridge;
	struct acpiphp_bridge *bridge;


	bridge = kmalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
	bridge = kzalloc(sizeof(struct acpiphp_bridge), GFP_KERNEL);
	if (bridge == NULL) {
	if (bridge == NULL) {
		err("out of memory\n");
		err("out of memory\n");
		return;
		return;
	}
	}


	memset(bridge, 0, sizeof(struct acpiphp_bridge));

	bridge->type = BRIDGE_TYPE_P2P;
	bridge->type = BRIDGE_TYPE_P2P;
	bridge->handle = handle;
	bridge->handle = handle;


+3 −6
Original line number Original line Diff line number Diff line
@@ -248,22 +248,19 @@ cpci_hp_register_bus(struct pci_bus *bus, u8 first, u8 last)
	 * with the pci_hotplug subsystem.
	 * with the pci_hotplug subsystem.
	 */
	 */
	for (i = first; i <= last; ++i) {
	for (i = first; i <= last; ++i) {
		slot = kmalloc(sizeof (struct slot), GFP_KERNEL);
		slot = kzalloc(sizeof (struct slot), GFP_KERNEL);
		if (!slot)
		if (!slot)
			goto error;
			goto error;
		memset(slot, 0, sizeof (struct slot));


		hotplug_slot =
		hotplug_slot =
		    kmalloc(sizeof (struct hotplug_slot), GFP_KERNEL);
			kzalloc(sizeof (struct hotplug_slot), GFP_KERNEL);
		if (!hotplug_slot)
		if (!hotplug_slot)
			goto error_slot;
			goto error_slot;
		memset(hotplug_slot, 0, sizeof (struct hotplug_slot));
		slot->hotplug_slot = 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)
		if (!info)
			goto error_hpslot;
			goto error_hpslot;
		memset(info, 0, sizeof (struct hotplug_slot_info));
		hotplug_slot->info = info;
		hotplug_slot->info = info;


		name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
		name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);
+4 −9
Original line number Original line Diff line number Diff line
@@ -347,26 +347,22 @@ static int ctrl_slot_setup(struct controller *ctrl,
	slot_number = ctrl->first_slot;
	slot_number = ctrl->first_slot;


	while (number_of_slots) {
	while (number_of_slots) {
		slot = kmalloc(sizeof(*slot), GFP_KERNEL);
		slot = kzalloc(sizeof(*slot), GFP_KERNEL);
		if (!slot)
		if (!slot)
			goto error;
			goto error;


		memset(slot, 0, sizeof(struct slot));
		slot->hotplug_slot = kzalloc(sizeof(*(slot->hotplug_slot)),
		slot->hotplug_slot = kmalloc(sizeof(*(slot->hotplug_slot)),
						GFP_KERNEL);
						GFP_KERNEL);
		if (!slot->hotplug_slot)
		if (!slot->hotplug_slot)
			goto error_slot;
			goto error_slot;
		hotplug_slot = slot->hotplug_slot;
		hotplug_slot = slot->hotplug_slot;
		memset(hotplug_slot, 0, sizeof(struct hotplug_slot));


		hotplug_slot->info =
		hotplug_slot->info =
				kmalloc(sizeof(*(hotplug_slot->info)),
				kzalloc(sizeof(*(hotplug_slot->info)),
							GFP_KERNEL);
							GFP_KERNEL);
		if (!hotplug_slot->info)
		if (!hotplug_slot->info)
			goto error_hpslot;
			goto error_hpslot;
		hotplug_slot_info = hotplug_slot->info;
		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);
		hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL);


		if (!hotplug_slot->name)
		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;
			goto err_disable_device;
		}
		}


		ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL);
		ctrl = kzalloc(sizeof(struct controller), GFP_KERNEL);
		if (!ctrl) {
		if (!ctrl) {
			err("%s : out of memory\n", __FUNCTION__);
			err("%s : out of memory\n", __FUNCTION__);
			rc = -ENOMEM;
			rc = -ENOMEM;
			goto err_disable_device;
			goto err_disable_device;
		}
		}
		memset(ctrl, 0, sizeof(struct controller));


		rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsystem_deviceid);
		rc = pci_read_config_word(pdev, PCI_SUBSYSTEM_ID, &subsystem_deviceid);
		if (rc) {
		if (rc) {
+3 −6
Original line number Original line Diff line number Diff line
@@ -95,15 +95,13 @@ static int add_slot(struct pci_dev *dev)
	struct hotplug_slot *slot;
	struct hotplug_slot *slot;
	int retval = -ENOMEM;
	int retval = -ENOMEM;


	slot = kmalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
	slot = kzalloc(sizeof(struct hotplug_slot), GFP_KERNEL);
	if (!slot)
	if (!slot)
		goto error;
		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)
	if (!slot->info)
		goto error_slot;
		goto error_slot;
	memset(slot->info, 0, sizeof(struct hotplug_slot_info));


	slot->info->power_status = 1;
	slot->info->power_status = 1;
	slot->info->max_bus_speed = PCI_SPEED_UNKNOWN;
	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;
	unsigned int devfn;
	struct pci_dev *dev;
	struct pci_dev *dev;
	dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL);
	dev = kzalloc(sizeof(struct pci_dev), GFP_KERNEL);
	if (!dev)
	if (!dev)
		return;
		return;


	memset(dev, 0, sizeof(dev));
	dev->bus = (struct pci_bus*)bus;
	dev->bus = (struct pci_bus*)bus;
	dev->sysdata = bus->sysdata;
	dev->sysdata = bus->sysdata;
	for (devfn = 0; devfn < 0x100; devfn += 8) {
	for (devfn = 0; devfn < 0x100; devfn += 8) {
+2 −4
Original line number Original line Diff line number Diff line
@@ -1141,7 +1141,7 @@ static int enable_slot(struct hotplug_slot *hs)
		goto error_power;
		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) {
	if (!slot_cur->func) {
		/* We cannot do update_slot_info here, since no memory for
		/* We cannot do update_slot_info here, since no memory for
		 * kmalloc n.e.ways, and update_slot_info allocates some */
		 * kmalloc n.e.ways, and update_slot_info allocates some */
@@ -1149,7 +1149,6 @@ static int enable_slot(struct hotplug_slot *hs)
		rc = -ENOMEM;
		rc = -ENOMEM;
		goto error_power;
		goto error_power;
	}
	}
	memset(slot_cur->func, 0, sizeof(struct pci_func));
	slot_cur->func->busno = slot_cur->bus;
	slot_cur->func->busno = slot_cur->bus;
	slot_cur->func->device = slot_cur->device;
	slot_cur->func->device = slot_cur->device;
	for (i = 0; i < 4; i++)
	for (i = 0; i < 4; i++)
@@ -1252,13 +1251,12 @@ int ibmphp_do_disable_slot(struct slot *slot_cur)


	if (slot_cur->func == NULL) {
	if (slot_cur->func == NULL) {
		/* We need this for fncs's that were there on bootup */
		/* 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) {
		if (!slot_cur->func) {
			err("out of system memory\n");
			err("out of system memory\n");
			rc = -ENOMEM;
			rc = -ENOMEM;
			goto error;
			goto error;
		}
		}
		memset(slot_cur->func, 0, sizeof(struct pci_func));
		slot_cur->func->busno = slot_cur->bus;
		slot_cur->func->busno = slot_cur->bus;
		slot_cur->func->device = slot_cur->device;
		slot_cur->func->device = slot_cur->device;
	}
	}
Loading