Commit 11fdcf05 authored by Krzysztof Wilczynski's avatar Krzysztof Wilczynski Committed by Bjorn Helgaas
Browse files

pcmcia: Use CardBus window names (PCI_CB_BRIDGE_IO_0_WINDOW etc) when freeing

Remove the loop used to free CardBus resources and replace it with
a yenta_free_res() helper used to release bridge resources explicitly.

Link: https://lore.kernel.org/r/20200520183411.1534621-3-kw@linux.com


Signed-off-by: default avatarKrzysztof Wilczynski <kw@linux.com>
Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Acked-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent 6e0688db
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -745,6 +745,18 @@ static int yenta_allocate_res(struct yenta_socket *socket, int nr, unsigned type
	return 0;
}

static void yenta_free_res(struct yenta_socket *socket, int nr)
{
	struct pci_dev *dev = socket->dev;
	struct resource *res;

	res = &dev->resource[nr];
	if (res->start != 0 && res->end != 0)
		release_resource(res);

	res->start = res->end = res->flags = 0;
}

/*
 * Allocate the bridge mappings for the device..
 */
@@ -773,14 +785,10 @@ static void yenta_allocate_resources(struct yenta_socket *socket)
 */
static void yenta_free_resources(struct yenta_socket *socket)
{
	int i;
	for (i = 0; i < 4; i++) {
		struct resource *res;
		res = socket->dev->resource + PCI_BRIDGE_RESOURCES + i;
		if (res->start != 0 && res->end != 0)
			release_resource(res);
		res->start = res->end = res->flags = 0;
	}
	yenta_free_res(socket, PCI_CB_BRIDGE_IO_0_WINDOW);
	yenta_free_res(socket, PCI_CB_BRIDGE_IO_1_WINDOW);
	yenta_free_res(socket, PCI_CB_BRIDGE_MEM_0_WINDOW);
	yenta_free_res(socket, PCI_CB_BRIDGE_MEM_1_WINDOW);
}