Skip to content

Commit 9b79a3d

Browse files
jognesspmladek
authored andcommitted
printk: nbcon: Relocate nbcon_atomic_emit_one()
Move nbcon_atomic_emit_one() so that it can be used by nbcon_kthread_func() in a follow-up commit. Signed-off-by: John Ogness <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Petr Mladek <[email protected]>
1 parent 76f258b commit 9b79a3d

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

kernel/printk/nbcon.c

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,45 @@ static bool nbcon_emit_next_record(struct nbcon_write_context *wctxt, bool use_a
10421042
return nbcon_context_exit_unsafe(ctxt);
10431043
}
10441044

1045+
/*
1046+
* nbcon_atomic_emit_one - Print one record for an nbcon console using the
1047+
* write_atomic() callback
1048+
* @wctxt: An initialized write context struct to use for this context
1049+
*
1050+
* Return: True, when a record has been printed and there are still
1051+
* pending records. The caller might want to continue flushing.
1052+
*
1053+
* False, when there is no pending record, or when the console
1054+
* context cannot be acquired, or the ownership has been lost.
1055+
* The caller should give up. Either the job is done, cannot be
1056+
* done, or will be handled by the owning context.
1057+
*
1058+
* This is an internal helper to handle the locking of the console before
1059+
* calling nbcon_emit_next_record().
1060+
*/
1061+
static bool nbcon_atomic_emit_one(struct nbcon_write_context *wctxt)
1062+
{
1063+
struct nbcon_context *ctxt = &ACCESS_PRIVATE(wctxt, ctxt);
1064+
1065+
if (!nbcon_context_try_acquire(ctxt))
1066+
return false;
1067+
1068+
/*
1069+
* nbcon_emit_next_record() returns false when the console was
1070+
* handed over or taken over. In both cases the context is no
1071+
* longer valid.
1072+
*
1073+
* The higher priority printing context takes over responsibility
1074+
* to print the pending records.
1075+
*/
1076+
if (!nbcon_emit_next_record(wctxt, true))
1077+
return false;
1078+
1079+
nbcon_context_release(ctxt);
1080+
1081+
return ctxt->backlog;
1082+
}
1083+
10451084
/**
10461085
* nbcon_kthread_should_wakeup - Check whether a printer thread should wakeup
10471086
* @con: Console to operate on
@@ -1319,45 +1358,6 @@ enum nbcon_prio nbcon_get_default_prio(void)
13191358
return NBCON_PRIO_NORMAL;
13201359
}
13211360

1322-
/*
1323-
* nbcon_atomic_emit_one - Print one record for an nbcon console using the
1324-
* write_atomic() callback
1325-
* @wctxt: An initialized write context struct to use for this context
1326-
*
1327-
* Return: True, when a record has been printed and there are still
1328-
* pending records. The caller might want to continue flushing.
1329-
*
1330-
* False, when there is no pending record, or when the console
1331-
* context cannot be acquired, or the ownership has been lost.
1332-
* The caller should give up. Either the job is done, cannot be
1333-
* done, or will be handled by the owning context.
1334-
*
1335-
* This is an internal helper to handle the locking of the console before
1336-
* calling nbcon_emit_next_record().
1337-
*/
1338-
static bool nbcon_atomic_emit_one(struct nbcon_write_context *wctxt)
1339-
{
1340-
struct nbcon_context *ctxt = &ACCESS_PRIVATE(wctxt, ctxt);
1341-
1342-
if (!nbcon_context_try_acquire(ctxt))
1343-
return false;
1344-
1345-
/*
1346-
* nbcon_emit_next_record() returns false when the console was
1347-
* handed over or taken over. In both cases the context is no
1348-
* longer valid.
1349-
*
1350-
* The higher priority printing context takes over responsibility
1351-
* to print the pending records.
1352-
*/
1353-
if (!nbcon_emit_next_record(wctxt, true))
1354-
return false;
1355-
1356-
nbcon_context_release(ctxt);
1357-
1358-
return ctxt->backlog;
1359-
}
1360-
13611361
/**
13621362
* nbcon_legacy_emit_next_record - Print one record for an nbcon console
13631363
* in legacy contexts

0 commit comments

Comments
 (0)