@@ -190,17 +190,21 @@ struct spi_buf {
190190 * See spi_transceive() for argument descriptions
191191 */
192192typedef int (* spi_api_io )(struct spi_config * config ,
193- const struct spi_buf * * tx_bufs ,
194- struct spi_buf * * rx_bufs );
193+ const struct spi_buf * tx_bufs ,
194+ size_t tx_count ,
195+ struct spi_buf * rx_bufs ,
196+ size_t rx_count );
195197
196198/**
197199 * @typedef spi_api_io
198200 * @brief Callback API for asynchronous I/O
199201 * See spi_transceive_async() for argument descriptions
200202 */
201203typedef int (* spi_api_io_async )(struct spi_config * config ,
202- const struct spi_buf * * tx_bufs ,
203- struct spi_buf * * rx_bufs ,
204+ const struct spi_buf * tx_bufs ,
205+ size_t tx_count ,
206+ struct spi_buf * rx_bufs ,
207+ size_t rx_count ,
204208 struct k_poll_signal * async );
205209
206210/**
@@ -229,20 +233,24 @@ struct spi_driver_api {
229233 * Note: This function is synchronous.
230234 *
231235 * @param config Pointer to a valid spi_config structure instance.
232- * @param tx_bufs NULL terminated buffer array where data to be sent
233- * originates from, or NULL if none.
234- * @param rx_bufs NULL terminated buffer array where data to be read
235- * will be written to, or NULL if none.
236+ * @param tx_bufs Buffer array where data to be sent originates from,
237+ * or NULL if none.
238+ * @param tx_count Number of element in the tx_bufs array.
239+ * @param rx_bufs Buffer array where data to be read will be written to,
240+ * or NULL if none.
241+ * @param rx_count Number of element in the rx_bufs array.
236242 *
237243 * @retval 0 If successful, negative errno code otherwise.
238244 */
239245static inline int spi_transceive (struct spi_config * config ,
240- const struct spi_buf * * tx_bufs ,
241- struct spi_buf * * rx_bufs )
246+ const struct spi_buf * tx_bufs ,
247+ size_t tx_count ,
248+ struct spi_buf * rx_bufs ,
249+ size_t rx_count )
242250{
243251 const struct spi_driver_api * api = config -> dev -> driver_api ;
244252
245- return api -> transceive (config , tx_bufs , rx_bufs );
253+ return api -> transceive (config , tx_bufs , tx_count , rx_bufs , rx_count );
246254}
247255
248256/**
@@ -251,17 +259,18 @@ static inline int spi_transceive(struct spi_config *config,
251259 * Note: This function is synchronous.
252260 *
253261 * @param config Pointer to a valid spi_config structure instance.
254- * @param rx_bufs NULL terminated buffer array where data to be read
255- * will be written to .
262+ * @param rx_bufs Buffer array where data to be read will be written to.
263+ * @param rx_count Number of element in the rx_bufs array .
256264 *
257265 * @retval 0 If successful, negative errno code otherwise.
258266 */
259267static inline int spi_read (struct spi_config * config ,
260- struct spi_buf * * rx_bufs )
268+ struct spi_buf * rx_bufs ,
269+ size_t rx_count )
261270{
262271 const struct spi_driver_api * api = config -> dev -> driver_api ;
263272
264- return api -> transceive (config , NULL , rx_bufs );
273+ return api -> transceive (config , NULL , 0 , rx_bufs , rx_count );
265274}
266275
267276/**
@@ -270,17 +279,18 @@ static inline int spi_read(struct spi_config *config,
270279 * Note: This function is synchronous.
271280 *
272281 * @param config Pointer to a valid spi_config structure instance.
273- * @param tx_bufs NULL terminated buffer array where data to be sent
274- * originates from .
282+ * @param tx_bufs Buffer array where data to be sent originates from.
283+ * @param tx_count Number of element in the tx_bufs array .
275284 *
276285 * @retval 0 If successful, negative errno code otherwise.
277286 */
278287static inline int spi_write (struct spi_config * config ,
279- const struct spi_buf * * tx_bufs )
288+ const struct spi_buf * tx_bufs ,
289+ size_t tx_count )
280290{
281291 const struct spi_driver_api * api = config -> dev -> driver_api ;
282292
283- return api -> transceive (config , tx_bufs , NULL );
293+ return api -> transceive (config , tx_bufs , tx_count , NULL , 0 );
284294}
285295
286296#ifdef CONFIG_POLL
@@ -290,10 +300,12 @@ static inline int spi_write(struct spi_config *config,
290300 * Note: This function is asynchronous.
291301 *
292302 * @param config Pointer to a valid spi_config structure instance.
293- * @param tx_bufs NULL terminated buffer array where data to be sent
294- * originates from, or NULL if none.
295- * @param rx_bufs NULL terminated buffer array where data to be read
296- * will be written to, or NULL if none.
303+ * @param tx_bufs Buffer array where data to be sent originates from,
304+ * or NULL if none.
305+ * @param tx_count Number of element in the tx_bufs array.
306+ * @param rx_bufs Buffer array where data to be read will be written to,
307+ * or NULL if none.
308+ * @param rx_count Number of element in the rx_bufs array.
297309 * @param async A pointer to a valid and ready to be signaled
298310 * struct k_poll_signal. (Note: if NULL this function will not
299311 * notify the end of the transaction, and whether it went
@@ -302,13 +314,16 @@ static inline int spi_write(struct spi_config *config,
302314 * @retval 0 If successful, negative errno code otherwise.
303315 */
304316static inline int spi_transceive_async (struct spi_config * config ,
305- const struct spi_buf * * tx_bufs ,
306- struct spi_buf * * rx_bufs ,
317+ const struct spi_buf * tx_bufs ,
318+ size_t tx_count ,
319+ struct spi_buf * rx_bufs ,
320+ size_t rx_count ,
307321 struct k_poll_signal * async )
308322{
309323 const struct spi_driver_api * api = config -> dev -> driver_api ;
310324
311- return api -> transceive_async (config , tx_bufs , rx_bufs , async );
325+ return api -> transceive_async (config , tx_bufs , tx_count ,
326+ rx_bufs , rx_count , async );
312327}
313328
314329/**
@@ -317,8 +332,8 @@ static inline int spi_transceive_async(struct spi_config *config,
317332 * Note: This function is asynchronous.
318333 *
319334 * @param config Pointer to a valid spi_config structure instance.
320- * @param rx_bufs NULL terminated buffer array where data to be read
321- * will be written to .
335+ * @param rx_bufs Buffer array where data to be read will be written to.
336+ * @param rx_count Number of element in the rx_bufs array .
322337 * @param async A pointer to a valid and ready to be signaled
323338 * struct k_poll_signal. (Note: if NULL this function will not
324339 * notify the end of the transaction, and whether it went
@@ -327,12 +342,14 @@ static inline int spi_transceive_async(struct spi_config *config,
327342 * @retval 0 If successful, negative errno code otherwise.
328343 */
329344static inline int spi_read_async (struct spi_config * config ,
330- struct spi_buf * * rx_bufs ,
345+ struct spi_buf * rx_bufs ,
346+ size_t rx_count ,
331347 struct k_poll_signal * async )
332348{
333349 const struct spi_driver_api * api = config -> dev -> driver_api ;
334350
335- return api -> transceive_async (config , NULL , rx_bufs , async );
351+ return api -> transceive_async (config , NULL , 0 ,
352+ rx_bufs , rx_count , async );
336353}
337354
338355/**
@@ -341,8 +358,8 @@ static inline int spi_read_async(struct spi_config *config,
341358 * Note: This function is asynchronous.
342359 *
343360 * @param config Pointer to a valid spi_config structure instance.
344- * @param tx_bufs NULL terminated buffer array where data to be sent
345- * originates from .
361+ * @param tx_bufs Buffer array where data to be sent originates from.
362+ * @param tx_count Number of element in the tx_bufs array .
346363 * @param async A pointer to a valid and ready to be signaled
347364 * struct k_poll_signal. (Note: if NULL this function will not
348365 * notify the end of the transaction, and whether it went
@@ -351,12 +368,14 @@ static inline int spi_read_async(struct spi_config *config,
351368 * @retval 0 If successful, negative errno code otherwise.
352369 */
353370static inline int spi_write_async (struct spi_config * config ,
354- const struct spi_buf * * tx_bufs ,
371+ const struct spi_buf * tx_bufs ,
372+ size_t tx_count ,
355373 struct k_poll_signal * async )
356374{
357375 const struct spi_driver_api * api = config -> dev -> driver_api ;
358376
359- return api -> transceive_async (config , tx_bufs , NULL , async );
377+ return api -> transceive_async (config , tx_bufs , tx_count ,
378+ NULL , 0 , async );
360379}
361380#endif /* CONFIG_POLL */
362381
0 commit comments