From 869b2ffac0bec8c981844cdbe3a065c927f25c1e Mon Sep 17 00:00:00 2001 From: Matias Israelson <57065102+israpps@users.noreply.github.com> Date: Wed, 6 Nov 2024 12:27:23 -0300 Subject: [PATCH] use generic function for unsuported IOP device OPS since ps2dev/ps2sdk/pull/625 was merged This streamlines the unsuported operations by using the same function and also by returning always the same value: `ENOTSUP` --- modules/debug/ps2link/net_fsys.c | 32 +++++++++------- modules/debug/udptty-ingame/udptty.c | 30 ++++++--------- modules/hdd/xhdd/xhdd.c | 49 +++++++++++-------------- modules/iopcore/cdvdman/dev9.c | 48 ++++++++++++------------ modules/iopcore/imgdrv/imgdrv.c | 23 +++++------- modules/isofs/isofs.c | 43 ++++++++++------------ modules/vmc/genvmc/genvmc.c | 55 ++++++++++++---------------- 7 files changed, 129 insertions(+), 151 deletions(-) diff --git a/modules/debug/ps2link/net_fsys.c b/modules/debug/ps2link/net_fsys.c index 4fcc6c15b..93fcf16a2 100644 --- a/modules/debug/ps2link/net_fsys.c +++ b/modules/debug/ps2link/net_fsys.c @@ -49,13 +49,6 @@ static int fsys_sema; static int fsys_pid = 0; // static iop_device_t fsys_driver; -//////////////////////////////////////////////////////////////////////// -static int dummy5() -{ - printf("dummy function called\n"); - return -5; -} - //////////////////////////////////////////////////////////////////////// static void fsysInit(iop_device_t *driver) { @@ -303,12 +296,25 @@ static int fsysDclose(int fd) return ret; } -iop_device_ops_t fsys_functarray = {(void *)fsysInit, (void *)fsysDestroy, (void *)dummy5, - (void *)fsysOpen, (void *)fsysClose, (void *)fsysRead, - (void *)fsysWrite, (void *)fsysLseek, (void *)dummy5, - (void *)fsysRemove, (void *)fsysMkdir, (void *)fsysRmdir, - (void *)fsysDopen, (void *)fsysDclose, (void *)fsysDread, - (void *)dummy5, (void *)dummy5}; +iop_device_ops_t fsys_functarray = { + (void *)fsysInit, + (void *)fsysDestroy, + NOT_SUPPORTED, + (void *)fsysOpen, + (void *)fsysClose, + (void *)fsysRead, + (void *)fsysWrite, + (void *)fsysLseek, + NOT_SUPPORTED, + (void *)fsysRemove, + (void *)fsysMkdir, + (void *)fsysRmdir, + (void *)fsysDopen, + (void *)fsysDclose, + (void *)fsysDread, + NOT_SUPPORTED, + NOT_SUPPORTED, +}; iop_device_t fsys_driver = {fsname, 16, 1, "fsys driver", &fsys_functarray}; diff --git a/modules/debug/udptty-ingame/udptty.c b/modules/debug/udptty-ingame/udptty.c index 59b285613..380f2ea0c 100644 --- a/modules/debug/udptty-ingame/udptty.c +++ b/modules/debug/udptty-ingame/udptty.c @@ -41,27 +41,26 @@ static int tty_init(iop_device_t *device); static int tty_deinit(iop_device_t *device); static int tty_stdout_fd(void); static int tty_write(iop_file_t *file, void *buf, size_t size); -static int tty_error(void); /* device ops */ static iop_device_ops_t tty_ops = { tty_init, tty_deinit, - (void *)tty_error, + NOT_SUPPORTED, (void *)tty_stdout_fd, (void *)tty_stdout_fd, - (void *)tty_error, + NOT_SUPPORTED, (void *)tty_write, - (void *)tty_error, - (void *)tty_error, - (void *)tty_error, - (void *)tty_error, - (void *)tty_error, - (void *)tty_error, - (void *)tty_error, - (void *)tty_error, - (void *)tty_error, - (void *)tty_error}; + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED}; /* device descriptor */ static iop_device_t tty_device = { @@ -266,8 +265,3 @@ static int tty_write(iop_file_t *file, void *buf, size_t size) return res; } - -static int tty_error(void) -{ - return -EIO; -} diff --git a/modules/hdd/xhdd/xhdd.c b/modules/hdd/xhdd/xhdd.c index 5f3e48a26..e0d4324fb 100644 --- a/modules/hdd/xhdd/xhdd.c +++ b/modules/hdd/xhdd/xhdd.c @@ -18,11 +18,6 @@ static int xhddInit(iop_device_t *device) return 0; } -static int xhddUnsupported(void) -{ - return -1; -} - static int xhddDevctl(iop_file_t *fd, const char *name, int cmd, void *arg, unsigned int arglen, void *buf, unsigned int buflen) { ata_devinfo_t *devinfo; @@ -45,28 +40,28 @@ static int xhddDevctl(iop_file_t *fd, const char *name, int cmd, void *arg, unsi static iop_device_ops_t xhdd_ops = { &xhddInit, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, - (void *)&xhddUnsupported, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, &xhddDevctl, }; diff --git a/modules/iopcore/cdvdman/dev9.c b/modules/iopcore/cdvdman/dev9.c index 4bcd75fbb..2c12cf71a 100644 --- a/modules/iopcore/cdvdman/dev9.c +++ b/modules/iopcore/cdvdman/dev9.c @@ -81,7 +81,6 @@ static int pcmcia_init(void); static void expbay_set_stat(int stat); static int expbay_init(void); -static int dev9x_dummy(void) { return 0; } static int dev9x_devctl(iop_file_t *f, const char *name, int cmd, void *args, int arglen, void *buf, int buflen) { switch (cmd) { @@ -98,31 +97,32 @@ static int dev9x_devctl(iop_file_t *f, const char *name, int cmd, void *args, in /* driver ops func tab */ static iop_device_ops_t dev9x_ops = { - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, - (void *)dev9x_dummy, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, (void *)dev9x_devctl}; + /* driver descriptor */ static iop_device_t dev9x_dev = { "dev9x", diff --git a/modules/iopcore/imgdrv/imgdrv.c b/modules/iopcore/imgdrv/imgdrv.c index a51880da0..ba656490f 100644 --- a/modules/iopcore/imgdrv/imgdrv.c +++ b/modules/iopcore/imgdrv/imgdrv.c @@ -10,11 +10,6 @@ unsigned int ioprpimg = 0xDEC1DEC1; int ioprpsiz = 0xDEC2DEC2; const char name[] = "host"; -int dummy_fs() -{ - return 0; -} - int lseek_fs(iop_file_t *fd, int offset, int whence) { if (whence == SEEK_END) { @@ -59,15 +54,15 @@ typedef struct _iop_device_ops_tm iop_device_ops_t my_device_ops = { - dummy_fs, // init - dummy_fs, // deinit - NULL, // dummy_fs,// format - dummy_fs, // open_fs,// open - close_fs, // close - read_fs, // read - NULL, // dummy_fs,// write - lseek_fs, // lseek - /* + NOT_SUPPORTED, // init + NOT_SUPPORTED, // deinit + NOT_SUPPORTED, // format + NOT_SUPPORTED, // open + NOT_SUPPORTED, // close + NOT_SUPPORTED, // read + NOT_SUPPORTED, // write + NOT_SUPPORTED, // lseek + /* dummy_fs, // ioctl dummy_fs, // remove dummy_fs, // mkdir diff --git a/modules/isofs/isofs.c b/modules/isofs/isofs.c index df8c2ea73..fa5ebaf7c 100644 --- a/modules/isofs/isofs.c +++ b/modules/isofs/isofs.c @@ -67,11 +67,6 @@ struct MountData static struct MountData MountPoint; static unsigned char cdvdman_buf[2048]; -static int IsofsUnsupported(void) -{ - return -1; -} - static int IsofsInit(iop_device_t *device) { iop_sema_t SemaData; @@ -603,31 +598,31 @@ static int IsofsUmount(iop_file_t *f, const char *fsname) static iop_device_ops_t IsofsDeviceOps = { &IsofsInit, &IsofsDeinit, - (void *)&IsofsUnsupported, + NOT_SUPPORTED, &IsofsOpen, &IsofsClose, &IsofsRead, - (void *)&IsofsUnsupported, + NOT_SUPPORTED, &IsofsLseek, - (void *)&IsofsUnsupported, - (void *)&IsofsUnsupported, - (void *)&IsofsUnsupported, - (void *)&IsofsUnsupported, - (void *)&IsofsUnsupported, - (void *)&IsofsUnsupported, - (void *)&IsofsUnsupported, - (void *)&IsofsUnsupported, - (void *)&IsofsUnsupported, - (void *)&IsofsUnsupported, - (void *)&IsofsUnsupported, - (void *)&IsofsUnsupported, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, &IsofsMount, &IsofsUmount, - (void *)&IsofsUnsupported, - (void *)&IsofsUnsupported, - (void *)&IsofsUnsupported, - (void *)&IsofsUnsupported, - (void *)&IsofsUnsupported}; + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED}; static iop_device_t IsofsDevice = { "iso", diff --git a/modules/vmc/genvmc/genvmc.c b/modules/vmc/genvmc/genvmc.c index 4b74a2319..0b1e49d5d 100644 --- a/modules/vmc/genvmc/genvmc.c +++ b/modules/vmc/genvmc/genvmc.c @@ -32,7 +32,6 @@ IRX_ID(MODNAME, 1, 1); // driver ops protypes -static int genvmc_dummy(void); static int genvmc_init(iop_device_t *dev); static int genvmc_deinit(iop_device_t *dev); static int genvmc_devctl(iop_file_t *f, const char *name, int cmd, void *args, unsigned int arglen, void *buf, unsigned int buflen); @@ -41,31 +40,31 @@ static int genvmc_devctl(iop_file_t *f, const char *name, int cmd, void *args, u static iop_device_ops_t genvmc_ops = { &genvmc_init, &genvmc_deinit, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED, &genvmc_devctl, - (void *)genvmc_dummy, - (void *)genvmc_dummy, - (void *)genvmc_dummy}; + NOT_SUPPORTED, + NOT_SUPPORTED, + NOT_SUPPORTED}; // driver descriptor static iop_device_t genvmc_dev = { @@ -523,12 +522,6 @@ static int vmc_mcformat(char *filename, int size_kb, int blocksize, int *progres return r; } -//-------------------------------------------------------------- -static int genvmc_dummy(void) -{ - return -EPERM; -} - //-------------------------------------------------------------- static int genvmc_init(iop_device_t *dev) {