Commit 33c16dc1 authored by Srinivas Pandruvada's avatar Srinivas Pandruvada Committed by Hans de Goede

platform/x86: ISST: Add IOCTL default callback

The common IOCTL handler has a predefined list of IOCTLs it can
handle. There is no default handler, if there is no match.

Allow a client driver to define their own version of default IOCTL
callback. In this way the default handling is passed to the client
drivers to handle.

With the introduction of TPMI target, IOCTL list is extended. The
additional TPMI specific IOCTLs will be passed to the TPMI client
driver default IOCTL handler.
Signed-off-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20230211063257.311746-4-srinivas.pandruvada@linux.intel.comSigned-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
parent 6614823a
...@@ -588,6 +588,7 @@ static long isst_if_def_ioctl(struct file *file, unsigned int cmd, ...@@ -588,6 +588,7 @@ static long isst_if_def_ioctl(struct file *file, unsigned int cmd,
struct isst_if_cmd_cb cmd_cb; struct isst_if_cmd_cb cmd_cb;
struct isst_if_cmd_cb *cb; struct isst_if_cmd_cb *cb;
long ret = -ENOTTY; long ret = -ENOTTY;
int i;
switch (cmd) { switch (cmd) {
case ISST_IF_GET_PLATFORM_INFO: case ISST_IF_GET_PLATFORM_INFO:
...@@ -616,6 +617,16 @@ static long isst_if_def_ioctl(struct file *file, unsigned int cmd, ...@@ -616,6 +617,16 @@ static long isst_if_def_ioctl(struct file *file, unsigned int cmd,
ret = isst_if_exec_multi_cmd(argp, &cmd_cb); ret = isst_if_exec_multi_cmd(argp, &cmd_cb);
break; break;
default: default:
for (i = 0; i < ISST_IF_DEV_MAX; ++i) {
struct isst_if_cmd_cb *cb = &punit_callbacks[i];
int ret;
if (cb->def_ioctl) {
ret = cb->def_ioctl(file, cmd, arg);
if (!ret)
return ret;
}
}
break; break;
} }
......
...@@ -48,6 +48,8 @@ ...@@ -48,6 +48,8 @@
* response to user ioctl buffer. The "resume" argument * response to user ioctl buffer. The "resume" argument
* can be used to avoid storing the command for replay * can be used to avoid storing the command for replay
* during system resume * during system resume
* @def_ioctl: Default IOCTL handler callback, if there is no match in
* the existing list of IOCTL handled by the common handler.
* *
* This structure is used to register an handler for IOCTL. To avoid * This structure is used to register an handler for IOCTL. To avoid
* code duplication common code handles all the IOCTL command read/write * code duplication common code handles all the IOCTL command read/write
...@@ -58,8 +60,10 @@ struct isst_if_cmd_cb { ...@@ -58,8 +60,10 @@ struct isst_if_cmd_cb {
int registered; int registered;
int cmd_size; int cmd_size;
int offset; int offset;
struct module *owner; struct module *owner;
long (*cmd_callback)(u8 *ptr, int *write_only, int resume); long (*cmd_callback)(u8 *ptr, int *write_only, int resume);
long (*def_ioctl)(struct file *file, unsigned int cmd, unsigned long arg);
}; };
/* Internal interface functions */ /* Internal interface functions */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment