summaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-script.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2016-05-27 11:16:53 -0400
committerTakashi Iwai <tiwai@suse.de>2016-05-27 11:16:53 -0400
commiteb4606e64a7d548f5d60a9583baa8104890b2c6e (patch)
tree2dc8e587fc79c207dab2fb74830963cc84dcf801 /tools/perf/builtin-script.c
parent86c72d1ce91d804e4fa8d90b316a89597dd220f1 (diff)
parentbf65921380cd50b87618df550398e06581f4a361 (diff)
Merge tag 'asoc-v4.7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Updates for v4.7 part 2 Really sorry about this late pull request. It looks like at the time I sent my pull request for v4.7 there was some conflict or other issue which caused my script to stop merging the ASoC branches at some point after the HDMI changes. It's all specific driver updates, including: - New drivers for MAX98371 and TAS5720. - SPI support for TLV320AIC32x4. - TDM support for STI Uniperf IPs. This code should all have been in -next prior to the merge window apart from some fixes, it dropped out on the 18th.
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r--tools/perf/builtin-script.c70
1 files changed, 34 insertions, 36 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 3770c3dffe5e..52826696c852 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -1415,21 +1415,19 @@ static int is_directory(const char *base_path, const struct dirent *dent)
1415 return S_ISDIR(st.st_mode); 1415 return S_ISDIR(st.st_mode);
1416} 1416}
1417 1417
1418#define for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next)\ 1418#define for_each_lang(scripts_path, scripts_dir, lang_dirent) \
1419 while (!readdir_r(scripts_dir, &lang_dirent, &lang_next) && \ 1419 while ((lang_dirent = readdir(scripts_dir)) != NULL) \
1420 lang_next) \ 1420 if ((lang_dirent->d_type == DT_DIR || \
1421 if ((lang_dirent.d_type == DT_DIR || \ 1421 (lang_dirent->d_type == DT_UNKNOWN && \
1422 (lang_dirent.d_type == DT_UNKNOWN && \ 1422 is_directory(scripts_path, lang_dirent))) && \
1423 is_directory(scripts_path, &lang_dirent))) && \ 1423 (strcmp(lang_dirent->d_name, ".")) && \
1424 (strcmp(lang_dirent.d_name, ".")) && \ 1424 (strcmp(lang_dirent->d_name, "..")))
1425 (strcmp(lang_dirent.d_name, ".."))) 1425
1426 1426#define for_each_script(lang_path, lang_dir, script_dirent) \
1427#define for_each_script(lang_path, lang_dir, script_dirent, script_next)\ 1427 while ((script_dirent = readdir(lang_dir)) != NULL) \
1428 while (!readdir_r(lang_dir, &script_dirent, &script_next) && \ 1428 if (script_dirent->d_type != DT_DIR && \
1429 script_next) \ 1429 (script_dirent->d_type != DT_UNKNOWN || \
1430 if (script_dirent.d_type != DT_DIR && \ 1430 !is_directory(lang_path, script_dirent)))
1431 (script_dirent.d_type != DT_UNKNOWN || \
1432 !is_directory(lang_path, &script_dirent)))
1433 1431
1434 1432
1435#define RECORD_SUFFIX "-record" 1433#define RECORD_SUFFIX "-record"
@@ -1575,7 +1573,7 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
1575 const char *s __maybe_unused, 1573 const char *s __maybe_unused,
1576 int unset __maybe_unused) 1574 int unset __maybe_unused)
1577{ 1575{
1578 struct dirent *script_next, *lang_next, script_dirent, lang_dirent; 1576 struct dirent *script_dirent, *lang_dirent;
1579 char scripts_path[MAXPATHLEN]; 1577 char scripts_path[MAXPATHLEN];
1580 DIR *scripts_dir, *lang_dir; 1578 DIR *scripts_dir, *lang_dir;
1581 char script_path[MAXPATHLEN]; 1579 char script_path[MAXPATHLEN];
@@ -1590,19 +1588,19 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
1590 if (!scripts_dir) 1588 if (!scripts_dir)
1591 return -1; 1589 return -1;
1592 1590
1593 for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) { 1591 for_each_lang(scripts_path, scripts_dir, lang_dirent) {
1594 snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, 1592 snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
1595 lang_dirent.d_name); 1593 lang_dirent->d_name);
1596 lang_dir = opendir(lang_path); 1594 lang_dir = opendir(lang_path);
1597 if (!lang_dir) 1595 if (!lang_dir)
1598 continue; 1596 continue;
1599 1597
1600 for_each_script(lang_path, lang_dir, script_dirent, script_next) { 1598 for_each_script(lang_path, lang_dir, script_dirent) {
1601 script_root = get_script_root(&script_dirent, REPORT_SUFFIX); 1599 script_root = get_script_root(script_dirent, REPORT_SUFFIX);
1602 if (script_root) { 1600 if (script_root) {
1603 desc = script_desc__findnew(script_root); 1601 desc = script_desc__findnew(script_root);
1604 snprintf(script_path, MAXPATHLEN, "%s/%s", 1602 snprintf(script_path, MAXPATHLEN, "%s/%s",
1605 lang_path, script_dirent.d_name); 1603 lang_path, script_dirent->d_name);
1606 read_script_info(desc, script_path); 1604 read_script_info(desc, script_path);
1607 free(script_root); 1605 free(script_root);
1608 } 1606 }
@@ -1690,7 +1688,7 @@ static int check_ev_match(char *dir_name, char *scriptname,
1690 */ 1688 */
1691int find_scripts(char **scripts_array, char **scripts_path_array) 1689int find_scripts(char **scripts_array, char **scripts_path_array)
1692{ 1690{
1693 struct dirent *script_next, *lang_next, script_dirent, lang_dirent; 1691 struct dirent *script_dirent, *lang_dirent;
1694 char scripts_path[MAXPATHLEN], lang_path[MAXPATHLEN]; 1692 char scripts_path[MAXPATHLEN], lang_path[MAXPATHLEN];
1695 DIR *scripts_dir, *lang_dir; 1693 DIR *scripts_dir, *lang_dir;
1696 struct perf_session *session; 1694 struct perf_session *session;
@@ -1713,9 +1711,9 @@ int find_scripts(char **scripts_array, char **scripts_path_array)
1713 return -1; 1711 return -1;
1714 } 1712 }
1715 1713
1716 for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) { 1714 for_each_lang(scripts_path, scripts_dir, lang_dirent) {
1717 snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path, 1715 snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path,
1718 lang_dirent.d_name); 1716 lang_dirent->d_name);
1719#ifdef NO_LIBPERL 1717#ifdef NO_LIBPERL
1720 if (strstr(lang_path, "perl")) 1718 if (strstr(lang_path, "perl"))
1721 continue; 1719 continue;
@@ -1729,16 +1727,16 @@ int find_scripts(char **scripts_array, char **scripts_path_array)
1729 if (!lang_dir) 1727 if (!lang_dir)
1730 continue; 1728 continue;
1731 1729
1732 for_each_script(lang_path, lang_dir, script_dirent, script_next) { 1730 for_each_script(lang_path, lang_dir, script_dirent) {
1733 /* Skip those real time scripts: xxxtop.p[yl] */ 1731 /* Skip those real time scripts: xxxtop.p[yl] */
1734 if (strstr(script_dirent.d_name, "top.")) 1732 if (strstr(script_dirent->d_name, "top."))
1735 continue; 1733 continue;
1736 sprintf(scripts_path_array[i], "%s/%s", lang_path, 1734 sprintf(scripts_path_array[i], "%s/%s", lang_path,
1737 script_dirent.d_name); 1735 script_dirent->d_name);
1738 temp = strchr(script_dirent.d_name, '.'); 1736 temp = strchr(script_dirent->d_name, '.');
1739 snprintf(scripts_array[i], 1737 snprintf(scripts_array[i],
1740 (temp - script_dirent.d_name) + 1, 1738 (temp - script_dirent->d_name) + 1,
1741 "%s", script_dirent.d_name); 1739 "%s", script_dirent->d_name);
1742 1740
1743 if (check_ev_match(lang_path, 1741 if (check_ev_match(lang_path,
1744 scripts_array[i], session)) 1742 scripts_array[i], session))
@@ -1756,7 +1754,7 @@ int find_scripts(char **scripts_array, char **scripts_path_array)
1756 1754
1757static char *get_script_path(const char *script_root, const char *suffix) 1755static char *get_script_path(const char *script_root, const char *suffix)
1758{ 1756{
1759 struct dirent *script_next, *lang_next, script_dirent, lang_dirent; 1757 struct dirent *script_dirent, *lang_dirent;
1760 char scripts_path[MAXPATHLEN]; 1758 char scripts_path[MAXPATHLEN];
1761 char script_path[MAXPATHLEN]; 1759 char script_path[MAXPATHLEN];
1762 DIR *scripts_dir, *lang_dir; 1760 DIR *scripts_dir, *lang_dir;
@@ -1769,21 +1767,21 @@ static char *get_script_path(const char *script_root, const char *suffix)
1769 if (!scripts_dir) 1767 if (!scripts_dir)
1770 return NULL; 1768 return NULL;
1771 1769
1772 for_each_lang(scripts_path, scripts_dir, lang_dirent, lang_next) { 1770 for_each_lang(scripts_path, scripts_dir, lang_dirent) {
1773 snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, 1771 snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
1774 lang_dirent.d_name); 1772 lang_dirent->d_name);
1775 lang_dir = opendir(lang_path); 1773 lang_dir = opendir(lang_path);
1776 if (!lang_dir) 1774 if (!lang_dir)
1777 continue; 1775 continue;
1778 1776
1779 for_each_script(lang_path, lang_dir, script_dirent, script_next) { 1777 for_each_script(lang_path, lang_dir, script_dirent) {
1780 __script_root = get_script_root(&script_dirent, suffix); 1778 __script_root = get_script_root(script_dirent, suffix);
1781 if (__script_root && !strcmp(script_root, __script_root)) { 1779 if (__script_root && !strcmp(script_root, __script_root)) {
1782 free(__script_root); 1780 free(__script_root);
1783 closedir(lang_dir); 1781 closedir(lang_dir);
1784 closedir(scripts_dir); 1782 closedir(scripts_dir);
1785 snprintf(script_path, MAXPATHLEN, "%s/%s", 1783 snprintf(script_path, MAXPATHLEN, "%s/%s",
1786 lang_path, script_dirent.d_name); 1784 lang_path, script_dirent->d_name);
1787 return strdup(script_path); 1785 return strdup(script_path);
1788 } 1786 }
1789 free(__script_root); 1787 free(__script_root);