Skip to content

Commit

Permalink
use generic function for unsuported IOP device OPS
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
israpps committed Nov 6, 2024
1 parent 5a3ef8a commit 869b2ff
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 151 deletions.
32 changes: 19 additions & 13 deletions modules/debug/ps2link/net_fsys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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};
Expand Down
30 changes: 12 additions & 18 deletions modules/debug/udptty-ingame/udptty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
}
49 changes: 22 additions & 27 deletions modules/hdd/xhdd/xhdd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
};

Expand Down
48 changes: 24 additions & 24 deletions modules/iopcore/cdvdman/dev9.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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",
Expand Down
23 changes: 9 additions & 14 deletions modules/iopcore/imgdrv/imgdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
43 changes: 19 additions & 24 deletions modules/isofs/isofs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down
55 changes: 24 additions & 31 deletions modules/vmc/genvmc/genvmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 = {
Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit 869b2ff

Please sign in to comment.