summaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-88pm860x.c
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavo@embeddedor.com>2019-08-30 13:14:48 -0500
committerJacek Anaszewski <jacek.anaszewski@gmail.com>2019-09-01 13:33:29 +0200
commit1669ec78b87c0f04c963a5fc0885505d97468c7a (patch)
tree5520f9694ca4fda4fdb1e1b1ce99c679258ba92e /drivers/leds/leds-88pm860x.c
parent2637fd436c60c599e0967faee1903cce58c4a7f9 (diff)
downloadlinux-stable-1669ec78b87c0f04c963a5fc0885505d97468c7a.tar.gz
linux-stable-1669ec78b87c0f04c963a5fc0885505d97468c7a.tar.bz2
linux-stable-1669ec78b87c0f04c963a5fc0885505d97468c7a.zip
leds: is31fl32xx: Use struct_size() helper
One of the more common cases of allocation size calculations is finding the size of a structure that has a zero-sized array at the end, along with memory for some number of elements for that array. For example: struct is31fl32xx_priv { ... struct is31fl32xx_led_data leds[0]; }; Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes. So, replace the following function: static inline size_t sizeof_is31fl32xx_priv(int num_leds) { return sizeof(struct is31fl32xx_priv) + (sizeof(struct is31fl32xx_led_data) * num_leds); } with: struct_size(priv, leds, count) This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Diffstat (limited to 'drivers/leds/leds-88pm860x.c')
0 files changed, 0 insertions, 0 deletions