atmel-i2c.c (59f71498c7ff591824863be55b0eff5aae743947) | atmel-i2c.c (0a2f4b5785ca5e9c5bc2d4e59183e016096ee889) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Microchip / Atmel ECC (I2C) driver. 4 * 5 * Copyright (c) 2017, Microchip Technology Inc. 6 * Author: Tudor Ambarus <tudor.ambarus@microchip.com> 7 */ 8 --- 249 unchanged lines hidden (view full) --- 258 struct atmel_i2c_cmd *cmd = &work_data->cmd; 259 struct i2c_client *client = work_data->client; 260 int status; 261 262 status = atmel_i2c_send_receive(client, cmd); 263 work_data->cbk(work_data, work_data->areq, status); 264} 265 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Microchip / Atmel ECC (I2C) driver. 4 * 5 * Copyright (c) 2017, Microchip Technology Inc. 6 * Author: Tudor Ambarus <tudor.ambarus@microchip.com> 7 */ 8 --- 249 unchanged lines hidden (view full) --- 258 struct atmel_i2c_cmd *cmd = &work_data->cmd; 259 struct i2c_client *client = work_data->client; 260 int status; 261 262 status = atmel_i2c_send_receive(client, cmd); 263 work_data->cbk(work_data, work_data->areq, status); 264} 265 |
266static struct workqueue_struct *atmel_wq; 267 |
|
266void atmel_i2c_enqueue(struct atmel_i2c_work_data *work_data, 267 void (*cbk)(struct atmel_i2c_work_data *work_data, 268 void *areq, int status), 269 void *areq) 270{ 271 work_data->cbk = (void *)cbk; 272 work_data->areq = areq; 273 274 INIT_WORK(&work_data->work, atmel_i2c_work_handler); | 268void atmel_i2c_enqueue(struct atmel_i2c_work_data *work_data, 269 void (*cbk)(struct atmel_i2c_work_data *work_data, 270 void *areq, int status), 271 void *areq) 272{ 273 work_data->cbk = (void *)cbk; 274 work_data->areq = areq; 275 276 INIT_WORK(&work_data->work, atmel_i2c_work_handler); |
275 schedule_work(&work_data->work); | 277 queue_work(atmel_wq, &work_data->work); |
276} 277EXPORT_SYMBOL(atmel_i2c_enqueue); 278 | 278} 279EXPORT_SYMBOL(atmel_i2c_enqueue); 280 |
281void atmel_i2c_flush_queue(void) 282{ 283 flush_workqueue(atmel_wq); 284} 285EXPORT_SYMBOL(atmel_i2c_flush_queue); 286 |
|
279static inline size_t atmel_i2c_wake_token_sz(u32 bus_clk_rate) 280{ 281 u32 no_of_bits = DIV_ROUND_UP(TWLO_USEC * bus_clk_rate, USEC_PER_SEC); 282 283 /* return the size of the wake_token in bytes */ 284 return DIV_ROUND_UP(no_of_bits, 8); 285} 286 --- 76 unchanged lines hidden (view full) --- 363 atomic_set(&i2c_priv->tfm_count, 0); 364 365 i2c_set_clientdata(client, i2c_priv); 366 367 return device_sanity_check(client); 368} 369EXPORT_SYMBOL(atmel_i2c_probe); 370 | 287static inline size_t atmel_i2c_wake_token_sz(u32 bus_clk_rate) 288{ 289 u32 no_of_bits = DIV_ROUND_UP(TWLO_USEC * bus_clk_rate, USEC_PER_SEC); 290 291 /* return the size of the wake_token in bytes */ 292 return DIV_ROUND_UP(no_of_bits, 8); 293} 294 --- 76 unchanged lines hidden (view full) --- 371 atomic_set(&i2c_priv->tfm_count, 0); 372 373 i2c_set_clientdata(client, i2c_priv); 374 375 return device_sanity_check(client); 376} 377EXPORT_SYMBOL(atmel_i2c_probe); 378 |
379static int __init atmel_i2c_init(void) 380{ 381 atmel_wq = alloc_workqueue("atmel_wq", 0, 0); 382 return atmel_wq ? 0 : -ENOMEM; 383} 384 385static void __exit atmel_i2c_exit(void) 386{ 387 destroy_workqueue(atmel_wq); 388} 389 390module_init(atmel_i2c_init); 391module_exit(atmel_i2c_exit); 392 |
|
371MODULE_AUTHOR("Tudor Ambarus <tudor.ambarus@microchip.com>"); 372MODULE_DESCRIPTION("Microchip / Atmel ECC (I2C) driver"); 373MODULE_LICENSE("GPL v2"); | 393MODULE_AUTHOR("Tudor Ambarus <tudor.ambarus@microchip.com>"); 394MODULE_DESCRIPTION("Microchip / Atmel ECC (I2C) driver"); 395MODULE_LICENSE("GPL v2"); |