device: avoid casting away const from config_info pointer
The driver-specific config_info structure referenced from the device structure is marked const. Some drivers fail to preserve that qualifier when casting the pointer to the driver-specific structure, violating MISRA 11.8. Changes produced by scripts/coccinelle/const_config_info.cocci. Some changes proposed by the script are not included because they reveal mutation of state through the const pointer, though the code works as long as the driver-specific object is defined without the const qualifier. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
parent
49e8c7080f
commit
4f16b419e8
18 changed files with 41 additions and 41 deletions
|
@ -92,7 +92,7 @@ static int pwm_nrf5_sw_pin_set(struct device *dev, u32_t pwm,
|
|||
u32_t period_cycles, u32_t pulse_cycles,
|
||||
pwm_flags_t flags)
|
||||
{
|
||||
struct pwm_config *config;
|
||||
const struct pwm_config *config;
|
||||
NRF_TIMER_Type *timer;
|
||||
struct pwm_data *data;
|
||||
u8_t ppi_index;
|
||||
|
@ -100,7 +100,7 @@ static int pwm_nrf5_sw_pin_set(struct device *dev, u32_t pwm,
|
|||
u16_t div;
|
||||
u32_t ret;
|
||||
|
||||
config = (struct pwm_config *)dev->config_info;
|
||||
config = (const struct pwm_config *)dev->config_info;
|
||||
timer = config->timer;
|
||||
data = dev->driver_data;
|
||||
|
||||
|
@ -216,9 +216,9 @@ pin_set_pwm_off:
|
|||
static int pwm_nrf5_sw_get_cycles_per_sec(struct device *dev, u32_t pwm,
|
||||
u64_t *cycles)
|
||||
{
|
||||
struct pwm_config *config;
|
||||
const struct pwm_config *config;
|
||||
|
||||
config = (struct pwm_config *)dev->config_info;
|
||||
config = (const struct pwm_config *)dev->config_info;
|
||||
|
||||
/* HF timer frequency is derived from 16MHz source with a prescaler */
|
||||
*cycles = 16000000UL / BIT(config->prescaler);
|
||||
|
@ -233,10 +233,10 @@ static const struct pwm_driver_api pwm_nrf5_sw_drv_api_funcs = {
|
|||
|
||||
static int pwm_nrf5_sw_init(struct device *dev)
|
||||
{
|
||||
struct pwm_config *config;
|
||||
const struct pwm_config *config;
|
||||
NRF_TIMER_Type *timer;
|
||||
|
||||
config = (struct pwm_config *)dev->config_info;
|
||||
config = (const struct pwm_config *)dev->config_info;
|
||||
timer = config->timer;
|
||||
|
||||
/* setup HF timer */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue