From: Marc Rittinghaus Date: Thu, 20 Apr 2023 14:39:25 +0000 (+0200) Subject: lib/devfs: Remove unused devops X-Git-Tag: RELEASE-0.13.0~110 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=82b28da3c355c3e725878458514d6e716f792413;p=unikraft%2Funikraft.git lib/devfs: Remove unused devops This commit removes unused operations from the device operations structure and updates the no-op macros and functions to be usable for seldomly set operations (also externally). Checkpatch-Ignore: FUNCTION_WITHOUT_ARGS Checkpatch-Ignore: USE_NEGATIVE_ERRNO 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 d67aee4a3..9cc3c52a3 100644 --- a/lib/devfs/device.c +++ b/lib/devfs/device.c @@ -52,6 +52,7 @@ #include #include +#include #include #include @@ -425,14 +426,13 @@ device_info(struct devinfo *info) } int -enodev(void) +devop_noop() { - return ENODEV; + return 0; } int -nullop(void) +devop_eperm() { - return 0; + return EPERM; } - diff --git a/lib/devfs/exportsyms.uk b/lib/devfs/exportsyms.uk index e5edd9052..8aacd3b7a 100644 --- a/lib/devfs/exportsyms.uk +++ b/lib/devfs/exportsyms.uk @@ -4,3 +4,6 @@ device_close device_read device_ioctl device_info + +devop_noop +devop_eperm diff --git a/lib/devfs/include/devfs/device.h b/lib/devfs/include/devfs/device.h index cec718496..376576bd9 100644 --- a/lib/devfs/include/devfs/device.h +++ b/lib/devfs/include/devfs/device.h @@ -36,12 +36,10 @@ #include #include -#include - #define MAXDEVNAME 12 #define DO_RWMASK 0x3 -struct bio; +struct uio; struct device; /* @@ -62,13 +60,11 @@ struct devinfo { #define D_REM 0x00000004 /* removable device */ #define D_TTY 0x00000010 /* tty device */ -typedef int (*devop_open_t) (struct device *, int); -typedef int (*devop_close_t) (struct device *); -typedef int (*devop_read_t) (struct device *, struct uio *, int); -typedef int (*devop_write_t) (struct device *, struct uio *, int); -typedef int (*devop_ioctl_t) (struct device *, unsigned long, void *); -typedef int (*devop_devctl_t) (struct device *, unsigned long, void *); -typedef void (*devop_strategy_t)(struct bio *); +typedef int (*devop_open_t)(struct device *, int); +typedef int (*devop_close_t)(struct device *); +typedef int (*devop_read_t)(struct device *, struct uio *, int); +typedef int (*devop_write_t)(struct device *, struct uio *, int); +typedef int (*devop_ioctl_t)(struct device *, unsigned long, void *); /* * Device operations @@ -79,17 +75,11 @@ struct devops { devop_read_t read; devop_write_t write; devop_ioctl_t ioctl; - devop_devctl_t devctl; - devop_strategy_t strategy; }; - -#define no_open ((devop_open_t)nullop) -#define no_close ((devop_close_t)nullop) -#define no_read ((devop_read_t)enodev) -#define no_write ((devop_write_t)enodev) -#define no_ioctl ((devop_ioctl_t)enodev) -#define no_devctl ((devop_devctl_t)nullop) +#define dev_noop_open ((devop_open_t)devop_noop) +#define dev_noop_close ((devop_close_t)devop_noop) +#define dev_noop_ioctl ((devop_ioctl_t)devop_eperm) /* * Driver object @@ -200,8 +190,8 @@ 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 enodev(void); -int nullop(void); +int devop_noop(); +int devop_eperm(); struct device *device_create(struct driver *drv, const char *name, int flags); int device_destroy(struct device *dev);