@@ -69,13 +69,14 @@ static void produce_data(unsigned char val)
6969 if (kfifo_is_full (& rx_fifo )) {
7070 unsigned char dummy ;
7171 len = kfifo_out (& rx_fifo , & dummy , sizeof (dummy ));
72- if (len != sizeof (dummy ))
73- pr_warn ("Failed to remove the oldest element (%u bytes)\n" , len );
72+ if (unlikely (len != sizeof (dummy )))
73+ pr_warn_ratelimited (
74+ "Failed to remove the oldest element (%u bytes)\n" , len );
7475 }
75-
7676 len = kfifo_in (& rx_fifo , & val , sizeof (val ));
77- if (unlikely (len < sizeof (val )) && printk_ratelimit ())
78- pr_warn ("%s: %zu bytes dropped\n" , __func__ , sizeof (val ) - len );
77+ if (unlikely (len < sizeof (val )))
78+ pr_warn_ratelimited ("%s: %zu bytes dropped\n" , __func__ ,
79+ sizeof (val ) - len );
7980
8081 pr_debug ("simrupt: %s: in %u/%u bytes\n" , __func__ , len ,
8182 kfifo_len (& rx_fifo ));
@@ -225,8 +226,8 @@ static void process_data(void)
225226
226227 pr_info ("simrupt: [CPU#%d] produce data\n" , smp_processor_id ());
227228 int ret = fast_buf_put (update_simrupt_data ());
228- if (unlikely (ret < 0 ) && printk_ratelimit () )
229- pr_warn ("simrupt: fast_buf is full, dropping data\n" );
229+ if (unlikely (ret < 0 ))
230+ pr_warn_ratelimited ("simrupt: fast_buf is full, dropping data\n" );
230231
231232 pr_info ("simrupt: [CPU#%d] scheduling tasklet\n" , smp_processor_id ());
232233 tasklet_schedule (& simrupt_tasklet );
0 commit comments