mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-04 04:02:26 +00:00
tty: hvc_console: use flexible array for outbuf
This means: * move outbuf to the end of struct hvc_struct and convert from pointer to flexible array (the structure is smaller now) * use struct_size() at the allocation site * align outbuf in the struct instead of ALIGN() at kzalloc() And apart from the above, use u8 instead of char (which are the same thanks to -funsigned-char). The former is now preferred over the latter. It makes the code easier to understand. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Cc: linuxppc-dev@lists.ozlabs.org Link: https://lore.kernel.org/r/20231121092258.9334-12-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
4ccef1f142
commit
7588b08203
@ -922,8 +922,7 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
hp = kzalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size,
|
||||
GFP_KERNEL);
|
||||
hp = kzalloc(struct_size(hp, outbuf, outbuf_size), GFP_KERNEL);
|
||||
if (!hp)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
@ -931,7 +930,6 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
|
||||
hp->data = data;
|
||||
hp->ops = ops;
|
||||
hp->outbuf_size = outbuf_size;
|
||||
hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))];
|
||||
|
||||
tty_port_init(&hp->port);
|
||||
hp->port.ops = &hvc_port_ops;
|
||||
|
@ -37,7 +37,6 @@ struct hvc_struct {
|
||||
spinlock_t lock;
|
||||
int index;
|
||||
int do_wakeup;
|
||||
char *outbuf;
|
||||
int outbuf_size;
|
||||
int n_outbuf;
|
||||
uint32_t vtermno;
|
||||
@ -48,6 +47,7 @@ struct hvc_struct {
|
||||
struct work_struct tty_resize;
|
||||
struct list_head next;
|
||||
unsigned long flags;
|
||||
u8 outbuf[] __aligned(sizeof(long));
|
||||
};
|
||||
|
||||
/* implemented by a low level driver */
|
||||
|
Loading…
Reference in New Issue
Block a user