summaryrefslogtreecommitdiff
path: root/drivers/i2c/muxes
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavo@embeddedor.com>2019-06-03 17:53:35 +0300
committerPeter Rosin <peda@axentia.se>2019-06-10 10:28:56 +0300
commit90af27317b63403bce3874566b71883fc1e1f459 (patch)
tree3a84c85725a961590ee1a7d7c5d38ed7720fae87 /drivers/i2c/muxes
parentd9a183bfd29d44c927b3920ae49ba2f682793976 (diff)
downloadlinux-90af27317b63403bce3874566b71883fc1e1f459.tar.xz
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>
Diffstat (limited to 'drivers/i2c/muxes')
-rw-r--r--drivers/i2c/muxes/i2c-mux-pinctrl.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c b/drivers/i2c/muxes/i2c-mux-pinctrl.c
index cc6818aabab5..ff3e8c9d4dd8 100644
--- a/drivers/i2c/muxes/i2c-mux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c
@@ -27,7 +27,7 @@
struct i2c_mux_pinctrl {
struct pinctrl *pinctrl;
- struct pinctrl_state **states;
+ struct pinctrl_state *states[];
};
static int i2c_mux_pinctrl_select(struct i2c_mux_core *muxc, u32 chan)
@@ -104,14 +104,13 @@ static int i2c_mux_pinctrl_probe(struct platform_device *pdev)
return PTR_ERR(parent);
muxc = i2c_mux_alloc(parent, dev, num_names,
- sizeof(*mux) + num_names * sizeof(*mux->states),
+ struct_size(mux, states, num_names),
0, i2c_mux_pinctrl_select, NULL);
if (!muxc) {
ret = -ENOMEM;
goto err_put_parent;
}
mux = i2c_mux_priv(muxc);
- mux->states = (struct pinctrl_state **)(mux + 1);
platform_set_drvdata(pdev, muxc);