Skip to content

Commit 223af4a

Browse files
nehebpH5
authored andcommitted
reset: sti: kzalloc + kcalloc to kzalloc
Simplify allocation. Signed-off-by: Rosen Penev <rosenp@gmail.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
1 parent 62d11b8 commit 223af4a

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

drivers/reset/sti/reset-syscfg.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct syscfg_reset_channel {
4141
struct syscfg_reset_controller {
4242
struct reset_controller_dev rst;
4343
bool active_low;
44-
struct syscfg_reset_channel *channels;
44+
struct syscfg_reset_channel channels[];
4545
};
4646

4747
#define to_syscfg_reset_controller(_rst) \
@@ -135,15 +135,10 @@ static int syscfg_reset_controller_register(struct device *dev,
135135
struct syscfg_reset_controller *rc;
136136
int i, err;
137137

138-
rc = devm_kzalloc(dev, sizeof(*rc), GFP_KERNEL);
138+
rc = devm_kzalloc(dev, struct_size(rc, channels, data->nr_channels), GFP_KERNEL);
139139
if (!rc)
140140
return -ENOMEM;
141141

142-
rc->channels = devm_kcalloc(dev, data->nr_channels,
143-
sizeof(*rc->channels), GFP_KERNEL);
144-
if (!rc->channels)
145-
return -ENOMEM;
146-
147142
rc->rst.ops = &syscfg_reset_ops;
148143
rc->rst.of_node = dev->of_node;
149144
rc->rst.nr_resets = data->nr_channels;

0 commit comments

Comments
 (0)