in adgs1408.c [53:103]
static int adgs1408_probe(struct spi_device *spi)
{
struct device *dev = &spi->dev;
enum adgs1408_chip_id chip_id;
struct mux_chip *mux_chip;
struct mux_control *mux;
s32 idle_state;
int ret;
chip_id = (enum adgs1408_chip_id)device_get_match_data(dev);
if (!chip_id)
chip_id = spi_get_device_id(spi)->driver_data;
mux_chip = devm_mux_chip_alloc(dev, 1, 0);
if (IS_ERR(mux_chip))
return PTR_ERR(mux_chip);
mux_chip->ops = &adgs1408_ops;
ret = adgs1408_spi_reg_write(spi, ADGS1408_SW_DATA, ADGS1408_DISABLE);
if (ret < 0)
return ret;
ret = device_property_read_u32(dev, "idle-state", (u32 *)&idle_state);
if (ret < 0)
idle_state = MUX_IDLE_AS_IS;
mux = mux_chip->mux;
if (chip_id == ADGS1408)
mux->states = 8;
else
mux->states = 4;
switch (idle_state) {
case MUX_IDLE_DISCONNECT:
case MUX_IDLE_AS_IS:
case 0 ... 7:
/* adgs1409 supports only 4 states */
if (idle_state < mux->states) {
mux->idle_state = idle_state;
break;
}
fallthrough;
default:
dev_err(dev, "invalid idle-state %d\n", idle_state);
return -EINVAL;
}
return devm_mux_chip_register(dev, mux_chip);
}