11
11
#include <linux/property.h>
12
12
#include <linux/slab.h>
13
13
14
- static int pci_pwrctl_notify (struct notifier_block * nb , unsigned long action ,
15
- void * data )
14
+ static int pci_pwrctrl_notify (struct notifier_block * nb , unsigned long action ,
15
+ void * data )
16
16
{
17
- struct pci_pwrctl * pwrctl = container_of (nb , struct pci_pwrctl , nb );
17
+ struct pci_pwrctrl * pwrctrl = container_of (nb , struct pci_pwrctrl , nb );
18
18
struct device * dev = data ;
19
19
20
- if (dev_fwnode (dev ) != dev_fwnode (pwrctl -> dev ))
20
+ if (dev_fwnode (dev ) != dev_fwnode (pwrctrl -> dev ))
21
21
return NOTIFY_DONE ;
22
22
23
23
switch (action ) {
@@ -40,31 +40,32 @@ static int pci_pwrctl_notify(struct notifier_block *nb, unsigned long action,
40
40
41
41
static void rescan_work_func (struct work_struct * work )
42
42
{
43
- struct pci_pwrctl * pwrctl = container_of (work , struct pci_pwrctl , work );
43
+ struct pci_pwrctrl * pwrctrl = container_of (work ,
44
+ struct pci_pwrctrl , work );
44
45
45
46
pci_lock_rescan_remove ();
46
- pci_rescan_bus (to_pci_dev (pwrctl -> dev -> parent )-> bus );
47
+ pci_rescan_bus (to_pci_dev (pwrctrl -> dev -> parent )-> bus );
47
48
pci_unlock_rescan_remove ();
48
49
}
49
50
50
51
/**
51
- * pci_pwrctl_init () - Initialize the PCI power control context struct
52
+ * pci_pwrctrl_init () - Initialize the PCI power control context struct
52
53
*
53
- * @pwrctl : PCI power control data
54
+ * @pwrctrl : PCI power control data
54
55
* @dev: Parent device
55
56
*/
56
- void pci_pwrctl_init (struct pci_pwrctl * pwrctl , struct device * dev )
57
+ void pci_pwrctrl_init (struct pci_pwrctrl * pwrctrl , struct device * dev )
57
58
{
58
- pwrctl -> dev = dev ;
59
- INIT_WORK (& pwrctl -> work , rescan_work_func );
59
+ pwrctrl -> dev = dev ;
60
+ INIT_WORK (& pwrctrl -> work , rescan_work_func );
60
61
}
61
- EXPORT_SYMBOL_GPL (pci_pwrctl_init );
62
+ EXPORT_SYMBOL_GPL (pci_pwrctrl_init );
62
63
63
64
/**
64
- * pci_pwrctl_device_set_ready () - Notify the pwrctl subsystem that the PCI
65
+ * pci_pwrctrl_device_set_ready () - Notify the pwrctrl subsystem that the PCI
65
66
* device is powered-up and ready to be detected.
66
67
*
67
- * @pwrctl : PCI power control data.
68
+ * @pwrctrl : PCI power control data.
68
69
*
69
70
* Returns:
70
71
* 0 on success, negative error number on error.
@@ -74,73 +75,73 @@ EXPORT_SYMBOL_GPL(pci_pwrctl_init);
74
75
* that the bus rescan was successfully started. The device will get bound to
75
76
* its PCI driver asynchronously.
76
77
*/
77
- int pci_pwrctl_device_set_ready (struct pci_pwrctl * pwrctl )
78
+ int pci_pwrctrl_device_set_ready (struct pci_pwrctrl * pwrctrl )
78
79
{
79
80
int ret ;
80
81
81
- if (!pwrctl -> dev )
82
+ if (!pwrctrl -> dev )
82
83
return - ENODEV ;
83
84
84
- pwrctl -> nb .notifier_call = pci_pwrctl_notify ;
85
- ret = bus_register_notifier (& pci_bus_type , & pwrctl -> nb );
85
+ pwrctrl -> nb .notifier_call = pci_pwrctrl_notify ;
86
+ ret = bus_register_notifier (& pci_bus_type , & pwrctrl -> nb );
86
87
if (ret )
87
88
return ret ;
88
89
89
- schedule_work (& pwrctl -> work );
90
+ schedule_work (& pwrctrl -> work );
90
91
91
92
return 0 ;
92
93
}
93
- EXPORT_SYMBOL_GPL (pci_pwrctl_device_set_ready );
94
+ EXPORT_SYMBOL_GPL (pci_pwrctrl_device_set_ready );
94
95
95
96
/**
96
- * pci_pwrctl_device_unset_ready () - Notify the pwrctl subsystem that the PCI
97
+ * pci_pwrctrl_device_unset_ready () - Notify the pwrctrl subsystem that the PCI
97
98
* device is about to be powered-down.
98
99
*
99
- * @pwrctl : PCI power control data.
100
+ * @pwrctrl : PCI power control data.
100
101
*/
101
- void pci_pwrctl_device_unset_ready (struct pci_pwrctl * pwrctl )
102
+ void pci_pwrctrl_device_unset_ready (struct pci_pwrctrl * pwrctrl )
102
103
{
103
104
/*
104
105
* We don't have to delete the link here. Typically, this function
105
106
* is only called when the power control device is being detached. If
106
107
* it is being detached then the child PCI device must have already
107
108
* been unbound too or the device core wouldn't let us unbind.
108
109
*/
109
- bus_unregister_notifier (& pci_bus_type , & pwrctl -> nb );
110
+ bus_unregister_notifier (& pci_bus_type , & pwrctrl -> nb );
110
111
}
111
- EXPORT_SYMBOL_GPL (pci_pwrctl_device_unset_ready );
112
+ EXPORT_SYMBOL_GPL (pci_pwrctrl_device_unset_ready );
112
113
113
- static void devm_pci_pwrctl_device_unset_ready (void * data )
114
+ static void devm_pci_pwrctrl_device_unset_ready (void * data )
114
115
{
115
- struct pci_pwrctl * pwrctl = data ;
116
+ struct pci_pwrctrl * pwrctrl = data ;
116
117
117
- pci_pwrctl_device_unset_ready ( pwrctl );
118
+ pci_pwrctrl_device_unset_ready ( pwrctrl );
118
119
}
119
120
120
121
/**
121
- * devm_pci_pwrctl_device_set_ready - Managed variant of
122
- * pci_pwrctl_device_set_ready ().
122
+ * devm_pci_pwrctrl_device_set_ready - Managed variant of
123
+ * pci_pwrctrl_device_set_ready ().
123
124
*
124
- * @dev: Device managing this pwrctl provider.
125
- * @pwrctl : PCI power control data.
125
+ * @dev: Device managing this pwrctrl provider.
126
+ * @pwrctrl : PCI power control data.
126
127
*
127
128
* Returns:
128
129
* 0 on success, negative error number on error.
129
130
*/
130
- int devm_pci_pwrctl_device_set_ready (struct device * dev ,
131
- struct pci_pwrctl * pwrctl )
131
+ int devm_pci_pwrctrl_device_set_ready (struct device * dev ,
132
+ struct pci_pwrctrl * pwrctrl )
132
133
{
133
134
int ret ;
134
135
135
- ret = pci_pwrctl_device_set_ready ( pwrctl );
136
+ ret = pci_pwrctrl_device_set_ready ( pwrctrl );
136
137
if (ret )
137
138
return ret ;
138
139
139
140
return devm_add_action_or_reset (dev ,
140
- devm_pci_pwrctl_device_unset_ready ,
141
- pwrctl );
141
+ devm_pci_pwrctrl_device_unset_ready ,
142
+ pwrctrl );
142
143
}
143
- EXPORT_SYMBOL_GPL (devm_pci_pwrctl_device_set_ready );
144
+ EXPORT_SYMBOL_GPL (devm_pci_pwrctrl_device_set_ready );
144
145
145
146
MODULE_AUTHOR (
"Bartosz Golaszewski <[email protected] >" );
146
147
MODULE_DESCRIPTION ("PCI Device Power Control core driver" );
0 commit comments