i2c: mux: pinctrl: use flexible-array member and struct_size() helper
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Mon, 3 Jun 2019 14:53:35 +0000 (09:53 -0500)
committerPeter Rosin <peda@axentia.se>
Mon, 10 Jun 2019 07:28:56 +0000 (09:28 +0200)
commit90af27317b63403bce3874566b71883fc1e1f459
tree3a84c85725a961590ee1a7d7c5d38ed7720fae87
parentd9a183bfd29d44c927b3920ae49ba2f682793976
i2c: mux: pinctrl: use flexible-array member and struct_size() helper

Update the code to use a flexible array member instead of a pointer in
structure i2c_mux_pinctrl and use the struct_size() helper.

Also, make use of the struct_size() helper instead of an open-coded
version in order to avoid any potential type mistakes, in particular
in the context in which this code is being used.

So, replace the following form:

sizeof(*mux) + num_names * sizeof(*mux->states)

with:

struct_size(mux, states, num_names)

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Peter Rosin <peda@axentia.se>
drivers/i2c/muxes/i2c-mux-pinctrl.c