summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-09-25 08:56:06 -0600
committerBin Meng <bmeng.cn@gmail.com>2019-10-08 13:57:40 +0800
commit37a1cf9c9c4c670e074feb8fb2fc6b4a40a80b1b (patch)
tree3424513b1fc8f6a8864b5ceaa5e075dde0222510 /drivers
parentfae2c16ede7bf00c8f7873a96fc2b34d5345d751 (diff)
sandbox: pci: Move pci_offset_to_barnum() to pci.h
This function is useful in PCI emulators. More it into the header file to avoid duplicating it in other drivers. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/misc/swap_case.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/misc/swap_case.c b/drivers/misc/swap_case.c
index 18d756e9cd..75fe641670 100644
--- a/drivers/misc/swap_case.c
+++ b/drivers/misc/swap_case.c
@@ -24,9 +24,6 @@ struct swap_case_platdata {
u32 bar[6];
};
-#define offset_to_barnum(offset) \
- (((offset) - PCI_BASE_ADDRESS_0) / sizeof(u32))
-
enum {
MEM_TEXT_SIZE = 0x100,
};
@@ -144,7 +141,7 @@ static int sandbox_swap_case_read_config(struct udevice *emul, uint offset,
int barnum;
u32 *bar, result;
- barnum = offset_to_barnum(offset);
+ barnum = pci_offset_to_barnum(offset);
bar = &plat->bar[barnum];
result = *bar;
@@ -224,7 +221,7 @@ static int sandbox_swap_case_write_config(struct udevice *emul, uint offset,
int barnum;
u32 *bar;
- barnum = offset_to_barnum(offset);
+ barnum = pci_offset_to_barnum(offset);
bar = &plat->bar[barnum];
debug("w bar %d=%lx\n", barnum, value);