aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2
diff options
context:
space:
mode:
authorTodd Poynor <tpoynor@mvista.com>2005-07-11 22:34:39 -0400
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-07-12 18:03:19 -0400
commit751382dd5cb2702368d281a50b55c2d6c4e8fbfc (patch)
tree1d9195fe0bf264668b92fe2b2c36a4d76d253162 /fs/jffs2
parentb62205986a73a40e4fc174d2ef668e3895e925bc (diff)
[JFFS2] Avoid compiler warnings when JFFS2_FS_WRITEBUFFER=n
Signed-off-by: Todd Poynor <tpoynor@mvista.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'fs/jffs2')
-rw-r--r--fs/jffs2/os-linux.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
index 7bf72e012c94..d900c8929b09 100644
--- a/fs/jffs2/os-linux.h
+++ b/fs/jffs2/os-linux.h
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: os-linux.h,v 1.57 2005/07/06 12:13:09 dwmw2 Exp $ 10 * $Id: os-linux.h,v 1.58 2005/07/12 02:34:35 tpoynor Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -86,6 +86,8 @@ static inline void jffs2_init_inode_info(struct jffs2_inode_info *f)
86#define jffs2_dataflash(c) (0) 86#define jffs2_dataflash(c) (0)
87#define jffs2_nor_ecc_flash_setup(c) (0) 87#define jffs2_nor_ecc_flash_setup(c) (0)
88#define jffs2_nor_ecc_flash_cleanup(c) do {} while (0) 88#define jffs2_nor_ecc_flash_cleanup(c) do {} while (0)
89#define jffs2_dataflash_setup(c) (0)
90#define jffs2_dataflash_cleanup(c) do {} while (0)
89 91
90#else /* NAND and/or ECC'd NOR support present */ 92#else /* NAND and/or ECC'd NOR support present */
91 93
/a> 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054
/*
 * Copyright (C) 2009, 2010 Red Hat Inc, Steven Rostedt <srostedt@redhat.com>
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License (not later!)
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <gtk/gtk.h>
#include <glib-object.h>

#include "trace-cmd.h"
#include "trace-local.h"
#include "trace-view.h"
#include "trace-gui.h"
#include "trace-compat.h"
#include "cpu.h"
#include "util.h"

enum {
	COL_INDEX,
	COL_CPU,
	COL_TS,
	COL_COMM,
	COL_PID,
	COL_LAT,
	COL_EVENT,
	COL_INFO,
	NUM_COLS
};

static char* col_labels[] = {
	"#",
	"CPU",
	"Time Stamp",
	"Task",
	"PID",
	"Latency",
	"Event",
	"Info",
	NULL
};
static int col_chars[] = {
	0,	/* INDEX */
	0,	/* CPU */
	0,	/* TS */
	0,	/* COMM */
	0,	/* PID */
	0,	/* LAT */
	0,	/* EVENT */
	0,	/* INFO */
	0
};

static GtkTreeModel *
create_trace_view_model(struct tracecmd_input *handle)
{
	TraceViewStore *store;

	store = trace_view_store_new(handle);

	return GTK_TREE_MODEL(store);
}

static void
spin_changed(gpointer data, GtkWidget *spin)
{
	GtkTreeView *tree = data;
	GtkTreeModel *model;
	gint val, page;

	val = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin));

	model = gtk_tree_view_get_model(tree);
	/* This can be called when we NULL out the model */
	if (!model)
		return;
	page = trace_view_store_get_page(TRACE_VIEW_STORE(model));
	if (page == val)
		return;

	g_object_ref(model);
	gtk_tree_view_set_model(tree, NULL);

	trace_view_store_set_page(TRACE_VIEW_STORE(model), val);

	gtk_tree_view_set_model(tree, model);
	g_object_unref(model);
}

void trace_view_data_func(GtkTreeViewColumn *column, GtkCellRenderer *renderer,
			  GtkTreeModel *model, GtkTreeIter *iter,
			  gpointer data)
{
	long col_num = (long)data;
	int str_len, label_len;
	gchar *text, *str;
	int new_w, x_pad;
	GValue val = {0};
	GtkWidget *view;

	PangoFontDescription *pfd;
	PangoLayout *playout;

	/* Put the text in the renderer. */
	gtk_tree_model_get_value(model, iter, col_num, &val);
	g_object_set_property(G_OBJECT(renderer), "text", &val);

	g_object_get(G_OBJECT(renderer),
			"text", &text,
			"font-desc", &pfd,
			NULL);

	if (!text)
		goto out;

	/* Make sure there is enough room to render the column label. */
	str = text;
	str_len = strlen(str);
	label_len = strlen(col_labels[col_num]);
	if (label_len > str_len) {
		str = col_labels[col_num];
		str_len = label_len;
	}

	/* Don't bother with pango unless we have more chars than the max. */
	if (str_len > col_chars[col_num]) {
		col_chars[col_num] = str_len;

		view = GTK_WIDGET(gtk_tree_view_column_get_tree_view(column));
		playout = gtk_widget_create_pango_layout(GTK_WIDGET(view), str);
		pango_layout_set_font_description(playout, pfd);
		pango_layout_get_pixel_size(playout, &new_w, NULL);
		gtk_cell_renderer_get_padding(renderer, &x_pad, NULL);
		/* +10 to avoid another adjustment for one char */
		new_w += 2*x_pad + 10;
		g_object_unref(playout);

		if (new_w > gtk_tree_view_column_get_width(column))
			gtk_tree_view_column_set_fixed_width(column, new_w);
	}

	g_free(text);
 out:
	pango_font_description_free(pfd);
	g_value_unset(&val);
}

void
trace_view_load(GtkWidget *view, struct tracecmd_input *handle,
		GtkWidget *spin)
{
	GtkCellRenderer *renderer;
	GtkCellRenderer *fix_renderer;
	GtkTreeModel *model;
	long c;


	/* --- CPU column --- */

	renderer = gtk_cell_renderer_text_new();
	fix_renderer = gtk_cell_renderer_text_new();

	g_object_set(fix_renderer,
		     "family", "Monospace",
		     "family-set", TRUE,
		     NULL);

	/*
	 * Set fixed height mode now which will cause all the columns below to
	 * be created with their sizing property to be set to
	 * GTK_TREE_VIEW_COLUMN_FIXED.
	 */
	gtk_tree_view_set_fixed_height_mode(GTK_TREE_VIEW(view), TRUE);

	for (c = 0; c < NUM_COLS; c++)
	{
		gtk_tree_view_insert_column_with_data_func(GTK_TREE_VIEW(view),
				-1,
				col_labels[c],
				(c == COL_LAT || c == COL_INFO) ? fix_renderer : renderer,
				trace_view_data_func,
				(gpointer)c,
				NULL);
	}

	g_signal_connect_swapped (G_OBJECT (spin), "value-changed",
				  G_CALLBACK (spin_changed),
				  (gpointer) view);


	if (handle) {
		model = create_trace_view_model(handle);
		trace_view_store_set_spin_button(TRACE_VIEW_STORE(model), spin);
		gtk_tree_view_set_model(GTK_TREE_VIEW(view), model);
		g_object_unref(model); /* destroy model automatically with view */
	}
}

void trace_view_reload(GtkWidget *view, struct tracecmd_input *handle,
		       GtkWidget *spin)
{
	GtkTreeModel *model;

	if (!handle)
		return;

	model = create_trace_view_model(handle);
	if (!model)
		return;
	trace_view_store_set_spin_button(TRACE_VIEW_STORE(model), spin);
	gtk_tree_view_set_model(GTK_TREE_VIEW(view), model);

}

/**
 * trace_view_get_selected_row - return the selected row
 * @treeview: The tree view
 *
 * Returns the selected row number (or -1 if none is selected)
 */
