Browse Source

drivers: syscon: remove unnecessary checks for `dev` pointer

The `dev` pointer passed to the implementation should never be `NULL`,
remove the checks.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
pull/92716/head
Yong Cong Sin 3 weeks ago committed by Dan Kalowsky
parent
commit
9696765b56
  1. 26
      drivers/syscon/syscon.c

26
drivers/syscon/syscon.c

@ -29,27 +29,16 @@ struct syscon_generic_data {
static int syscon_generic_get_base(const struct device *dev, uintptr_t *addr) static int syscon_generic_get_base(const struct device *dev, uintptr_t *addr)
{ {
if (!dev) {
return -ENODEV;
}
*addr = DEVICE_MMIO_GET(dev); *addr = DEVICE_MMIO_GET(dev);
return 0; return 0;
} }
static int syscon_generic_read_reg(const struct device *dev, uint16_t reg, uint32_t *val) static int syscon_generic_read_reg(const struct device *dev, uint16_t reg, uint32_t *val)
{ {
const struct syscon_generic_config *config; const struct syscon_generic_config *config = dev->config;
struct syscon_generic_data *data; struct syscon_generic_data *data = dev->data;
uintptr_t base_address; uintptr_t base_address;
if (!dev) {
return -ENODEV;
}
data = dev->data;
config = dev->config;
if (!val) { if (!val) {
return -EINVAL; return -EINVAL;
} }
@ -79,17 +68,10 @@ static int syscon_generic_read_reg(const struct device *dev, uint16_t reg, uint3
static int syscon_generic_write_reg(const struct device *dev, uint16_t reg, uint32_t val) static int syscon_generic_write_reg(const struct device *dev, uint16_t reg, uint32_t val)
{ {
const struct syscon_generic_config *config; const struct syscon_generic_config *config = dev->config;
struct syscon_generic_data *data; struct syscon_generic_data *data = dev->data;
uintptr_t base_address; uintptr_t base_address;
if (!dev) {
return -ENODEV;
}
data = dev->data;
config = dev->config;
if (syscon_sanitize_reg(&reg, data->size, config->reg_width)) { if (syscon_sanitize_reg(&reg, data->size, config->reg_width)) {
return -EINVAL; return -EINVAL;
} }

Loading…
Cancel
Save