// SPDX-License-Identifier: GPL-2.0-only /* * ---------------------------------------------------------------------------- * drivers/nfc/st95hf/spi.c function definitions for SPI communication * ---------------------------------------------------------------------------- * Copyright (C) 2015 STMicroelectronics Pvt. Ltd. All rights reserved.
*/
#include"spi.h"
/* Function to send user provided buffer to ST95HF through SPI */ int st95hf_spi_send(struct st95hf_spi_context *spicontext, unsignedchar *buffertx, int datalen, enum req_type reqtype)
{ struct spi_message m; int result = 0; struct spi_device *spidev = spicontext->spidev; struct spi_transfer tx_transfer = {
.tx_buf = buffertx,
.len = datalen,
};
result = spi_sync(spidev, &m); if (result) {
dev_err(&spidev->dev, "error: sending cmd to st95hf using SPI = %d\n",
result);
mutex_unlock(&spicontext->spi_lock); return result;
}
/* return for asynchronous or no-wait case */ if (reqtype == ASYNC) {
mutex_unlock(&spicontext->spi_lock); return 0;
}
result = wait_for_completion_timeout(&spicontext->done,
msecs_to_jiffies(1000)); /* check for timeout or success */ if (!result) {
dev_err(&spidev->dev, "error: response not ready timeout\n");
result = -ETIMEDOUT;
} else {
result = 0;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.