gint trace_view_get_selected_row(GtkWidget *treeview)
{
	GtkTreeView *tree = GTK_TREE_VIEW(treeview);
	GtkTreeSelection *selection;
	GtkTreeModel *model;
	GtkTreePath *path;
	gchar *spath;
	GList *glist;
	gint row;

	model = gtk_tree_view_get_model(tree);
	if (!model)
		return -1;

	selection = gtk_tree_view_get_selection(tree);
	glist = gtk_tree_selection_get_selected_rows(selection, &model);
	if (!glist)
		return -1;

	/* Only one row may be selected */
	path = glist->data;
	spath = gtk_tree_path_to_string(path);
	row = atoi(spath);
	g_free(spath);

	gtk_tree_path_free(path);
	g_list_free(glist);

	return row;
}

void trace_view_make_selection_visible(GtkWidget *treeview)
{
	GtkTreeView *tree = GTK_TREE_VIEW(treeview);
	GtkTreePath *path;
	gchar *spath;
	GString *gstr;
	gint row;

	row = trace_view_get_selected_row(treeview);
	if (row < 0)
		return;

	gstr = g_string_new("");
	g_string_printf(gstr, "%d", row);
	spath = g_string_free(gstr, FALSE);

	path = gtk_tree_path_new_from_string(spath);
	g_free(spath);

	gtk_tree_view_scroll_to_cell(tree, path, NULL, TRUE, 0.5, 0.0);

	gtk_tree_path_free(path);
}

void trace_view_update_filters(GtkWidget *treeview,
			       struct filter_task *task_filter,
			       struct filter_task *hide_tasks)
{
	GtkTreeView *tree = GTK_TREE_VIEW(treeview);
	TraceViewRecord *vrec;
	GtkTreeModel *model;
	guint64 time;
	gint row;

	model = gtk_tree_view_get_model(tree);
	if (!model)
		return;

	/* Keep track of the currently selected row */
	row = trace_view_get_selected_row(treeview);
	if (row >= 0) {
		vrec = trace_view_store_get_row(TRACE_VIEW_STORE(model), row);
		time = vrec->timestamp;
	}

	g_object_ref(model);
	gtk_tree_view_set_model(tree, NULL);

	trace_view_store_assign_filters(TRACE_VIEW_STORE(model), task_filter, hide_tasks);
	trace_view_store_update_filter(TRACE_VIEW_STORE(model));

	gtk_tree_view_set_model(tree, model);
	g_object_unref(model);

	/* Keep selection near previous selection */
	if (row >= 0)
		trace_view_select(treeview, time);
}

static void select_row_from_path(GtkTreeView *tree, GtkTreePath *path)
{
	GtkTreeSelection *selection;

	selection = gtk_tree_view_get_selection(tree);
	gtk_tree_view_set_cursor(tree, path, NULL, FALSE);
}

void trace_view_select(GtkWidget *treeview, guint64 time)
{
	GtkTreeView *tree = GTK_TREE_VIEW(treeview);
	GtkTreeModel *model;
	GtkTreePath *path;
	gint select_page, page;
	GtkWidget *spin;
	gchar buf[100];
	gint row;

	model = gtk_tree_view_get_model(tree);
	/* This can be called when we NULL out the model */
	if (!model)
		return;

	if (!trace_view_store_visible_rows(TRACE_VIEW_STORE(model)))
		return;

	page = trace_view_store_get_page(TRACE_VIEW_STORE(model));
	select_page = trace_view_store_get_timestamp_page(TRACE_VIEW_STORE(model),
							  time);

	/* Make sure the page contains the selected event */
	if (page != select_page) {
		spin = trace_view_store_get_spin(TRACE_VIEW_STORE(model));
		/* If a spin button exists, it should update when changed */
		if (spin)
			gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), select_page);
		else {
			g_object_ref(model);
			gtk_tree_view_set_model(tree, NULL);

			trace_view_store_set_page(TRACE_VIEW_STORE(model), select_page);

			gtk_tree_view_set_model(tree, model);
			g_object_unref(model);
		}
	}

	/* Select the event */
	row = trace_view_store_get_timestamp_visible_row(TRACE_VIEW_STORE(model), time);
	snprintf(buf, 100, "%d", row);
	path = gtk_tree_path_new_from_string(buf);
	select_row_from_path(tree, path);
	gtk_tree_path_free(path);
}

