Skip to content

Commit

Permalink
Try to use generic functions for NOT_IMPLEMENTED and DUMMY_IMPLEMENTA…
Browse files Browse the repository at this point in the history
…TION
  • Loading branch information
fjtrujy committed Nov 14, 2024
1 parent 400d8fc commit ad77943
Show file tree
Hide file tree
Showing 38 changed files with 772 additions and 1,074 deletions.
22 changes: 8 additions & 14 deletions ee/iopreboot/src/imgdrv/src/imgdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
IRX_ID(MODNAME, 1, 1);

// Function prototypes
static int imgdrv_dummy(void);
static int imgdrv_read(iop_file_t *f, void *buf, int size);
static int imgdrv_lseek(iop_file_t *f, int offset, int whence);

Expand All @@ -41,14 +40,14 @@ typedef struct _iop_device_ops_short
} iop_device_ops_short_t;

static iop_device_ops_short_t imgdrv_ops = {
(void *)&imgdrv_dummy, // init
(void *)&imgdrv_dummy, // deinit
NULL, // format
(void *)&imgdrv_dummy, // open
(void *)&imgdrv_dummy, // close
&imgdrv_read, // read
NULL, // write
&imgdrv_lseek, // lseek
DUMMY_IMPLEMENTATION, // init
DUMMY_IMPLEMENTATION, // deinit
NOT_SUPPORTED, // format
NOT_SUPPORTED, // open
NOT_SUPPORTED, // close
&imgdrv_read, // read
NOT_SUPPORTED, // write
&imgdrv_lseek, // lseek
};

#define MAX_IMAGES 2
Expand All @@ -69,11 +68,6 @@ int _start(int argc, char *argv[])
return (AddDrv(&img_device) < 0) ? MODULE_NO_RESIDENT_END : MODULE_RESIDENT_END;
}

static int imgdrv_dummy(void)
{
return 0;
}

static int imgdrv_read(iop_file_t *f, void *buf, int size)
{
int i;
Expand Down
41 changes: 18 additions & 23 deletions iop/arcade/accdvd/src/cddrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ static int cddrv_read(iop_file_t *io, void *buf, int cnt);
static int cddrv_write(iop_file_t *io, void *buf, int cnt);
static int cddrv_lseek(iop_file_t *io, int offset, int whence);
static int cddrv_ioctl(iop_file_t *io, int cmd, void *arg);
static int cddrv_dummy();

static iop_device_ops_t Cddrv_ops = {
&cddrv_adddrv,
&cddrv_deldrv,
&cddrv_dummy,
&cddrv_open,
&cddrv_close,
&cddrv_read,
&cddrv_write,
&cddrv_lseek,
&cddrv_ioctl,
&cddrv_dummy,
&cddrv_dummy,
&cddrv_dummy,
&cddrv_dummy,
&cddrv_dummy,
&cddrv_dummy,
&cddrv_dummy,
&cddrv_dummy};
&cddrv_adddrv, // init
&cddrv_deldrv, // deinit
NOT_SUPPORTED, // format
&cddrv_open, // open
&cddrv_close, // close
&cddrv_read, // read
&cddrv_write, // write
&cddrv_lseek, // lseek
&cddrv_ioctl, // ioctl
NOT_SUPPORTED, // remove
NOT_SUPPORTED, // mkdir
NOT_SUPPORTED, // rmdir
NOT_SUPPORTED, // dopen
NOT_SUPPORTED, // dclose
NOT_SUPPORTED, // dread
NOT_SUPPORTED, // getstat
NOT_SUPPORTED, // chstat
};

static iop_device_t Cddrv = {"cdrom", 16u, 0u, "ATAPI_C/DVD-ROM", &Cddrv_ops};

Expand Down Expand Up @@ -158,11 +158,6 @@ static int cddrv_ioctl(iop_file_t *io, int cmd, void *arg)
return -EINVAL;
}

static int cddrv_dummy()
{
return -EINVAL;
}

