static int __init pcrypt_init(void)
{
+ int err = -ENOMEM;
encwq = create_workqueue("pencrypt");
if (!encwq)
goto err;
pcrypt_dec_padata = padata_alloc(cpu_possible_mask, decwq);
if (!pcrypt_dec_padata)
- goto err_free_padata;
+ goto err_free_enc_padata;
- padata_start(pcrypt_enc_padata);
- padata_start(pcrypt_dec_padata);
+ err = padata_start(pcrypt_enc_padata);
+ if (err)
+ goto err_free_dec_padata;
+
+ err = padata_start(pcrypt_dec_padata);
+ if (err)
+ goto err_free_dec_padata;
return crypto_register_template(&pcrypt_tmpl);
-err_free_padata:
+err_free_dec_padata:
+ padata_free(pcrypt_dec_padata);
+
+err_free_enc_padata:
padata_free(pcrypt_enc_padata);
err_destroy_decwq:
destroy_workqueue(encwq);
err:
- return -ENOMEM;
+ return err;
}
static void __exit pcrypt_exit(void)
u8 flags;
#define PADATA_INIT 1
#define PADATA_RESET 2
+#define PADATA_INVALID 4
};
extern struct padata_instance *padata_alloc(const struct cpumask *cpumask,
cpumask_var_t cpumask);
extern int padata_add_cpu(struct padata_instance *pinst, int cpu);
extern int padata_remove_cpu(struct padata_instance *pinst, int cpu);
-extern void padata_start(struct padata_instance *pinst);
+extern int padata_start(struct padata_instance *pinst);
extern void padata_stop(struct padata_instance *pinst);
#endif
BUG_ON(atomic_read(&pd->refcnt) != 0);
}
+static void __padata_start(struct padata_instance *pinst)
+{
+ pinst->flags |= PADATA_INIT;
+}
+
/* Replace the internal control stucture with a new one. */
static void padata_replace(struct padata_instance *pinst,
struct parallel_data *pd_new)
*
* @pinst: padata instance to start
*/
-void padata_start(struct padata_instance *pinst)
+int padata_start(struct padata_instance *pinst)
{
+ int err = 0;
+
mutex_lock(&pinst->lock);
- pinst->flags |= PADATA_INIT;
+
+ if (pinst->flags & PADATA_INVALID)
+ err =-EINVAL;
+
+ __padata_start(pinst);
+
mutex_unlock(&pinst->lock);
+
+ return err;
}
EXPORT_SYMBOL(padata_start);