| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * I2C multiplexer using pinctrl API |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 7 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 8 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 11 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 12 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 13 | | - * more details. |
|---|
| 14 | | - * |
|---|
| 15 | | - * You should have received a copy of the GNU General Public License |
|---|
| 16 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 17 | 6 | */ |
|---|
| 18 | 7 | |
|---|
| 19 | 8 | #include <linux/i2c.h> |
|---|
| .. | .. |
|---|
| 27 | 16 | |
|---|
| 28 | 17 | struct i2c_mux_pinctrl { |
|---|
| 29 | 18 | struct pinctrl *pinctrl; |
|---|
| 30 | | - struct pinctrl_state **states; |
|---|
| 19 | + struct pinctrl_state *states[]; |
|---|
| 31 | 20 | }; |
|---|
| 32 | 21 | |
|---|
| 33 | 22 | static int i2c_mux_pinctrl_select(struct i2c_mux_core *muxc, u32 chan) |
|---|
| .. | .. |
|---|
| 104 | 93 | return PTR_ERR(parent); |
|---|
| 105 | 94 | |
|---|
| 106 | 95 | muxc = i2c_mux_alloc(parent, dev, num_names, |
|---|
| 107 | | - sizeof(*mux) + num_names * sizeof(*mux->states), |
|---|
| 96 | + struct_size(mux, states, num_names), |
|---|
| 108 | 97 | 0, i2c_mux_pinctrl_select, NULL); |
|---|
| 109 | 98 | if (!muxc) { |
|---|
| 110 | 99 | ret = -ENOMEM; |
|---|
| 111 | 100 | goto err_put_parent; |
|---|
| 112 | 101 | } |
|---|
| 113 | 102 | mux = i2c_mux_priv(muxc); |
|---|
| 114 | | - mux->states = (struct pinctrl_state **)(mux + 1); |
|---|
| 115 | 103 | |
|---|
| 116 | 104 | platform_set_drvdata(pdev, muxc); |
|---|
| 117 | 105 | |
|---|