drivers: remove redundant data/config casts

Some drivers explicitely casted data/config from void * to the
corresponding type. However, this is unnecessary and, in many drivers it
has been misused to drop const qualifier (refer to previous commits).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2022-01-19 12:14:50 +01:00 committed by Carles Cufí
commit 435213a753
20 changed files with 68 additions and 69 deletions

View file

@ -229,7 +229,7 @@ static int adc_cc32xx_read_async(const struct device *dev,
static void adc_cc32xx_isr(const struct device *dev, int no) static void adc_cc32xx_isr(const struct device *dev, int no)
{ {
const struct adc_cc32xx_cfg *config = dev->config; const struct adc_cc32xx_cfg *config = dev->config;
struct adc_cc32xx_data *data = (struct adc_cc32xx_data *)dev->data; struct adc_cc32xx_data *data = dev->data;
const int chan = s_channel[no]; const int chan = s_channel[no];
unsigned long mask = MAP_ADCIntStatus(config->base, chan); unsigned long mask = MAP_ADCIntStatus(config->base, chan);
int cnt = 0; int cnt = 0;

View file

@ -704,7 +704,7 @@ static void adc_context_update_buffer_pointer(struct adc_context *ctx,
static void adc_stm32_isr(const struct device *dev) static void adc_stm32_isr(const struct device *dev)
{ {
struct adc_stm32_data *data = (struct adc_stm32_data *)dev->data; struct adc_stm32_data *data = dev->data;
const struct adc_stm32_cfg *config = const struct adc_stm32_cfg *config =
(const struct adc_stm32_cfg *)dev->config; (const struct adc_stm32_cfg *)dev->config;
ADC_TypeDef *adc = config->base; ADC_TypeDef *adc = config->base;

View file

@ -82,7 +82,7 @@ static int mcp4725_channel_setup(const struct device *dev,
static int mcp4725_write_value(const struct device *dev, uint8_t channel, static int mcp4725_write_value(const struct device *dev, uint8_t channel,
uint32_t value) uint32_t value)
{ {
const struct mcp4725_config *config = (struct mcp4725_config *)dev->config; const struct mcp4725_config *config = dev->config;
uint8_t tx_data[2]; uint8_t tx_data[2];
int ret; int ret;

View file

@ -22,8 +22,7 @@ struct dummy_display_data {
static int dummy_display_init(const struct device *dev) static int dummy_display_init(const struct device *dev)
{ {
struct dummy_display_data *disp_data = struct dummy_display_data *disp_data = dev->data;
(struct dummy_display_data *)dev->data;
disp_data->current_pixel_format = PIXEL_FORMAT_ARGB_8888; disp_data->current_pixel_format = PIXEL_FORMAT_ARGB_8888;

View file

@ -141,14 +141,14 @@ static int st7735r_reset_display(struct st7735r_data *data)
static int st7735r_blanking_on(const struct device *dev) static int st7735r_blanking_on(const struct device *dev)
{ {
struct st7735r_data *data = (struct st7735r_data *)dev->data; struct st7735r_data *data = dev->data;
return st7735r_transmit(data, ST7735R_CMD_DISP_OFF, NULL, 0); return st7735r_transmit(data, ST7735R_CMD_DISP_OFF, NULL, 0);
} }
static int st7735r_blanking_off(const struct device *dev) static int st7735r_blanking_off(const struct device *dev)
{ {
struct st7735r_data *data = (struct st7735r_data *)dev->data; struct st7735r_data *data = dev->data;
return st7735r_transmit(data, ST7735R_CMD_DISP_ON, NULL, 0); return st7735r_transmit(data, ST7735R_CMD_DISP_ON, NULL, 0);
} }
@ -196,7 +196,7 @@ static int st7735r_write(const struct device *dev,
const struct display_buffer_descriptor *desc, const struct display_buffer_descriptor *desc,
const void *buf) const void *buf)
{ {
struct st7735r_data *data = (struct st7735r_data *)dev->data; struct st7735r_data *data = dev->data;
const uint8_t *write_data_start = (uint8_t *) buf; const uint8_t *write_data_start = (uint8_t *) buf;
struct spi_buf tx_buf; struct spi_buf tx_buf;
struct spi_buf_set tx_bufs; struct spi_buf_set tx_bufs;
@ -269,7 +269,7 @@ static int st7735r_set_contrast(const struct device *dev,
static void st7735r_get_capabilities(const struct device *dev, static void st7735r_get_capabilities(const struct device *dev,
struct display_capabilities *capabilities) struct display_capabilities *capabilities)
{ {
const struct st7735r_config *config = (const struct st7735r_config *)dev->config; const struct st7735r_config *config = dev->config;
memset(capabilities, 0, sizeof(struct display_capabilities)); memset(capabilities, 0, sizeof(struct display_capabilities));
capabilities->x_resolution = config->width; capabilities->x_resolution = config->width;
@ -288,7 +288,7 @@ static void st7735r_get_capabilities(const struct device *dev,
static int st7735r_set_pixel_format(const struct device *dev, static int st7735r_set_pixel_format(const struct device *dev,
const enum display_pixel_format pixel_format) const enum display_pixel_format pixel_format)
{ {
const struct st7735r_config *config = (const struct st7735r_config *)dev->config; const struct st7735r_config *config = dev->config;
if ((pixel_format == PIXEL_FORMAT_RGB_565) && if ((pixel_format == PIXEL_FORMAT_RGB_565) &&
(~config->madctl & ST7735R_MADCTL_BGR)) { (~config->madctl & ST7735R_MADCTL_BGR)) {
@ -436,8 +436,8 @@ static int st7735r_lcd_init(struct st7735r_data *data)
static int st7735r_init(const struct device *dev) static int st7735r_init(const struct device *dev)
{ {
struct st7735r_data *data = (struct st7735r_data *)dev->data; struct st7735r_data *data = dev->data;
const struct st7735r_config *config = (const struct st7735r_config *)dev->config; const struct st7735r_config *config = dev->config;
int ret; int ret;
if (!spi_is_ready(&config->bus)) { if (!spi_is_ready(&config->bus)) {
@ -499,7 +499,7 @@ static int st7735r_pm_action(const struct device *dev,
enum pm_device_action action) enum pm_device_action action)
{ {
int ret = 0; int ret = 0;
struct st7735r_data *data = (struct st7735r_data *)dev->data; struct st7735r_data *data = dev->data;
switch (action) { switch (action) {
case PM_DEVICE_ACTION_RESUME: case PM_DEVICE_ACTION_RESUME:

View file

@ -218,7 +218,7 @@ void eth_mcux_phy_stop(struct eth_context *context);
static int eth_mcux_device_pm_action(const struct device *dev, static int eth_mcux_device_pm_action(const struct device *dev,
enum pm_device_action action) enum pm_device_action action)
{ {
struct eth_context *eth_ctx = (struct eth_context *)dev->data; struct eth_context *eth_ctx = dev->data;
int ret = 0; int ret = 0;
if (!eth_ctx->clock_dev) { if (!eth_ctx->clock_dev) {

View file

@ -78,7 +78,7 @@ static int write_port_regs(const struct device *dev, uint8_t reg, uint16_t value
*/ */
static int setup_pin_dir(const struct device *dev, uint32_t pin, int flags) static int setup_pin_dir(const struct device *dev, uint32_t pin, int flags)
{ {
struct mcp23xxx_drv_data *drv_data = (struct mcp23xxx_drv_data *)dev->data; struct mcp23xxx_drv_data *drv_data = dev->data;
uint16_t dir = drv_data->reg_cache.iodir; uint16_t dir = drv_data->reg_cache.iodir;
uint16_t output = drv_data->reg_cache.gpio; uint16_t output = drv_data->reg_cache.gpio;
int ret; int ret;
@ -119,7 +119,7 @@ static int setup_pin_dir(const struct device *dev, uint32_t pin, int flags)
*/ */
static int setup_pin_pull(const struct device *dev, uint32_t pin, int flags) static int setup_pin_pull(const struct device *dev, uint32_t pin, int flags)
{ {
struct mcp23xxx_drv_data *drv_data = (struct mcp23xxx_drv_data *)dev->data; struct mcp23xxx_drv_data *drv_data = dev->data;
uint16_t port; uint16_t port;
int ret; int ret;
@ -141,7 +141,7 @@ static int setup_pin_pull(const struct device *dev, uint32_t pin, int flags)
static int mcp23xxx_pin_cfg(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags) static int mcp23xxx_pin_cfg(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags)
{ {
struct mcp23xxx_drv_data *drv_data = (struct mcp23xxx_drv_data *)dev->data; struct mcp23xxx_drv_data *drv_data = dev->data;
int ret; int ret;
if (k_is_in_isr()) { if (k_is_in_isr()) {
@ -174,7 +174,7 @@ done:
static int mcp23xxx_port_get_raw(const struct device *dev, uint32_t *value) static int mcp23xxx_port_get_raw(const struct device *dev, uint32_t *value)
{ {
struct mcp23xxx_drv_data *drv_data = (struct mcp23xxx_drv_data *)dev->data; struct mcp23xxx_drv_data *drv_data = dev->data;
uint16_t buf; uint16_t buf;
int ret; int ret;
@ -195,7 +195,7 @@ static int mcp23xxx_port_get_raw(const struct device *dev, uint32_t *value)
static int mcp23xxx_port_set_masked_raw(const struct device *dev, uint32_t mask, uint32_t value) static int mcp23xxx_port_set_masked_raw(const struct device *dev, uint32_t mask, uint32_t value)
{ {
struct mcp23xxx_drv_data *drv_data = (struct mcp23xxx_drv_data *)dev->data; struct mcp23xxx_drv_data *drv_data = dev->data;
uint16_t buf; uint16_t buf;
int ret; int ret;
@ -229,7 +229,7 @@ static int mcp23xxx_port_clear_bits_raw(const struct device *dev, uint32_t mask)
static int mcp23xxx_port_toggle_bits(const struct device *dev, uint32_t mask) static int mcp23xxx_port_toggle_bits(const struct device *dev, uint32_t mask)
{ {
struct mcp23xxx_drv_data *drv_data = (struct mcp23xxx_drv_data *)dev->data; struct mcp23xxx_drv_data *drv_data = dev->data;
uint16_t buf; uint16_t buf;
int ret; int ret;
@ -277,7 +277,7 @@ const struct gpio_driver_api gpio_mcp23xxx_api_table = {
int gpio_mcp23xxx_init(const struct device *dev) int gpio_mcp23xxx_init(const struct device *dev)
{ {
const struct mcp23xxx_config *config = dev->config; const struct mcp23xxx_config *config = dev->config;
struct mcp23xxx_drv_data *drv_data = (struct mcp23xxx_drv_data *)dev->data; struct mcp23xxx_drv_data *drv_data = dev->data;
int err; int err;
if (config->ngpios != 8U && config->ngpios != 16U) { if (config->ngpios != 8U && config->ngpios != 16U) {

View file

@ -204,7 +204,7 @@ static int stmpe1600_port_get_raw(const struct device *dev, uint32_t *value)
static int stmpe1600_port_set_masked_raw(const struct device *dev, static int stmpe1600_port_set_masked_raw(const struct device *dev,
uint32_t mask, uint32_t value) uint32_t mask, uint32_t value)
{ {
struct stmpe1600_drvdata *const drvdata = (struct stmpe1600_drvdata *const)dev->data; struct stmpe1600_drvdata *const drvdata = dev->data;
uint16_t GPSR; uint16_t GPSR;
int ret; int ret;
@ -235,7 +235,7 @@ static int stmpe1600_port_clear_bits_raw(const struct device *dev, uint32_t mask
static int stmpe1600_port_toggle_bits(const struct device *dev, uint32_t mask) static int stmpe1600_port_toggle_bits(const struct device *dev, uint32_t mask)
{ {
struct stmpe1600_drvdata *const drvdata = (struct stmpe1600_drvdata *const)dev->data; struct stmpe1600_drvdata *const drvdata = dev->data;
uint16_t GPSR; uint16_t GPSR;
int ret; int ret;

View file

@ -111,7 +111,7 @@ static inline void i2s_purge_stream_buffers(struct stream *strm,
static void i2s_tx_stream_disable(const struct device *dev) static void i2s_tx_stream_disable(const struct device *dev)
{ {
struct i2s_dev_data *dev_data = (struct i2s_dev_data *)dev->data; struct i2s_dev_data *dev_data = dev->data;
struct stream *strm = &dev_data->tx; struct stream *strm = &dev_data->tx;
const struct device *dev_dma = dev_data->dev_dma; const struct device *dev_dma = dev_data->dev_dma;
const struct i2s_mcux_config *dev_cfg = dev->config; const struct i2s_mcux_config *dev_cfg = dev->config;
@ -144,7 +144,7 @@ static void i2s_tx_stream_disable(const struct device *dev)
static void i2s_rx_stream_disable(const struct device *dev) static void i2s_rx_stream_disable(const struct device *dev)
{ {
struct i2s_dev_data *dev_data = (struct i2s_dev_data *)dev->data; struct i2s_dev_data *dev_data = dev->data;
struct stream *strm = &dev_data->rx; struct stream *strm = &dev_data->rx;
const struct device *dev_dma = dev_data->dev_dma; const struct device *dev_dma = dev_data->dev_dma;
const struct i2s_mcux_config *dev_cfg = dev->config; const struct i2s_mcux_config *dev_cfg = dev->config;
@ -184,7 +184,7 @@ static void i2s_dma_tx_callback(const struct device *dma_dev,
const struct device *dev = (struct device *)arg; const struct device *dev = (struct device *)arg;
const struct i2s_mcux_config *dev_cfg = dev->config; const struct i2s_mcux_config *dev_cfg = dev->config;
I2S_Type *base = (I2S_Type *)dev_cfg->base; I2S_Type *base = (I2S_Type *)dev_cfg->base;
struct i2s_dev_data *dev_data = (struct i2s_dev_data *)dev->data; struct i2s_dev_data *dev_data = dev->data;
struct stream *strm = &dev_data->tx; struct stream *strm = &dev_data->tx;
void *buffer = NULL; void *buffer = NULL;
int ret; int ret;
@ -255,7 +255,7 @@ static void i2s_dma_rx_callback(const struct device *dma_dev,
struct device *dev = (struct device *)arg; struct device *dev = (struct device *)arg;
const struct i2s_mcux_config *dev_cfg = dev->config; const struct i2s_mcux_config *dev_cfg = dev->config;
I2S_Type *base = (I2S_Type *)dev_cfg->base; I2S_Type *base = (I2S_Type *)dev_cfg->base;
struct i2s_dev_data *dev_data = (struct i2s_dev_data *)dev->data; struct i2s_dev_data *dev_data = dev->data;
struct stream *strm = &dev_data->rx; struct stream *strm = &dev_data->rx;
void *buffer; void *buffer;
int ret; int ret;
@ -361,7 +361,7 @@ static int i2s_mcux_config(const struct device *dev, enum i2s_dir dir,
{ {
const struct i2s_mcux_config *dev_cfg = dev->config; const struct i2s_mcux_config *dev_cfg = dev->config;
I2S_Type *base = (I2S_Type *)dev_cfg->base; I2S_Type *base = (I2S_Type *)dev_cfg->base;
struct i2s_dev_data *dev_data = (struct i2s_dev_data *)dev->data; struct i2s_dev_data *dev_data = dev->data;
sai_transceiver_t config; sai_transceiver_t config;
uint32_t mclk; uint32_t mclk;
/*num_words is frame size*/ /*num_words is frame size*/
@ -614,7 +614,7 @@ static int i2s_mcux_config(const struct device *dev, enum i2s_dir dir,
const struct i2s_config *i2s_mcux_config_get(const struct device *dev, const struct i2s_config *i2s_mcux_config_get(const struct device *dev,
enum i2s_dir dir) enum i2s_dir dir)
{ {
struct i2s_dev_data *dev_data = (struct i2s_dev_data *)dev->data; struct i2s_dev_data *dev_data = dev->data;
if (dir == I2S_DIR_RX) if (dir == I2S_DIR_RX)
return &dev_data->rx.cfg; return &dev_data->rx.cfg;
@ -626,7 +626,7 @@ static int i2s_tx_stream_start(const struct device *dev)
{ {
int ret = 0; int ret = 0;
void *buffer; void *buffer;
struct i2s_dev_data *dev_data = (struct i2s_dev_data *)dev->data; struct i2s_dev_data *dev_data = dev->data;
struct stream *strm = &dev_data->tx; struct stream *strm = &dev_data->tx;
uint32_t data_path = strm->start_channel; uint32_t data_path = strm->start_channel;
const struct device *dev_dma = dev_data->dev_dma; const struct device *dev_dma = dev_data->dev_dma;
@ -680,7 +680,7 @@ static int i2s_rx_stream_start(const struct device *dev)
{ {
int ret = 0; int ret = 0;
void *buffer; void *buffer;
struct i2s_dev_data *dev_data = (struct i2s_dev_data *)dev->data; struct i2s_dev_data *dev_data = dev->data;
struct stream *strm = &dev_data->rx; struct stream *strm = &dev_data->rx;
const struct device *dev_dma = dev_data->dev_dma; const struct device *dev_dma = dev_data->dev_dma;
const struct i2s_mcux_config *dev_cfg = dev->config; const struct i2s_mcux_config *dev_cfg = dev->config;
@ -732,7 +732,7 @@ static int i2s_rx_stream_start(const struct device *dev)
static int i2s_mcux_trigger(const struct device *dev, enum i2s_dir dir, static int i2s_mcux_trigger(const struct device *dev, enum i2s_dir dir,
enum i2s_trigger_cmd cmd) enum i2s_trigger_cmd cmd)
{ {
struct i2s_dev_data *dev_data = (struct i2s_dev_data *)dev->data; struct i2s_dev_data *dev_data = dev->data;
struct stream *strm; struct stream *strm;
unsigned int key; unsigned int key;
int ret = 0; int ret = 0;
@ -830,7 +830,7 @@ static int i2s_mcux_read(const struct device *dev, void **mem_block,
size_t *size) size_t *size)
{ {
const struct i2s_mcux_config *dev_cfg = dev->config; const struct i2s_mcux_config *dev_cfg = dev->config;
struct i2s_dev_data *dev_data = (struct i2s_dev_data *)dev->data; struct i2s_dev_data *dev_data = dev->data;
struct stream *strm = &dev_data->rx; struct stream *strm = &dev_data->rx;
void *buffer; void *buffer;
int ret = 0; int ret = 0;
@ -869,7 +869,7 @@ static int i2s_mcux_read(const struct device *dev, void **mem_block,
static int i2s_mcux_write(const struct device *dev, void *mem_block, static int i2s_mcux_write(const struct device *dev, void *mem_block,
size_t size) size_t size)
{ {
struct i2s_dev_data *dev_data = (struct i2s_dev_data *)dev->data; struct i2s_dev_data *dev_data = dev->data;
struct stream *strm = &dev_data->tx; struct stream *strm = &dev_data->tx;
int ret; int ret;
@ -1013,7 +1013,7 @@ static int i2s_mcux_initialize(const struct device *dev)
{ {
const struct i2s_mcux_config *dev_cfg = dev->config; const struct i2s_mcux_config *dev_cfg = dev->config;
I2S_Type *base = (I2S_Type *)dev_cfg->base; I2S_Type *base = (I2S_Type *)dev_cfg->base;
struct i2s_dev_data *dev_data = (struct i2s_dev_data *)dev->data; struct i2s_dev_data *dev_data = dev->data;
uint32_t mclk; uint32_t mclk;
if (!dev_data->dev_dma) { if (!dev_data->dev_dma) {

View file

@ -423,7 +423,7 @@ static int its_send_invall_cmd(struct gicv3_its_data *data, uint32_t icid)
static int gicv3_its_send_int(const struct device *dev, uint32_t device_id, uint32_t event_id) static int gicv3_its_send_int(const struct device *dev, uint32_t device_id, uint32_t event_id)
{ {
struct gicv3_its_data *data = (struct gicv3_its_data *)dev->data; struct gicv3_its_data *data = dev->data;
/* TOFIX check device_id & event_id bounds */ /* TOFIX check device_id & event_id bounds */
@ -432,8 +432,8 @@ static int gicv3_its_send_int(const struct device *dev, uint32_t device_id, uint
static void its_setup_cmd_queue(const struct device *dev) static void its_setup_cmd_queue(const struct device *dev)
{ {
const struct gicv3_its_config *cfg = (const struct gicv3_its_config *)dev->config; const struct gicv3_its_config *cfg = dev->config;
struct gicv3_its_data *data = (struct gicv3_its_data *)dev->data; struct gicv3_its_data *data = dev->data;
uint64_t reg = 0; uint64_t reg = 0;
/* Zero out cmd table */ /* Zero out cmd table */
@ -458,7 +458,7 @@ static void its_setup_cmd_queue(const struct device *dev)
static uintptr_t gicv3_rdist_get_rdbase(const struct device *dev, unsigned int cpuid) static uintptr_t gicv3_rdist_get_rdbase(const struct device *dev, unsigned int cpuid)
{ {
struct gicv3_its_data *data = (struct gicv3_its_data *)dev->data; struct gicv3_its_data *data = dev->data;
uint64_t typer = sys_read64(data->base + GITS_TYPER); uint64_t typer = sys_read64(data->base + GITS_TYPER);
if (GITS_TYPER_PTA_GET(typer)) { if (GITS_TYPER_PTA_GET(typer)) {
@ -471,7 +471,7 @@ static uintptr_t gicv3_rdist_get_rdbase(const struct device *dev, unsigned int c
static int gicv3_its_map_intid(const struct device *dev, uint32_t device_id, uint32_t event_id, static int gicv3_its_map_intid(const struct device *dev, uint32_t device_id, uint32_t event_id,
unsigned int intid) unsigned int intid)
{ {
struct gicv3_its_data *data = (struct gicv3_its_data *)dev->data; struct gicv3_its_data *data = dev->data;
int ret; int ret;
/* TOFIX check device_id, event_id & intid bounds */ /* TOFIX check device_id, event_id & intid bounds */
@ -494,7 +494,7 @@ static int gicv3_its_map_intid(const struct device *dev, uint32_t device_id, uin
static int gicv3_its_init_device_id(const struct device *dev, uint32_t device_id, static int gicv3_its_init_device_id(const struct device *dev, uint32_t device_id,
unsigned int nites) unsigned int nites)
{ {
struct gicv3_its_data *data = (struct gicv3_its_data *)dev->data; struct gicv3_its_data *data = dev->data;
size_t entry_size, alloc_size; size_t entry_size, alloc_size;
int nr_ites; int nr_ites;
void *itt; void *itt;
@ -610,8 +610,8 @@ void its_rdist_invall(void)
static int gicv3_its_init(const struct device *dev) static int gicv3_its_init(const struct device *dev)
{ {
const struct gicv3_its_config *cfg = (const struct gicv3_its_config *)dev->config; const struct gicv3_its_config *cfg = dev->config;
struct gicv3_its_data *data = (struct gicv3_its_data *)dev->data; struct gicv3_its_data *data = dev->data;
uint32_t reg; uint32_t reg;
int ret; int ret;

View file

@ -96,7 +96,7 @@ static bool verify_chip(void)
static int ft8xx_init(const struct device *dev) static int ft8xx_init(const struct device *dev)
{ {
int ret; int ret;
const struct ft8xx_config *config = (const struct ft8xx_config *)dev->config; const struct ft8xx_config *config = dev->config;
ret = ft8xx_drv_init(); ret = ft8xx_drv_init();
if (ret < 0) { if (ret < 0) {

View file

@ -41,8 +41,8 @@ struct pcie_ecam_data {
static int pcie_ecam_init(const struct device *dev) static int pcie_ecam_init(const struct device *dev)
{ {
const struct pcie_ctrl_config *cfg = (const struct pcie_ctrl_config *)dev->config; const struct pcie_ctrl_config *cfg = dev->config;
struct pcie_ecam_data *data = (struct pcie_ecam_data *)dev->data; struct pcie_ecam_data *data = dev->data;
int i; int i;
/* /*
@ -172,7 +172,7 @@ static int pcie_ecam_init(const struct device *dev)
static uint32_t pcie_ecam_ctrl_conf_read(const struct device *dev, pcie_bdf_t bdf, unsigned int reg) static uint32_t pcie_ecam_ctrl_conf_read(const struct device *dev, pcie_bdf_t bdf, unsigned int reg)
{ {
struct pcie_ecam_data *data = (struct pcie_ecam_data *)dev->data; struct pcie_ecam_data *data = dev->data;
return pcie_generic_ctrl_conf_read(data->cfg_addr, bdf, reg); return pcie_generic_ctrl_conf_read(data->cfg_addr, bdf, reg);
} }
@ -180,7 +180,7 @@ static uint32_t pcie_ecam_ctrl_conf_read(const struct device *dev, pcie_bdf_t bd
static void pcie_ecam_ctrl_conf_write(const struct device *dev, pcie_bdf_t bdf, unsigned int reg, static void pcie_ecam_ctrl_conf_write(const struct device *dev, pcie_bdf_t bdf, unsigned int reg,
uint32_t reg_data) uint32_t reg_data)
{ {
struct pcie_ecam_data *data = (struct pcie_ecam_data *)dev->data; struct pcie_ecam_data *data = dev->data;
pcie_generic_ctrl_conf_write(data->cfg_addr, bdf, reg, reg_data); pcie_generic_ctrl_conf_write(data->cfg_addr, bdf, reg, reg_data);
} }
@ -207,7 +207,7 @@ static bool pcie_ecam_region_allocate(const struct device *dev, pcie_bdf_t bdf,
bool mem, bool mem64, size_t bar_size, bool mem, bool mem64, size_t bar_size,
uintptr_t *bar_bus_addr) uintptr_t *bar_bus_addr)
{ {
struct pcie_ecam_data *data = (struct pcie_ecam_data *)dev->data; struct pcie_ecam_data *data = dev->data;
enum pcie_region_type type; enum pcie_region_type type;
if (mem && !data->regions[PCIE_REGION_MEM64].size && if (mem && !data->regions[PCIE_REGION_MEM64].size &&
@ -244,7 +244,7 @@ static bool pcie_ecam_region_translate(const struct device *dev, pcie_bdf_t bdf,
bool mem, bool mem64, uintptr_t bar_bus_addr, bool mem, bool mem64, uintptr_t bar_bus_addr,
uintptr_t *bar_addr) uintptr_t *bar_addr)
{ {
struct pcie_ecam_data *data = (struct pcie_ecam_data *)dev->data; struct pcie_ecam_data *data = dev->data;
enum pcie_region_type type; enum pcie_region_type type;
/* Means it hasn't been allocated */ /* Means it hasn't been allocated */

View file

@ -344,7 +344,7 @@ static int bme680_read_compensation(const struct device *dev)
static int bme680_chip_init(const struct device *dev) static int bme680_chip_init(const struct device *dev)
{ {
struct bme680_data *data = (struct bme680_data *)dev->data; struct bme680_data *data = dev->data;
int err; int err;
err = bme680_reg_read(dev, BME680_REG_CHIP_ID, &data->chip_id, 1); err = bme680_reg_read(dev, BME680_REG_CHIP_ID, &data->chip_id, 1);

View file

@ -61,8 +61,8 @@ static inline int lm75_fetch_temp(const struct lm75_config *cfg, struct lm75_dat
static int lm75_sample_fetch(const struct device *dev, static int lm75_sample_fetch(const struct device *dev,
enum sensor_channel chan) enum sensor_channel chan)
{ {
struct lm75_data *data = (struct lm75_data *)dev->data; struct lm75_data *data = dev->data;
const struct lm75_config *cfg = (const struct lm75_config *)dev->config; const struct lm75_config *cfg = dev->config;
switch (chan) { switch (chan) {
case SENSOR_CHAN_ALL: case SENSOR_CHAN_ALL:
@ -77,7 +77,7 @@ static int lm75_channel_get(const struct device *dev,
enum sensor_channel chan, enum sensor_channel chan,
struct sensor_value *val) struct sensor_value *val)
{ {
struct lm75_data *data = (struct lm75_data *)dev->data; struct lm75_data *data = dev->data;
switch (chan) { switch (chan) {
case SENSOR_CHAN_AMBIENT_TEMP: case SENSOR_CHAN_AMBIENT_TEMP:
@ -96,7 +96,7 @@ static const struct sensor_driver_api lm75_driver_api = {
int lm75_init(const struct device *dev) int lm75_init(const struct device *dev)
{ {
const struct lm75_config *cfg = (const struct lm75_config *)dev->config; const struct lm75_config *cfg = dev->config;
if (device_is_ready(cfg->i2c_dev)) { if (device_is_ready(cfg->i2c_dev)) {
return 0; return 0;

View file

@ -23,7 +23,7 @@ static int sbs_cmd_reg_read(const struct device *dev,
uint8_t i2c_data[2]; uint8_t i2c_data[2];
int status; int status;
cfg = (struct sbs_gauge_config *)dev->config; cfg = dev->config;
status = i2c_burst_read(cfg->i2c_dev, cfg->i2c_addr, reg_addr, status = i2c_burst_read(cfg->i2c_dev, cfg->i2c_addr, reg_addr,
i2c_data, ARRAY_SIZE(i2c_data)); i2c_data, ARRAY_SIZE(i2c_data));
if (status < 0) { if (status < 0) {
@ -48,7 +48,7 @@ static int sbs_gauge_channel_get(const struct device *dev,
struct sbs_gauge_data *data; struct sbs_gauge_data *data;
int32_t int_temp; int32_t int_temp;
data = (struct sbs_gauge_data *)dev->data; data = dev->data;
val->val2 = 0; val->val2 = 0;
switch (chan) { switch (chan) {
@ -128,7 +128,7 @@ static int sbs_gauge_sample_fetch(const struct device *dev,
struct sbs_gauge_data *data; struct sbs_gauge_data *data;
int status = 0; int status = 0;
data = (struct sbs_gauge_data *)dev->data; data = dev->data;
switch (chan) { switch (chan) {
case SENSOR_CHAN_GAUGE_VOLTAGE: case SENSOR_CHAN_GAUGE_VOLTAGE:
@ -262,7 +262,7 @@ static int sbs_gauge_init(const struct device *dev)
{ {
const struct sbs_gauge_config *cfg; const struct sbs_gauge_config *cfg;
cfg = (struct sbs_gauge_config *)dev->config; cfg = dev->config;
if (!device_is_ready(cfg->i2c_dev)) { if (!device_is_ready(cfg->i2c_dev)) {
LOG_ERR("%s device is not ready", cfg->i2c_dev->name); LOG_ERR("%s device is not ready", cfg->i2c_dev->name);

View file

@ -84,7 +84,7 @@ int sht3xd_attr_set(const struct device *dev,
static inline void setup_alert(const struct device *dev, static inline void setup_alert(const struct device *dev,
bool enable) bool enable)
{ {
struct sht3xd_data *data = (struct sht3xd_data *)dev->data; struct sht3xd_data *data = dev->data;
const struct sht3xd_config *cfg = const struct sht3xd_config *cfg =
(const struct sht3xd_config *)dev->config; (const struct sht3xd_config *)dev->config;
unsigned int flags = enable unsigned int flags = enable
@ -99,11 +99,11 @@ static inline void handle_alert(const struct device *dev)
setup_alert(dev, false); setup_alert(dev, false);
#if defined(CONFIG_SHT3XD_TRIGGER_OWN_THREAD) #if defined(CONFIG_SHT3XD_TRIGGER_OWN_THREAD)
struct sht3xd_data *data = (struct sht3xd_data *)dev->data; struct sht3xd_data *data = dev->data;
k_sem_give(&data->gpio_sem); k_sem_give(&data->gpio_sem);
#elif defined(CONFIG_SHT3XD_TRIGGER_GLOBAL_THREAD) #elif defined(CONFIG_SHT3XD_TRIGGER_GLOBAL_THREAD)
struct sht3xd_data *data = (struct sht3xd_data *)dev->data; struct sht3xd_data *data = dev->data;
k_work_submit(&data->work); k_work_submit(&data->work);
#endif #endif
@ -113,7 +113,7 @@ int sht3xd_trigger_set(const struct device *dev,
const struct sensor_trigger *trig, const struct sensor_trigger *trig,
sensor_trigger_handler_t handler) sensor_trigger_handler_t handler)
{ {
struct sht3xd_data *data = (struct sht3xd_data *)dev->data; struct sht3xd_data *data = dev->data;
const struct sht3xd_config *cfg = const struct sht3xd_config *cfg =
(const struct sht3xd_config *)dev->config; (const struct sht3xd_config *)dev->config;
@ -153,7 +153,7 @@ static void sht3xd_gpio_callback(const struct device *dev,
static void sht3xd_thread_cb(const struct device *dev) static void sht3xd_thread_cb(const struct device *dev)
{ {
struct sht3xd_data *data = (struct sht3xd_data *)dev->data; struct sht3xd_data *data = dev->data;
if (data->handler != NULL) { if (data->handler != NULL) {
data->handler(dev, &data->trigger); data->handler(dev, &data->trigger);

View file

@ -70,7 +70,7 @@ static int vl53l0x_channel_get(const struct device *dev,
enum sensor_channel chan, enum sensor_channel chan,
struct sensor_value *val) struct sensor_value *val)
{ {
struct vl53l0x_data *drv_data = (struct vl53l0x_data *)dev->data; struct vl53l0x_data *drv_data = dev->data;
__ASSERT_NO_MSG(chan == SENSOR_CHAN_DISTANCE __ASSERT_NO_MSG(chan == SENSOR_CHAN_DISTANCE
|| chan == SENSOR_CHAN_PROX); || chan == SENSOR_CHAN_PROX);

View file

@ -257,7 +257,7 @@ static void uart_liteuart_irq_callback_set(const struct device *dev,
{ {
struct uart_liteuart_data *data; struct uart_liteuart_data *data;
data = (struct uart_liteuart_data *)dev->data; data = dev->data;
data->callback = cb; data->callback = cb;
data->cb_data = cb_data; data->cb_data = cb_data;
} }

View file

@ -475,7 +475,7 @@ static void dma_callback(const struct device *dma_dev, void *callback_arg,
const struct device *dev = (struct device *)callback_arg; const struct device *dev = (struct device *)callback_arg;
const struct spi_mcux_config *config = dev->config; const struct spi_mcux_config *config = dev->config;
SPI_Type *base = config->base; SPI_Type *base = config->base;
struct spi_mcux_data *data = (struct spi_mcux_data *)dev->data; struct spi_mcux_data *data = dev->data;
LOG_DBG("=dma call back @channel %d=", channel); LOG_DBG("=dma call back @channel %d=", channel);

View file

@ -450,7 +450,7 @@ static inline int z_impl_dma_request_channel(const struct device *dev,
const struct dma_driver_api *api = const struct dma_driver_api *api =
(const struct dma_driver_api *)dev->api; (const struct dma_driver_api *)dev->api;
/* dma_context shall be the first one in dev data */ /* dma_context shall be the first one in dev data */
struct dma_context *dma_ctx = (struct dma_context *)dev->data; struct dma_context *dma_ctx = dev->data;
if (dma_ctx->magic != DMA_MAGIC) { if (dma_ctx->magic != DMA_MAGIC) {
return channel; return channel;
@ -486,7 +486,7 @@ __syscall void dma_release_channel(const struct device *dev,
static inline void z_impl_dma_release_channel(const struct device *dev, static inline void z_impl_dma_release_channel(const struct device *dev,
uint32_t channel) uint32_t channel)
{ {
struct dma_context *dma_ctx = (struct dma_context *)dev->data; struct dma_context *dma_ctx = dev->data;
if (dma_ctx->magic != DMA_MAGIC) { if (dma_ctx->magic != DMA_MAGIC) {
return; return;