tree: Combine NVMe file descriptor into struct nvme_dev
Currently, our references to the nvme device are fragmented: we have the
device name and stat buf stored in the global nvme_dev, and then a
separate nvme device file descriptor passed between functions
This change moves the fd into the struct nvme_dev:
struct nvme_dev {
+ int fd;
struct stat stat;
const char *name;
};
and changes parse_and_open to now populate a pointer to the dev on
successful return. Callers can now access the fd through dev->fd,
unifying this with the name and statbuf.
[At the moment, this just uses the global nvme_dev variable, but we'll
make that neater in a future change]
There are a large number of functions that use the fd directly, hence
the size of this patch. I've attempted to make this as atomic as
possible, but there are some call sites which warrant some reformatting
as we go here.
There may be some future opportunities to pass around the struct
nvme_dev * rather than the fd, but this change just implements the
minimal change to group our nvme device into the one struct.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>