Message ID | 1453407813-14646-3-git-send-email-javier@osg.samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 22.01.2016 05:23, Javier Martinez Canillas wrote: > It is better to use the ARRAY_SIZE() macro instead of the array length > to avoid bugs if the array is later changed and the length not updated. > > Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> > Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> > > --- Tested on Trats2 board with max77686: Tested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Best regards, Krzysztof -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Friday 22 January 2016 01:53 AM, Javier Martinez Canillas wrote: > It is better to use the ARRAY_SIZE() macro instead of the array length > to avoid bugs if the array is later changed and the length not updated. > > Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> > Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> > > Acked-by: Laxman Dewangan <ldewangan@nvidia.com> Similar stuffs are there on multiple places: u8 data[RTC_NR_TIME]; ::: ret = regmap_bulk_read(info->max77686->rtc_regmap, MAX77686_ALARM1_SEC, data, RTC_NR_TIME); Should we say: ret = regmap_bulk_read(info->max77686->rtc_regmap, MAX77686_ALARM1_SEC, data, ARRAY_SIZE(data)); -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello Laxman, Thanks a lot for your feedback and acks. On 01/22/2016 06:39 AM, Laxman Dewangan wrote: > > On Friday 22 January 2016 01:53 AM, Javier Martinez Canillas wrote: >> It is better to use the ARRAY_SIZE() macro instead of the array length >> to avoid bugs if the array is later changed and the length not updated. >> >> Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> >> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> >> >> > Acked-by: Laxman Dewangan <ldewangan@nvidia.com> > > > Similar stuffs are there on multiple places: > u8 data[RTC_NR_TIME]; > > ::: > ret = regmap_bulk_read(info->max77686->rtc_regmap, > MAX77686_ALARM1_SEC, data, RTC_NR_TIME); > > > Should we say: > ret = regmap_bulk_read(info->max77686->rtc_regmap, > MAX77686_ALARM1_SEC, data, ARRAY_SIZE(data)); > Very good point, I'll change those on this patch as well for v3. Best regards,
diff --git a/drivers/rtc/rtc-max77686.c b/drivers/rtc/rtc-max77686.c index 6653c3d11b66..98fabdb308b9 100644 --- a/drivers/rtc/rtc-max77686.c +++ b/drivers/rtc/rtc-max77686.c @@ -406,7 +406,8 @@ static int max77686_rtc_init_reg(struct max77686_rtc_info *info) info->rtc_24hr_mode = 1; - ret = regmap_bulk_write(info->max77686->rtc_regmap, MAX77686_RTC_CONTROLM, data, 2); + ret = regmap_bulk_write(info->max77686->rtc_regmap, + MAX77686_RTC_CONTROLM, data, ARRAY_SIZE(data)); if (ret < 0) { dev_err(info->dev, "%s: fail to write controlm reg(%d)\n", __func__, ret);