]> www.infradead.org Git - users/sagi/nvme-cli.git/commit
tree: Combine NVMe file descriptor into struct nvme_dev
authorJeremy Kerr <jk@codeconstruct.com.au>
Tue, 12 Jul 2022 06:55:34 +0000 (14:55 +0800)
committerDaniel Wagner <dwagner@suse.de>
Fri, 12 Aug 2022 06:50:51 +0000 (08:50 +0200)
commit11542bbdb1c1ad7b1f425925ce474c7ce06162d0
tree903b9d78947a85b64fa16c25d9bbf42a29fe9b2f
parentbd9af05822391753de43f0bf7ce4a45e07367aec
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>
21 files changed:
nvme-rpmb.c
nvme.c
nvme.h
plugins/dera/dera-nvme.c
plugins/innogrit/innogrit-nvme.c
plugins/intel/intel-nvme.c
plugins/memblaze/memblaze-nvme.c
plugins/micron/micron-nvme.c
plugins/ocp/ocp-nvme.c
plugins/scaleflux/sfx-nvme.c
plugins/seagate/seagate-nvme.c
plugins/shannon/shannon-nvme.c
plugins/solidigm/solidigm-garbage-collection.c
plugins/solidigm/solidigm-latency-tracking.c
plugins/solidigm/solidigm-smart.c
plugins/toshiba/toshiba-nvme.c
plugins/transcend/transcend-nvme.c
plugins/virtium/virtium-nvme.c
plugins/wdc/wdc-nvme.c
plugins/ymtc/ymtc-nvme.c
plugins/zns/zns.c