xiaoxiang781216 commented on code in PR #16920: URL: https://github.com/apache/nuttx/pull/16920#discussion_r2324889796
########## sched/event/event_clear.c: ########## @@ -0,0 +1,71 @@ +/**************************************************************************** + * sched/event/event_clear.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/sched.h> + +#include "event.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxevent_clear + * + * Description: + * Clear specific bits from the event mask of the given event object. + * + * Input Parameters: + * event - Address of the event object + * mask - Bit mask specifying which event flags should be cleared + * + * Returned Value: + * Returns the previous event mask value of the event object before + * applying the clear operation. + * + * Notes: + * - This is an internal OS interface and must not be invoked directly + * by user applications. + * - This function is safe to call from an interrupt handler. + * + ****************************************************************************/ + +nxevent_mask_t nxevent_clear(FAR nxevent_t *event, nxevent_mask_t mask) +{ + nxevent_mask_t events; + irqstate_t flags; + + DEBUGASSERT(event != NULL); + + flags = spin_lock_irqsave_nopreempt(&event->lock); + + events = event->events; + event->events &= ~mask; + + spin_unlock_irqrestore_nopreempt(&event->lock, flags); Review Comment: ```suggestion spin_unlock_irqrestore(&event->lock, flags); ``` ########## sched/event/event_clear.c: ########## @@ -0,0 +1,71 @@ +/**************************************************************************** + * sched/event/event_clear.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include <nuttx/sched.h> + +#include "event.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nxevent_clear + * + * Description: + * Clear specific bits from the event mask of the given event object. + * + * Input Parameters: + * event - Address of the event object + * mask - Bit mask specifying which event flags should be cleared + * + * Returned Value: + * Returns the previous event mask value of the event object before + * applying the clear operation. + * + * Notes: + * - This is an internal OS interface and must not be invoked directly + * by user applications. + * - This function is safe to call from an interrupt handler. + * + ****************************************************************************/ + +nxevent_mask_t nxevent_clear(FAR nxevent_t *event, nxevent_mask_t mask) +{ + nxevent_mask_t events; + irqstate_t flags; + + DEBUGASSERT(event != NULL); + + flags = spin_lock_irqsave_nopreempt(&event->lock); Review Comment: ```suggestion flags = spin_lock_irqsave(&event->lock); ``` -- 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: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org