File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -250,22 +250,21 @@ static void mes_add_event(struct mock_event_store *mes,
250250 * Vary the number of events returned to simulate events occuring while the
251251 * logs are being read.
252252 */
253- static int ret_limit = 0 ;
253+ static atomic_t event_counter = ATOMIC_INIT ( 0 ) ;
254254
255255static int mock_get_event (struct device * dev , struct cxl_mbox_cmd * cmd )
256256{
257257 struct cxl_get_event_payload * pl ;
258258 struct mock_event_log * log ;
259- u16 nr_overflow ;
259+ int ret_limit ;
260260 u8 log_type ;
261261 int i ;
262262
263263 if (cmd -> size_in != sizeof (log_type ))
264264 return - EINVAL ;
265265
266- ret_limit = (ret_limit + 1 ) % CXL_TEST_EVENT_RET_MAX ;
267- if (!ret_limit )
268- ret_limit = 1 ;
266+ /* Vary return limit from 1 to CXL_TEST_EVENT_RET_MAX */
267+ ret_limit = (atomic_inc_return (& event_counter ) % CXL_TEST_EVENT_RET_MAX ) + 1 ;
269268
270269 if (cmd -> size_out < struct_size (pl , records , ret_limit ))
271270 return - EINVAL ;
@@ -299,7 +298,7 @@ static int mock_get_event(struct device *dev, struct cxl_mbox_cmd *cmd)
299298 u64 ns ;
300299
301300 pl -> flags |= CXL_GET_EVENT_FLAG_OVERFLOW ;
302- pl -> overflow_err_count = cpu_to_le16 (nr_overflow );
301+ pl -> overflow_err_count = cpu_to_le16 (log -> nr_overflow );
303302 ns = ktime_get_real_ns ();
304303 ns -= 5000000000 ; /* 5s ago */
305304 pl -> first_overflow_timestamp = cpu_to_le64 (ns );
You can’t perform that action at this time.
0 commit comments