Useless forward declarations.
static struct psp_device *psp_alloc_struct(struct sp_device *sp)
{
struct device *dev = sp->dev;
...
+static int sev_do_cmd_locked(int cmd, void *data, int *psp_ret)
You can use the "__" prefix to denote that it is a lower-level helper:
__sev_do_cmd
__sev_do_cmd_locked
Ditto for the other locked functions.
...
+static int sev_platform_init_locked(struct sev_data_init *data, int *error)
+{
+ struct psp_device *psp = psp_master;
+ struct sev_data_init *input = NULL;
+ int rc = 0;
+
+ if (!psp)
+ return -ENODEV;
+
+ if (psp->sev_state == SEV_STATE_INIT)
+ return 0;
+
+ if (!data) {
+ input = kzalloc(sizeof(*input), GFP_KERNEL);
+ if (!input)
+ return -ENOMEM;
+
+ data = input;
+ }
You can do the allocation in the enclosing function, outside of the
critical region so that you can keep it shorter.
Or even better: if you're going to synchronize the commands with a
mutex, you can define a static struct sev_data_init input in this file
which you always hand in and then you can save yourself the kmalloc
calls.
+
+int sev_platform_shutdown(int *error)
+{
+ if (error)
+ *error = 0;
+
+ return 0;
+}
I'm guessing that that's just bare-bones and it will get filled up in
the next patches. Otherwise it looks pretty useless.
If it is just to block the user from sending SHUTDOWN to the PSP
master, just do that in the ioctl directly - no need to call some empty
functions.