12 #include "helpers/helpers.h"
13 #include "helpers/sysfs.h"
15 static struct option info_opts
[] = {
16 { .name
= "disable", .has_arg
= required_argument
, .flag
= NULL
, .val
= 'd'},
17 { .name
= "enable", .has_arg
= required_argument
, .flag
= NULL
, .val
= 'e'},
22 int cmd_idle_set(int argc
, char **argv
)
25 extern int optind
, opterr
, optopt
;
26 int ret
= 0, cont
= 1, param
= 0, idlestate
= 0;
30 ret
= getopt_long(argc
, argv
, "d:e:", info_opts
, NULL
);
45 idlestate
= atoi(optarg
);
54 idlestate
= atoi(optarg
);
64 printf(_("You can't specify more than one "
65 "output-specific argument\n"));
68 printf(_("invalid or unknown argument\n"));
72 /* Default is: set all CPUs */
73 if (bitmask_isallclear(cpus_chosen
))
74 bitmask_setall(cpus_chosen
);
76 for (cpu
= bitmask_first(cpus_chosen
);
77 cpu
<= bitmask_last(cpus_chosen
); cpu
++) {
79 if (!bitmask_isbitset(cpus_chosen
, cpu
))
85 ret
= sysfs_idlestate_disable(cpu
, idlestate
, 1);
87 printf(_("Idlestate %u disabled on CPU %u\n"), idlestate
, cpu
);
89 printf(_("Idlestate %u not available on CPU %u\n"),
92 printf(_("Idlestate disabling not supported by kernel\n"));
94 printf(_("Idlestate %u not disabled on CPU %u\n"),
98 ret
= sysfs_idlestate_disable(cpu
, idlestate
, 0);
100 printf(_("Idlestate %u enabled on CPU %u\n"), idlestate
, cpu
);
102 printf(_("Idlestate %u not available on CPU %u\n"),
105 printf(_("Idlestate enabling not supported by kernel\n"));
107 printf(_("Idlestate %u not enabled on CPU %u\n"),
111 /* Not reachable with proper args checking */
112 printf(_("Invalid or unknown argument\n"));