kern_cpu.c (67c8649f7fb5783bd325211ad1edaf06018fcb3e) kern_cpu.c (e94a0c1a18e6974bd6467d32a0f0fec8bffe5307)
1/*-
2 * Copyright (c) 2004-2005 Nate Lawson (SDG)
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

399 /* Skip devices that aren't ready. */
400 if (!device_is_attached(devs[i]))
401 continue;
402
403 /*
404 * Get settings, skipping drivers that offer no settings or
405 * provide settings for informational purposes only.
406 */
1/*-
2 * Copyright (c) 2004-2005 Nate Lawson (SDG)
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

399 /* Skip devices that aren't ready. */
400 if (!device_is_attached(devs[i]))
401 continue;
402
403 /*
404 * Get settings, skipping drivers that offer no settings or
405 * provide settings for informational purposes only.
406 */
407 error = CPUFREQ_DRV_TYPE(devs[i], &type);
408 if (error || (type & CPUFREQ_FLAG_INFO_ONLY))
409 continue;
407 set_count = MAX_SETTINGS;
410 set_count = MAX_SETTINGS;
408 error = CPUFREQ_DRV_SETTINGS(devs[i], sets, &set_count, &type);
409 if (error || set_count == 0 || (type & CPUFREQ_FLAG_INFO_ONLY))
411 error = CPUFREQ_DRV_SETTINGS(devs[i], sets, &set_count);
412 if (error || set_count == 0)
410 continue;
411
412 /* Add the settings to our absolute/relative lists. */
413 switch (type & CPUFREQ_TYPE_MASK) {
414 case CPUFREQ_TYPE_ABSOLUTE:
415 error = cpufreq_insert_abs(sc, sets, set_count);
416 break;
417 case CPUFREQ_TYPE_RELATIVE:

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

767
768 return (device_probe_and_attach(cf_dev));
769}
770
771int
772cpufreq_unregister(device_t dev)
773{
774 device_t cf_dev, *devs;
413 continue;
414
415 /* Add the settings to our absolute/relative lists. */
416 switch (type & CPUFREQ_TYPE_MASK) {
417 case CPUFREQ_TYPE_ABSOLUTE:
418 error = cpufreq_insert_abs(sc, sets, set_count);
419 break;
420 case CPUFREQ_TYPE_RELATIVE:

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

770
771 return (device_probe_and_attach(cf_dev));
772}
773
774int
775cpufreq_unregister(device_t dev)
776{
777 device_t cf_dev, *devs;
775 int cfcount, count, devcount, error, i, type;
776 struct cf_setting set;
778 int cfcount, devcount, error, i, type;
777
778 /*
779 * If this is the last cpufreq child device, remove the control
780 * device as well. We identify cpufreq children by calling a method
781 * they support.
782 */
783 error = device_get_children(device_get_parent(dev), &devs, &devcount);
784 if (error)
785 return (error);
786 cf_dev = device_find_child(device_get_parent(dev), "cpufreq", -1);
787 cfcount = 0;
788 for (i = 0; i < devcount; i++) {
789 if (!device_is_attached(devs[i]))
790 continue;
779
780 /*
781 * If this is the last cpufreq child device, remove the control
782 * device as well. We identify cpufreq children by calling a method
783 * they support.
784 */
785 error = device_get_children(device_get_parent(dev), &devs, &devcount);
786 if (error)
787 return (error);
788 cf_dev = device_find_child(device_get_parent(dev), "cpufreq", -1);
789 cfcount = 0;
790 for (i = 0; i < devcount; i++) {
791 if (!device_is_attached(devs[i]))
792 continue;
791 count = 1;
792 if (CPUFREQ_DRV_SETTINGS(devs[i], &set, &count, &type) == 0)
793 if (CPUFREQ_DRV_TYPE(devs[i], &type) == 0)
793 cfcount++;
794 }
795 if (cfcount <= 1)
796 device_delete_child(device_get_parent(cf_dev), cf_dev);
797 free(devs, M_TEMP);
798
799 return (0);
800}
794 cfcount++;
795 }
796 if (cfcount <= 1)
797 device_delete_child(device_get_parent(cf_dev), cf_dev);
798 free(devs, M_TEMP);
799
800 return (0);
801}