Lines Matching defs:state
37 static int sps30_i2c_xfer(struct sps30_state *state, unsigned char *txbuf, size_t txsize,
40 struct i2c_client *client = to_i2c_client(state->dev);
65 static int sps30_i2c_command(struct sps30_state *state, u16 cmd, void *arg, size_t arg_size,
103 ret = sps30_i2c_xfer(state, buf, i, buf, rsp_size);
112 dev_err(state->dev, "data integrity check failed\n");
123 static int sps30_i2c_start_meas(struct sps30_state *state)
128 return sps30_i2c_command(state, SPS30_I2C_START_MEAS, buf, sizeof(buf), NULL, 0);
131 static int sps30_i2c_stop_meas(struct sps30_state *state)
133 return sps30_i2c_command(state, SPS30_I2C_STOP_MEAS, NULL, 0, NULL, 0);
136 static int sps30_i2c_reset(struct sps30_state *state)
140 ret = sps30_i2c_command(state, SPS30_I2C_RESET, NULL, 0, NULL, 0);
144 * some controllers end up in error state. Recover simply by placing
148 sps30_i2c_stop_meas(state);
153 static bool sps30_i2c_meas_ready(struct sps30_state *state)
158 ret = sps30_i2c_command(state, SPS30_I2C_MEAS_READY, NULL, 0, buf, sizeof(buf));
165 static int sps30_i2c_read_meas(struct sps30_state *state, __be32 *meas, size_t num)
171 if (!sps30_i2c_meas_ready(state))
174 return sps30_i2c_command(state, SPS30_I2C_READ_MEAS, NULL, 0, meas, sizeof(num) * num);
177 static int sps30_i2c_clean_fan(struct sps30_state *state)
179 return sps30_i2c_command(state, SPS30_I2C_CLEAN_FAN, NULL, 0, NULL, 0);
182 static int sps30_i2c_read_cleaning_period(struct sps30_state *state, __be32 *period)
184 return sps30_i2c_command(state, SPS30_I2C_PERIOD, NULL, 0, period, sizeof(*period));
187 static int sps30_i2c_write_cleaning_period(struct sps30_state *state, __be32 period)
189 return sps30_i2c_command(state, SPS30_I2C_PERIOD, &period, sizeof(period), NULL, 0);
192 static int sps30_i2c_show_info(struct sps30_state *state)
198 ret = sps30_i2c_command(state, SPS30_I2C_READ_SERIAL, NULL, 0, buf, sizeof(buf) - 1);
202 dev_info(state->dev, "serial number: %s\n", buf);
204 ret = sps30_i2c_command(state, SPS30_I2C_READ_VERSION, NULL, 0, buf, 2);
208 dev_info(state->dev, "fw version: %u.%u\n", buf[0], buf[1]);