drivers: dac: 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:
Gerard Marull-Paretas 2022-01-18 15:20:23 +01:00 committed by Carles Cufí
parent c4550bc931
commit 3b6201e23a
2 changed files with 9 additions and 15 deletions

View file

@ -47,16 +47,12 @@ struct dac_sam_dev_data {
};
#define DEV_NAME(dev) ((dev)->name)
#define DEV_CFG(dev) \
((const struct dac_sam_dev_cfg *const)(dev)->config)
#define DEV_DATA(dev) \
((struct dac_sam_dev_data *const)(dev)->data)
static void dac_sam_isr(void *arg)
{
const struct device *dev = (const struct device *)arg;
const struct dac_sam_dev_cfg *const dev_cfg = DEV_CFG(dev);
struct dac_sam_dev_data *const dev_data = DEV_DATA(dev);
const struct dac_sam_dev_cfg *const dev_cfg = dev->config;
struct dac_sam_dev_data *const dev_data = dev->data;
Dacc *const dac = dev_cfg->regs;
uint32_t int_stat;
@ -78,7 +74,7 @@ static void dac_sam_isr(void *arg)
static int dac_sam_channel_setup(const struct device *dev,
const struct dac_channel_cfg *channel_cfg)
{
const struct dac_sam_dev_cfg *const dev_cfg = DEV_CFG(dev);
const struct dac_sam_dev_cfg *const dev_cfg = dev->config;
Dacc *const dac = dev_cfg->regs;
if (channel_cfg->channel_id >= DAC_CHANNEL_NO) {
@ -97,8 +93,8 @@ static int dac_sam_channel_setup(const struct device *dev,
static int dac_sam_write_value(const struct device *dev, uint8_t channel,
uint32_t value)
{
struct dac_sam_dev_data *const dev_data = DEV_DATA(dev);
const struct dac_sam_dev_cfg *const dev_cfg = DEV_CFG(dev);
struct dac_sam_dev_data *const dev_data = dev->data;
const struct dac_sam_dev_cfg *const dev_cfg = dev->config;
Dacc *const dac = dev_cfg->regs;
if (channel >= DAC_CHANNEL_NO) {
@ -123,8 +119,8 @@ static int dac_sam_write_value(const struct device *dev, uint8_t channel,
static int dac_sam_init(const struct device *dev)
{
const struct dac_sam_dev_cfg *const dev_cfg = DEV_CFG(dev);
struct dac_sam_dev_data *const dev_data = DEV_DATA(dev);
const struct dac_sam_dev_cfg *const dev_cfg = dev->config;
struct dac_sam_dev_data *const dev_data = dev->data;
Dacc *const dac = dev_cfg->regs;
/* Configure interrupts */

View file

@ -28,13 +28,11 @@ struct dac_sam0_cfg {
uint8_t refsel;
};
#define DEV_CFG(dev) ((const struct dac_sam0_cfg *const)(dev)->config)
/* Write to the DAC. */
static int dac_sam0_write_value(const struct device *dev, uint8_t channel,
uint32_t value)
{
const struct dac_sam0_cfg *const cfg = DEV_CFG(dev);
const struct dac_sam0_cfg *const cfg = dev->config;
Dac *regs = cfg->regs;
regs->DATA.reg = (uint16_t)value;
@ -62,7 +60,7 @@ static int dac_sam0_channel_setup(const struct device *dev,
/* Initialise and enable the DAC. */
static int dac_sam0_init(const struct device *dev)
{
const struct dac_sam0_cfg *const cfg = DEV_CFG(dev);
const struct dac_sam0_cfg *const cfg = dev->config;
Dac *regs = cfg->regs;
/* Enable the GCLK */