mirror of
https://github.com/edk2-porting/linux-next.git
synced 2025-01-09 06:04:05 +08:00
crypto: atmel - Avoid flush_scheduled_work() usage
Flushing system-wide workqueues is dangerous and will be forbidden. Replace system_wq with local atmel_wq. If CONFIG_CRYPTO_DEV_ATMEL_{I2C,ECC,SHA204A}=y, the ordering in Makefile guarantees that module_init() for atmel-i2c runs before module_init() for atmel-ecc and atmel-sha204a runs. Link: https://lkml.kernel.org/r/49925af7-78a8-a3dd-bce6-cfc02e1a9236@I-love.SAKURA.ne.jp Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
59f71498c7
commit
0a2f4b5785
@ -3,6 +3,7 @@ obj-$(CONFIG_CRYPTO_DEV_ALLWINNER) += allwinner/
|
||||
obj-$(CONFIG_CRYPTO_DEV_ATMEL_AES) += atmel-aes.o
|
||||
obj-$(CONFIG_CRYPTO_DEV_ATMEL_SHA) += atmel-sha.o
|
||||
obj-$(CONFIG_CRYPTO_DEV_ATMEL_TDES) += atmel-tdes.o
|
||||
# __init ordering requires atmel-i2c being before atmel-ecc and atmel-sha204a.
|
||||
obj-$(CONFIG_CRYPTO_DEV_ATMEL_I2C) += atmel-i2c.o
|
||||
obj-$(CONFIG_CRYPTO_DEV_ATMEL_ECC) += atmel-ecc.o
|
||||
obj-$(CONFIG_CRYPTO_DEV_ATMEL_SHA204A) += atmel-sha204a.o
|
||||
|
@ -398,7 +398,7 @@ static int __init atmel_ecc_init(void)
|
||||
|
||||
static void __exit atmel_ecc_exit(void)
|
||||
{
|
||||
flush_scheduled_work();
|
||||
atmel_i2c_flush_queue();
|
||||
i2c_del_driver(&atmel_ecc_driver);
|
||||
}
|
||||
|
||||
|
@ -263,6 +263,8 @@ static void atmel_i2c_work_handler(struct work_struct *work)
|
||||
work_data->cbk(work_data, work_data->areq, status);
|
||||
}
|
||||
|
||||
static struct workqueue_struct *atmel_wq;
|
||||
|
||||
void atmel_i2c_enqueue(struct atmel_i2c_work_data *work_data,
|
||||
void (*cbk)(struct atmel_i2c_work_data *work_data,
|
||||
void *areq, int status),
|
||||
@ -272,10 +274,16 @@ void atmel_i2c_enqueue(struct atmel_i2c_work_data *work_data,
|
||||
work_data->areq = areq;
|
||||
|
||||
INIT_WORK(&work_data->work, atmel_i2c_work_handler);
|
||||
schedule_work(&work_data->work);
|
||||
queue_work(atmel_wq, &work_data->work);
|
||||
}
|
||||
EXPORT_SYMBOL(atmel_i2c_enqueue);
|
||||
|
||||
void atmel_i2c_flush_queue(void)
|
||||
{
|
||||
flush_workqueue(atmel_wq);
|
||||
}
|
||||
EXPORT_SYMBOL(atmel_i2c_flush_queue);
|
||||
|
||||
static inline size_t atmel_i2c_wake_token_sz(u32 bus_clk_rate)
|
||||
{
|
||||
u32 no_of_bits = DIV_ROUND_UP(TWLO_USEC * bus_clk_rate, USEC_PER_SEC);
|
||||
@ -368,6 +376,20 @@ int atmel_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
}
|
||||
EXPORT_SYMBOL(atmel_i2c_probe);
|
||||
|
||||
static int __init atmel_i2c_init(void)
|
||||
{
|
||||
atmel_wq = alloc_workqueue("atmel_wq", 0, 0);
|
||||
return atmel_wq ? 0 : -ENOMEM;
|
||||
}
|
||||
|
||||
static void __exit atmel_i2c_exit(void)
|
||||
{
|
||||
destroy_workqueue(atmel_wq);
|
||||
}
|
||||
|
||||
module_init(atmel_i2c_init);
|
||||
module_exit(atmel_i2c_exit);
|
||||
|
||||
MODULE_AUTHOR("Tudor Ambarus <tudor.ambarus@microchip.com>");
|
||||
MODULE_DESCRIPTION("Microchip / Atmel ECC (I2C) driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
@ -173,6 +173,7 @@ void atmel_i2c_enqueue(struct atmel_i2c_work_data *work_data,
|
||||
void (*cbk)(struct atmel_i2c_work_data *work_data,
|
||||
void *areq, int status),
|
||||
void *areq);
|
||||
void atmel_i2c_flush_queue(void);
|
||||
|
||||
int atmel_i2c_send_receive(struct i2c_client *client, struct atmel_i2c_cmd *cmd);
|
||||
|
||||
|
@ -160,7 +160,7 @@ static int __init atmel_sha204a_init(void)
|
||||
|
||||
static void __exit atmel_sha204a_exit(void)
|
||||
{
|
||||
flush_scheduled_work();
|
||||
atmel_i2c_flush_queue();
|
||||
i2c_del_driver(&atmel_sha204a_driver);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user