static void update_rows(GtkTreeView *trace_tree, TraceViewStore *store)
{
	TraceViewRecord *vrec;
	guint64 time;
	gint row;

	/* Keep track of the currently selected row */
	row = trace_view_get_selected_row(GTK_WIDGET(trace_tree));
	if (row >= 0) {
		vrec = trace_view_store_get_row(store, row);
		time = vrec->timestamp;
	}

	/* Force an update */
	g_object_ref(store);
	gtk_tree_view_set_model(trace_tree, NULL);
	trace_view_store_update_filter(store);
	gtk_tree_view_set_model(trace_tree, GTK_TREE_MODEL(store));
	g_object_unref(store);

	if (row >= 0)
		trace_view_select(GTK_WIDGET(trace_tree), time);
}

void trace_view_event_filter_callback(gboolean accept,
				      gboolean all_events,
				      gchar **systems,
				      gint *events,
				      gpointer data)
{
	struct event_filter *event_filter;
	GtkTreeView *trace_tree = data;
	GtkTreeModel *model;
	TraceViewStore *store;

	if (!accept)
		return;

	model = gtk_tree_view_get_model(trace_tree);
	if (!model)
		return;

	store = TRACE_VIEW_STORE(model);

	if (all_events) {
		if (trace_view_store_get_all_events_enabled(store))
			return;

		trace_view_store_set_all_events_enabled(store);
	} else {
		trace_view_store_clear_all_events_enabled(store);

		event_filter = trace_view_store_get_event_filter(store);

		trace_filter_convert_char_to_filter(event_filter, systems, events);
	}

	update_rows(trace_tree, store);
}

void trace_view_adv_filter_callback(gboolean accept,
				    const gchar *text,
				    gint *event_ids,
				    gpointer data)
{
	struct event_filter *event_filter;
	GtkTreeView *trace_tree = data;
	GtkTreeModel *model;
	TraceViewStore *store;
	char *error_str;
	int ret;
	int i;

	if (!accept)
		return;

	model = gtk_tree_view_get_model(trace_tree);
	if (!model)
		return;

	if (!has_text(text) && !event_ids)
		return;

	store = TRACE_VIEW_STORE(model);

	event_filter = trace_view_store_get_event_filter(store);

	if (event_ids) {
		for (i = 0; event_ids[i] >= 0; i++)
			pevent_filter_remove_event(event_filter, event_ids[i]);
	}

	if (has_text(text)) {

		trace_view_store_clear_all_events_enabled(store);

		ret = pevent_filter_add_filter_str(event_filter, text, &error_str);
		if (ret < 0) {
			warning("filter failed due to: %s", error_str);
			free(error_str);
			return;
		}
	}

	update_rows(trace_tree, store);
}

void trace_view_copy_filter(GtkWidget *treeview,
			    gboolean all_events,
			    struct event_filter *src_event_filter)
{
	GtkTreeView *trace_tree;
	struct event_filter *event_filter;
	GtkTreeModel *model;
	TraceViewStore *store;

	trace_tree = GTK_TREE_VIEW(treeview);

	model = gtk_tree_view_get_model(trace_tree);
	if (!model)
		return;

	store = TRACE_VIEW_STORE(model);

	if (all_events) {
		if (trace_view_store_get_all_events_enabled(store))
			return;

		trace_view_store_set_all_events_enabled(store);
	} else {
		trace_view_store_clear_all_events_enabled(store);

		event_filter = trace_view_store_get_event_filter(store);

		pevent_filter_copy(event_filter, src_event_filter);
	}

	update_rows(trace_tree, store);
}

