Skip to content

Commit 8156693

Browse files
vadimp-nvidiawsakernel
authored andcommitted
i2c: mux: mlxcpld: Prepare mux selection infrastructure for two-byte support
Allow to program register value zero to the mux register, which is required for word address mux register space support. Change key selector type from 'unsigned short' to 'integer' in order to allow to set it to -1 on deselection. Rename key selector field from 'last_chan' to 'last_val', since this fields keeps actually selector value and not channel number. Signed-off-by: Vadim Pasternak <[email protected]> Acked-by: Peter Rosin <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 84af1b1 commit 8156693

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/i2c/muxes/i2c-mux-mlxcpld.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
#define CPLD_MUX_MAX_NCHANS 8
1919

2020
/* mlxcpld_mux - mux control structure:
21-
* @last_chan - last register value
21+
* @last_val - last selected register value or -1 if mux deselected
2222
* @client - I2C device client
2323
* @pdata: platform data
2424
*/
2525
struct mlxcpld_mux {
26-
u8 last_chan;
26+
int last_val;
2727
struct i2c_client *client;
2828
struct mlxcpld_mux_plat_data pdata;
2929
};
@@ -60,7 +60,7 @@ struct mlxcpld_mux {
6060
* for this as they will try to lock adapter a second time.
6161
*/
6262
static int mlxcpld_mux_reg_write(struct i2c_adapter *adap,
63-
struct mlxcpld_mux *mux, u8 val)
63+
struct mlxcpld_mux *mux, u32 val)
6464
{
6565
struct i2c_client *client = mux->client;
6666
union i2c_smbus_data data = { .byte = val };
@@ -73,13 +73,13 @@ static int mlxcpld_mux_reg_write(struct i2c_adapter *adap,
7373
static int mlxcpld_mux_select_chan(struct i2c_mux_core *muxc, u32 chan)
7474
{
7575
struct mlxcpld_mux *mux = i2c_mux_priv(muxc);
76-
u8 regval = chan + 1;
76+
u32 regval = chan + 1;
7777
int err = 0;
7878

7979
/* Only select the channel if its different from the last channel */
80-
if (mux->last_chan != regval) {
80+
if (mux->last_val != regval) {
8181
err = mlxcpld_mux_reg_write(muxc->parent, mux, regval);
82-
mux->last_chan = err < 0 ? 0 : regval;
82+
mux->last_val = err < 0 ? -1 : regval;
8383
}
8484

8585
return err;
@@ -90,9 +90,9 @@ static int mlxcpld_mux_deselect(struct i2c_mux_core *muxc, u32 chan)
9090
struct mlxcpld_mux *mux = i2c_mux_priv(muxc);
9191

9292
/* Deselect active channel */
93-
mux->last_chan = 0;
93+
mux->last_val = -1;
9494

95-
return mlxcpld_mux_reg_write(muxc->parent, mux, mux->last_chan);
95+
return mlxcpld_mux_reg_write(muxc->parent, mux, 0);
9696
}
9797

9898
/* Probe/reomove functions */
@@ -122,7 +122,7 @@ static int mlxcpld_mux_probe(struct platform_device *pdev)
122122
data = i2c_mux_priv(muxc);
123123
data->client = client;
124124
memcpy(&data->pdata, pdata, sizeof(*pdata));
125-
data->last_chan = 0; /* force the first selection */
125+
data->last_val = -1; /* force the first selection */
126126

127127
/* Create an adapter for each channel. */
128128
for (num = 0; num < CPLD_MUX_MAX_NCHANS; num++) {

0 commit comments

Comments
 (0)