| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Power capping class |
|---|
| 3 | 4 | * 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 | | - * |
|---|
| 17 | 5 | */ |
|---|
| 18 | 6 | |
|---|
| 19 | 7 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 542 | 530 | power_zone->name = kstrdup(name, GFP_KERNEL); |
|---|
| 543 | 531 | if (!power_zone->name) |
|---|
| 544 | 532 | goto err_name_alloc; |
|---|
| 545 | | - dev_set_name(&power_zone->dev, "%s:%x", |
|---|
| 546 | | - dev_name(power_zone->dev.parent), |
|---|
| 547 | | - power_zone->id); |
|---|
| 548 | 533 | power_zone->constraints = kcalloc(nr_constraints, |
|---|
| 549 | 534 | sizeof(*power_zone->constraints), |
|---|
| 550 | 535 | GFP_KERNEL); |
|---|
| .. | .. |
|---|
| 567 | 552 | power_zone->dev_attr_groups[0] = &power_zone->dev_zone_attr_group; |
|---|
| 568 | 553 | power_zone->dev_attr_groups[1] = NULL; |
|---|
| 569 | 554 | 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); |
|---|
| 570 | 558 | 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 | + } |
|---|
| 573 | 565 | |
|---|
| 574 | 566 | control_type->nr_zones++; |
|---|
| 575 | 567 | mutex_unlock(&control_type->lock); |
|---|
| .. | .. |
|---|
| 683 | 675 | return class_register(&powercap_class); |
|---|
| 684 | 676 | } |
|---|
| 685 | 677 | |
|---|
| 686 | | -device_initcall(powercap_init); |
|---|
| 678 | +fs_initcall(powercap_init); |
|---|
| 687 | 679 | |
|---|
| 688 | 680 | MODULE_DESCRIPTION("PowerCap sysfs Driver"); |
|---|
| 689 | 681 | MODULE_AUTHOR("Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>"); |
|---|