Commit 161e81d9 authored by Alessandro Rubini's avatar Alessandro Rubini

dev/devicelist: use a simple vendor-id selection code

This is the simpler thing: have vendor ID in the data structure.

We have 100 bytes more of data, but we save 50 bytes of code.  Total:
50 more but with simpler code (not bound to cern and gsi, thus
reusable).

Please maintainer choose and squash.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 079b7847
...@@ -56,33 +56,21 @@ void sdb_print_devices(void) ...@@ -56,33 +56,21 @@ void sdb_print_devices(void)
#define VID_CERN 0x0000ce42LL #define VID_CERN 0x0000ce42LL
#define VID_GSI 0x00000651LL #define VID_GSI 0x00000651LL
enum {
VID_IS_CERN,
VID_IS_GSI
};
static int vendors[] = {
[VID_IS_CERN] = VID_CERN,
[VID_IS_GSI] = VID_GSI,
};
struct wrc_device { struct wrc_device {
unsigned char **base; unsigned char **base;
int vendor; uint64_t vid;
uint32_t did; uint32_t did;
}; };
static uint64_t vid
struct wrc_device devs[] = { struct wrc_device devs[] = {
{&BASE_MINIC, VID_IS_CERN, 0xab28633a}, {&BASE_MINIC, VID_CERN, 0xab28633a},
{&BASE_EP, VID_IS_CERN, 0x650c2d4f}, {&BASE_EP, VID_CERN, 0x650c2d4f},
{&BASE_SOFTPLL, VID_IS_CERN, 0x65158dc0}, {&BASE_SOFTPLL, VID_CERN, 0x65158dc0},
{&BASE_PPS_GEN, VID_IS_CERN, 0xde0d8ced}, {&BASE_PPS_GEN, VID_CERN, 0xde0d8ced},
{&BASE_SYSCON, VID_IS_CERN, 0xff07fc47}, {&BASE_SYSCON, VID_CERN, 0xff07fc47},
{&BASE_UART, VID_IS_CERN, 0xe2d13d04}, {&BASE_UART, VID_CERN, 0xe2d13d04},
{&BASE_ONEWIRE, VID_IS_CERN, 0x779c5443}, {&BASE_ONEWIRE, VID_CERN, 0x779c5443},
{&BASE_ETHERBONE_CFG, VID_IS_GSI, 0x68202b22}, {&BASE_ETHERBONE_CFG, VID_GSI, 0x68202b22},
}; };
void sdb_find_devices(void) void sdb_find_devices(void)
...@@ -97,6 +85,6 @@ void sdb_find_devices(void) ...@@ -97,6 +85,6 @@ void sdb_find_devices(void)
} }
for (d = devs, i = 0; i < ARRAY_SIZE(devs); d++, i++) { for (d = devs, i = 0; i < ARRAY_SIZE(devs); d++, i++) {
*(d->base) = (void *)sdbfs_find_id(&wrc_fpga_sdb, *(d->base) = (void *)sdbfs_find_id(&wrc_fpga_sdb,
vnedirs[d->vendor], d->did); d->vid, d->did);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment