Lines Matching refs:msg
78 struct ssp_msg *msg; in ssp_create_msg() local
80 msg = kzalloc(sizeof(*msg), GFP_KERNEL); in ssp_create_msg()
81 if (!msg) in ssp_create_msg()
89 msg->buffer = kzalloc(SSP_HEADER_SIZE_ALIGNED + len, in ssp_create_msg()
91 if (!msg->buffer) { in ssp_create_msg()
92 kfree(msg); in ssp_create_msg()
96 msg->length = len; in ssp_create_msg()
97 msg->options = opt; in ssp_create_msg()
99 memcpy(msg->buffer, &h, SSP_HEADER_SIZE); in ssp_create_msg()
101 return msg; in ssp_create_msg()
177 static int ssp_do_transfer(struct ssp_data *data, struct ssp_msg *msg, in ssp_do_transfer() argument
185 const bool use_no_irq = msg->length == 0; in ssp_do_transfer()
190 msg->done = done; in ssp_do_transfer()
198 status = spi_write(data->spi, msg->buffer, SSP_HEADER_SIZE); in ssp_do_transfer()
207 list_add_tail(&msg->list, &data->pending_list); in ssp_do_transfer()
215 list_del(&msg->list); in ssp_do_transfer()
228 list_del(&msg->list); in ssp_do_transfer()
244 struct ssp_msg *msg) in ssp_spi_sync_command() argument
246 return ssp_do_transfer(data, msg, NULL, 0); in ssp_spi_sync_command()
249 static int ssp_spi_sync(struct ssp_data *data, struct ssp_msg *msg, in ssp_spi_sync() argument
254 if (WARN_ON(!msg->length)) in ssp_spi_sync()
257 return ssp_do_transfer(data, msg, &done, timeout); in ssp_spi_sync()
338 struct ssp_msg *msg = NULL, *iter, *n; in ssp_irq_msg() local
367 msg = iter; in ssp_irq_msg()
372 if (!msg) { in ssp_irq_msg()
399 &msg->buffer[SSP_HEADER_SIZE_ALIGNED], in ssp_irq_msg()
400 msg->length); in ssp_irq_msg()
404 &msg->buffer[SSP_HEADER_SIZE_ALIGNED], in ssp_irq_msg()
405 msg->length); in ssp_irq_msg()
407 msg->options = in ssp_irq_msg()
409 msg->length = 1; in ssp_irq_msg()
411 list_add_tail(&msg->list, &data->pending_list); in ssp_irq_msg()
416 if (msg->done) in ssp_irq_msg()
417 if (!completion_done(msg->done)) in ssp_irq_msg()
418 complete(msg->done); in ssp_irq_msg()
449 struct ssp_msg *msg, *n; in ssp_clean_pending_list() local
452 list_for_each_entry_safe(msg, n, &data->pending_list, list) { in ssp_clean_pending_list()
453 list_del(&msg->list); in ssp_clean_pending_list()
455 if (msg->done) in ssp_clean_pending_list()
456 if (!completion_done(msg->done)) in ssp_clean_pending_list()
457 complete(msg->done); in ssp_clean_pending_list()
465 struct ssp_msg *msg; in ssp_command() local
467 msg = ssp_create_msg(command, 0, SSP_AP2HUB_WRITE, arg); in ssp_command()
468 if (!msg) in ssp_command()
473 ret = ssp_spi_sync_command(data, msg); in ssp_command()
474 ssp_clean_msg(msg); in ssp_command()
483 struct ssp_msg *msg; in ssp_send_instruction() local
496 msg = ssp_create_msg(inst, length + 2, SSP_AP2HUB_WRITE, 0); in ssp_send_instruction()
497 if (!msg) in ssp_send_instruction()
500 ssp_fill_buffer(msg, 0, &sensor_type, 1); in ssp_send_instruction()
501 ssp_fill_buffer(msg, 1, send_buf, length); in ssp_send_instruction()
506 ret = ssp_spi_sync(data, msg, 1000); in ssp_send_instruction()
507 ssp_clean_msg(msg); in ssp_send_instruction()
516 struct ssp_msg *msg; in ssp_get_chipid() local
518 msg = ssp_create_msg(SSP_MSG2SSP_AP_WHOAMI, 1, SSP_AP2HUB_READ, 0); in ssp_get_chipid()
519 if (!msg) in ssp_get_chipid()
522 ret = ssp_spi_sync(data, msg, 1000); in ssp_get_chipid()
524 buffer = SSP_GET_BUFFER_AT_INDEX(msg, 0); in ssp_get_chipid()
526 ssp_clean_msg(msg); in ssp_get_chipid()
534 struct ssp_msg *msg; in ssp_set_magnetic_matrix() local
536 msg = ssp_create_msg(SSP_MSG2SSP_AP_SET_MAGNETIC_STATIC_MATRIX, in ssp_set_magnetic_matrix()
539 if (!msg) in ssp_set_magnetic_matrix()
542 ssp_fill_buffer(msg, 0, data->sensorhub_info->mag_table, in ssp_set_magnetic_matrix()
545 ret = ssp_spi_sync(data, msg, 1000); in ssp_set_magnetic_matrix()
546 ssp_clean_msg(msg); in ssp_set_magnetic_matrix()
557 struct ssp_msg *msg = ssp_create_msg(SSP_MSG2SSP_AP_SENSOR_SCANNING, 4, in ssp_get_sensor_scanning_info() local
559 if (!msg) in ssp_get_sensor_scanning_info()
562 ret = ssp_spi_sync(data, msg, 1000); in ssp_get_sensor_scanning_info()
568 ssp_get_buffer(msg, 0, &result, 4); in ssp_get_sensor_scanning_info()
574 ssp_clean_msg(msg); in ssp_get_sensor_scanning_info()
583 struct ssp_msg *msg = ssp_create_msg(SSP_MSG2SSP_AP_FIRMWARE_REV, 4, in ssp_get_firmware_rev() local
585 if (!msg) in ssp_get_firmware_rev()
588 ret = ssp_spi_sync(data, msg, 1000); in ssp_get_firmware_rev()
595 ssp_get_buffer(msg, 0, &result, 4); in ssp_get_firmware_rev()
599 ssp_clean_msg(msg); in ssp_get_firmware_rev()