mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 22:14:03 +02:00
powerpc/rtasd: Use struct_size() to simplify log_rtas_len()
Now that struct rtas_error_log uses a flexible array member for the extended log buffer, use struct_size() to calculate the total RTAS error log size and avoid using the hard-coded header size of 8 bytes. Use min() to replace the open-coded implementation while at it. Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/20260627104730.276858-3-thorsten.blum@linux.dev
This commit is contained in:
parent
7cc3d3fdc9
commit
6a7f74525a
|
|
@ -10,6 +10,7 @@
|
|||
#include <linux/sched.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/overflow.h>
|
||||
#include <linux/poll.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/init.h>
|
||||
|
|
@ -160,25 +161,17 @@ static void printk_log_rtas(char *buf, int len)
|
|||
|
||||
static int log_rtas_len(char * buf)
|
||||
{
|
||||
int len;
|
||||
size_t len;
|
||||
struct rtas_error_log *err;
|
||||
uint32_t extended_log_length;
|
||||
u32 extended_log_length;
|
||||
|
||||
/* rtas fixed header */
|
||||
len = 8;
|
||||
err = (struct rtas_error_log *)buf;
|
||||
extended_log_length = rtas_error_extended_log_length(err);
|
||||
if (rtas_error_extended(err) && extended_log_length) {
|
||||
|
||||
/* extended header */
|
||||
len += extended_log_length;
|
||||
}
|
||||
extended_log_length = rtas_error_extended(err) ? rtas_error_extended_log_length(err) : 0;
|
||||
len = struct_size(err, buffer, extended_log_length);
|
||||
|
||||
if (rtas_error_log_max == 0)
|
||||
rtas_error_log_max = rtas_get_error_log_max();
|
||||
|
||||
if (len > rtas_error_log_max)
|
||||
len = rtas_error_log_max;
|
||||
len = min(len, rtas_error_log_max);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user