cpufreq.c (17ffc8b083ac299ff798419d1887b7cdcd4ae4d2) cpufreq.c (8101f99703048ceaa31c756abe1098d099249ad9)
1/*
2 * linux/drivers/cpufreq/cpufreq.c
3 *
4 * Copyright (C) 2001 Russell King
5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
6 * (C) 2013 Viresh Kumar <viresh.kumar@linaro.org>
7 *
8 * Oct 2005 - Ashok Raj <ashok.raj@intel.com>

--- 1274 unchanged lines hidden (view full) ---

1283 * Restore the saved policy when doing light-weight init and fall back
1284 * to the full init if that fails.
1285 */
1286 policy = recover_policy ? cpufreq_policy_restore(cpu) : NULL;
1287 if (!policy) {
1288 recover_policy = false;
1289 policy = cpufreq_policy_alloc(dev);
1290 if (!policy)
1/*
2 * linux/drivers/cpufreq/cpufreq.c
3 *
4 * Copyright (C) 2001 Russell King
5 * (C) 2002 - 2003 Dominik Brodowski <linux@brodo.de>
6 * (C) 2013 Viresh Kumar <viresh.kumar@linaro.org>
7 *
8 * Oct 2005 - Ashok Raj <ashok.raj@intel.com>

--- 1274 unchanged lines hidden (view full) ---

1283 * Restore the saved policy when doing light-weight init and fall back
1284 * to the full init if that fails.
1285 */
1286 policy = recover_policy ? cpufreq_policy_restore(cpu) : NULL;
1287 if (!policy) {
1288 recover_policy = false;
1289 policy = cpufreq_policy_alloc(dev);
1290 if (!policy)
1291 goto nomem_out;
1291 goto out_release_rwsem;
1292 }
1293
1294 cpumask_copy(policy->cpus, cpumask_of(cpu));
1295
1296 /* call driver. From then on the cpufreq must be able
1297 * to accept all calls to ->verify and ->setpolicy for this CPU
1298 */
1299 ret = cpufreq_driver->init(policy);
1300 if (ret) {
1301 pr_debug("initialization failed\n");
1292 }
1293
1294 cpumask_copy(policy->cpus, cpumask_of(cpu));
1295
1296 /* call driver. From then on the cpufreq must be able
1297 * to accept all calls to ->verify and ->setpolicy for this CPU
1298 */
1299 ret = cpufreq_driver->init(policy);
1300 if (ret) {
1301 pr_debug("initialization failed\n");
1302 goto err_set_policy_cpu;
1302 goto out_free_policy;
1303 }
1304
1305 down_write(&policy->rwsem);
1306
1307 /* related cpus should atleast have policy->cpus */
1308 cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus);
1309
1310 /*

--- 11 unchanged lines hidden (view full) ---

1322 per_cpu(cpufreq_cpu_data, j) = policy;
1323 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
1324 }
1325
1326 if (cpufreq_driver->get && !cpufreq_driver->setpolicy) {
1327 policy->cur = cpufreq_driver->get(policy->cpu);
1328 if (!policy->cur) {
1329 pr_err("%s: ->get() failed\n", __func__);
1303 }
1304
1305 down_write(&policy->rwsem);
1306
1307 /* related cpus should atleast have policy->cpus */
1308 cpumask_or(policy->related_cpus, policy->related_cpus, policy->cpus);
1309
1310 /*

--- 11 unchanged lines hidden (view full) ---

1322 per_cpu(cpufreq_cpu_data, j) = policy;
1323 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
1324 }
1325
1326 if (cpufreq_driver->get && !cpufreq_driver->setpolicy) {
1327 policy->cur = cpufreq_driver->get(policy->cpu);
1328 if (!policy->cur) {
1329 pr_err("%s: ->get() failed\n", __func__);
1330 goto err_get_freq;
1330 goto out_exit_policy;
1331 }
1332 }
1333
1334 /*
1335 * Sometimes boot loaders set CPU frequency to a value outside of
1336 * frequency table present with cpufreq core. In such cases CPU might be
1337 * unstable if it has to run on that frequency for long duration of time
1338 * and so its better to set it to a frequency which is specified in

--- 33 unchanged lines hidden (view full) ---

1372 }
1373
1374 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
1375 CPUFREQ_START, policy);
1376
1377 if (!recover_policy) {
1378 ret = cpufreq_add_dev_interface(policy, dev);
1379 if (ret)
1331 }
1332 }
1333
1334 /*
1335 * Sometimes boot loaders set CPU frequency to a value outside of
1336 * frequency table present with cpufreq core. In such cases CPU might be
1337 * unstable if it has to run on that frequency for long duration of time
1338 * and so its better to set it to a frequency which is specified in

--- 33 unchanged lines hidden (view full) ---

1372 }
1373
1374 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
1375 CPUFREQ_START, policy);
1376
1377 if (!recover_policy) {
1378 ret = cpufreq_add_dev_interface(policy, dev);
1379 if (ret)
1380 goto err_out_unregister;
1380 goto out_exit_policy;
1381 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
1382 CPUFREQ_CREATE_POLICY, policy);
1383
1384 write_lock_irqsave(&cpufreq_driver_lock, flags);
1385 list_add(&policy->policy_list, &cpufreq_policy_list);
1386 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
1387 }
1388

--- 12 unchanged lines hidden (view full) ---

1401 /* Callback for handling stuff after policy is ready */
1402 if (cpufreq_driver->ready)
1403 cpufreq_driver->ready(policy);
1404
1405 pr_debug("initialization complete\n");
1406
1407 return 0;
1408
1381 blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
1382 CPUFREQ_CREATE_POLICY, policy);
1383
1384 write_lock_irqsave(&cpufreq_driver_lock, flags);
1385 list_add(&policy->policy_list, &cpufreq_policy_list);
1386 write_unlock_irqrestore(&cpufreq_driver_lock, flags);
1387 }
1388

--- 12 unchanged lines hidden (view full) ---

1401 /* Callback for handling stuff after policy is ready */
1402 if (cpufreq_driver->ready)
1403 cpufreq_driver->ready(policy);
1404
1405 pr_debug("initialization complete\n");
1406
1407 return 0;
1408
1409err_out_unregister:
1410err_get_freq:
1409out_exit_policy:
1411 up_write(&policy->rwsem);
1412
1413 if (cpufreq_driver->exit)
1414 cpufreq_driver->exit(policy);
1410 up_write(&policy->rwsem);
1411
1412 if (cpufreq_driver->exit)
1413 cpufreq_driver->exit(policy);
1415err_set_policy_cpu:
1414out_free_policy:
1416 cpufreq_policy_free(policy, recover_policy);
1415 cpufreq_policy_free(policy, recover_policy);
1417nomem_out:
1416out_release_rwsem:
1418 up_read(&cpufreq_rwsem);
1419
1420 return ret;
1421}
1422
1423static int __cpufreq_remove_dev_prepare(struct device *dev,
1424 struct subsys_interface *sif)
1425{

--- 1202 unchanged lines hidden ---
1417 up_read(&cpufreq_rwsem);
1418
1419 return ret;
1420}
1421
1422static int __cpufreq_remove_dev_prepare(struct device *dev,
1423 struct subsys_interface *sif)
1424{

--- 1202 unchanged lines hidden ---