Skip to content

Commit 2b897a1

Browse files
andredlag-linaro
authored andcommitted
mfd: sec-common: Use sizeof(*var), not sizeof(struct type_of_var)
Using sizeof(*var) is generally preferred over using the size of its open-coded type when allocating memory. This helps avoiding bugs when the variable type changes but the memory allocation isn't updated, and it simplifies renaming of the struct if ever necessary. No functional change. Signed-off-by: André Draszik <andre.draszik@linaro.org> Link: https://lore.kernel.org/r/20250409-s2mpg10-v4-20-d66d5f39b6bf@linaro.org Signed-off-by: Lee Jones <lee@kernel.org>
1 parent 856c651 commit 2b897a1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/mfd/sec-common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ int sec_pmic_probe(struct device *dev, int device_type, unsigned int irq,
163163
struct sec_pmic_dev *sec_pmic;
164164
int ret, num_sec_devs;
165165

166-
sec_pmic = devm_kzalloc(dev, sizeof(struct sec_pmic_dev), GFP_KERNEL);
166+
sec_pmic = devm_kzalloc(dev, sizeof(*sec_pmic), GFP_KERNEL);
167167
if (!sec_pmic)
168168
return -ENOMEM;
169169

0 commit comments

Comments
 (0)