Skip to content

Commit

Permalink
driver: There is no need to use sched_[un]lock
Browse files Browse the repository at this point in the history
Signed-off-by: hujun5 <[email protected]>
  • Loading branch information
hujun260 committed Apr 14, 2024
1 parent 3ce84d1 commit e54951d
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 33 deletions.
10 changes: 0 additions & 10 deletions drivers/bch/bchdev_unregister.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@ int bchdev_unregister(FAR const char *chardev)
return ret;
}

/* Lock out context switches. If there are no other references
* and no context switches, then we can assume that we can safely
* teardown the driver.
*/

sched_lock();

/* Check if the internal structure is non-busy (we hold one reference). */

if (bch->refs > 1)
Expand All @@ -117,15 +110,12 @@ int bchdev_unregister(FAR const char *chardev)
goto errout_with_lock;
}

sched_unlock();

/* Release the internal structure */

bch->refs = 0;
return bchlib_teardown(bch);

errout_with_lock:
bch->refs--;
sched_unlock();
return ret;
}
5 changes: 0 additions & 5 deletions drivers/ioexpander/pcf8574.c
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,6 @@ static void pcf8574_irqworker(void *arg)

/* Re-start the poll timer */

sched_lock();
ret = wd_start(&priv->wdog, PCF8574_POLLDELAY,
pcf8574_poll_expiry, (wdparm_t)priv);
if (ret < 0)
Expand All @@ -951,10 +950,6 @@ static void pcf8574_irqworker(void *arg)
/* Re-enable interrupts */

priv->config->enable(priv->config, true);

#ifdef CONFIG_PCF8574_INT_POLL
sched_unlock();
#endif
}
#endif

Expand Down
5 changes: 0 additions & 5 deletions drivers/ioexpander/tca64xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,6 @@ static void tca64_irqworker(void *arg)

/* Re-start the poll timer */

sched_lock();
ret = wd_start(&priv->wdog, TCA64XX_POLLDELAY,
tca64_poll_expiry, (wdparm_t)priv);
if (ret < 0)
Expand All @@ -1224,10 +1223,6 @@ static void tca64_irqworker(void *arg)
/* Re-enable interrupts */

priv->config->enable(priv->config, true);

#ifdef CONFIG_TCA64XX_INT_POLL
sched_unlock();
#endif
}
#endif

Expand Down
11 changes: 0 additions & 11 deletions drivers/syslog/syslog_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,6 @@ static int syslog_dev_outputready(FAR struct syslog_dev_s *syslog_dev)
return -EAGAIN; /* Can't access the SYSLOG now... maybe next time? */
}

/* NOTE that the scheduler is locked. That is because we do not have
* fully initialized mutex capability until the SYSLOG device is
* successfully initialized.
*/

sched_lock();

/* Case (6) */

if (syslog_dev->sl_state == SYSLOG_FAILURE)
Expand Down Expand Up @@ -352,12 +345,10 @@ static int syslog_dev_outputready(FAR struct syslog_dev_s *syslog_dev)
(int)syslog_dev->sl_mode);
if (ret < 0)
{
sched_unlock();
return ret;
}
}

sched_unlock();
DEBUGASSERT(syslog_dev->sl_state == SYSLOG_OPENED);
}

Expand Down Expand Up @@ -758,7 +749,6 @@ void syslog_dev_uninitialize(FAR struct syslog_channel_s *channel)

/* Attempt to flush any buffered data. */

sched_lock();
syslog_dev_flush(channel);

/* Close the detached file instance, and destroy the mutex. These are
Expand Down Expand Up @@ -787,5 +777,4 @@ void syslog_dev_uninitialize(FAR struct syslog_channel_s *channel)
/* Free the channel structure */

kmm_free(syslog_dev);
sched_unlock();
}
5 changes: 3 additions & 2 deletions drivers/syslog/syslog_filechannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ static void log_rotate(FAR const char *log_file)
FAR struct syslog_channel_s *syslog_file_channel(FAR const char *devpath)
{
FAR struct syslog_channel_s *file_channel;
irqstate_t flags;

/* Reset the default SYSLOG channel so that we can safely modify the
* SYSLOG device. This is an atomic operation and we should be safe
Expand All @@ -176,7 +177,7 @@ FAR struct syslog_channel_s *syslog_file_channel(FAR const char *devpath)
* important debug output is lost while we futz with the channels.
*/

sched_lock();
flags = enter_critical_section();

/* Rotate the log file, if needed. */

Expand Down Expand Up @@ -209,7 +210,7 @@ FAR struct syslog_channel_s *syslog_file_channel(FAR const char *devpath)
}

errout_with_lock:
sched_unlock();
leave_critical_section(flags);
return file_channel;
}

Expand Down

0 comments on commit e54951d

Please sign in to comment.