platform/x86: ISST: Add API version of the target
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Sat, 11 Feb 2023 06:32:49 +0000 (22:32 -0800)
committerHans de Goede <hdegoede@redhat.com>
Tue, 7 Mar 2023 11:08:30 +0000 (12:08 +0100)
User space can get the API version using IOCTL
ISST_IF_GET_PLATFORM_INFO. This information can be used to get IOCTLs
supported by the kernel driver. This version is hardcoded in the driver.

Allow the registered client to specify the supported API version. In
this way a registered client can specify a higher API version to extend
IOCTL set.

Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Link: https://lore.kernel.org/r/20230211063257.311746-5-srinivas.pandruvada@linux.intel.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/intel/speed_select_if/isst_if_common.c
drivers/platform/x86/intel/speed_select_if/isst_if_common.h

index cdf0501f4e4fb1cc10502ac86c39c7150f3359d7..19e671500f006ff65ec36448ce8909fad4d4d42f 100644 (file)
@@ -262,11 +262,13 @@ bool isst_if_mbox_cmd_set_req(struct isst_if_mbox_cmd *cmd)
 }
 EXPORT_SYMBOL_GPL(isst_if_mbox_cmd_set_req);
 
+static int isst_if_api_version;
+
 static int isst_if_get_platform_info(void __user *argp)
 {
        struct isst_if_platform_info info;
 
-       info.api_version = ISST_IF_API_VERSION;
+       info.api_version = isst_if_api_version;
        info.driver_version = ISST_IF_DRIVER_VERSION;
        info.max_cmds_per_ioctl = ISST_IF_CMD_LIMIT;
        info.mbox_supported = punit_callbacks[ISST_IF_DEV_MBOX].registered;
@@ -767,6 +769,10 @@ int isst_if_cdev_register(int device_type, struct isst_if_cmd_cb *cb)
                mutex_unlock(&punit_misc_dev_open_lock);
                return -EAGAIN;
        }
+       if (!cb->api_version)
+               cb->api_version = ISST_IF_API_VERSION;
+       if (cb->api_version > isst_if_api_version)
+               isst_if_api_version = cb->api_version;
        memcpy(&punit_callbacks[device_type], cb, sizeof(*cb));
        punit_callbacks[device_type].registered = 1;
        mutex_unlock(&punit_misc_dev_open_lock);
index 34a172e5c82c8d132a7f35d2509baae5abae4c3d..1004f2c9cca86bf2f47d24e13ddf55a6d80ad7d0 100644 (file)
@@ -41,6 +41,7 @@
  * @offset:    Offset to the first valid member in command structure.
  *             This will be the offset of the start of the command
  *             after command count field
+ * @api_version: API version supported for this target. 0, if none.
  * @owner:     Registered module owner
  * @cmd_callback: Callback function to handle IOCTL. The callback has the
  *             command pointer with data for command. There is a pointer
@@ -60,7 +61,7 @@ struct isst_if_cmd_cb {
        int registered;
        int cmd_size;
        int offset;
-
+       int api_version;
        struct module *owner;
        long (*cmd_callback)(u8 *ptr, int *write_only, int resume);
        long (*def_ioctl)(struct file *file, unsigned int cmd, unsigned long arg);