xiaoxiang781216 commented on code in PR #17360:
URL: https://github.com/apache/nuttx/pull/17360#discussion_r2549785021
##########
include/sys/param.h:
##########
@@ -53,6 +53,32 @@
# define nitems(_a) (sizeof(_a) / sizeof(0[(_a)]))
#endif /* nitems */
+/* Macros for counting and rounding. */
+
+#ifndef howmany
+#define howmany(a, b) (((a) + ((b) - 1)) / (b))
Review Comment:
indent in all places
##########
drivers/can/can.c:
##########
@@ -702,6 +717,13 @@ static ssize_t can_write(FAR struct file *filep, FAR const
char *buffer,
/* Increment the number of bytes that were sent */
nsent += msglen;
+
+ if (msgalign > 1)
+ {
+ nsent = powerof2(msgalign)
Review Comment:
what's benifit to runtime check align? this check/jump may already consume
the similar overhead of divide
##########
include/nuttx/can/can.h:
##########
@@ -796,13 +823,14 @@ struct can_ops_s
*
* The elements of 'cd_ops', and 'cd_priv'
*
- * The common logic will initialize all semaphores.
+ * The common logic will initialize all semaphores and set 'msgalign' to '1'.
*/
struct can_reader_s
{
struct list_node list;
struct can_rxfifo_s fifo; /* Describes receive FIFO */
+ unsigned msgalign;
Review Comment:
unsigned int
##########
drivers/can/can.c:
##########
@@ -595,9 +608,11 @@ static int can_xmit(FAR struct can_dev_s *dev)
static ssize_t can_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen)
{
- FAR struct inode *inode = filep->f_inode;
- FAR struct can_dev_s *dev = inode->i_private;
- FAR struct can_txcache_s *sender = &dev->cd_sender;
+ FAR struct inode *inode = filep->f_inode;
+ FAR struct can_dev_s *dev = inode->i_private;
+ FAR struct can_txcache_s *sender = &dev->cd_sender;
+ FAR struct can_reader_s *reader = filep->f_priv;
+ int msgalign = reader->msgalign;
Review Comment:
unsigned int
##########
drivers/can/can.c:
##########
@@ -380,6 +382,7 @@ static ssize_t can_read(FAR struct file *filep, FAR char
*buffer,
{
FAR struct can_reader_s *reader;
FAR struct can_rxfifo_s *fifo;
+ int msgalign;
Review Comment:
unsigned int
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]