Skip to content

Commit 9696765

Browse files
ycsindkalowsk
authored andcommitted
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>
1 parent 095d318 commit 9696765

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

drivers/syscon/syscon.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,16 @@ struct syscon_generic_data {
2929

3030
static int syscon_generic_get_base(const struct device *dev, uintptr_t *addr)
3131
{
32-
if (!dev) {
33-
return -ENODEV;
34-
}
35-
3632
*addr = DEVICE_MMIO_GET(dev);
3733
return 0;
3834
}
3935

4036
static int syscon_generic_read_reg(const struct device *dev, uint16_t reg, uint32_t *val)
4137
{
42-
const struct syscon_generic_config *config;
43-
struct syscon_generic_data *data;
38+
const struct syscon_generic_config *config = dev->config;
39+
struct syscon_generic_data *data = dev->data;
4440
uintptr_t base_address;
4541

46-
if (!dev) {
47-
return -ENODEV;
48-
}
49-
50-
data = dev->data;
51-
config = dev->config;
52-
5342
if (!val) {
5443
return -EINVAL;
5544
}
@@ -79,17 +68,10 @@ static int syscon_generic_read_reg(const struct device *dev, uint16_t reg, uint3
7968

8069
static int syscon_generic_write_reg(const struct device *dev, uint16_t reg, uint32_t val)
8170
{
82-
const struct syscon_generic_config *config;
83-
struct syscon_generic_data *data;
71+
const struct syscon_generic_config *config = dev->config;
72+
struct syscon_generic_data *data = dev->data;
8473
uintptr_t base_address;
8574

86-
if (!dev) {
87-
return -ENODEV;
88-
}
89-
90-
data = dev->data;
91-
config = dev->config;
92-
9375
if (syscon_sanitize_reg(&reg, data->size, config->reg_width)) {
9476
return -EINVAL;
9577
}

0 commit comments

Comments
 (0)