From: Marc Rittinghaus Date: Thu, 20 Apr 2023 14:47:45 +0000 (+0200) Subject: lib/devfs: Remove unused fields and functions X-Git-Tag: RELEASE-0.13.0~109 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c1e0d66cdde80d53091180f083656f87b5d6f947;p=unikraft%2Funikraft.git lib/devfs: Remove unused fields and functions The definition for device objects contain numerous fields which are not used. In addition, there are various function definitions and declarations which are not used or not even related to generic devices (e.g., partition table). This commit removes all of these definitions. Signed-off-by: Marc Rittinghaus Reviewed-by: Razvan Deaconescu Approved-by: Razvan Deaconescu Tested-by: Unikraft CI GitHub-Closes: #855 --- diff --git a/lib/devfs/device.c b/lib/devfs/device.c index 9cc3c52a3..47826e494 100644 --- a/lib/devfs/device.c +++ b/lib/devfs/device.c @@ -78,20 +78,6 @@ device_lookup(const char *name) return NULL; } -struct partition_table_entry { - uint8_t bootable; - uint8_t starting_head; - uint16_t starting_sector:6; - uint16_t starting_cylinder:10; - uint8_t system_id; - uint8_t ending_head; - uint16_t ending_sector:6; - uint16_t ending_cylinder:10; - uint32_t rela_sector; - uint32_t total_sectors; -} __packed; - - void device_register(struct device *dev, const char *name, int flags) { size_t len; @@ -123,10 +109,8 @@ void device_register(struct device *dev, const char *name, int flags) dev->flags = flags; dev->active = 1; dev->refcnt = 1; - dev->offset = 0; dev->private_data = priv; dev->next = device_list; - dev->max_io_size = UINT_MAX; device_list = dev; uk_mutex_unlock(&devfs_lock); diff --git a/lib/devfs/include/devfs/device.h b/lib/devfs/include/devfs/device.h index 376576bd9..22a47b443 100644 --- a/lib/devfs/include/devfs/device.h +++ b/lib/devfs/include/devfs/device.h @@ -46,7 +46,7 @@ struct device; * Device information */ struct devinfo { - unsigned long cookie; /* index cookie */ + unsigned long cookie; /* index cookie */ struct device *id; /* device id */ int flags; /* device characteristics flags */ char name[MAXDEVNAME]; /* device name */ @@ -91,20 +91,6 @@ struct driver { int flags; /* state of driver */ }; -/* - * flags for the driver. - */ - -typedef enum device_state { - DS_INACTIVE = 0x00, /* driver is inactive */ - DS_ALIVE = 0x01, /* probe succeded */ - DS_ACTIVE = 0x02, /* intialized */ - DS_DEBUG = 0x04, /* debug */ - DS_NOTPRESENT = 0x08, /* not probed or probe failed */ - DS_ATTACHING = 0x10, /* currently attaching */ - DS_ATTACHED = 0x20, /*attach method called */ -} device_state_t; - /* * Device object */ @@ -115,71 +101,9 @@ struct device { int flags; /* D_* flags defined above */ int active; /* device has not been destroyed */ int refcnt; /* reference count */ - off_t size; /* device size */ - off_t offset; /* 0 for the main drive, if we have a - * partition, this is the start address - */ - size_t max_io_size; void *private_data; /* private storage */ - - void *softc; - void *ivars; - device_state_t state; - const char *desc; - int unit; - int irq; - int vector; }; -typedef struct device *device_t; - -static inline int -device_set_unit(device_t dev, int unit) -{ - dev->unit = unit; - return 0; -} - -static inline int -device_get_unit(device_t dev) -{ - return dev->unit; -} - -static inline const char * -device_get_desc(device_t dev) -{ - return dev->desc; -} - -static inline void -device_set_desc(device_t dev, const char *desc) -{ - dev->desc = desc; -} - -static inline void -device_set_softc(device_t dev, void *softc) -{ - dev->softc = softc; -} - -static inline void * -device_get_softc(device_t dev) -{ - return dev->softc; -} - -static inline void device_quiet(device_t dev __unused) -{ -} - -static inline const char * -devtoname(struct device *dev) -{ - return dev->name; -} - int device_open(const char *name, int mode, struct device **devp); int device_close(struct device *dev); int device_read(struct device *dev, struct uio *uio, int ioflags); @@ -187,17 +111,11 @@ int device_write(struct device *dev, struct uio *uio, int ioflags); int device_ioctl(struct device *dev, unsigned long cmd, void *arg); int device_info(struct devinfo *info); -int bdev_read(struct device *dev, struct uio *uio, int ioflags); -int bdev_write(struct device *dev, struct uio *uio, int ioflags); - int devop_noop(); int devop_eperm(); struct device *device_create(struct driver *drv, const char *name, int flags); int device_destroy(struct device *dev); -int device_destroy_locked(struct device *dev); -void device_register(struct device *device, const char *name, int flags); -void read_partition_table(struct device *device); /* * Ideally, any dev node registration should happen before we mount devfs.