summaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorEduardo Valentin <edubezval@gmail.com>2016-11-08 00:09:26 -0500
committerZhang Rui <rui.zhang@intel.com>2016-11-22 21:06:12 -0500
commitb819dc9ef064430118634160330eaa93708aad28 (patch)
tree950b989f8f92b5899e0878d5bb72fa52801dee14 /drivers/thermal
parent95e3ed1513494aa2d0aaba7a99fb7aa8b51dcfc8 (diff)
thermal: sysfs: use kcalloc() instead of kzalloc()
Simplify size computation by using kcalloc() for allocating memory for arrays. Cc: Zhang Rui <rui.zhang@intel.com> Cc: linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Eduardo Valentin <edubezval@gmail.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/thermal_sysfs.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index 4807015c26de..a694de907a26 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -511,7 +511,6 @@ static const struct attribute_group *thermal_zone_attribute_groups[] = {
511 */ 511 */
512static int create_trip_attrs(struct thermal_zone_device *tz, int mask) 512static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
513{ 513{
514 int size = sizeof(struct thermal_attr) * tz->trips;
515 struct attribute **attrs; 514 struct attribute **attrs;
516 int indx; 515 int indx;
517 516
@@ -519,18 +518,22 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
519 if (tz->trips <= 0) 518 if (tz->trips <= 0)
520 return -EINVAL; 519 return -EINVAL;
521 520
522 tz->trip_type_attrs = kzalloc(size, GFP_KERNEL); 521 tz->trip_type_attrs = kcalloc(tz->trips, sizeof(*tz->trip_type_attrs),
522 GFP_KERNEL);
523 if (!tz->trip_type_attrs) 523 if (!tz->trip_type_attrs)
524 return -ENOMEM; 524 return -ENOMEM;
525 525
526 tz->trip_temp_attrs = kzalloc(size, GFP_KERNEL); 526 tz->trip_temp_attrs = kcalloc(tz->trips, sizeof(*tz->trip_temp_attrs),
527 GFP_KERNEL);
527 if (!tz->trip_temp_attrs) { 528 if (!tz->trip_temp_attrs) {
528 kfree(tz->trip_type_attrs); 529 kfree(tz->trip_type_attrs);
529 return -ENOMEM; 530 return -ENOMEM;
530 } 531 }
531 532
532 if (tz->ops->get_trip_hyst) { 533 if (tz->ops->get_trip_hyst) {
533 tz->trip_hyst_attrs = kzalloc(size, GFP_KERNEL); 534 tz->trip_hyst_attrs = kcalloc(tz->trips,
535 sizeof(*tz->trip_hyst_attrs),
536 GFP_KERNEL);
534 if (!tz->trip_hyst_attrs) { 537 if (!tz->trip_hyst_attrs) {
535 kfree(tz->trip_type_attrs); 538 kfree(tz->trip_type_attrs);
536 kfree(tz->trip_temp_attrs); 539 kfree(tz->trip_temp_attrs);
@@ -538,7 +541,7 @@ static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
538 } 541 }
539 } 542 }
540 543
541 attrs = kzalloc(sizeof(*attrs) * tz->trips * 3 + 1, GFP_KERNEL); 544 attrs = kcalloc(tz->trips * 3 + 1, sizeof(*attrs), GFP_KERNEL);
542 if (!attrs) { 545 if (!attrs) {
543 kfree(tz->trip_type_attrs); 546 kfree(tz->trip_type_attrs);
544 kfree(tz->trip_temp_attrs); 547 kfree(tz->trip_temp_attrs);