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

Commit 6708be93 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Lorenzo Pieralisi
Browse files

PCI: hv: Convert remove_lock to refcount



Use refcount instead of atomic for the reference counting
on bus. Refcount is safer because it handles overflow correctly.

Signed-off-by: default avatarStephen Hemminger <sthemmin@microsoft.com>
[lorenzo.pieralisi@arm.com: updated commit subject]
Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
parent 8c99e120
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -433,7 +433,7 @@ enum hv_pcibus_state {
struct hv_pcibus_device {
struct hv_pcibus_device {
	struct pci_sysdata sysdata;
	struct pci_sysdata sysdata;
	enum hv_pcibus_state state;
	enum hv_pcibus_state state;
	atomic_t remove_lock;
	refcount_t remove_lock;
	struct hv_device *hdev;
	struct hv_device *hdev;
	resource_size_t low_mmio_space;
	resource_size_t low_mmio_space;
	resource_size_t high_mmio_space;
	resource_size_t high_mmio_space;
@@ -2430,12 +2430,12 @@ static int hv_send_resources_released(struct hv_device *hdev)


static void get_hvpcibus(struct hv_pcibus_device *hbus)
static void get_hvpcibus(struct hv_pcibus_device *hbus)
{
{
	atomic_inc(&hbus->remove_lock);
	refcount_inc(&hbus->remove_lock);
}
}


static void put_hvpcibus(struct hv_pcibus_device *hbus)
static void put_hvpcibus(struct hv_pcibus_device *hbus)
{
{
	if (atomic_dec_and_test(&hbus->remove_lock))
	if (refcount_dec_and_test(&hbus->remove_lock))
		complete(&hbus->remove_event);
		complete(&hbus->remove_event);
}
}


@@ -2479,7 +2479,7 @@ static int hv_pci_probe(struct hv_device *hdev,
			       hdev->dev_instance.b[8] << 8;
			       hdev->dev_instance.b[8] << 8;


	hbus->hdev = hdev;
	hbus->hdev = hdev;
	atomic_inc(&hbus->remove_lock);
	refcount_set(&hbus->remove_lock, 1);
	INIT_LIST_HEAD(&hbus->children);
	INIT_LIST_HEAD(&hbus->children);
	INIT_LIST_HEAD(&hbus->dr_list);
	INIT_LIST_HEAD(&hbus->dr_list);
	INIT_LIST_HEAD(&hbus->resources_for_children);
	INIT_LIST_HEAD(&hbus->resources_for_children);