s390: simplify dynamic sysctl registration for appldata_register_ops
authorLuis Chamberlain <mcgrof@kernel.org>
Fri, 10 Mar 2023 23:45:25 +0000 (15:45 -0800)
committerHeiko Carstens <hca@linux.ibm.com>
Mon, 20 Mar 2023 09:56:49 +0000 (10:56 +0100)
commit7db12246306ea601809f22b26d7c2093dd80e146
tree951768eb00a691449246c5919daa49fe1cc981a9
parent7ddc873dcb1d05eaafceeb4a2afd53bbb31addb8
s390: simplify dynamic sysctl registration for appldata_register_ops

The routine appldata_register_ops() allocates a sysctl table
with 4 entries. The firsts one,   ops->ctl_table[0] is the parent directory
with an empty entry following it, ops->ctl_table[1]. The next entry is
for the ops->name and that is     ops->ctl_table[2]. It needs an empty
entry following that, and that is ops->ctl_table[3]. And so hence the
kcalloc(4, sizeof(struct ctl_table), GFP_KERNEL).

We can simplify this considerably since sysctl_register("foo", table)
can create the parent directory for us if it does not exist. So we
can just remove the first two entries and move back the ops->name to
the first entry, and just use kcalloc(2, ...).

[gor@linux.ibm.com: appldata_generic_handler fixup ctl_table index 2->0]
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20230310234525.3986352-7-mcgrof@kernel.org
Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/appldata/appldata_base.c