int cddrv_module_start(int argc, char **argv)
{
int v2;
Expand Down
36 changes: 17 additions & 19 deletions iop/arcade/acuart/src/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
int acUartWrite(void *buf, int count);
int acUartRead(void *buf, int count);

int dummy() {return -ENOTSUP;}

static int acuart_read(iop_file_t *f, void *buffer, int size) {
(void)f;
return acUartRead(buffer, size);
Expand All @@ -17,23 +15,23 @@ static int acuart_write(iop_file_t *f, void *buffer, int size) {
}

static iop_device_ops_t uart_ops = {
(void *)&dummy,
(void *)&dummy,
(void *)&dummy,
(void *)&dummy,
(void *)&dummy,
&acuart_read,
&acuart_write,
(void *)&dummy,
(void *)&dummy,
(void *)&dummy,
(void *)&dummy,
(void *)&dummy,
(void *)&dummy,
(void *)&dummy,
(void *)&dummy,
(void *)&dummy,
(void *)&dummy,
DUMMY_IMPLEMENTATION, // init
DUMMY_IMPLEMENTATION, // deinit
NOT_SUPPORTED, // format
NOT_SUPPORTED, // open
NOT_SUPPORTED, // close
&acuart_read, // read
&acuart_write, // write
NOT_SUPPORTED, // lseek
NOT_SUPPORTED, // ioctl
NOT_SUPPORTED, // remove
NOT_SUPPORTED, // mkdir
NOT_SUPPORTED, // rmdir
NOT_SUPPORTED, // dopen
NOT_SUPPORTED, // dclose
NOT_SUPPORTED, // dread
NOT_SUPPORTED, // getstat
NOT_SUPPORTED, // chstat
};

#define DEVNAME "tty"
Expand Down
39 changes: 17 additions & 22 deletions iop/cdvd/cdfs/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,29 +418,24 @@ static int fio_getstat(iop_file_t *fd, const char *name, io_stat_t *stat)
return ret;
}

static int cdfs_dummy() {
DPRINTF("CDFS: dummy function called\n\n");
return -EIO;
}

static iop_device_ops_t fio_ops = {
&fio_init,
&fio_deinit,
(void *)&cdfs_dummy,
&fio_open,
&fio_close,
&fio_read,
&fio_write,
&fio_lseek,
(void *)&cdfs_dummy,
(void *)&cdfs_dummy,
(void *)&cdfs_dummy,
(void *)&cdfs_dummy,
&fio_openDir,
&fio_closeDir,
&fio_dread,
&fio_getstat,
(void *)&cdfs_dummy,
&fio_init, // init
&fio_deinit, // deinit
NOT_SUPPORTED, // format
&fio_open, // open
&fio_close, // close
&fio_read, // read
&fio_write, // write
&fio_lseek, // lseek
NOT_SUPPORTED, // ioctl
NOT_SUPPORTED, // remove
NOT_SUPPORTED, // mkdir
NOT_SUPPORTED, // rmdir
&fio_openDir, // dopen
&fio_closeDir, // dclose
&fio_dread, // dread
&fio_getstat, // getstat
NOT_SUPPORTED, // chstat
};

static iop_device_t fio_driver = {
Expand Down
66 changes: 27 additions & 39 deletions iop/cdvd/xesdrv/src/xesdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ static int esdrv_df_devctl(
iomanX_iop_file_t *f, const char *name, int cmd, void *arg, unsigned int arglen, void *buf, unsigned int buflen);
static int
esdrv_df_ioctl2(iomanX_iop_file_t *f, int cmd, void *arg, unsigned int arglen, void *buf, unsigned int buflen);
static int esdrv_df_null();
static s64 esdrv_df_null_long();
static int
esioctl2_func_1(iomanX_iop_file_t *f, int cmd, void *arg, unsigned int arglen, void *buf, unsigned int buflen);
static int
Expand Down Expand Up @@ -221,33 +219,33 @@ struct DevctlCmdTbl_t
};

static iomanX_iop_device_ops_t DvrFuncTbl = {
&esdrv_df_init,
&esdrv_df_exit,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
&esdrv_df_ioctl,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null_long,
&esdrv_df_devctl,
(void *)&esdrv_df_null,
(void *)&esdrv_df_null,
&esdrv_df_ioctl2,
&esdrv_df_init, // init
&esdrv_df_exit, // deinit
NOT_SUPPORTED, // format
NOT_SUPPORTED, // open
NOT_SUPPORTED, // close
NOT_SUPPORTED, // read
NOT_SUPPORTED, // write
NOT_SUPPORTED, // lseek
&esdrv_df_ioctl, // ioctl
NOT_SUPPORTED, // remove
NOT_SUPPORTED, // mkdir
NOT_SUPPORTED, // rmdir
NOT_SUPPORTED, // dopen
NOT_SUPPORTED, // dclose
NOT_SUPPORTED, // dread
NOT_SUPPORTED, // getstat
NOT_SUPPORTED, // chstat
NOT_SUPPORTED, // rename
NOT_SUPPORTED, // chdir
NOT_SUPPORTED, // sync
NOT_SUPPORTED, // mount
NOT_SUPPORTED, // umount
NOT_SUPPORTED_S64, // lseek64
&esdrv_df_devctl, // devctl
NOT_SUPPORTED, // symlink
NOT_SUPPORTED, // readlink
&esdrv_df_ioctl2, // ioctl2
};
static iomanX_iop_device_t ESDRV = {
.name = "es_drv",
Expand Down Expand Up @@ -372,16 +370,6 @@ esdrv_df_ioctl2(iomanX_iop_file_t *f, int cmd, void *arg, unsigned int arglen, v
return -EINVAL;
}

static int esdrv_df_null()
{
return -EUNSUP;
}

static s64 esdrv_df_null_long()
{
return -EUNSUP;
}

static void EsAcsSetAaryptorIoMode(void)
{
es_regs->r_es0C = 0;
Expand Down
36 changes: 17 additions & 19 deletions iop/debug/iop_sbusdbg/src/sbus_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ Of course this requires that the EE-side code accept this command and output the

extern void sbus_tty_puts(const char *str);

static int ttyfs_error() { return -EPERM; }

static int ttyfs_init()
{
//DBG_puts("SIOTTY: FS Init()\n");
Expand Down Expand Up @@ -96,23 +94,23 @@ static int ttyfs_write(iop_file_t *file, void *ptr, int size) {

static iop_device_ops_t fsd_ops =
{
&ttyfs_init,
&ttyfs_deinit,
(void *)&ttyfs_error,
&ttyfs_open,
&ttyfs_close,
(void *)&ttyfs_error,
&ttyfs_write,
(void *)&ttyfs_error,
(void *)&ttyfs_error,
(void *)&ttyfs_error,
(void *)&ttyfs_error,
(void *)&ttyfs_error,
&ttyfs_dopen,
&ttyfs_close,
(void *)&ttyfs_error,
(void *)&ttyfs_error,
(void *)&ttyfs_error,
&ttyfs_init, // init
&ttyfs_deinit, // deinit
NOT_SUPPORTED, // format
&ttyfs_open, // open
&ttyfs_close, // close
NOT_SUPPORTED, // read
&ttyfs_write, // write
NOT_SUPPORTED, // lseek
NOT_SUPPORTED, // ioctl
NOT_SUPPORTED, // remove
NOT_SUPPORTED, // mkdir
NOT_SUPPORTED, // rmdir
&ttyfs_dopen, // dopen
&ttyfs_close, // dclose
NOT_SUPPORTED, // dread
NOT_SUPPORTED, // getstat
NOT_SUPPORTED, // chstat
};

static iop_device_t tty_fsd =
Expand Down
Loading

0 comments on commit ad77943

Please sign in to comment.