tools/intel_gpu_frequency: remove use of getsubopt
PATCH 1/1 tools/intel_gpu_frequency: remove use of getsubopt
From: Tim Gore <[email protected]>
getsubopt is not available in android. The "get" option doesn't really need sub-options, just display all the current frequency settings (as per discussion with Ben Widawsky)
--- man/intel_gpu_frequency.man | 6 +++--- tools/intel_gpu_frequency.c | 27 ++++----------------------- 2 files changed, 7 insertions(+), 26 deletions(-)
man/intel_gpu_frequency.man +3 -3
@@ -3,7 +3,7 @@ intel_gpu_frequency: \- manual page for intel_gpu_frequency .SH SYNOPSIS .B intel_gpu_frequency -[\fI\,-e\/\fR] [\fI\,--min | --max\/\fR] [\fI\,-g (min|max|efficient)\/\fR] [\fI\,-s frequency_mhz\/\fR] +[\fI\,-e\/\fR] [\fI\,--min | --max\/\fR] [\fI\,-g\/\fR] [\fI\,-s frequency_mhz\/\fR] .SH DESCRIPTION \&A program to manipulate Intel GPU frequencies. Intel GPUs will automatically throttle the frequencies based on system demands, up when
@@ -19,8 +19,8 @@ safe bet. \fB\-e\fR Lock frequency to the most efficient frequency .TP -\fB\-g\fR, \fB\-\-get=\fR -Get the frequency comma separated list of ("cur"|"min"|"max"|"eff") +\fB\-g\fR, \fB\-\-get\fR +Get all the current frequency settings .TP \fB\-s\fR, \fB\-\-set\fR Lock frequency to an absolute value (MHz)
tools/intel_gpu_frequency.c +4 -23
@@ -152,7 +152,7 @@ usage(const char *prog)printf ("Usage: %s [-e] [--min | --max] [-g (min|max|efficient)] [-s frequency_mhz]\n\n" , prog);printf ("Options: \n" );printf (" -e Lock frequency to the most efficient frequency\n" ); -printf (" -g, --get= Get the frequency (optional arg: \"cur\"|\"min\"|\"max\"|\"eff\")\n" ); +printf (" -g, --get Get all the frequency settings (eg \"cur\"|\"min\"|\"max\"|\"eff\")\n" );printf (" -s, --set Lock frequency to an absolute value (MHz)\n" );printf (" -c, --custom Set a min, or max frequency \"min=X | max=Y\"\n" );printf (" -m --max Lock frequency to max frequency\n" );
@@ -184,13 +184,6 @@ parse(int argc, char *argv[], bool *act_upon, size_t act_upon_n, int *new_freq)int c, tmp;bool write = false; -char *token[] = { - (char *)info[CUR ].name, - (char *)info[MIN ].name, - (char *)"eff" , - (char *)info[MAX ].name - }; -/* No args means -g" */ if (argc ==1 ) {for (c =0 ; c < act_upon_n; c++)
@@ -200,7 +193,7 @@ parse(int argc, char *argv[], bool *act_upon, size_t act_upon_n, int *new_freq)while (1 ) {int option_index =0 ;static struct option long_options[] = { - {"get" , optional_argument,NULL ,'g' }, + {"get" , no_argument,NULL ,'g' }, {"set" , required_argument,NULL ,'s' }, {"custom" , required_argument,NULL ,'c' }, {"min" , no_argument,NULL ,'i' },
@@ -211,7 +204,7 @@ parse(int argc, char *argv[], bool *act_upon, size_t act_upon_n, int *new_freq) { NULL, 0, NULL, 0} }; - c =getopt_long (argc, argv,"eg::s:c:midh" , long_options, &option_index); + c =getopt_long (argc, argv,"egs:c:midh" , long_options, &option_index);if (c ==-1 )break ;
@@ -219,19 +212,7 @@ parse(int argc, char *argv[], bool *act_upon, size_t act_upon_n, int *new_freq)case 'g' :if (write == true)fprintf (stderr,"Read and write operations not support simultaneously.\n" ); - -if (optarg) { -char *value, *subopts = optarg; -int x; -while (*subopts !='\0' ) { - x =getsubopt (&subopts, token, &value); -if (x ==-1 ) { -fprintf (stderr,"Unrecognized option (%s)\n" , value); -break ; - }else - act_upon[x] = true; - } - }else { + {int i;for (i =0 ; i < act_upon_n; i++) act_upon[i] = true;
Signature · 6 lines
2.2.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 42 lines · On Thu, Jan 15, 2015 at 05:27:50PM +0000, [email protected] wrote:
From: Tim Gore <[email protected]>
getsubopt is not available in android. The "get" option doesn't really need sub-options, just display all the current frequency settings (as per discussion with Ben Widawsky)
Signed-off-by Tim Gore <[email protected]>--- man/intel_gpu_frequency.man | 6 +++--- tools/intel_gpu_frequency.c | 27 ++++----------------------- 2 files changed, 7 insertions(+), 26 deletions(-)man/intel_gpu_frequency.man +3
-3@@ -3,7 +3,7 @@ intel_gpu_frequency: \- manual page for intel_gpu_frequency .SH SYNOPSIS .B intel_gpu_frequency -[\fI\,-e\/\fR] [\fI\,--min | --max\/\fR] [\fI\,-g (min|max|efficient)\/\fR] [\fI\,-s frequency_mhz\/\fR] +[\fI\,-e\/\fR] [\fI\,--min | --max\/\fR] [\fI\,-g\/\fR] [\fI\,-s frequency_mhz\/\fR] .SH DESCRIPTION \&A program to manipulate Intel GPU frequencies. Intel GPUs will automatically throttle the frequencies based on system demands, up when@@ -19,8 +19,8 @@ safe bet. \fB\-e\fR Lock frequency to the most efficient frequency .TP -\fB\-g\fR, \fB\-\-get=\fR -Get the frequency comma separated list of ("cur"|"min"|"max"|"eff") +\fB\-g\fR, \fB\-\-get\fR +Get all the current frequency settings .TP \fB\-s\fR, \fB\-\-set\fR Lock frequency to an absolute value (MHz)tools/intel_gpu_frequency.c +0
-0
tools/intel_gpu_frequency.c usage(const char *prog) · line 155
Quoted 5 lines
tools/intel_gpu_frequency.c +1
-1@@ -152,7 +152,7 @@ usage(const char *prog)printf ("Usage: %s [-e] [--min | --max] [-g (min|max|efficient)] [-s frequency_mhz]\n\n" , prog);printf ("Options: \n" );printf (" -e Lock frequency to the most efficient frequency\n" ); -printf (" -g, --get= Get the frequency (optional arg: \"cur\"|\"min\"|\"max\"|\"eff\")\n" ); +printf (" -g, --get Get all the frequency settings (eg \"cur\"|\"min\"|\"max\"|\"eff\")\n" );
Should beprintf(" -g, --get Get all the frequency settings);
Quoted 46 lines
tools/intel_gpu_frequency.c +2
-16printf (" -s, --set Lock frequency to an absolute value (MHz)\n" );printf (" -c, --custom Set a min, or max frequency \"min=X | max=Y\"\n" );printf (" -m --max Lock frequency to max frequency\n" );@@ -184,13 +184,6 @@ parse(int argc, char *argv[], bool *act_upon, size_t act_upon_n, int *new_freq)int c, tmp;bool write = false; -char *token[] = { - (char *)info[CUR ].name, - (char *)info[MIN ].name, - (char *)"eff" , - (char *)info[MAX ].name - }; -/* No args means -g" */ if (argc ==1 ) {for (c =0 ; c < act_upon_n; c++)@@ -200,7 +193,7 @@ parse(int argc, char *argv[], bool *act_upon, size_t act_upon_n, int *new_freq)while (1 ) {int option_index =0 ;static struct option long_options[] = { - {"get" , optional_argument,NULL ,'g' }, + {"get" , no_argument,NULL ,'g' }, {"set" , required_argument,NULL ,'s' }, {"custom" , required_argument,NULL ,'c' }, {"min" , no_argument,NULL ,'i' },@@ -211,7 +204,7 @@ parse(int argc, char *argv[], bool *act_upon, size_t act_upon_n, int *new_freq) { NULL, 0, NULL, 0} }; - c =getopt_long (argc, argv,"eg::s:c:midh" , long_options, &option_index); + c =getopt_long (argc, argv,"egs:c:midh" , long_options, &option_index);if (c ==-1 )break ;@@ -219,19 +212,7 @@ parse(int argc, char *argv[], bool *act_upon, size_t act_upon_n, int *new_freq)case 'g' :if (write == true)fprintf (stderr,"Read and write operations not support simultaneously.\n" ); - -if (optarg) { -char *value, *subopts = optarg; -int x; -while (*subopts !='\0' ) { - x =getsubopt (&subopts, token, &value); -if (x ==-1 ) {
tools/intel_gpu_frequency.c parse(int argc, char *argv[], bool *act_upon, size_t act_upon_n, int *new_freq) · line 218
Quoted 10 lines
tools/intel_gpu_frequency.c +1
-6-fprintf (stderr,"Unrecognized option (%s)\n" , value); -break ; - }else - act_upon[x] = true; - } - }else { + {int i;for (i =0 ; i < act_upon_n; i++) act_upon[i] = true;
You missed one of the examples in the top of the file:
* intel_gpu_frequency --get=cur,min,max,eff
With those two,
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx