drivers: adc: drop DEV_DATA/DEV_CFG usage
Stop using redundant DEV_DATA/DEV_CFG macros and use dev->data and dev->config instead. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
2a0e66453c
commit
6745333511
4 changed files with 31 additions and 50 deletions
|
@ -20,10 +20,6 @@ LOG_MODULE_REGISTER(adc_ite_it8xxx2);
|
|||
#define ADC_CONTEXT_USES_KERNEL_TIMER
|
||||
#include "adc_context.h"
|
||||
|
||||
#define DEV_DATA(dev) ((struct adc_it8xxx2_data * const)(dev)->data)
|
||||
|
||||
#define DEV_CFG(dev) ((struct adc_it8xxx2_cfg * const)(dev)->config)
|
||||
|
||||
/* ADC internal reference voltage (Unit:mV) */
|
||||
#define IT8XXX2_ADC_VREF_VOL 3000
|
||||
/* ADC channels disabled */
|
||||
|
@ -74,7 +70,7 @@ struct adc_it8xxx2_cfg {
|
|||
static int adc_it8xxx2_channel_setup(const struct device *dev,
|
||||
const struct adc_channel_cfg *channel_cfg)
|
||||
{
|
||||
struct adc_it8xxx2_cfg *config = DEV_CFG(dev);
|
||||
struct adc_it8xxx2_cfg *config = dev->config;
|
||||
|
||||
if (channel_cfg->acquisition_time != ADC_ACQ_TIME_DEFAULT) {
|
||||
LOG_ERR("Selected ADC acquisition time is not valid");
|
||||
|
@ -157,7 +153,7 @@ static int check_buffer_size(const struct adc_sequence *sequence,
|
|||
static int adc_it8xxx2_start_read(const struct device *dev,
|
||||
const struct adc_sequence *sequence)
|
||||
{
|
||||
struct adc_it8xxx2_data *data = DEV_DATA(dev);
|
||||
struct adc_it8xxx2_data *data = dev->data;
|
||||
uint32_t channel_mask = sequence->channels;
|
||||
|
||||
if (!channel_mask || channel_mask & ~BIT_MASK(CHIP_ADC_COUNT)) {
|
||||
|
@ -189,7 +185,7 @@ static void adc_context_start_sampling(struct adc_context *ctx)
|
|||
static int adc_it8xxx2_read(const struct device *dev,
|
||||
const struct adc_sequence *sequence)
|
||||
{
|
||||
struct adc_it8xxx2_data *data = DEV_DATA(dev);
|
||||
struct adc_it8xxx2_data *data = dev->data;
|
||||
uint32_t channel_mask = sequence->channels;
|
||||
uint8_t channel_count = 0;
|
||||
int err = 0;
|
||||
|
@ -229,7 +225,7 @@ static void adc_context_update_buffer_pointer(struct adc_context *ctx,
|
|||
/* Get result for each ADC selected channel. */
|
||||
static void adc_it8xxx2_get_sample(const struct device *dev)
|
||||
{
|
||||
struct adc_it8xxx2_data *data = DEV_DATA(dev);
|
||||
struct adc_it8xxx2_data *data = dev->data;
|
||||
struct adc_it8xxx2_regs *const adc_regs = ADC_IT8XXX2_REG_BASE;
|
||||
bool valid = false;
|
||||
|
||||
|
@ -251,7 +247,7 @@ static void adc_it8xxx2_get_sample(const struct device *dev)
|
|||
static void adc_it8xxx2_isr(const void *arg)
|
||||
{
|
||||
struct device *dev = (struct device *)arg;
|
||||
struct adc_it8xxx2_data *data = DEV_DATA(dev);
|
||||
struct adc_it8xxx2_data *data = dev->data;
|
||||
|
||||
LOG_DBG("ADC ISR triggered.");
|
||||
|
||||
|
@ -288,7 +284,7 @@ static void adc_accuracy_initialization(void)
|
|||
|
||||
static int adc_it8xxx2_init(const struct device *dev)
|
||||
{
|
||||
struct adc_it8xxx2_data *data = DEV_DATA(dev);
|
||||
struct adc_it8xxx2_data *data = dev->data;
|
||||
struct adc_it8xxx2_regs *const adc_regs = ADC_IT8XXX2_REG_BASE;
|
||||
|
||||
/* ADC analog accuracy initialization */
|
||||
|
|
|
@ -67,10 +67,6 @@ struct mcux_adc16_data {
|
|||
uint8_t channel_id;
|
||||
};
|
||||
|
||||
#define DEV_CFG(dev) ((const struct mcux_adc16_config *const)dev->config)
|
||||
#define DEV_DATA(dev) ((struct mcux_adc16_data *)dev->data)
|
||||
#define DEV_BASE(dev) ((ADC_Type *)DEV_CFG(dev)->base)
|
||||
|
||||
#ifdef CONFIG_ADC_MCUX_ADC16_HW_TRIGGER
|
||||
#define SIM_SOPT7_ADCSET(x, shifts, mask) \
|
||||
(((uint32_t)(((uint32_t)(x)) << shifts)) & mask)
|
||||
|
@ -81,7 +77,7 @@ static void adc_dma_callback(const struct device *dma_dev, void *callback_arg,
|
|||
uint32_t channel, int error_code)
|
||||
{
|
||||
struct device *dev = (struct device *)callback_arg;
|
||||
struct mcux_adc16_data *data = DEV_DATA(dev);
|
||||
struct mcux_adc16_data *data = dev->data;
|
||||
|
||||
LOG_DBG("DMA done");
|
||||
adc_context_on_sampling_done(&data->ctx, dev);
|
||||
|
|
|
@ -58,11 +58,6 @@ struct adc_sam0_cfg {
|
|||
void (*config_func)(const struct device *dev);
|
||||
};
|
||||
|
||||
#define DEV_CFG(dev) \
|
||||
((const struct adc_sam0_cfg *const)(dev)->config)
|
||||
#define DEV_DATA(dev) \
|
||||
((struct adc_sam0_data *)(dev)->data)
|
||||
|
||||
static void wait_synchronization(Adc *const adc)
|
||||
{
|
||||
#if defined(ADC_SYNCBUSY_MASK)
|
||||
|
@ -77,7 +72,7 @@ static void wait_synchronization(Adc *const adc)
|
|||
static int adc_sam0_acquisition_to_clocks(const struct device *dev,
|
||||
uint16_t acquisition_time)
|
||||
{
|
||||
const struct adc_sam0_cfg *const cfg = DEV_CFG(dev);
|
||||
const struct adc_sam0_cfg *const cfg = dev->config;
|
||||
uint64_t scaled_acq;
|
||||
|
||||
switch (ADC_ACQ_TIME_UNIT(acquisition_time)) {
|
||||
|
@ -122,7 +117,7 @@ static int adc_sam0_acquisition_to_clocks(const struct device *dev,
|
|||
static int adc_sam0_channel_setup(const struct device *dev,
|
||||
const struct adc_channel_cfg *channel_cfg)
|
||||
{
|
||||
const struct adc_sam0_cfg *const cfg = DEV_CFG(dev);
|
||||
const struct adc_sam0_cfg *const cfg = dev->config;
|
||||
Adc *const adc = cfg->regs;
|
||||
int retval;
|
||||
uint8_t SAMPCTRL = 0;
|
||||
|
@ -182,7 +177,7 @@ static int adc_sam0_channel_setup(const struct device *dev,
|
|||
adc->REFCTRL.reg = REFCTRL;
|
||||
wait_synchronization(adc);
|
||||
#ifdef ADC_SAM0_REFERENCE_GLITCH
|
||||
struct adc_sam0_data *data = DEV_DATA(dev);
|
||||
struct adc_sam0_data *data = dev->data;
|
||||
|
||||
data->reference_changed = 1;
|
||||
#endif
|
||||
|
@ -283,7 +278,7 @@ static int adc_sam0_channel_setup(const struct device *dev,
|
|||
|
||||
static void adc_sam0_start_conversion(const struct device *dev)
|
||||
{
|
||||
const struct adc_sam0_cfg *const cfg = DEV_CFG(dev);
|
||||
const struct adc_sam0_cfg *const cfg = dev->config;
|
||||
Adc *const adc = cfg->regs;
|
||||
|
||||
LOG_DBG("Starting conversion");
|
||||
|
@ -336,8 +331,8 @@ static int check_buffer_size(const struct adc_sequence *sequence,
|
|||
static int start_read(const struct device *dev,
|
||||
const struct adc_sequence *sequence)
|
||||
{
|
||||
const struct adc_sam0_cfg *const cfg = DEV_CFG(dev);
|
||||
struct adc_sam0_data *data = DEV_DATA(dev);
|
||||
const struct adc_sam0_cfg *const cfg = dev->config;
|
||||
struct adc_sam0_data *data = dev->data;
|
||||
Adc *const adc = cfg->regs;
|
||||
int error;
|
||||
|
||||
|
@ -419,7 +414,7 @@ static int start_read(const struct device *dev,
|
|||
static int adc_sam0_read(const struct device *dev,
|
||||
const struct adc_sequence *sequence)
|
||||
{
|
||||
struct adc_sam0_data *data = DEV_DATA(dev);
|
||||
struct adc_sam0_data *data = dev->data;
|
||||
int error;
|
||||
|
||||
adc_context_lock(&data->ctx, false, NULL);
|
||||
|
@ -431,8 +426,8 @@ static int adc_sam0_read(const struct device *dev,
|
|||
|
||||
static void adc_sam0_isr(const struct device *dev)
|
||||
{
|
||||
struct adc_sam0_data *data = DEV_DATA(dev);
|
||||
const struct adc_sam0_cfg *const cfg = DEV_CFG(dev);
|
||||
struct adc_sam0_data *data = dev->data;
|
||||
const struct adc_sam0_cfg *const cfg = dev->config;
|
||||
Adc *const adc = cfg->regs;
|
||||
uint16_t result;
|
||||
|
||||
|
@ -456,8 +451,8 @@ static void adc_sam0_isr(const struct device *dev)
|
|||
|
||||
static int adc_sam0_init(const struct device *dev)
|
||||
{
|
||||
const struct adc_sam0_cfg *const cfg = DEV_CFG(dev);
|
||||
struct adc_sam0_data *data = DEV_DATA(dev);
|
||||
const struct adc_sam0_cfg *const cfg = dev->config;
|
||||
struct adc_sam0_data *data = dev->data;
|
||||
Adc *const adc = cfg->regs;
|
||||
|
||||
#ifdef MCLK
|
||||
|
@ -502,7 +497,7 @@ static int adc_sam0_read_async(const struct device *dev,
|
|||
const struct adc_sequence *sequence,
|
||||
struct k_poll_signal *async)
|
||||
{
|
||||
struct adc_sam0_data *data = DEV_DATA(dev);
|
||||
struct adc_sam0_data *data = dev->data;
|
||||
int error;
|
||||
|
||||
adc_context_lock(&data->ctx, true, async);
|
||||
|
@ -549,7 +544,7 @@ static const struct adc_driver_api adc_sam0_api = {
|
|||
|
||||
#define ADC_SAM0_CONFIGURE(n) \
|
||||
do { \
|
||||
const struct adc_sam0_cfg *const cfg = DEV_CFG(dev); \
|
||||
const struct adc_sam0_cfg *const cfg = dev->config; \
|
||||
Adc * const adc = cfg->regs; \
|
||||
uint32_t comp = ADC_SAM0_BIASCOMP(n); \
|
||||
uint32_t r2r = ADC_SAM0_BIASR2R(n); \
|
||||
|
@ -569,7 +564,7 @@ do { \
|
|||
|
||||
#define ADC_SAM0_CONFIGURE(n) \
|
||||
do { \
|
||||
const struct adc_sam0_cfg *const cfg = DEV_CFG(dev); \
|
||||
const struct adc_sam0_cfg *const cfg = dev->config; \
|
||||
Adc * const adc = cfg->regs; \
|
||||
/* Linearity is split across two words */ \
|
||||
uint32_t lin = ((*(uint32_t *)ADC_FUSES_LINEARITY_0_ADDR) & \
|
||||
|
|
|
@ -62,16 +62,10 @@ struct adc_sam_cfg {
|
|||
struct soc_gpio_pin afec_trg_pin;
|
||||
};
|
||||
|
||||
#define DEV_CFG(dev) \
|
||||
((const struct adc_sam_cfg *const)(dev)->config)
|
||||
|
||||
#define DEV_DATA(dev) \
|
||||
((struct adc_sam_data *)(dev)->data)
|
||||
|
||||
static int adc_sam_channel_setup(const struct device *dev,
|
||||
const struct adc_channel_cfg *channel_cfg)
|
||||
{
|
||||
const struct adc_sam_cfg * const cfg = DEV_CFG(dev);
|
||||
const struct adc_sam_cfg * const cfg = dev->config;
|
||||
Afec *const afec = cfg->regs;
|
||||
|
||||
uint8_t channel_id = channel_cfg->channel_id;
|
||||
|
@ -120,8 +114,8 @@ static int adc_sam_channel_setup(const struct device *dev,
|
|||
|
||||
static void adc_sam_start_conversion(const struct device *dev)
|
||||
{
|
||||
const struct adc_sam_cfg *const cfg = DEV_CFG(dev);
|
||||
struct adc_sam_data *data = DEV_DATA(dev);
|
||||
const struct adc_sam_cfg *const cfg = dev->config;
|
||||
struct adc_sam_data *data = dev->data;
|
||||
Afec *const afec = cfg->regs;
|
||||
|
||||
data->channel_id = find_lsb_set(data->channels) - 1;
|
||||
|
@ -186,7 +180,7 @@ static int check_buffer_size(const struct adc_sequence *sequence,
|
|||
static int start_read(const struct device *dev,
|
||||
const struct adc_sequence *sequence)
|
||||
{
|
||||
struct adc_sam_data *data = DEV_DATA(dev);
|
||||
struct adc_sam_data *data = dev->data;
|
||||
int error = 0;
|
||||
uint32_t channels = sequence->channels;
|
||||
|
||||
|
@ -251,7 +245,7 @@ static int start_read(const struct device *dev,
|
|||
static int adc_sam_read(const struct device *dev,
|
||||
const struct adc_sequence *sequence)
|
||||
{
|
||||
struct adc_sam_data *data = DEV_DATA(dev);
|
||||
struct adc_sam_data *data = dev->data;
|
||||
int error;
|
||||
|
||||
adc_context_lock(&data->ctx, false, NULL);
|
||||
|
@ -263,8 +257,8 @@ static int adc_sam_read(const struct device *dev,
|
|||
|
||||
static int adc_sam_init(const struct device *dev)
|
||||
{
|
||||
const struct adc_sam_cfg *const cfg = DEV_CFG(dev);
|
||||
struct adc_sam_data *data = DEV_DATA(dev);
|
||||
const struct adc_sam_cfg *const cfg = dev->config;
|
||||
struct adc_sam_data *data = dev->data;
|
||||
Afec *const afec = cfg->regs;
|
||||
|
||||
/* Reset the AFEC. */
|
||||
|
@ -306,7 +300,7 @@ static int adc_sam_read_async(const struct device *dev,
|
|||
const struct adc_sequence *sequence,
|
||||
struct k_poll_signal *async)
|
||||
{
|
||||
struct adc_sam_data *data = DEV_DATA(dev);
|
||||
struct adc_sam_data *data = dev->data;
|
||||
int error;
|
||||
|
||||
adc_context_lock(&data->ctx, true, async);
|
||||
|
@ -327,8 +321,8 @@ static const struct adc_driver_api adc_sam_api = {
|
|||
|
||||
static void adc_sam_isr(const struct device *dev)
|
||||
{
|
||||
struct adc_sam_data *data = DEV_DATA(dev);
|
||||
const struct adc_sam_cfg *const cfg = DEV_CFG(dev);
|
||||
struct adc_sam_data *data = dev->data;
|
||||
const struct adc_sam_cfg *const cfg = dev->config;
|
||||
Afec *const afec = cfg->regs;
|
||||
uint16_t result;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue