return dev_err_probe(dev, ret,
"can't get and enable vdd supply\n");
- ret = data->ops->init(data->dev);
- if (ret)
- return ret;
-
ret = device_property_read_u32(dev,
"honeywell,transfer-function", &func);
if (ret)
* @chan.pres: pressure value
* @chan.ts: timestamp
* @rx_buf: raw conversion data
+ * @tx_buf: output buffer
*/
struct mpr_data {
struct device *dev;
aligned_s64 ts;
} chan;
u8 rx_buf[MPR_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN);
+ u8 tx_buf[MPR_MEASUREMENT_RD_SIZE];
};
struct mpr_ops {
- int (*init)(struct device *dev);
int (*read)(struct mpr_data *data, const u8 cmd, const u8 cnt);
int (*write)(struct mpr_data *data, const u8 cmd, const u8 cnt);
};
#include "mprls0025pa.h"
-static int mpr_i2c_init(struct device *unused)
-{
- return 0;
-}
-
static int mpr_i2c_read(struct mpr_data *data, const u8 unused, const u8 cnt)
{
int ret;
{
int ret;
struct i2c_client *client = to_i2c_client(data->dev);
- u8 wdata[MPR_PKT_SYNC_LEN] = { cmd };
- ret = i2c_master_send(client, wdata, MPR_PKT_SYNC_LEN);
+ data->tx_buf[0] = cmd;
+ ret = i2c_master_send(client, data->tx_buf, MPR_PKT_SYNC_LEN);
if (ret < 0)
return ret;
else if (ret != MPR_PKT_SYNC_LEN)
}
static const struct mpr_ops mpr_i2c_ops = {
- .init = mpr_i2c_init,
.read = mpr_i2c_read,
.write = mpr_i2c_write,
};
#include "mprls0025pa.h"
-struct mpr_spi_buf {
- u8 tx[MPR_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN);
-};
-
-static int mpr_spi_init(struct device *dev)
-{
- struct spi_device *spi = to_spi_device(dev);
- struct mpr_spi_buf *buf;
-
- buf = devm_kzalloc(dev, sizeof(*buf), GFP_KERNEL);
- if (!buf)
- return -ENOMEM;
-
- spi_set_drvdata(spi, buf);
-
- return 0;
-}
-
static int mpr_spi_xfer(struct mpr_data *data, const u8 cmd, const u8 pkt_len)
{
struct spi_device *spi = to_spi_device(data->dev);
- struct mpr_spi_buf *buf = spi_get_drvdata(spi);
struct spi_transfer xfers[2] = { };
if (pkt_len > MPR_MEASUREMENT_RD_SIZE)
return -EOVERFLOW;
- buf->tx[0] = cmd;
+ data->tx_buf[0] = cmd;
/*
* Dummy transfer with no data, just cause a 2.5us+ delay between the CS assert
xfers[0].delay.value = 2500;
xfers[0].delay.unit = SPI_DELAY_UNIT_NSECS;
- xfers[1].tx_buf = buf->tx;
+ xfers[1].tx_buf = data->tx_buf;
xfers[1].rx_buf = data->rx_buf;
xfers[1].len = pkt_len;
}
static const struct mpr_ops mpr_spi_ops = {
- .init = mpr_spi_init,
.read = mpr_spi_xfer,
.write = mpr_spi_xfer,
};