drivers: spi: drop get_dev_data/get_dev_config usage
Replace all get_dev_data()/get_dev_config() accessor utilities with dev->data and dev->config. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
a6614968a8
commit
468de7eb29
4 changed files with 56 additions and 84 deletions
|
@ -37,22 +37,12 @@ struct spi_cc13xx_cc26xx_data {
|
|||
|
||||
#define CPU_FREQ DT_PROP(DT_PATH(cpus, cpu_0), clock_frequency)
|
||||
|
||||
static inline struct spi_cc13xx_cc26xx_data *get_dev_data(const struct device *dev)
|
||||
{
|
||||
return dev->data;
|
||||
}
|
||||
|
||||
static inline const struct spi_cc13xx_cc26xx_config *
|
||||
get_dev_config(const struct device *dev)
|
||||
{
|
||||
return dev->config;
|
||||
}
|
||||
|
||||
static int spi_cc13xx_cc26xx_configure(const struct device *dev,
|
||||
const struct spi_config *config)
|
||||
{
|
||||
const struct spi_cc13xx_cc26xx_config *cfg = get_dev_config(dev);
|
||||
struct spi_context *ctx = &get_dev_data(dev)->ctx;
|
||||
const struct spi_cc13xx_cc26xx_config *cfg = dev->config;
|
||||
struct spi_cc13xx_cc26xx_data *data = dev->data;
|
||||
struct spi_context *ctx = &data->ctx;
|
||||
uint32_t prot;
|
||||
|
||||
if (spi_context_configured(ctx, config)) {
|
||||
|
@ -143,8 +133,9 @@ static int spi_cc13xx_cc26xx_transceive(const struct device *dev,
|
|||
const struct spi_buf_set *tx_bufs,
|
||||
const struct spi_buf_set *rx_bufs)
|
||||
{
|
||||
const struct spi_cc13xx_cc26xx_config *cfg = get_dev_config(dev);
|
||||
struct spi_context *ctx = &get_dev_data(dev)->ctx;
|
||||
const struct spi_cc13xx_cc26xx_config *cfg = dev->config;
|
||||
struct spi_cc13xx_cc26xx_data *data = dev->data;
|
||||
struct spi_context *ctx = &data->ctx;
|
||||
uint32_t txd, rxd;
|
||||
int err;
|
||||
|
||||
|
@ -196,13 +187,15 @@ done:
|
|||
static int spi_cc13xx_cc26xx_release(const struct device *dev,
|
||||
const struct spi_config *config)
|
||||
{
|
||||
struct spi_context *ctx = &get_dev_data(dev)->ctx;
|
||||
const struct spi_cc13xx_cc26xx_config *cfg = dev->config;
|
||||
struct spi_cc13xx_cc26xx_data *data = dev->data;
|
||||
struct spi_context *ctx = &data->ctx;
|
||||
|
||||
if (!spi_context_configured(ctx, config)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (SSIBusy(get_dev_config(dev)->base)) {
|
||||
if (SSIBusy(cfg->base)) {
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
|
@ -215,20 +208,22 @@ static int spi_cc13xx_cc26xx_release(const struct device *dev,
|
|||
static int spi_cc13xx_cc26xx_pm_action(const struct device *dev,
|
||||
enum pm_device_action action)
|
||||
{
|
||||
const struct spi_cc13xx_cc26xx_config *config = dev->config;
|
||||
|
||||
switch (action) {
|
||||
case PM_DEVICE_ACTION_RESUME:
|
||||
if (get_dev_config(dev)->base == DT_INST_REG_ADDR(0)) {
|
||||
if (config->base == DT_INST_REG_ADDR(0)) {
|
||||
Power_setDependency(PowerCC26XX_PERIPH_SSI0);
|
||||
} else {
|
||||
Power_setDependency(PowerCC26XX_PERIPH_SSI1);
|
||||
}
|
||||
break;
|
||||
case PM_DEVICE_ACTION_SUSPEND:
|
||||
SSIDisable(get_dev_config(dev)->base);
|
||||
SSIDisable(config->base);
|
||||
/*
|
||||
* Release power dependency
|
||||
*/
|
||||
if (get_dev_config(dev)->base == DT_INST_REG_ADDR(0)) {
|
||||
if (config->base == DT_INST_REG_ADDR(0)) {
|
||||
Power_releaseDependency(PowerCC26XX_PERIPH_SSI0);
|
||||
} else {
|
||||
Power_releaseDependency(PowerCC26XX_PERIPH_SSI1);
|
||||
|
@ -306,15 +301,16 @@ static const struct spi_driver_api spi_cc13xx_cc26xx_driver_api = {
|
|||
#define SPI_CC13XX_CC26XX_INIT_FUNC(n) \
|
||||
static int spi_cc13xx_cc26xx_init_##n(const struct device *dev) \
|
||||
{ \
|
||||
struct spi_cc13xx_cc26xx_data *data = dev->data; \
|
||||
int err; \
|
||||
SPI_CC13XX_CC26XX_POWER_SPI(n); \
|
||||
\
|
||||
err = spi_context_cs_configure_all(&get_dev_data(dev)->ctx); \
|
||||
err = spi_context_cs_configure_all(&data->ctx); \
|
||||
if (err < 0) { \
|
||||
return err; \
|
||||
} \
|
||||
\
|
||||
spi_context_unlock_unconditionally(&get_dev_data(dev)->ctx); \
|
||||
spi_context_unlock_unconditionally(&data->ctx); \
|
||||
\
|
||||
return 0; \
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue