I am lookig into a code which is writing some data on SPI line,using spi_transfer structure
struct spi_transfer
{
const void * tx_buf;
void * rx_buf;
unsigned len;
dma_addr_t tx_dma;
dma_addr_t rx_dma;
unsigned cs_change:1;
u8 bits_per_word;
u16 delay_usecs;
u32 speed_hz;
struct list_head transfer_list;
};
Now some like this is been done in Code
u8 *cmd
cmd=kmalloc(3,GFP_KERNEL);
cmd[0]=16;
cmd[1]=32;
Now t[0].tx_buf = cmd;
now I am wondering what is being written into this buffer and what tx_buf expects here?? We are writng to some watch dog counter through SPI line.
Looks like you are sending bytes 0x10, 0x20, 0x00 to the SPI device. There should be other code which has defined and initialized the rest of the struct spi_transfer t[]. Notably, t[0].len must be set to 3.
Perhaps your code base is for a kernel module / device driver. Functions spi_message_add_tail() etc. are in kernel source include/linux/spi/spi.h. They are not dynamic modules, but your module will be linked with kernel when your module is loaded.
Check kernel source for examples of SPI infrastructure use, e.g. drivers/base/regmap/regmap-spi.c.