hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/powercap/powercap_sys.c
....@@ -1,19 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Power capping class
34 * Copyright (c) 2013, Intel Corporation.
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms and conditions of the GNU General Public License,
7
- * version 2, as published by the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
13
- *
14
- * You should have received a copy of the GNU General Public License along with
15
- * this program; if not, write to the Free Software Foundation, Inc.
16
- *
175 */
186
197 #include <linux/module.h>
....@@ -542,9 +530,6 @@
542530 power_zone->name = kstrdup(name, GFP_KERNEL);
543531 if (!power_zone->name)
544532 goto err_name_alloc;
545
- dev_set_name(&power_zone->dev, "%s:%x",
546
- dev_name(power_zone->dev.parent),
547
- power_zone->id);
548533 power_zone->constraints = kcalloc(nr_constraints,
549534 sizeof(*power_zone->constraints),
550535 GFP_KERNEL);
....@@ -567,9 +552,16 @@
567552 power_zone->dev_attr_groups[0] = &power_zone->dev_zone_attr_group;
568553 power_zone->dev_attr_groups[1] = NULL;
569554 power_zone->dev.groups = power_zone->dev_attr_groups;
555
+ dev_set_name(&power_zone->dev, "%s:%x",
556
+ dev_name(power_zone->dev.parent),
557
+ power_zone->id);
570558 result = device_register(&power_zone->dev);
571
- if (result)
572
- goto err_dev_ret;
559
+ if (result) {
560
+ put_device(&power_zone->dev);
561
+ mutex_unlock(&control_type->lock);
562
+
563
+ return ERR_PTR(result);
564
+ }
573565
574566 control_type->nr_zones++;
575567 mutex_unlock(&control_type->lock);
....@@ -683,7 +675,7 @@
683675 return class_register(&powercap_class);
684676 }
685677
686
-device_initcall(powercap_init);
678
+fs_initcall(powercap_init);
687679
688680 MODULE_DESCRIPTION("PowerCap sysfs Driver");
689681 MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>");