driver.c (cf40a76e7d5874bb25f4404eecc58a2e033af885) | driver.c (cb5d8c45ab6c3daf8269e550cfb2d5018a876fe3) |
---|---|
1/* 2 * driver.c - driver support 3 * 4 * (C) 2006-2007 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> 5 * Shaohua Li <shaohua.li@intel.com> 6 * Adam Belay <abelay@novell.com> 7 * 8 * This code is licenced under the GPL. --- 240 unchanged lines hidden (view full) --- 249 * Register the driver under a lock to prevent concurrent attempts to 250 * [un]register the driver from occuring at the same time. 251 * 252 * Returns 0 on success, a negative error code (returned by 253 * __cpuidle_register_driver()) otherwise. 254 */ 255int cpuidle_register_driver(struct cpuidle_driver *drv) 256{ | 1/* 2 * driver.c - driver support 3 * 4 * (C) 2006-2007 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com> 5 * Shaohua Li <shaohua.li@intel.com> 6 * Adam Belay <abelay@novell.com> 7 * 8 * This code is licenced under the GPL. --- 240 unchanged lines hidden (view full) --- 249 * Register the driver under a lock to prevent concurrent attempts to 250 * [un]register the driver from occuring at the same time. 251 * 252 * Returns 0 on success, a negative error code (returned by 253 * __cpuidle_register_driver()) otherwise. 254 */ 255int cpuidle_register_driver(struct cpuidle_driver *drv) 256{ |
257 struct cpuidle_governor *gov; |
|
257 int ret; 258 259 spin_lock(&cpuidle_driver_lock); 260 ret = __cpuidle_register_driver(drv); 261 spin_unlock(&cpuidle_driver_lock); 262 | 258 int ret; 259 260 spin_lock(&cpuidle_driver_lock); 261 ret = __cpuidle_register_driver(drv); 262 spin_unlock(&cpuidle_driver_lock); 263 |
264 if (!ret && !strlen(param_governor) && drv->governor && 265 (cpuidle_get_driver() == drv)) { 266 mutex_lock(&cpuidle_lock); 267 gov = cpuidle_find_governor(drv->governor); 268 if (gov) { 269 cpuidle_prev_governor = cpuidle_curr_governor; 270 if (cpuidle_switch_governor(gov) < 0) 271 cpuidle_prev_governor = NULL; 272 } 273 mutex_unlock(&cpuidle_lock); 274 } 275 |
|
263 return ret; 264} 265EXPORT_SYMBOL_GPL(cpuidle_register_driver); 266 267/** 268 * cpuidle_unregister_driver - unregisters a driver 269 * @drv: a pointer to a valid struct cpuidle_driver 270 * 271 * Unregisters the cpuidle driver under a lock to prevent concurrent attempts 272 * to [un]register the driver from occuring at the same time. @drv has to 273 * match the currently registered driver. 274 */ 275void cpuidle_unregister_driver(struct cpuidle_driver *drv) 276{ | 276 return ret; 277} 278EXPORT_SYMBOL_GPL(cpuidle_register_driver); 279 280/** 281 * cpuidle_unregister_driver - unregisters a driver 282 * @drv: a pointer to a valid struct cpuidle_driver 283 * 284 * Unregisters the cpuidle driver under a lock to prevent concurrent attempts 285 * to [un]register the driver from occuring at the same time. @drv has to 286 * match the currently registered driver. 287 */ 288void cpuidle_unregister_driver(struct cpuidle_driver *drv) 289{ |
290 bool enabled = (cpuidle_get_driver() == drv); 291 |
|
277 spin_lock(&cpuidle_driver_lock); 278 __cpuidle_unregister_driver(drv); 279 spin_unlock(&cpuidle_driver_lock); | 292 spin_lock(&cpuidle_driver_lock); 293 __cpuidle_unregister_driver(drv); 294 spin_unlock(&cpuidle_driver_lock); |
295 296 if (!enabled) 297 return; 298 299 mutex_lock(&cpuidle_lock); 300 if (cpuidle_prev_governor) { 301 if (!cpuidle_switch_governor(cpuidle_prev_governor)) 302 cpuidle_prev_governor = NULL; 303 } 304 mutex_unlock(&cpuidle_lock); |
|
280} 281EXPORT_SYMBOL_GPL(cpuidle_unregister_driver); 282 283/** 284 * cpuidle_get_driver - return the driver tied to the current CPU. 285 * 286 * Returns a struct cpuidle_driver pointer, or NULL if no driver is registered. 287 */ --- 69 unchanged lines hidden --- | 305} 306EXPORT_SYMBOL_GPL(cpuidle_unregister_driver); 307 308/** 309 * cpuidle_get_driver - return the driver tied to the current CPU. 310 * 311 * Returns a struct cpuidle_driver pointer, or NULL if no driver is registered. 312 */ --- 69 unchanged lines hidden --- |