void trace_view_cpu_filter_callback(gboolean accept,
				    gboolean all_cpus,
				    guint64 *selected_cpu_mask,
				    gpointer data)
{
	GtkTreeView *trace_tree = data;
	TraceViewRecord *rec;
	GtkTreeModel *model;
	TraceViewStore *store;
	guint64 time = 0;
	gint selected_row;
	gint cpus;
	gint cpu;

	if (!accept)
		return;

	model = gtk_tree_view_get_model(trace_tree);
	if (!model)
		return;

	store = TRACE_VIEW_STORE(model);

	selected_row = trace_view_get_selected_row(GTK_WIDGET(trace_tree));
	if (selected_row < 0)
		selected_row = 0;

	g_object_ref(store);
	gtk_tree_view_set_model(trace_tree, NULL);

	/*
	 * If the selected row is not part of one of the CPUs
	 * that are kept, then find one that is. Do nothing if
	 * the first row is selected.
	 */
	if (selected_row) {
		/* Save this timestamp */
		rec = trace_view_store_get_visible_row(TRACE_VIEW_STORE(model), selected_row);
		time = rec->timestamp;
	}

	if (all_cpus) {
		trace_view_store_set_all_cpus(store);
		goto set_model;
	}

	cpus = trace_view_store_get_cpus(store);

	for (cpu = 0; cpu < cpus; cpu++) {
		if (cpu_isset(selected_cpu_mask, cpu))
			trace_view_store_set_cpu(store, cpu);
		else
			trace_view_store_clear_cpu(store, cpu);
	}

 set_model:
	gtk_tree_view_set_model(trace_tree, GTK_TREE_MODEL(store));
	g_object_unref(store);

	if (!time)
		return;
	/*
	 * Try to select the row that was near the selection
	 * before the change.
	 */
	trace_view_select(GTK_WIDGET(trace_tree), time);
}

static GtkTreeModel *create_col_model(GtkTreeView *treeview)
{
	GtkListStore *store;
	GtkTreeViewColumn *col;
	GtkTreeIter iter;
	const gchar *title;
	int i;

	store = gtk_list_store_new(1, G_TYPE_STRING);

	i = 0;
	col = gtk_tree_view_get_column(treeview, i++);
	while (col) {
		title = gtk_tree_view_column_get_title(col);
		if (!title)
			break;

		gtk_list_store_append(store, &iter);
		gtk_list_store_set(store, &iter,
				   0, title,
				   -1);

		col = gtk_tree_view_get_column(treeview, i++);
	}

	return GTK_TREE_MODEL(store);
}

struct search_info {
	GtkTreeView		*treeview;
	GtkWidget		*entry;
	GtkWidget		*selection;
	GtkWidget		*column;
};

#define SELECTION_NAMES					\
	C(	contains,	CONTAINS	),	\
	C(	full match,	FULL_MATCH	),	\
	C(	does not have,	NOT_IN		)

#undef C
#define C(a, b)	#a

static gchar *select_names[] = { SELECTION_NAMES, NULL };

#undef C
#define C(a, b) SEL_##b

enum select_options { SELECTION_NAMES };

static gboolean test_int(gint val, gint search_val, enum select_options sel)
{
	gint tens;
	gboolean match = TRUE;

	switch (sel) {
	case SEL_NOT_IN:
		match = FALSE;
	case SEL_CONTAINS:
		for (tens = 1; search_val / tens; tens *= 10)
			;

		while (val) {
			if (val - search_val == (val / tens) * tens)
				return match;
			val /= 10;
		}
		return !match;

	case SEL_FULL_MATCH:
		return search_val == val;
	}
	return FALSE;
}

static gboolean test_text(const gchar *text, const gchar *search_text, enum select_options sel)
{
	gboolean match = TRUE;

	switch (sel) {
	case SEL_NOT_IN:
		match = FALSE;
	case SEL_CONTAINS:

		text = strcasestr(text, search_text);
		if (text)
			return match;
		return !match;

	case SEL_FULL_MATCH:
		return strcmp(text, search_text) == 0;
	}
	return FALSE;
}

static gboolean test_row(GtkTreeModel *model, GtkTreeIter *iter, gint sel,
			 gint col_num, gint search_val, const gchar *search_text)
{
	gchar *text = NULL;
	gboolean found = FALSE;
	gint val;