iwlagn: fix the race in the unmapping of the HCMD

As Stanislaw pointed out, my patch

	iwlagn: fix a race in the unmapping of the TFDs

solved only part of the problem. The race still exists for TFDs of
the host commands. Fix that too.

Reported-by: Stanislaw Gruszka <1542dc81552e668e197a396f69e655c1621c300d@redhat.com>
Signed-off-by: Emmanuel Grumbach <643a80aaf16a8332d6a70921c14d4bb265446494@intel.com>
Signed-off-by: Wey-Yi Guy <15ba08e2ad0b84ec2e6b8e47b27706f8a8e5edd0@intel.com>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>

--- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
+++ drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
@@ -407,6 +407,7 @@
 	struct iwl_queue *q = &txq->q;
 	enum dma_data_direction dma_dir;
 	unsigned long flags;
+	spinlock_t *lock;

 	if (!q->n_bd)
 		return;
@@ -414,19 +415,22 @@
 	/* In the command queue, all the TBs are mapped as BIDI
 	 * so unmap them as such.
 	 */
-	if (txq_id == trans->shrd->cmd_queue)
+	if (txq_id == trans->shrd->cmd_queue) {
 		dma_dir = DMA_BIDIRECTIONAL;
-	else
+		lock = &trans->hcmd_lock;
+	} else {
 		dma_dir = DMA_TO_DEVICE;
-
-	spin_lock_irqsave(&trans->shrd->sta_lock, flags);
+		lock = &trans->shrd->sta_lock;
+	}
+
+	spin_lock_irqsave(lock, flags);
 	while (q->write_ptr != q->read_ptr) {
 		/* The read_ptr needs to bound by q->n_window */
 		iwlagn_txq_free_tfd(trans, txq, get_cmd_index(q, q->read_ptr),
 				    dma_dir);
 		q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd);
 	}
-	spin_unlock_irqrestore(&trans->shrd->sta_lock, flags);
+	spin_unlock_irqrestore(lock, flags);
 }

 /**


staging: comedi: amplc_pci224: use comedi_buf_read_samples()

Use the new generic method to read the analog output samples from the async
buffer.

Signed-off-by: H Hartley Sweeten <382ff55d8e07d1082d179e669636cd1552da4f36@visionengravers.com>
Reviewed-by: Ian Abbott <9e6ba6483b6a3e14d61f7c987e72ecb5b46122d6@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/staging/comedi/drivers/amplc_pci224.c
+++ drivers/staging/comedi/drivers/amplc_pci224.c
@@ -514,14 +514,13 @@
 {
 	struct pci224_private *devpriv = dev->private;
 	struct comedi_cmd *cmd = &s->async->cmd;
-	unsigned int bytes_per_scan = comedi_bytes_per_scan(s);
 	unsigned int num_scans;
 	unsigned int room;
 	unsigned short dacstat;
 	unsigned int i, n;

 	/* Determine number of scans available in buffer. */
-	num_scans = comedi_buf_read_n_available(s) / bytes_per_scan;
+	num_scans = comedi_buf_read_n_available(s) / comedi_bytes_per_scan(s);
 	if (cmd->stop_src == TRIG_COUNT) {
 		/* Fixed number of scans. */
 		if (num_scans > devpriv->ao_stop_count)
@@ -568,8 +567,8 @@

 	/* Process scans. */
 	for (n = 0; n < num_scans; n++) {
-		cfc_read_array_from_buffer(s, &devpriv->ao_scan_vals[0],
-					   bytes_per_scan);
+		comedi_buf_read_samples(s, &devpriv->ao_scan_vals[0],
+					cmd->chanlist_len);
 		for (i = 0; i < cmd->chanlist_len; i++) {
 			outw(devpriv->ao_scan_vals[devpriv->ao_scan_order[i]],
 			     dev->iobase + PCI224_DACDATA);


staging: comedi: daqboard2000: cleanup range_daqboard2000_ai

Change the whitespace of the range table to avoid the > 80 char
lines and the ugly line breaks. Convert the RANGE() values into
the appropriate {BIP,UNI}_RANGE().

Signed-off-by: H Hartley Sweeten <382ff55d8e07d1082d179e669636cd1552da4f36@visionengravers.com>
Cc: Ian Abbott <9e6ba6483b6a3e14d61f7c987e72ecb5b46122d6@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/staging/comedi/drivers/daqboard2000.c
+++ drivers/staging/comedi/drivers/daqboard2000.c
@@ -140,29 +140,22 @@
 #define DAQBOARD2000_CPLD_INIT 		0x0002
 #define DAQBOARD2000_CPLD_DONE 		0x0004

-/* Available ranges */
-static const struct comedi_lrange range_daqboard2000_ai = { 13, {
-								 RANGE(-10, 10),
-								 RANGE(-5, 5),
-								 RANGE(-2.5,
-								       2.5),
-								 RANGE(-1.25,
-								       1.25),
-								 RANGE(-0.625,
-								       0.625),
-								 RANGE(-0.3125,
-								       0.3125),
-								 RANGE(-0.156,
-								       0.156),
-								 RANGE(0, 10),
-								 RANGE(0, 5),
-								 RANGE(0, 2.5),
-								 RANGE(0, 1.25),
-								 RANGE(0,
-								       0.625),
-								 RANGE(0,
-								       0.3125)
-								 }
+static const struct comedi_lrange range_daqboard2000_ai = {
+	13, {
+		BIP_RANGE(10),
+		BIP_RANGE(5),
+		BIP_RANGE(2.5),
+		BIP_RANGE(1.25),
+		BIP_RANGE(0.625),
+		BIP_RANGE(0.3125),
+		BIP_RANGE(0.156),
+		UNI_RANGE(10),
+		UNI_RANGE(5),
+		UNI_RANGE(2.5),
+		UNI_RANGE(1.25),
+		UNI_RANGE(0.625),
+		UNI_RANGE(0.3125)
+	}
 };

 /*


staging: lustre: obdclass: simplify class_uuid_unparse

This patch simplifies uuid unparse logic by using sprintf "%pU" extension.
And eliminates the code with a coding style error:

ERROR: Macros with complex values should be enclosed in parentheses
+#define CONSUME(val, ptr) (val) = consume(sizeof(val), (ptr))

Signed-off-by: Vasiliy Korchagin <b2e08e720b60eafc518d848de0239b7366ef311a@gmail.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/staging/lustre/lustre/obdclass/uuid.c
+++ drivers/staging/lustre/lustre/obdclass/uuid.c
@@ -43,40 +43,8 @@
 #include "../include/obd_support.h"
 #include "../include/obd_class.h"

-
-static inline __u32 consume(int nob, __u8 **ptr)
-{
-	__u32 value;
-
-	LASSERT(nob <= sizeof(value));
-
-	for (value = 0; nob > 0; --nob)
-		value = (value << 8) | *((*ptr)++);
-	return value;
-}
-
-#define CONSUME(val, ptr) (val) = consume(sizeof(val), (ptr))
-
-static void uuid_unpack(class_uuid_t in, __u16 *uu, int nr)
-{
-	__u8 *ptr = in;
-
-	LASSERT(nr * sizeof(*uu) == sizeof(class_uuid_t));
-
-	while (nr-- > 0)
-		CONSUME(uu[nr], &ptr);
-}
-
 void class_uuid_unparse(class_uuid_t uu, struct obd_uuid *out)
 {
-	/* uu as an array of __u16's */
-	__u16 uuid[sizeof(class_uuid_t) / sizeof(__u16)];
-
-	CLASSERT(ARRAY_SIZE(uuid) == 8);
-
-	uuid_unpack(uu, uuid, ARRAY_SIZE(uuid));
-	sprintf(out->uuid, "%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
-		uuid[0], uuid[1], uuid[2], uuid[3],
-		uuid[4], uuid[5], uuid[6], uuid[7]);
+	sprintf(out->uuid, "%pU", uu);
 }
 EXPORT_SYMBOL(class_uuid_unparse);


staging: rtl8723au: OnProbeReq23a(): is_valid_p2p_probereq is always false

Signed-off-by: Jes Sorensen <0e1e349bdba396f044a06b01fef702e072aa66d3@redhat.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/staging/rtl8723au/core/rtw_mlme_ext.c
+++ drivers/staging/rtl8723au/core/rtw_mlme_ext.c
@@ -669,7 +669,6 @@
 	struct sk_buff *skb = precv_frame->pkt;
 	struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) skb->data;
 	int len = skb->len;
-	u8 is_valid_p2p_probereq = false;

 	if (check_fwstate(pmlmepriv, WIFI_STATION_STATE))
 		return _SUCCESS;
@@ -693,17 +692,14 @@
 	if (!ie)
 		goto out;

-	if (is_valid_p2p_probereq == false) {
-		if ((ie[1] &&
-		     memcmp(ie + 2, cur->Ssid.ssid, cur->Ssid.ssid_len)) ||
-		    (ie[1] == 0 && pmlmeinfo->hidden_ssid_mode)) {
-			return _SUCCESS;
-		}
+	if ((ie[1] && memcmp(ie + 2, cur->Ssid.ssid, cur->Ssid.ssid_len)) ||
+	    (ie[1] == 0 && pmlmeinfo->hidden_ssid_mode)) {
+		return _SUCCESS;
 	}

 	if (check_fwstate(pmlmepriv, _FW_LINKED) &&
 	    pmlmepriv->cur_network.join_res)
-		issue_probersp23a(padapter, mgmt->sa, is_valid_p2p_probereq);
+		issue_probersp23a(padapter, mgmt->sa, false);

 out:
 	return _SUCCESS;


gallium/include: update some comments

gallium/include: update some comments

--- src/gallium/include/pipe/p_state.h
+++ src/gallium/include/pipe/p_state.h
@@ -114,11 +114,29 @@
     * the vertex shader, clipping and viewport processing.  Note that
     * a vertex shader is still needed though, to indicate the mapping
     * from vertex elements to fragment shader input semantics.
+    *
+    * XXX: considered for removal.
     */
    unsigned bypass_vs_clip_and_viewport:1;

-   unsigned flatshade_first:1;   /**< take color attribute from the first vertex of a primitive */
-   unsigned gl_rasterization_rules:1; /**< enable tweaks for GL rasterization?  */
+   /**
+    * Use the first vertex of a primitive as the provoking vertex for
+    * flat shading.
+    */
+   unsigned flatshade_first:1;
+
+   /**
+    * When true, triangle rasterization uses (0.5, 0.5) pixel centers
+    * for determining pixel ownership.
+    *
+    * When false, triangle rasterization uses (0,0) pixel centers for
+    * determining pixel ownership.
+    *
+    * Triangle rasterization always uses a 'top,left' rule for pixel
+    * ownership, this just alters which point we consider the pixel
+    * center for that test.
+    */
+   unsigned gl_rasterization_rules:1;

    float line_width;
    float point_size;           /**< used when no per-vertex size */


staging: wilc1000: wilc_wfi_netdevice.c: remove braces for single statement block

Fix checkpatch warning found by checkpatch.pl
WARNING: braces {} are not necessary for single statement blocks

Signed-off-by: Chaehyun Lim <cbe9b9d6f673cb1ece7082f467dd3b6acd0f8185@gmail.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/staging/wilc1000/wilc_wfi_netdevice.c
+++ drivers/staging/wilc1000/wilc_wfi_netdevice.c
@@ -931,10 +931,8 @@
 	/* ret = host_int_init(&priv[0]->hWILCWFIDrv); */
 	/*copy handle to the other driver*/
 	/* priv[1]->hWILCWFIDrv = priv[0]->hWILCWFIDrv; */
-	if (ret) {
+	if (ret)
 		PRINT_ER("Error Init Driver\n");
-	}
-

 out:
 	if (ret)


Small refactor of _composite

Small refactor of _composite

--- src/gba/renderers/video-software.c
+++ src/gba/renderers/video-software.c
@@ -616,20 +616,21 @@
 	// The lower the number, the higher the priority, and sprites take precendence over backgrounds
 	// We want to do special processing if the color pixel is target 1, however
 	if (current & FLAG_UNWRITTEN) {
-		*pixel = color | (current & FLAG_OBJWIN);
+		color |= (current & FLAG_OBJWIN);
 	} else if ((color & FLAG_ORDER_MASK) < (current & FLAG_ORDER_MASK)) {
 		if (!(color & FLAG_TARGET_1) || !(current & FLAG_TARGET_2)) {
-			*pixel = color | FLAG_FINALIZED;
+			color |= FLAG_FINALIZED;
 		} else {
-			*pixel = _mix(renderer->bldb, current, renderer->blda, color) | FLAG_FINALIZED;
+			color = _mix(renderer->bldb, current, renderer->blda, color) | FLAG_FINALIZED;
 		}
 	} else {
 		if (current & FLAG_TARGET_1 && color & FLAG_TARGET_2) {
-			*pixel = _mix(renderer->blda, current, renderer->bldb, color) | FLAG_FINALIZED;
+			color = _mix(renderer->blda, current, renderer->bldb, color) | FLAG_FINALIZED;
 		} else {
-			*pixel = current | FLAG_FINALIZED;
-		}
-	}
+			color = current | FLAG_FINALIZED;
+		}
+	}
+	*pixel = color;
 }

 #define BACKGROUND_DRAW_PIXEL_16 \


Implement OBJWIN for OBJs

Implement OBJWIN for OBJs

--- src/gba/renderers/video-software.c
+++ src/gba/renderers/video-software.c
@@ -1545,11 +1545,27 @@
 	int x;
 	uint32_t* pixel = renderer->row;
 	uint32_t flags = FLAG_TARGET_2 * renderer->target2Obj;
-	for (x = 0; x < VIDEO_HORIZONTAL_PIXELS; ++x, ++pixel) {
-		uint32_t color = renderer->spriteLayer[x] & ~FLAG_OBJWIN;
-		uint32_t current = *pixel;
-		if ((color & FLAG_UNWRITTEN) != FLAG_UNWRITTEN && (color & FLAG_PRIORITY) >> OFFSET_PRIORITY == priority) {
-			_compositeBlendObjwin(renderer, pixel, color | flags, current);
+
+	int objwinSlowPath = renderer->dispcnt.objwinEnable;
+	int objwinDisable = 0;
+	if (objwinSlowPath) {
+		objwinDisable = !renderer->objwin.objEnable;
+	}
+	if (objwinSlowPath && objwinDisable) {
+		for (x = 0; x < VIDEO_HORIZONTAL_PIXELS; ++x, ++pixel) {
+			uint32_t color = renderer->spriteLayer[x] & ~FLAG_OBJWIN;
+			uint32_t current = *pixel;
+			if ((color & FLAG_UNWRITTEN) != FLAG_UNWRITTEN && !(current & FLAG_OBJWIN) && (color & FLAG_PRIORITY) >> OFFSET_PRIORITY == priority) {
+				_compositeBlendObjwin(renderer, pixel, color | flags, current);
+			}
+		}
+	} else {
+		for (x = 0; x < VIDEO_HORIZONTAL_PIXELS; ++x, ++pixel) {
+			uint32_t color = renderer->spriteLayer[x] & ~FLAG_OBJWIN;
+			uint32_t current = *pixel;
+			if ((color & FLAG_UNWRITTEN) != FLAG_UNWRITTEN && (color & FLAG_PRIORITY) >> OFFSET_PRIORITY == priority) {
+				_compositeBlendNoObjwin(renderer, pixel, color | flags, current);
+			}
 		}
 	}
 }


Rearrange _composite to optimize for common cases first

--- src/gba/renderers/video-software.c
+++ src/gba/renderers/video-software.c
@@ -613,10 +613,10 @@
 	// We stash the priority on the top bits so we can do a one-operator comparison
 	// The lower the number, the higher the priority, and sprites take precendence over backgrounds
 	// We want to do special processing if the color pixel is target 1, however
-	if ((color & FLAG_ORDER_MASK) < (current & FLAG_ORDER_MASK)) {
-		if (current & FLAG_UNWRITTEN) {
-			renderer->row[offset] = color | (current & FLAG_OBJWIN);
-		} else if (!(color & FLAG_TARGET_1) || !(current & FLAG_TARGET_2)) {
+	if (current & FLAG_UNWRITTEN) {
+		renderer->row[offset] = color | (current & FLAG_OBJWIN);
+	} else if ((color & FLAG_ORDER_MASK) < (current & FLAG_ORDER_MASK)) {
+		if (!(color & FLAG_TARGET_1) || !(current & FLAG_TARGET_2)) {
 			renderer->row[offset] = color | FLAG_FINALIZED;
 		} else {
 			renderer->row[offset] = _mix(renderer->bldb, current, renderer->blda, color) | FLAG_FINALIZED;


Relegate the GLX version message to DEBUG code and add a whole lot of GL information to the gfx list window command.

--- source/three_d_drawing/ThreeDDraw.c
+++ source/three_d_drawing/ThreeDDraw.c
@@ -774,6 +774,7 @@
 		/* check the existence of the GLX server extension */
 		if (True==glXQueryExtension(display,&error_base,&event_base))
 		{
+#if defined (DEBUG)
 			/* find  version numbers for the GLX extension */
 			if (True==glXQueryVersion(display,&major_version_number,
 				&minor_version_number))
@@ -787,6 +788,7 @@
 						major_version_number,minor_version_number);
 				}
 			}
+#endif /* defined (DEBUG) */
 			visual_info_template.screen=screen_number;
 			if (visual_info_list=XGetVisualInfo(display,VisualScreenMask,
 				&visual_info_template,&number_of_visual_infos))
@@ -908,6 +910,7 @@
 							XGetVisualInfo(display,VisualAllMask,best_visual_info,
 							  &number_of_visual_infos)))
 						{
+#if defined (DEBUG)
 							/*???debug */
 							/* only want to print this once, unless using different visuals */
 							if (!shareable_context)
@@ -915,6 +918,7 @@
 								printf("openGL visual id = %lu\n",(new->three_d_drawing)
 									.normal_buffer.visual_information->visualid);
 							}
+#endif /* defined (DEBUG) */
 							/* create the OpenGL rendering context */
 							direct_rendering=GL_TRUE;
 							if ((new->three_d_drawing).normal_buffer.rendering_context=


Hide action area in folder window on edit modes

pmo-trunk-r7667

--- src/hildon2/modest-folder-window.c
+++ src/hildon2/modest-folder-window.c
@@ -566,6 +566,7 @@
 		break;
 	}

+	hildon_tree_view_set_action_area_visible (GTK_TREE_VIEW (priv->folder_view), !enabled);
 	if (enabled) {
 		modest_folder_view_set_filter (MODEST_FOLDER_VIEW (priv->folder_view),
 					       filter);


remove two extra closing angular brackets

--- shared-bindings/msgpack/__init__.c
+++ shared-bindings/msgpack/__init__.c
@@ -81,7 +81,7 @@
 //| """

-//| def pack(obj: object, buffer: WriteableBuffer, *, default: Callable[[object], None]]=None) -> None:
+//| def pack(obj: object, buffer: WriteableBuffer, *, default: Callable[[object], None]=None) -> None:
 //|     """Ouput object to buffer in msgpack format.
 //|     :param object obj: Object to convert to msgpack format.
 //|     :param ~_typing.WriteableBuffer buffer: buffer to write into
@@ -110,7 +110,7 @@
 }
 MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_pack_obj, 1, mod_msgpack_pack);

-//| def unpack(buffer: ReadableBuffer, *, ext_hook: Callable[[int, bytes], object]]=None, use_list: bool=True) -> object:
+//| def unpack(buffer: ReadableBuffer, *, ext_hook: Callable[[int, bytes], object]=None, use_list: bool=True) -> object:
 //|     """Unpack and return one object from buffer.
 //|     :param ~_typing.ReadableBuffer buffer: buffer to read from
 //|     :param Optional[~_typing.Callable[[int, bytes], object]] ext_hook: function called for objects in


Use the BIN loader instead of the RIM loader in the console frontend

--- frontend/console/shell.c
+++ frontend/console/shell.c
@@ -37,7 +37,7 @@
 #include <time.h>

 #include <libpdp12/cpu.h>
-#include <libpdp12utils/rim.h>
+#include <libpdp12utils/bin.h>
 #include <libpdp12utils/log.h>

 #include "shell.h"
@@ -102,7 +102,7 @@
     if (argc >= 3)
         offset = atoi(argp[2]);

-    words = load_rim(f, offset, cpu->core, CPU_CORE_SIZE);
+    words = load_bin(f, offset, cpu->core, CPU_CORE_SIZE);
     if (words == -1) {
         lprintf(LOG_ERROR,
                 "Failed to load RIM-file...\n"


poly/tests: printing only real value of polynomial to screen (verbose)

--- src/math/tests/polynomial_autotest.c
+++ src/math/tests/polynomial_autotest.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007 - 2015 Joseph Gaeddert
+ * Copyright (c) 2007 - 2019 Joseph Gaeddert
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -328,7 +328,7 @@
     if (liquid_autotest_verbose) {
         printf("poly:\n");
         for (i=0; i<6; i++)
-            printf("  p[%3u] = %12.8f + j*%12.8f\n", i, crealf(p[i]), cimagf(p[i]));
+            printf("  p[%3u] = %12.8f\n", i, p[i]);

         printf("roots:\n");
         for (i=0; i<5; i++)


:construction: chore(type): updated the typedef for Chaos

--- Chaos/Utility/Traits.h
+++ Chaos/Utility/Traits.h
@@ -33,28 +33,28 @@
 // add reference `traits`
 template <typename T>
 struct AddRefImpl {
-  typedef T& type;
+  using type = T&;
 };

 template <typename T>
 struct AddRefImpl<T&&> {
-  typedef T&& type;
+  using type = T&&;
 };

 template <typename T>
 struct AddRef {
-  typedef typename AddRefImpl<T>::type type;
+  using type = typename AddRefImpl<T>::type;
 };

 template <typename T>
 struct AddRef<T&> {
-  typedef T& type;
+  using type = T&;
 };

 // disable_if `traits`
 template <bool B, typename T = void>
 struct DisableIf {
-  typedef T type;
+  using type = T;
 };

 template <typename T>


refactors memory leak printfs in u3a_sweep()

--- noun/allocate.c
+++ noun/allocate.c
@@ -1670,119 +1670,67 @@
   return   u3a_maid(pri_o, "total road stuff", tot_w);
 }

-/* u3a_sweep(): sweep a fully marked road.
-*/
-c3_w
-u3a_sweep(void)
-{
-  c3_w neg_w, pos_w, leq_w, weq_w;
+static c3_c*
+_ca_print_box(u3a_box* box_u)
+{
+  if ( u3a_minimum < box_u->siz_w ) {
+    // fprintf(stderr, "print box 1\r\n");
+    return u3m_pretty(u3a_to_pug(u3a_outa(u3a_boxto(box_u))));
+  }
+  else {
+    // this might not be a cell, but we can use the struct to inspect further
+    //
+    u3a_cell* cel_u = (u3a_cell*)box_u;
+
+    // this condition potentially corresponds to an indirect atom of only one word
+    //
+    if ( (1 == (c3_w)cel_u->hed) &&
+         (0x80000000 & (c3_w)cel_u->tel) )
+    {
+      // this might not be right, but we know it's safe
+      //
+      // fprintf(stderr, "print box 2\r\n");
+      return u3m_pretty(u3a_to_pug(u3a_outa(u3a_boxto(box_u))));
+    }
+
+    // fprintf(stderr, "print box 3 %x [%u %u]\r\n", u3a_to_pom(u3a_outa(u3a_boxto(box_u))), cel_u->hed, cel_u->tel);
+    return u3m_pretty(u3a_to_pom(u3a_outa(u3a_boxto(box_u))));
+  }
+}
+
 #ifdef U3_MEMORY_DEBUG
-  c3_w tot_w, caf_w;
-#endif
-
-  /* Measure allocated memory by counting the free list.
-  */
-  {
-    c3_w end_w;
-    c3_w fre_w = 0;
-    c3_w i_w;
-
-    end_w = _(u3a_is_north(u3R))
-                ? (u3R->hat_p - u3R->rut_p)
-                : (u3R->rut_p - u3R->hat_p);
-
-    for ( i_w = 0; i_w < u3a_fbox_no; i_w++ ) {
-      u3p(u3a_fbox) fre_p = u3R->all.fre_p[i_w];
-
-      while ( fre_p ) {
-        u3a_fbox* fre_u = u3to(u3a_fbox, fre_p);
-
-        fre_w += fre_u->box_u.siz_w;
-        fre_p = fre_u->nex_p;
-      }
-    }
-#ifdef U3_CPU_DEBUG
-    if ( fre_w != u3R->all.fre_w ) {
-      fprintf(stderr, "fre discrepancy (%x): %x, %x, %x\r\n", u3R->par_p,
-          fre_w, u3R->all.fre_w, (u3R->all.fre_w - fre_w));
-    }
-#endif
-    neg_w = (end_w - fre_w);
-  }
-
-  /* Sweep through the arena, repairing and counting leaks.
-  */
-  pos_w = leq_w = weq_w = 0;
-  {
-    u3_post box_p = _(u3a_is_north(u3R)) ? u3R->rut_p : u3R->hat_p;
-    u3_post end_p = _(u3a_is_north(u3R)) ? u3R->hat_p : u3R->rut_p;
-    c3_w*   box_w = u3a_into(box_p);
-    c3_w*   end_w = u3a_into(end_p);
-
-    while ( box_w < end_w ) {
-      u3a_box* box_u = (void *)box_w;
-
-#ifdef U3_MEMORY_DEBUG
-      /* I suspect these printfs fail hilariously in the case
-       * of non-direct atoms. We shouldn't unconditionally run
-       * u3a_to_pom(). In general, the condition
-       * box_u->siz_w > u3a_mimimum is sufficient, but not necessary,
-       * for the box to represent an atom.  The atoms between
-       * 2^31 and 2^32 are the exceptions.
-       *
-       * Update: so, apparently u3.md is incorrect, and a pug is just
-       * an indirect atom.  This code should be altered to handle
-       * that.
-      */
-      if ( box_u->use_w != box_u->eus_w ) {
-        if ( box_u->eus_w != 0 ) {
-          if ( box_u->use_w == 0 ) {
-            printf("dank %p (%d, %d)\r\n", box_u, box_u->use_w, box_u->eus_w);
-          }
-          else {
-            printf("weak %p %x (cell) %x (%d, %d)\r\n",
-                    box_u,
-                    (u3_noun)u3a_to_pom(u3a_outa(u3a_boxto(box_w))),
-                    ((u3a_noun *)(u3a_boxto(box_w)))->mug_w,
-                    box_u->use_w, box_u->eus_w);
-            u3a_print_memory("weak (minimum)", box_u->siz_w);
-            // u3m_p("weak", u3a_to_pom(u3a_outa(u3a_boxto(box_w))));
-          }
-          weq_w += box_u->siz_w;
-        }
-        else {
-          printf("leak %p %x (cell)/%x (%d)\r\n",
-                  box_u,
-                  (u3_noun)u3a_to_pom(u3a_outa(u3a_boxto(box_w))),
-                  ((u3a_noun *)(u3a_boxto(box_w)))->mug_w
-                    ? ((u3a_noun *)(u3a_boxto(box_w)))->mug_w
-                    : u3r_mug(u3a_to_pom(u3a_outa(u3a_boxto(box_w)))),
-                  box_u->use_w);
-          u3a_print_memory("leak (minimum)", box_u->siz_w);
-          // u3m_p("leak", u3a_to_pom(u3a_outa(u3a_boxto(box_w))));
-          leq_w += box_u->siz_w;
-        }
-        if ( box_u->cod_w ) {
-          u3m_p("  code", box_u->cod_w);
-        }
-        box_u->use_w = box_u->eus_w;
-      }
-      else {
-        if ( box_u->use_w ) {
-          pos_w += box_u->siz_w;
-        }
-      }
-      box_u->eus_w = 0;
+
+static void
+_ca_print_leak(c3_c* cap_c, u3a_box* box_u, c3_w eus_w, c3_w use_w)
+{
+  c3_c* dat_c = _ca_print_box(box_u);
+
+  fprintf(stderr, "%s: %p mug=%x (marked=%u swept=%u)\r\n",
+    cap_c, box_u, ((u3a_noun *)(u3a_boxto(box_u)))->mug_w,
+    eus_w, use_w);
+
+  if ( box_u->cod_w ) {
+    u3m_p("    code", box_u->cod_w);
+  }
+
+  u3a_print_memory("    size", box_u->siz_w);
+  fprintf(stderr,  "    data: %s\r\n", dat_c);
+
+  free(dat_c);
+}
+
 #else
-      c3_ws use_ws = (c3_ws)box_u->use_w;
-
-      if ( use_ws > 0 ) {
-        printf("leak %p %x\r\n",
-                box_u,
-                ((u3a_noun *)(u3a_boxto(box_w)))->mug_w
-                  ? ((u3a_noun *)(u3a_boxto(box_w)))->mug_w
-                  : u3r_mug(u3a_to_pom(u3a_outa(u3a_boxto(box_w)))));
-        // u3a_print_memory("leak (minimum)", box_u->siz_w);
+
+static void
+_ca_print_leak(c3_c* cap_c, u3a_box* box_u, c3_ws use_ws)
+{
+  c3_c* dat_c = _ca_print_box(box_u);
+
+  fprintf(stderr, "%s: %p mug=%x swept=%d\r\n",
+    cap_c, box_u, ((u3a_noun *)(u3a_boxto(box_u)))->mug_w, use_ws);
+
+  u3a_print_memory("    size", box_u->siz_w);
+  fprintf(stderr,  "    data: %s\r\n", dat_c);

 #if 0
         /*  For those times when you've really just got to crack open
@@ -1797,6 +1745,106 @@
         }
 #endif

+  free(dat_c);
+}
+
+#endif
+
+/* u3a_sweep(): sweep a fully marked road.
+*/
+c3_w
+u3a_sweep(void)
+{
+  c3_w neg_w, pos_w, leq_w, weq_w;
+#ifdef U3_MEMORY_DEBUG
+  c3_w tot_w, caf_w;
+#endif
+
+  /* Measure allocated memory by counting the free list.
+  */
+  {
+    c3_w end_w;
+    c3_w fre_w = 0;
+    c3_w i_w;
+
+    end_w = _(u3a_is_north(u3R))
+                ? (u3R->hat_p - u3R->rut_p)
+                : (u3R->rut_p - u3R->hat_p);
+
+    for ( i_w = 0; i_w < u3a_fbox_no; i_w++ ) {
+      u3p(u3a_fbox) fre_p = u3R->all.fre_p[i_w];
+
+      while ( fre_p ) {
+        u3a_fbox* fre_u = u3to(u3a_fbox, fre_p);
+
+        fre_w += fre_u->box_u.siz_w;
+        fre_p = fre_u->nex_p;
+      }
+    }
+#ifdef U3_CPU_DEBUG
+    if ( fre_w != u3R->all.fre_w ) {
+      fprintf(stderr, "fre discrepancy (%x): %x, %x, %x\r\n", u3R->par_p,
+          fre_w, u3R->all.fre_w, (u3R->all.fre_w - fre_w));
+    }
+#endif
+    neg_w = (end_w - fre_w);
+  }
+
+  /* Sweep through the arena, repairing and counting leaks.
+  */
+  pos_w = leq_w = weq_w = 0;
+  {
+    u3_post box_p = _(u3a_is_north(u3R)) ? u3R->rut_p : u3R->hat_p;
+    u3_post end_p = _(u3a_is_north(u3R)) ? u3R->hat_p : u3R->rut_p;
+    c3_w*   box_w = u3a_into(box_p);
+    c3_w*   end_w = u3a_into(end_p);
+
+    while ( box_w < end_w ) {
+      u3a_box* box_u = (void *)box_w;
+
+#ifdef U3_MEMORY_DEBUG
+      /* I suspect these printfs fail hilariously in the case
+       * of non-direct atoms. We shouldn't unconditionally run
+       * u3a_to_pom(). In general, the condition
+       * box_u->siz_w > u3a_minimum is sufficient, but not necessary,
+       * for the box to represent an atom.  The atoms between
+       * 2^31 and 2^32 are the exceptions.
+       *
+       * Update: so, apparently u3.md is incorrect, and a pug is just
+       * an indirect atom.  This code should be altered to handle
+       * that.
+      */
+      if ( box_u->use_w != box_u->eus_w ) {
+        if ( box_u->eus_w != 0 ) {
+          if ( box_u->use_w == 0 ) {
+            _ca_print_leak("dank", box_u, box_u->eus_w, box_u->use_w);
+          }
+          else {
+            _ca_print_leak("weak", box_u, box_u->eus_w, box_u->use_w);
+          }
+
+          weq_w += box_u->siz_w;
+        }
+        else {
+          _ca_print_leak("weak", box_u, box_u->eus_w, box_u->use_w);
+
+          leq_w += box_u->siz_w;
+        }
+
+        box_u->use_w = box_u->eus_w;
+      }
+      else {
+        if ( box_u->use_w ) {
+          pos_w += box_u->siz_w;
+        }
+      }
+      box_u->eus_w = 0;
+#else
+      c3_ws use_ws = (c3_ws)box_u->use_w;
+
+      if ( use_ws > 0 ) {
+        _ca_print_leak("leak", box_u, use_ws);
+
         leq_w += box_u->siz_w;
         box_u->use_w = 0;


Remove dead code.

Remove dead code.

git-svn-id: 5648d1bec6962b0a6d1d1b40eba8cf5cdb62da3d@1303 6f19259b-4bc3-4df7-8a09-765794883524

--- EdkModulePkg/Core/Dxe/DxeMain/DxeMain.c
+++ EdkModulePkg/Core/Dxe/DxeMain/DxeMain.c
@@ -394,12 +394,6 @@
   EFI_PHYSICAL_ADDRESS               MemoryBaseAddress;
   UINT64                             MemoryLength;

-#ifdef EFI_DXE_PERFORMANCE
-  UINT64                             Tick;
-
-  GetTimerValue (&Tick);
-#endif
-
   mHobStart = HobStart;

   //


Remove some dead stores.

Remove some dead stores.

--- Eigen/src/Core/arch/SSE/MathFunctions.h
+++ Eigen/src/Core/arch/SSE/MathFunctions.h
@@ -138,7 +138,6 @@
 #ifdef EIGEN_VECTORIZE_SSE4_1
   fx = _mm_floor_ps(fx);
 #else
-  tmp = _mm_setzero_ps();
   emm0 = _mm_cvttps_epi32(fx);
   tmp  = _mm_cvtepi32_ps(emm0);
   /* if greater, substract 1 */
@@ -207,7 +206,6 @@
 #ifdef EIGEN_VECTORIZE_SSE4_1
   fx = _mm_floor_pd(fx);
 #else
-  tmp = _mm_setzero_pd();
   emm0 = _mm_cvttpd_epi32(fx);
   tmp  = _mm_cvtepi32_pd(emm0);
   /* if greater, substract 1 */


FileSystem Entry: no need for a class to befriend itself


Update transceiver.c

Update transceiver.c

Fix comments

--- firmware/transceiver/transceiver.c
+++ firmware/transceiver/transceiver.c
@@ -20,7 +20,7 @@
  DATA2     - данные (байт 2)                     - 8 бит
  DATA3     - данные (байт 3)                     - 8 бит
  DATA4     - данные (байт 4)                     - 8 бит
- CHECKSUM  - контрольная сумма предыдущих 6 байт - 8 бит
+ CHECKSUM  - контрольная сумма предыдущих 7 байт - 8 бит

  -----------------------------------------------------------------------------------------------------------------------

@@ -79,17 +79,9 @@
 #define ERR_BUS_BUSY            1                                               // Линия занята
 #define ERR_PACKET_LOST         2                                               // Пакет потерян

-
-/*
-// Временные интервалы кодирования
-#define BIT_START_TIME          20                                              // Время стартового условия передачи бита
-#define BIT_ONE_TIME            2000                                            // Время кодирования 1
-#define BIT_ZERO_TIME           1000                                            // Время кодирования 0  */
-
 #define BIT_START_TIME          10                                              // Время стартового условия передачи бита
 #define BIT_ONE_TIME            30                                              // Время кодирования 1
 #define BIT_ZERO_TIME           10                                              // Время кодирования 0
-

 // Временные интервалы приема битов
 #define HI_TIME_MIN             55                                              // Минимальное время кодирования 1
@@ -103,9 +95,6 @@

 #define QUEUE_SIZE              16                                              // Максимальный размер очереди принятых команд (в командах)

-// Время ожидания подтверждения (мс)
-//#define ACK_TIMEOUT             10
-
 // Управление MAX485
 #define MAX485_TRANSMIT         { DE_RE_PIN = 1; DI_PIN = 0; }                  // Режим передачи
 #define MAX485_RECEIVE          { DE_RE_PIN = 0; DI_PIN = 0; }                  // Режим приема
@@ -114,13 +103,14 @@
 #define INT_ENABLE              { INTCON.GIE = 1; }                             // Все прерывания разрешены
 #define INT_DISABLE             { INTCON.GIE = 0; }                             // Все прерывания запрещены

+// Очередь команд (структура)
 struct s_data_queue
 {
     unsigned char b[COMMAND_SIZE];
 };

 // Глобальные переменные
-unsigned char device_addr = 0;                                                  // Адрес устройства ( 0 .. 254 )
+unsigned char device_addr = 0;                                                  // Адрес устройства ( 1 .. 255 )
 unsigned char packet_num = 0;                                                   // Номер пакета ( 1..127 )

 unsigned char send_buf[PACKET_SIZE];                                            // Буфер передачи
@@ -142,8 +132,11 @@
 bit comm_rd_complete;
 struct s_data_queue comm_cmd;                                                   // Буфер приема/передачи от мастер устройства

-unsigned char ack_timeout = 100;
-
+unsigned char ack_timeout = 100;                                                // Время одижания получения подтверждения
+
+//
+// Обработчик прерываний
+//
 void interrupt( )
 {
     if ( TMR0IF_bit )                                                           // Переполение таймера 0 (данные не передаются в течении длительного времени)
@@ -199,21 +192,9 @@
     }
 }

-/*
-
-  Контрольная сумма
-
-  Name  : CRC-8
-  Poly  : 0x31    x^8 + x^5 + x^4 + 1
-  Init  : 0xFF
-  Revert: false
-  XorOut: 0x00
-  Check : 0xF7 ("123456789")
-  MaxLen: 15 байт(127 бит) - обнаружение
-  одинарных, двойных, тройных
-  и всех нечетных ошибок
-
-*/
+//
+// Контрольная сумма CRC-8
+//
 unsigned char crc8( unsigned char *block )
 {
     unsigned char crc = 0xFF;
@@ -230,8 +211,9 @@
     return crc;
 }

-
+//
 // Передача данных (d - данные, size - размер)
+//
 void send_data( unsigned char *d, unsigned char size )
 {
     unsigned char b, i;
@@ -261,7 +243,9 @@
     DI_PIN = 1;
 }

+//
 // Передача пакета подтверждения (d - принятый буфер)
+//
 void send_ack( unsigned char *bf )
 {
     Delay_us(500);
@@ -282,7 +266,9 @@
     MAX485_RECEIVE;                                                             // Переводим MAX485 в режим приема
 }

-// Передача пакета ( cmd - данные (1 байт - получатель, 3 байта - данные))
+//
+// Передача пакета ( cmd - данные (1 байт - получатель, остальные 4 байта - данные))
+//
 unsigned char send_packet( unsigned char *cmd )
 {
     unsigned char res = ERR_PACKET_LOST;                                        // Результат выполнения
@@ -321,7 +307,7 @@
         {
             INT_DISABLE;

-            if ( crc8(recv_buf) == recv_buf[PACKET_SIZE - 1] )                   // Если контрольная сумма верная
+            if ( crc8(recv_buf) == recv_buf[PACKET_SIZE - 1] )                  // Если контрольная сумма верная
             {
                 if ( recv_buf[2] & 0b10000000 )                                 // Если полученные данные это подтверждение (ACK) ( установлен 8-й бит в номере пакета)
                 {
@@ -351,7 +337,9 @@
     return res;                                                                 // Возвращаем результат
 }

+//
 // Добавляем полученную команду в конец очереди
+//
 void push_command( )
 {
     if ( data_queue_size == QUEUE_SIZE - 1 )                                    // Если очередь полностью заполнена, игнорируем принимаемые данные
@@ -366,15 +354,17 @@
     data_queue_size++;                                                          // Смещаем указатель на последний элемент очереди
 }

+//
 // Извлекаем первую в очереди команду
+//
 void pop_command( struct s_data_queue *cmd )
 {
     unsigned char i;

-    if ( data_queue_size == 0 )                                                     // Если очередь пуста, ничего не делаем
+    if ( data_queue_size == 0 )                                                 // Если очередь пуста, ничего не делаем
         return;

-    memcpy(cmd, &data_queue[0], sizeof(struct s_data_queue));                    // Извлекаем первый элемент из очереди
+    memcpy(cmd, &data_queue[0], sizeof(struct s_data_queue));                   // Извлекаем первый элемент из очереди

     for ( i = 0; i < data_queue_size - 1; ++i )                                 // Смещаем очередь
         memcpy(&data_queue[i], &data_queue[i + 1], sizeof(struct s_data_queue));
@@ -382,7 +372,9 @@
     data_queue_size--;                                                          // Уменьшаем размер очереди
 }

+//
 // Обработка полученного пакета
+//
 void process_received_packet( )
 {
     if ( recv_done )                                                            // Данные получены
@@ -405,7 +397,9 @@
     }
 }

+//
 // Прием данных от мастер устройства
+//
 void comm_read( )
 {
     unsigned char i, n;
@@ -415,7 +409,6 @@

     memset(&comm_cmd, 0, sizeof(struct s_data_queue));

-    //comm_rw_value = 0;                                                          // 4-х байтовая переменная
     comm_clk_prev_state = 0;                                                    // Предыдущее состоянии COMM_CLK_PIN
     comm_rd_complete = 0;

@@ -439,7 +432,7 @@
         {
             comm_clk_prev_state = 1;

-            comm_cmd.b[i] <<= 1;                                                  // Сдвиг
+            comm_cmd.b[i] <<= 1;                                                // Сдвиг
             if ( COMM_DATA_PIN )                                                // Единица
                 comm_cmd.b[i] |= 1;

@@ -460,7 +453,7 @@

     if ( comm_rd_complete )                                                     // Принята команда
     {
-        if ( comm_cmd.b[0] == 255 )                              // Установка адреса устройства (если адрес получателя 0)  // fix 255 ?
+        if ( comm_cmd.b[0] == 255 )                                             // Установка адреса устройства (если адрес получателя 0)  // fix 255 ?
         {
             device_addr = comm_cmd.b[1];
             ack_timeout = comm_cmd.b[2];
@@ -468,8 +461,8 @@
         }
         else
         {
-            if ( send_packet(comm_cmd.b) == ERR_PACKET_LOST ) // Отправка пакета
-               memset(&comm_cmd, 0, sizeof(struct s_data_queue));                                                  // Ошибка отправки ( подтверждение не получено) - 0
+            if ( send_packet(comm_cmd.b) == ERR_PACKET_LOST )                   // Отправка пакета
+               memset(&comm_cmd, 0, sizeof(struct s_data_queue));               // Ошибка отправки ( подтверждение не получено) - 0
         }
     }

@@ -489,7 +482,7 @@
             else
                 COMM_DATA_PIN = 0;                                              // Ноль

-            comm_cmd.b[i] <<= 1;                                                     // Сдвиг
+            comm_cmd.b[i] <<= 1;                                                // Сдвиг
             if ( ++n >= 8 )
             {
                 if ( i )
@@ -508,9 +501,9 @@
     INT_ENABLE;
 }

-
-
+//
 // Передача данных в мастер устройство
+//
 void comm_write( )
 {
     unsigned char i, n;
@@ -520,7 +513,6 @@

     memset(&comm_cmd, 0, sizeof(struct s_data_queue));

-    //comm_rw_value = 0;                                                          // 4-х байтовая переменная
     comm_clk_prev_state = 0;                                                    // Предыдущее состоянии COMM_CLK_PIN
     comm_wr_processed = 0;                                                      // Процесс передачи не начат

@@ -528,13 +520,13 @@

     INT_DISABLE;

-    if ( recv_processing || data_queue_size == 0 )                                    // Если идет процесс приема пакета или очередь пуста, ничего не делаем
+    if ( recv_processing || data_queue_size == 0 )                              // Если идет процесс приема пакета или очередь пуста, ничего не делаем
     {
         INT_ENABLE;
         return;
     }

-    while ( !COMM_RD_PIN && !COMM_WR_PIN )                                                      // Если COMM_WR_PIN = 0 мастер устройство начало процесс приема данных
+    while ( !COMM_RD_PIN && !COMM_WR_PIN )                                      // Если COMM_WR_PIN = 0 мастер устройство начало процесс приема данных
     {
         if ( !comm_wr_processed )                                               // Если передача не начата
         {
@@ -544,7 +536,7 @@
             {
                 i = COMMAND_SIZE - 1;
                 n = 0;
-                pop_command(&comm_cmd);                                              // Извлекаем команду из очереди
+                pop_command(&comm_cmd);                                         // Извлекаем команду из очереди
                 COMM_DATA_DIR = 0;                                              // Пин данных - выход
                 COMM_DATA_READY_PIN = 1;                                        // Устанавливаем готовность передачи данных мастер устройству
             }
@@ -559,7 +551,7 @@
             else
                 COMM_DATA_PIN = 0;                                              // Ноль

-            comm_cmd.b[i] <<= 1;                                                     // Сдвиг
+            comm_cmd.b[i] <<= 1;                                                // Сдвиг
             if ( ++n >= 8 )
             {
                 if ( i )
@@ -578,7 +570,9 @@
     INT_ENABLE;
 }

-
+//
+// Точка входа
+//
 void main()
 {
     unsigned long led_counter = 0;
@@ -605,7 +599,7 @@
     OPTION_REG.T0CS     = 0;                                                    // Тактирование таймера 0 от внутреннего генератора
     OPTION_REG.PSA      = 0;                                                    // Использовать пределитель для таймера 0
     OPTION_REG.PS2      = 0;                                                    // Предделитель
-    OPTION_REG.PS1      = 1;  //1
+    OPTION_REG.PS1      = 1;
     OPTION_REG.PS0      = 0;

     INTCON.PEIE         = 1;                                                    // Разрешаем периферийные прерывания
@@ -628,10 +622,10 @@

         comm_write();                                                           // Передача данных в мастер устройство

-        if ( led_counter++ > 10000 )
+        if ( led_counter++ > 10000 )                                            // Индикация работы
         {
             led_counter = 0;
             LED_PIN = ~LED_PIN;
         }
     }
-}+}


[dp] Simplify the debug panel by supporting only syscall mode

--- modules/debugpanel/dp.c
+++ modules/debugpanel/dp.c
@@ -50,10 +50,6 @@
 bool ui_need_update;
 struct dp_screen *dp_ctx;

-static bool dp_enable_kb_handler;
-static bool in_debug_panel;
-static struct tty *dp_tty;
-static struct tty *saved_tty;
 static struct list dp_screens_list = make_list(dp_screens_list);

 static void dp_enter(void)
@@ -64,7 +60,6 @@
    term_read_info(&tparams);
    dp_set_cursor_enabled(false);

-   in_debug_panel = true;
    dp_rows = tparams.rows;
    dp_cols = tparams.cols;
    dp_start_row = (dp_rows - DP_H) / 2 + 1;
@@ -86,7 +81,6 @@
 static void dp_exit(void)
 {
    struct dp_screen *pos;
-   in_debug_panel = false;

    list_for_each_ro(pos, &dp_screens_list, node) {

@@ -115,51 +109,6 @@
    list_add_after(pred, &screen->node);
 }

-static int
-dp_switch_to_dedicated_video_tty(void)
-{
-   int rc = 0;
-
-   if (!dp_tty) {
-
-      dp_tty = create_tty_nodev();
-
-      if (!dp_tty) {
-         printk("ERROR: no enough memory for debug panel's TTY\n");
-         rc = -ENOMEM;
-         goto end;
-      }
-
-      dp_ctx = list_first_obj(&dp_screens_list, struct dp_screen, node);
-   }
-
-   saved_tty = get_curr_tty();
-
-   if ((rc = set_curr_tty(dp_tty)) < 0)
-      goto end;
-
-   dp_enter();
-
-end:
-   return rc;
-}
-
-static enum kb_handler_action
-dp_debug_panel_off_keypress(struct kb_dev *kb, struct key_event ke)
-{
-   int rc;
-
-   if (kb_is_ctrl_pressed(kb) && ke.key == KEY_F12) {
-
-      rc = dp_switch_to_dedicated_video_tty();
-
-      if (!rc || rc == -ENOMEM)
-         return kb_handler_ok_and_stop;
-   }
-
-   return kb_handler_nak;
-}
-
 static void redraw_screen(void)
 {
    struct dp_screen *pos;
@@ -179,11 +128,7 @@

    dp_draw_rect_raw(dp_start_row, dp_start_col, DP_H, DP_W);
    dp_move_cursor(dp_start_row, dp_start_col + 2);
-
-   if (dp_enable_kb_handler)
-      dp_write_raw(ESC_COLOR_YELLOW "[ TilckDebugPanel ]" RESET_ATTRS);
-   else
-      dp_write_raw(ESC_COLOR_YELLOW "[ TilckDebugPanel (cmd) ]" RESET_ATTRS);
+   dp_write_raw(ESC_COLOR_YELLOW "[ TilckDebugPanel ]" RESET_ATTRS);

    rc = snprintk(buf, sizeof(buf),
                  "[rows %02d - %02d of %02d]",
@@ -256,68 +201,6 @@
    return dp_screen_key_handled;
 }

-static void
-dp_video_quit(void)
-{
-   if (set_curr_tty(saved_tty) == 0)
-      dp_exit();
-}
-
-static enum kb_handler_action
-dp_keypress_handler(struct kb_dev *kb, struct key_event ke)
-{
-   int rc;
-   u8 mods;
-
-   if (!ke.pressed)
-      return kb_handler_nak; /* ignore key-release events */
-
-   if (kopt_serial_console)
-      return kb_handler_nak;
-
-   if (!dp_enable_kb_handler) {
-
-      /* Disable switch to any other TTY with ALT + Fn */
-      if (kb_is_alt_pressed(kb)) {
-         if (kb_get_fn_key_pressed(ke.key) > 0)
-            return kb_handler_ok_and_stop;
-      }
-
-      return kb_handler_nak;
-   }
-
-   if (!in_debug_panel) {
-
-      if (dp_debug_panel_off_keypress(kb, ke) == kb_handler_nak)
-         return kb_handler_nak;
-
-      ui_need_update = true;
-   }
-
-   ASSERT(in_debug_panel);
-   mods = kb_get_current_modifiers(kb);
-
-   if (mods == 4 /* ctrl */ && ke.print_char == 'c') {
-      dp_video_quit();
-      return kb_handler_ok_and_stop;
-   }
-
-   rc = dp_main_body(term_type_video, ke);
-
-   if (!rc && ke.print_char == 'q') {
-      dp_video_quit();
-      return kb_handler_ok_and_stop;
-   }
-
-   return kb_handler_ok_and_stop;
-}
-
-static struct keypress_handler_elem debugpanel_handler_elem =
-{
-   .handler = &dp_keypress_handler
-};
-
-
 static int
 read_ke_from_tty(fs_handle h, struct key_event *ke)
 {
@@ -442,9 +325,7 @@
    fs_handle h = NULL;
    int rc;

-   dp_enable_kb_handler = false;
    tt = get_curr_proc_tty_term_type();
-
    dp_ctx = list_first_obj(&dp_screens_list, struct dp_screen, node);
    dp_enter();

@@ -493,13 +374,10 @@
    dp_exit();
    dp_clear();
    dp_write_raw("\n");
-   dp_enable_kb_handler = true;
 }

 static void dp_init(void)
 {
-   dp_enable_kb_handler = true;
-   register_keypress_handler(&debugpanel_handler_elem);
    register_tilck_cmd(TILCK_CMD_DEBUG_PANEL, dp_tilck_cmd);
 }


demux: ts: add check for EAC3 registration

--- modules/demux/mpeg/ts.c
+++ modules/demux/mpeg/ts.c
@@ -4588,7 +4588,8 @@
     es_format_t *p_fmt = &p_pes->es.fmt;
     dvbpsi_descriptor_t *p_subs_dr = PMTEsFindDescriptor( p_dvbpsies, 0x59 );
     dvbpsi_descriptor_t *desc;
-    if( PMTEsFindDescriptor( p_dvbpsies, 0x7a ) )
+    if( PMTEsHasRegistration( p_demux, p_dvbpsies, "EAC3" ) ||
+        PMTEsFindDescriptor( p_dvbpsies, 0x7a ) )
     {
         /* DVB with stream_type 0x06 (ETS EN 300 468) */
         p_fmt->i_cat = AUDIO_ES;


Acquire the pull region before creating the pull handle to make things more simple

git-svn-id: 29c1264a5cf5e3532df57b06678e7347571c1a3c@2168 f1ba3bf5-cb5c-402b-92a9-7c6bdc83a356

--- driver/linux/omx_pull.c
+++ driver/linux/omx_pull.c
@@ -570,40 +570,19 @@
  */
 static INLINE struct omx_pull_handle *
 omx_pull_handle_create(struct omx_endpoint * endpoint,
+		       struct omx_user_region * region,
 		       struct omx_cmd_pull * cmd)
 {
 	struct omx_pull_handle * handle;
-	struct omx_user_region * region;
 	int i;
 	int err;
-
-	/* acquire the region */
-	region = omx_user_region_acquire(endpoint, cmd->local_rdma_id);
-	if (unlikely(!region)) {
-		err = -EINVAL;
-		goto out;
-	}
-
-	if (!omx_pin_synchronous) {
-		/* make sure the region is pinned */
-		struct omx_user_region_pin_state pinstate;
-
-		omx_user_region_demand_pin_init(&pinstate, region);
-		pinstate.next_chunk_pages = omx_pin_chunk_pages_max;
-		err = omx_user_region_demand_pin_finish(&pinstate);
-		/* FIXME: deal with omx_pin_progressive (will be _or_parallel) */
-		if (err < 0) {
-			dprintk(REG, "failed to pin user region\n");
-			goto out_with_region;
-		}
-	}

 	/* alloc the pull handle */
 	handle = kmalloc(sizeof(struct omx_pull_handle), GFP_KERNEL);
 	if (unlikely(!handle)) {
 		printk(KERN_INFO "Open-MX: Failed to allocate a pull handle\n");
 		err = -ENOMEM;
-		goto out_with_region;
+		goto out;
 	}
 	/* initialize the lock, we will acquire it soon */
 	spin_lock_init(&handle->lock);
@@ -684,8 +663,6 @@
 	spin_unlock(&handle->lock);
  out_with_handle:
 	kfree(handle);
- out_with_region:
-	omx_user_region_release(region);
  out:
 	return ERR_PTR(err);
 }
@@ -874,6 +851,7 @@
 {
 	struct omx_cmd_pull cmd;
 	struct omx_pull_handle * handle;
+	struct omx_user_region * region;
 	struct omx_iface * iface = endpoint->iface;
 	struct sk_buff * skb, * skbs[OMX_PULL_BLOCK_DESCS_NR] = { NULL };
 	uint32_t block_length;
@@ -893,11 +871,32 @@
 		return omx_shared_pull(endpoint, &cmd);
 #endif

+	/* acquire the region */
+	region = omx_user_region_acquire(endpoint, cmd.local_rdma_id);
+	if (unlikely(!region)) {
+		err = -EINVAL;
+		goto out;
+	}
+
+	if (!omx_pin_synchronous) {
+		/* make sure the region is pinned */
+		struct omx_user_region_pin_state pinstate;
+
+		omx_user_region_demand_pin_init(&pinstate, region);
+		pinstate.next_chunk_pages = omx_pin_chunk_pages_max;
+		err = omx_user_region_demand_pin_finish(&pinstate);
+		/* FIXME: deal with omx_pin_progressive (will be _or_parallel) */
+		if (err < 0) {
+			dprintk(REG, "failed to pin user region\n");
+			goto out_with_region;
+		}
+	}
+
 	/* create, acquire and lock the handle */
-	handle = omx_pull_handle_create(endpoint, &cmd);
+	handle = omx_pull_handle_create(endpoint, region, &cmd);
 	if (IS_ERR(handle)) {
 		err = PTR_ERR(handle);
-		goto out;
+		goto out_with_region;
 	}

 	/* tell the sparse checker that the lock has been taken by omx_pull_handle_create() */
@@ -961,6 +960,8 @@

 	return 0;

+ out_with_region:
+	omx_user_region_release(region);
  out:
 	return err;
 }


[PATCH] libata: print cdb[0] in failed qc report

Print cdb[0] in failed qc report.

Signed-off-by: Tejun Heo <ccfba69985e72fbcd9ba8bbb6db43d42971ad06d@gmail.com>
Signed-off-by: Jeff Garzik <f3e731dfa293c7a83119d8aacfa41b5d2d780be9@garzik.org>

--- drivers/ata/libata-eh.c
+++ drivers/ata/libata-eh.c
@@ -1452,14 +1452,15 @@

 		ata_dev_printk(qc->dev, KERN_ERR,
 			"cmd %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x "
-			"tag %d data %u %s\n         "
+			"tag %d cdb 0x%x data %u %s\n         "
 			"res %02x/%02x:%02x:%02x:%02x:%02x/%02x:%02x:%02x:%02x:%02x/%02x "
 			"Emask 0x%x (%s)\n",
 			cmd->command, cmd->feature, cmd->nsect,
 			cmd->lbal, cmd->lbam, cmd->lbah,
 			cmd->hob_feature, cmd->hob_nsect,
 			cmd->hob_lbal, cmd->hob_lbam, cmd->hob_lbah,
-			cmd->device, qc->tag, nbytes, dma_str[qc->dma_dir],
+			cmd->device, qc->tag, qc->cdb[0], nbytes,
+			dma_str[qc->dma_dir],
 			res->command, res->feature, res->nsect,
 			res->lbal, res->lbam, res->lbah,
 			res->hob_feature, res->hob_nsect,


put received bytes to fifo when error

put received bytes to fifo when error

--- ports/nrf/common-hal/busio/UART.c
+++ ports/nrf/common-hal/busio/UART.c
@@ -67,18 +67,24 @@
     r->iput = r->iget = 0;
 }

+// will overwrite old data
+static void ringbuf_put_n(ringbuf_t* r, uint8_t* buf, uint8_t bufsize)
+{
+    for(uint8_t i=0; i < bufsize; i++) {
+        if ( ringbuf_put(r, buf[i]) < 0 ) {
+            // if full overwrite old data
+            (void) ringbuf_get(r);
+            ringbuf_put(r, buf[i]);
+        }
+    }
+}
+
 static void uart_callback_irq (const nrfx_uarte_event_t * event, void * context) {
     busio_uart_obj_t* self = (busio_uart_obj_t*) context;

     switch ( event->type ) {
         case NRFX_UARTE_EVT_RX_DONE:
-            for(uint8_t i=0; i < event->data.rxtx.bytes; i++) {
-                if ( ringbuf_put(&self->rbuf, event->data.rxtx.p_data[i]) < 0 ) {
-                    // if full overwrite old data
-                    (void) ringbuf_get(&self->rbuf);
-                    ringbuf_put(&self->rbuf, event->data.rxtx.p_data[i]);
-                }
-            }
+            ringbuf_put_n(&self->rbuf, event->data.rxtx.p_data, event->data.rxtx.bytes);

             // keep receiving
             (void) nrfx_uarte_rx(&self->uarte, &self->rx_char, 1);
@@ -91,6 +97,8 @@
         case NRFX_UARTE_EVT_ERROR:
             // Possible Error source is Overrun, Parity, Framing, Break
             // uint32_t errsrc = event->data.error.error_mask;
+
+            ringbuf_put_n(&self->rbuf, event->data.error.rxtx.p_data, event->data.error.rxtx.bytes);

             // Keep receiving
             (void) nrfx_uarte_rx(&self->uarte, &self->rx_char, 1);


sata_rcar: correct 'sata_rcar_sht'

sata_rcar: correct 'sata_rcar_sht'

Using ATA_BMDMA_SHT() to intialize 'sata_rcar_sht' was suboptimal as
the R-Car descriptor table transfer counter is 28 bits wide (bit 1 to
bit 28), so that the 'dma_boundary' field of 0xFFFF is just too small,
as well as the 'sg_tablesize' field of 128.  Use ATA_BASE_SHT() to
initialize 'sata_rcar_sht' instead and give proper values to the
'dma_boundary' and 'sg_tablesize' fields explicitly.

Signed-off-by: Sergei Shtylyov <d8c69075be49b0738b690ec4af0e9025b8c97c9e@cogentembedded.com>
Signed-off-by: Tejun Heo <546b05909706652891a87f7bfe385ae147f61f91@kernel.org>

--- drivers/ata/sata_rcar.c
+++ drivers/ata/sata_rcar.c
@@ -120,6 +120,8 @@

 /* Descriptor table word 0 bit (when DTA32M = 1) */
 #define SATA_RCAR_DTEND			BIT(0)
+
+#define SATA_RCAR_DMA_BOUNDARY		0x1FFFFFFEUL

 struct sata_rcar_priv {
 	void __iomem *base;
@@ -575,7 +577,14 @@
 }

 static struct scsi_host_template sata_rcar_sht = {
-	ATA_BMDMA_SHT(DRV_NAME),
+	ATA_BASE_SHT(DRV_NAME),
+	/*
+	 * This controller allows transfer chunks up to 512MB which cross 64KB
+	 * boundaries, therefore the DMA limits are more relaxed than standard
+	 * ATA SFF.
+	 */
+	.sg_tablesize		= ATA_MAX_PRD,
+	.dma_boundary		= SATA_RCAR_DMA_BOUNDARY,
 };

 static struct ata_port_operations sata_rcar_port_ops = {


- gphoto-backend correctly initalized

  - gphoto-backend correctly initalized

git-svn-id: 40dd595c6684d839db675001a64203a1457e7319@927 67ed7778-7388-44ab-90cf-0a291f65f57c

--- frontends/gtk/src/main.c
+++ frontends/gtk/src/main.c
@@ -1,20 +1,16 @@
-/*
- * Initial main.c file generated by Glade. Edit as required.
- * Glade will not overwrite this file.
- */
-
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
 #endif
-
-#include <gtk/gtk.h>
-#ifndef WITHOUT_GNOME
-#include <gnome.h>
-#include <glade/glade.h>
+#ifdef WITHOUT_GNOME
+#  include <gtk/gtk.h>
+#else
+#  include <gnome.h>
+#  include <glade/glade.h>
 #endif
-
+#include <gphoto2.h>
 #include "interface.h"
 #include "support.h"
+

 int
 main (int argc, char *argv[])
@@ -28,26 +24,24 @@

   gtk_set_locale ();
 #ifdef WITHOUT_GNOME
+  /* Init gtk. */
   gtk_init (&argc, &argv);
 #else
+  /* Init gnome and glade. */
   gnome_init (PACKAGE, VERSION, argc, argv);
   glade_gnome_init ();
-  gtk_widget_push_visual (gdk_imlib_get_visual ());
-  gtk_widget_push_colormap (gdk_imlib_get_colormap ());
 #endif
+  /* Init gphoto backend. */
+  gp_init (0);

   add_pixmap_directory (PACKAGE_DATA_DIR "/pixmaps");
   add_pixmap_directory (PACKAGE_SOURCE_DIR "/pixmaps");

-  /*
-   * The following code was added by Glade to create one of each component
-   * (except popup menus), just so that you see something after building
-   * the project. Delete any components that you don't want shown initially.
-   */
+  /* Create the gui. */
   main_win = create_main_win ();
   gtk_widget_show (main_win);
+  gtk_main ();

-  gtk_main ();
-  return 0;
+  return (0);
 }


driver core: platform: Use drv->driver.bus instead of assuming platform_bus_type

In theory (although not *yet* in practice), a driver being passed
to platform_driver_probe might have driver.bus set to something
other than platform_bus_type. Locking drv->driver.bus is always
correct.

Signed-off-by: Patrick Pannuto <860ddc3aeb425c73e9a9a67794cca8f2b399070d@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>

--- drivers/base/platform.c
+++ drivers/base/platform.c
@@ -488,12 +488,12 @@
 	 * if the probe was successful, and make sure any forced probes of
 	 * new devices fail.
 	 */
-	spin_lock(&platform_bus_type.p->klist_drivers.k_lock);
+	spin_lock(&drv->driver.bus->p->klist_drivers.k_lock);
 	drv->probe = NULL;
 	if (code == 0 && list_empty(&drv->driver.p->klist_devices.k_list))
 		retval = -ENODEV;
 	drv->driver.probe = platform_drv_probe_fail;
-	spin_unlock(&platform_bus_type.p->klist_drivers.k_lock);
+	spin_unlock(&drv->driver.bus->p->klist_drivers.k_lock);

 	if (code != retval)
 		platform_driver_unregister(drv);


[PATCH] freevxfs: fix leak on error path

If register_filesystem() fails, vxfs_inode cache must be destroyed.

Signed-off-by: Alexey Dobriyan <b99bff5923d24d2fb8e844db9dac7cd59203da1d@gmail.com>
Acked-by: Christoph Hellwig <923f7720577207a44b32e59bbfbea59d27f1ae8e@lst.de>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@osdl.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@osdl.org>

--- fs/freevxfs/vxfs_super.c
+++ fs/freevxfs/vxfs_super.c
@@ -260,12 +260,17 @@
 static int __init
 vxfs_init(void)
 {
+	int rv;
+
 	vxfs_inode_cachep = kmem_cache_create("vxfs_inode",
 			sizeof(struct vxfs_inode_info), 0,
 			SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL, NULL);
-	if (vxfs_inode_cachep)
-		return register_filesystem(&vxfs_fs_type);
-	return -ENOMEM;
+	if (!vxfs_inode_cachep)
+		return -ENOMEM;
+	rv = register_filesystem(&vxfs_fs_type);
+	if (rv < 0)
+		kmem_cache_destroy(vxfs_inode_cachep);
+	return rv;
 }

 static void __exit


mg_disk: fix issue with data integrity on error in mg_write()

We cannot acknowledge the sector write before checking its status
(which is done on the next loop iteration) and we also need to do
the final status register check after writing the last sector.

Fix mg_write() to match mg_write_intr() in this regard.

While at it:
- add mg_read_one() and mg_write_one() helpers
- always use MG_SECTOR_SIZE and remove MG_STORAGE_BUFFER_SIZE

[bart: thanks to Tejun for porting the patch over recent block changes]

Cc: unsik Kim <donari75@gmail.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>

===================================================================
Signed-off-by: Jens Axboe <165ab144a3ccfd9429d5c6466b275f24fafdb114@oracle.com>

--- drivers/block/mg_disk.c
+++ drivers/block/mg_disk.c
@@ -36,7 +36,6 @@

 /* Register offsets */
 #define MG_BUFF_OFFSET			0x8000
-#define MG_STORAGE_BUFFER_SIZE		0x200
 #define MG_REG_OFFSET			0xC000
 #define MG_REG_FEATURE			(MG_REG_OFFSET + 2)	/* write case */
 #define MG_REG_ERROR			(MG_REG_OFFSET + 2)	/* read case */
@@ -477,9 +476,18 @@
 	return MG_ERR_NONE;
 }

+static void mg_read_one(struct mg_host *host, struct request *req)
+{
+	u16 *buff = (u16 *)req->buffer;
+	u32 i;
+
+	for (i = 0; i < MG_SECTOR_SIZE >> 1; i++)
+		*buff++ = inw((unsigned long)host->dev_base + MG_BUFF_OFFSET +
+			      (i << 1));
+}
+
 static void mg_read(struct request *req)
 {
-	u32 j;
 	struct mg_host *host = req->rq_disk->private_data;

 	if (mg_out(host, blk_rq_pos(req), blk_rq_sectors(req),
@@ -490,26 +498,33 @@
 	       blk_rq_sectors(req), blk_rq_pos(req), req->buffer);

 	do {
-		u16 *buff = (u16 *)req->buffer;
-
 		if (mg_wait(host, ATA_DRQ,
 			    MG_TMAX_WAIT_RD_DRQ) != MG_ERR_NONE) {
 			mg_bad_rw_intr(host);
 			return;
 		}
-		for (j = 0; j < MG_SECTOR_SIZE >> 1; j++)
-			*buff++ = inw((unsigned long)host->dev_base +
-				      MG_BUFF_OFFSET + (j << 1));
+
+		mg_read_one(host, req);

 		outb(MG_CMD_RD_CONF, (unsigned long)host->dev_base +
 				MG_REG_COMMAND);
 	} while (mg_end_request(host, 0, MG_SECTOR_SIZE));
 }

+static void mg_write_one(struct mg_host *host, struct request *req)
+{
+	u16 *buff = (u16 *)req->buffer;
+	u32 i;
+
+	for (i = 0; i < MG_SECTOR_SIZE >> 1; i++)
+		outw(*buff++, (unsigned long)host->dev_base + MG_BUFF_OFFSET +
+		     (i << 1));
+}
+
 static void mg_write(struct request *req)
 {
-	u32 j;
 	struct mg_host *host = req->rq_disk->private_data;
+	bool rem;

 	if (mg_out(host, blk_rq_pos(req), blk_rq_sectors(req),
 		   MG_CMD_WR, NULL) != MG_ERR_NONE) {
@@ -520,27 +535,37 @@
 	MG_DBG("requested %d sects (from %ld), buffer=0x%p\n",
 	       blk_rq_sectors(req), blk_rq_pos(req), req->buffer);

+	if (mg_wait(host, ATA_DRQ,
+		    MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) {
+		mg_bad_rw_intr(host);
+		return;
+	}
+
+	mg_write_one(host, req);
+
+	outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base + MG_REG_COMMAND);
+
 	do {
-		u16 *buff = (u16 *)req->buffer;
-
-	if (mg_wait(host, ATA_DRQ, MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) {
+		if (blk_rq_sectors(req) > 1 &&
+		     mg_wait(host, ATA_DRQ,
+			     MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) {
 			mg_bad_rw_intr(host);
 			return;
 		}
-		for (j = 0; j < MG_SECTOR_SIZE >> 1; j++)
-			outw(*buff++, (unsigned long)host->dev_base +
-				      MG_BUFF_OFFSET + (j << 1));
-
-		outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base +
-				MG_REG_COMMAND);
-	} while (mg_end_request(host, 0, MG_SECTOR_SIZE));
+
+		rem = mg_end_request(host, 0, MG_SECTOR_SIZE);
+		if (rem)
+			mg_write_one(host, req);
+
+		outb(MG_CMD_WR_CONF,
+		     (unsigned long)host->dev_base + MG_REG_COMMAND);
+	} while (rem);
 }

 static void mg_read_intr(struct mg_host *host)
 {
 	struct request *req = host->req;
 	u32 i;
-	u16 *buff;

 	/* check status */
 	do {
@@ -558,13 +583,7 @@
 	return;

 ok_to_read:
-	/* get current segment of request */
-	buff = (u16 *)req->buffer;
-
-	/* read 1 sector */
-	for (i = 0; i < MG_SECTOR_SIZE >> 1; i++)
-		*buff++ = inw((unsigned long)host->dev_base + MG_BUFF_OFFSET +
-			      (i << 1));
+	mg_read_one(host, req);

 	MG_DBG("sector %ld, remaining=%ld, buffer=0x%p\n",
 	       blk_rq_pos(req), blk_rq_sectors(req) - 1, req->buffer);
@@ -583,8 +602,7 @@
 static void mg_write_intr(struct mg_host *host)
 {
 	struct request *req = host->req;
-	u32 i, j;
-	u16 *buff;
+	u32 i;
 	bool rem;

 	/* check status */
@@ -605,12 +623,7 @@
 ok_to_write:
 	if ((rem = mg_end_request(host, 0, MG_SECTOR_SIZE))) {
 		/* write 1 sector and set handler if remains */
-		buff = (u16 *)req->buffer;
-		for (j = 0; j < MG_STORAGE_BUFFER_SIZE >> 1; j++) {
-			outw(*buff, (unsigned long)host->dev_base +
-					MG_BUFF_OFFSET + (j << 1));
-			buff++;
-		}
+		mg_write_one(host, req);
 		MG_DBG("sector %ld, remaining=%ld, buffer=0x%p\n",
 		       blk_rq_pos(req), blk_rq_sectors(req), req->buffer);
 		host->mg_do_intr = mg_write_intr;
@@ -675,9 +688,6 @@
 		unsigned int sect_num,
 		unsigned int sect_cnt)
 {
-	u16 *buff;
-	u32 i;
-
 	switch (rq_data_dir(req)) {
 	case READ:
 		if (mg_out(host, sect_num, sect_cnt, MG_CMD_RD, &mg_read_intr)
@@ -701,12 +711,7 @@
 			mg_bad_rw_intr(host);
 			return host->error;
 		}
-		buff = (u16 *)req->buffer;
-		for (i = 0; i < MG_SECTOR_SIZE >> 1; i++) {
-			outw(*buff, (unsigned long)host->dev_base +
-					MG_BUFF_OFFSET + (i << 1));
-			buff++;
-		}
+		mg_write_one(host, req);
 		mod_timer(&host->timer, jiffies + 3 * HZ);
 		outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base +
 				MG_REG_COMMAND);


First version of the SelectorTest

First version of the SelectorTest

git-svn-id: 769d22dfa2d22aad706b9a451492fb87c0735f19@4572 08b38cba-cd3b-11de-854e-f91c5b6e4272

error: pathspec 'modules/vapor/test/TestSuite/TestCases/IO/SelectorTest.h' did not match any file(s) known to git

--- modules/vapor/test/TestSuite/TestCases/IO/SelectorTest.h
+++ modules/vapor/test/TestSuite/TestCases/IO/SelectorTest.h
@@ -0,0 +1,235 @@
+#ifndef _SELECTOR_TEST_H
+#define _SELECTOR_TEST_H
+
+#include <stdio.h>
+#include <string.h>
+#include <iostream>
+
+#include <TestCase.h>
+#include <TestSuite.h>
+#include <TestCaller.h>
+
+#include <vprConfig.h>
+
+#include <IO/Socket/Socket.h>
+#include <IO/Socket/SocketStream.h>
+#include <IO/Socket/InetAddr.h>
+#include <IO/Socket/SocketAcceptor.h>
+#include <IO/Socket/SocketConnector.h>
+#include <IO/IOSys.h>
+#include <IO/Selector.h>
+
+#include <include/System.h>
+
+#include <Threads/Thread.h>
+#include <Threads/ThreadFunctor.h>
+#include <Sync/Mutex.h>
+#include <Sync/Cond.h>
+
+#include <vector>
+#include <map>
+
+using namespace vpr;
+
+namespace vprTest
+{
+
+class SelectorTest : public TestCase
+{
+public:
+   SelectorTest( std::string name )
+   : mThreadAssertTest(false), TestCase (name)
+   {;}
+
+   virtual ~SelectorTest()
+   {}
+
+   virtual void setUp()
+   {;}
+
+   virtual void tearDown()
+   {
+   }
+
+   // use this within your threads (CppUnit doesn't catch the assertTest there)
+   // then test mThreadAssertTest with assertTest in your parent func.
+   // then reset it to true.
+   void threadAssertTest( bool testcase, std::string text = std::string("none") )
+   {
+       if(!testcase)
+       {
+           mThreadAssertTest = testcase;
+           std::cerr << "threadAssertTest: " << text << std::endl;
+       }
+       else
+           std::cout << "." << std::flush;
+   }
+   void testAssertReset()
+   { mThreadAssertTest = true; }
+
+
+   // Test an acceptor pool
+   // This test is based upon the idea of having a pool of acceptors that
+   // Another process keeps connecting too.  A selector is used to determine
+   // which acceptor is actually being connected to so that only a single
+   // accept is needed (that never should really block)
+   void testAcceptorPoolSelection()
+   {
+       testAssertReset();
+       mRendevousPort = 47000 + (random() % 71);     // Get a partially random port
+       mNumRendevousPorts = 10;
+       mNumIters = 30;
+       mMessageValue = std::string("The Data");
+       mMessageLen = mMessageValue.length();
+
+       mState = NOT_READY;                        // Initialize
+
+       // Spawn acceptor thread
+       vpr::ThreadMemberFunctor<SelectorTest>
+           acceptor_functor( this, &SelectorTest::testAcceptorPoolSelection_acceptor );
+       vpr::Thread acceptor_thread( &acceptor_functor);
+
+       // Spawn connector thread
+       vpr::ThreadMemberFunctor<SelectorTest>
+           connector_functor( this, &SelectorTest::testAcceptorPoolSelection_connector );
+       vpr::Thread connector_thread( &connector_functor);
+
+       // Wait for threads
+       acceptor_thread.join();
+       connector_thread.join();
+
+       assertTest( mThreadAssertTest );
+   }
+   void testAcceptorPoolSelection_acceptor(void* arg)
+   {
+      unsigned i,j;
+      std::map<vpr::IOSys::Handle, vpr::SocketAcceptor*> acceptorTable;
+      vpr::Selector selector;
+      vpr::SocketStream* sock(NULL);
+      bool ret_val(false);
+
+      for(i=0;i<mNumRendevousPorts;i++)
+      {
+         vpr::SocketAcceptor* new_acceptor = new vpr::SocketAcceptor();          // Create acceptor
+         vpr::InetAddr local_acceptor_addr;
+         local_acceptor_addr.setAddress("localhost", (mRendevousPort+i));        // Set local address
+         new_acceptor->open(local_acceptor_addr);                                // Open acceptor
+         vpr::IOSys::Handle handle = new_acceptor->getHandle();                  // Get the Handle to register
+         acceptorTable[handle] = new_acceptor;
+         selector.addHandle(handle);                          // Add to selector
+         selector.setIn(handle, (vpr::Selector::READ | vpr::Selector::WRITE | vpr::Selector::EXCEPT));
+      }
+
+      // READY - Tell everyone that we are ready to accept
+      mCondVar.acquire();
+      {
+         mState = ACCEPTOR_READY;
+         mCondVar.signal();       // Tell any waiting threads
+      }
+      mCondVar.release();
+
+      // Use selector to find the acceptor to accept on
+      // Then accept and send a message back
+       for(i=0;i<mNumIters;i++)
+       {
+          vpr::Uint16 num_events;
+          bool ret = selector.select(num_events, 50000);
+
+          threadAssertTest((true == ret) && "Selection did not return successfully");
+          threadAssertTest((num_events == 1) && "There was not only 1 event");
+
+          int num_found(0);
+          vpr::SocketAcceptor* ready_acceptor;
+
+          for(j=0;j<selector.getNumHandles();j++)
+          {
+            if(selector.getOut(selector.getHandle(j)) & (vpr::Selector::READ | vpr::Selector::EXCEPT))
+            {
+               threadAssertTest((acceptorTable.find(selector.getHandle(j)) != acceptorTable.end()) && "Handle not found int acceptor table");
+               ready_acceptor = acceptorTable[selector.getHandle(j)];
+               num_found += 1;
+            }
+          }
+
+          threadAssertTest((num_found == 1) && "Wrong number of acceptors found");
+
+          // ACCEPT connection
+          sock = ready_acceptor->accept();
+          threadAssertTest((sock != NULL), "Accepted socket is null");
+          threadAssertTest((sock->isOpen()), "Accepted socket should be open");
+
+          ret_val = sock->write(mMessageValue, mMessageLen);      // Send a message
+          threadAssertTest((ret_val == true), "Problem writing in acceptor");
+          ret_val = sock->close();                                // Close the socket
+          threadAssertTest((ret_val == true), "Problem closing accepted socket");
+          delete sock;
+          sock = NULL;
+       }
+
+       // Delete acceptors
+       for( std::map<IOSys::Handle, vpr::SocketAcceptor*>::iterator a=acceptorTable.begin(); a != acceptorTable.end(); a++)
+       {
+          delete (*a).second;
+       }
+   }
+   void testAcceptorPoolSelection_connector(void* arg)
+   {
+      bool ret_val(true);
+      vpr::InetAddr remote_addr;
+      vpr::SocketConnector connector;           // Connect to acceptor
+
+      // WAIT for READY
+      mCondVar.acquire();
+      {
+         while(mState != ACCEPTOR_READY)
+            mCondVar.wait();
+      }
+      mCondVar.release();
+
+      // Connect randomly to the rendevous ports
+      for(int i=0;i<mNumIters;i++)
+      {
+         PRUint16 port_num = mRendevousPort+(i % mNumRendevousPorts);
+         remote_addr.setAddress("localhost", port_num);
+         vpr::SocketStream con_sock;
+         std::string       data;
+         ret_val = connector.connect(con_sock, remote_addr, 100);
+         threadAssertTest((ret_val == true), "Connector can't connect");
+
+         vpr::Uint16 size = con_sock.read(data, mMessageLen);   // Recieve data
+         threadAssertTest((size == mMessageLen), "Connector recieved message of wrong size" );
+
+         con_sock.close();                                   // Close socket
+      }
+   }
+
+   static Test* suite()
+   {
+      TestSuite *test_suite = new TestSuite ("SelectorTest");
+
+      test_suite->addTest( new TestCaller<SelectorTest>("testAcceptorPoolSelection", &SelectorTest::testAcceptorPoolSelection));
+
+      return test_suite;
+   }
+
+private:
+   bool             mThreadAssertTest; // true for no error
+
+protected:
+    int     mNumIters;
+
+    vpr::Uint16     mRendevousPort;       // The port the acceptor will be waiting on
+    vpr::Uint16     mNumRendevousPorts;   // The number of ports to use
+
+    vpr::Uint16     mMessageLen;        // Length of message to send
+    std::string     mMessageValue;      // The value of the message that is supposed to be sent (and recieved)
+
+    enum State { ACCEPTOR_READY, NOT_READY, CONNECTOR_CLOSED };
+    State           mState;         // State variable
+    vpr::Cond       mCondVar;       // Condition variable
+
+};
+
+}       // namespace
+
+#endif


tty:cyclades, load firmware even on Ze

tty:cyclades, load firmware even on Ze

Ze needs firmware to be loaded as well as Zo. Move cyz_load_fw one
level upper to achieve that.

Signed-off-by: Jiri Slaby <aeaaaa09d9a5fac7c38743ea79aa4bb8ffb08290@gmail.com>
Signed-off-by: Alan Cox <91e38e63b890fbb214c8914809fde03c73e7f24d@linux.intel.com>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- drivers/char/cyclades.c
+++ drivers/char/cyclades.c
@@ -5043,6 +5043,7 @@
 			nchan = ZE_V1_NPORTS;
 		} else {
 			card_name = "Cyclades-8Zo";
+			nchan = 8;

 #ifdef CY_PCI_DEBUG
 			if (mailbox == ZO_V1) {
@@ -5065,15 +5066,11 @@
 			 */
 			if ((mailbox == ZO_V1) || (mailbox == ZO_V2))
 				cy_writel(addr2 + ID_ADDRESS, 0L);
-
-			retval = cyz_load_fw(pdev, addr2, addr0, irq);
-			if (retval)
-				goto err_unmap;
-			/* This must be a Cyclades-8Zo/PCI.  The extendable
-			   version will have a different device_id and will
-			   be allocated its maximum number of ports. */
-			nchan = 8;
-		}
+		}
+
+		retval = cyz_load_fw(pdev, addr2, addr0, irq);
+		if (retval)
+			goto err_unmap;
 	}

 	if ((cy_next_channel + nchan) > NR_PORTS) {


Fix for USB HID API. Fixes build on NetBSD and FreeBSD, but maybe causes
 trouble on OpenBSD?

git-svn-id: 75429ccc2030f235ccf16e6b9b7f8e83d5edd22e@720 c70aab31-4412-0410-b14c-859654838e24

--- src/joystick/bsd/SDL_sysjoystick.c
+++ src/joystick/bsd/SDL_sysjoystick.c
@@ -409,9 +409,9 @@
 	int len;

 #ifdef USBHID_NEW
+	len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
+#else
 	len = hid_report_size(rd, repinfo[repind].kind, r->rid);
-#else
-	len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
 #endif
 	if (len < 0) {
 		SDL_SetError("Negative HID report size");


Fix mistake in description of `containerViewForHorizontalScrollingInScrollView:`.

--- Classes/EPSUIFactory.h
+++ Classes/EPSUIFactory.h
@@ -39,7 +39,7 @@
 /// @return A container view that is a subview of the given scroll view.
 + (UIView *)containerViewForVerticalScrollingInScrollView:(UIScrollView *)scrollView;

-/// Adds a container view as a subview of the given scroll view, and sets up constraints to ensure the scroll view will only scroll vertically.
+/// Adds a container view as a subview of the given scroll view, and sets up constraints to ensure the scroll view will only scroll horizontally.
 /// @param scrollView The scroll view to add a container view to.
 /// @return A container view that is a subview of the given scroll view.
 + (UIView *)containerViewForHorizontalScrollingInScrollView:(UIScrollView *)scrollView;


[S390] hvc_iucv: Update function documentation

Update documentation of functions.

Signed-off-by: Hendrik Brueckner <ea0a2d16c17dd61debc108adbc0ac849646dd099@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <52616596d8f5df0d597e85ab515377f92f939c68@de.ibm.com>

--- drivers/char/hvc_iucv.c
+++ drivers/char/hvc_iucv.c
@@ -1,14 +1,15 @@
 /*
- * hvc_iucv.c - z/VM IUCV back-end for the Hypervisor Console (HVC)
- *
- * This back-end for HVC provides terminal access via
+ * hvc_iucv.c - z/VM IUCV hypervisor console (HVC) device driver
+ *
+ * This HVC device driver provides terminal access using
  * z/VM IUCV communication paths.
  *
- * Copyright IBM Corp. 2008.
+ * Copyright IBM Corp. 2008
  *
  * Author(s):	Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
  */
 #define KMSG_COMPONENT		"hvc_iucv"
+#define pr_fmt(fmt)		KMSG_COMPONENT ": " fmt

 #include <linux/types.h>
 #include <asm/ebcdic.h>
@@ -22,7 +23,7 @@
 #include "hvc_console.h"

-/* HVC backend for z/VM IUCV */
+/* General device driver settings */
 #define HVC_IUCV_MAGIC		0xc9e4c3e5
 #define MAX_HVC_IUCV_LINES	HVC_ALLOC_TTY_ADAPTERS
 #define MEMPOOL_MIN_NR		(PAGE_SIZE / sizeof(struct iucv_tty_buffer)/4)
@@ -35,7 +36,6 @@
 #define MSG_TYPE_WINSIZE	0x08	/* Terminal window size update */
 #define MSG_TYPE_DATA		0x10	/* Terminal data */

-#define MSG_SIZE(s)		((s) + offsetof(struct iucv_tty_msg, data))
 struct iucv_tty_msg {
 	u8	version;		/* Message version */
 	u8	type;			/* Message type */
@@ -43,6 +43,7 @@
 	u16	datalen;		/* Payload length */
 	u8	data[];			/* Payload buffer */
 } __attribute__((packed));
+#define MSG_SIZE(s)		((s) + offsetof(struct iucv_tty_msg, data))

 enum iucv_state_t {
 	IUCV_DISCONN	= 0,
@@ -56,7 +57,7 @@
 };

 struct hvc_iucv_private {
-	struct hvc_struct	*hvc; /* HVC console struct reference */
+	struct hvc_struct	*hvc;		/* HVC struct reference */
 	u8			srv_name[8];	/* IUCV service name (ebcdic) */
 	enum iucv_state_t	iucv_state;	/* IUCV connection status */
 	enum tty_state_t	tty_state;	/* TTY status */
@@ -74,7 +75,7 @@

 struct iucv_tty_buffer {
 	struct list_head	list;	/* list pointer */
-	struct iucv_message	msg;	/* store an incoming IUCV message */
+	struct iucv_message	msg;	/* store an IUCV message */
 	size_t			offset;	/* data buffer offset */
 	struct iucv_tty_msg	*mbuf;	/* buffer to store input/output data */
 };
@@ -120,7 +121,7 @@
 }

 /**
- * alloc_tty_buffer() - Returns a new struct iucv_tty_buffer element.
+ * alloc_tty_buffer() - Return a new struct iucv_tty_buffer element.
  * @size:	Size of the internal buffer used to store data.
  * @flags:	Memory allocation flags passed to mempool.
  *
@@ -128,7 +129,6 @@
  * allocates an internal data buffer with the specified size @size.
  * Note: The total message size arises from the internal buffer size and the
  *	 members of the iucv_tty_msg structure.
- *
  * The function returns NULL if memory allocation has failed.
  */
 static struct iucv_tty_buffer *alloc_tty_buffer(size_t size, gfp_t flags)
@@ -157,9 +157,6 @@
 /**
  * destroy_tty_buffer() - destroy struct iucv_tty_buffer element.
  * @bufp:	Pointer to a struct iucv_tty_buffer element, SHALL NOT be NULL.
- *
- * The destroy_tty_buffer() function frees the internal data buffer and returns
- * the struct iucv_tty_buffer element back to the mempool for freeing.
  */
 static void destroy_tty_buffer(struct iucv_tty_buffer *bufp)
 {
@@ -169,11 +166,7 @@

 /**
  * destroy_tty_buffer_list() - call destroy_tty_buffer() for each list element.
- * @list:	List head pointer to a list containing struct iucv_tty_buffer
- *		elements.
- *
- * Calls destroy_tty_buffer() for each struct iucv_tty_buffer element in the
- * list @list.
+ * @list:	List containing struct iucv_tty_buffer elements.
  */
 static void destroy_tty_buffer_list(struct list_head *list)
 {
@@ -186,24 +179,24 @@
 }

 /**
- * hvc_iucv_write() - Receive IUCV message write data to HVC console buffer.
- * @priv:		Pointer to hvc_iucv_private structure.
- * @buf:		HVC console buffer for writing received terminal data.
- * @count:		HVC console buffer size.
+ * hvc_iucv_write() - Receive IUCV message & write data to HVC buffer.
+ * @priv:		Pointer to struct hvc_iucv_private
+ * @buf:		HVC buffer for writing received terminal data.
+ * @count:		HVC buffer size.
  * @has_more_data:	Pointer to an int variable.
  *
  * The function picks up pending messages from the input queue and receives
  * the message data that is then written to the specified buffer @buf.
- * If the buffer size @count is less than the data message size, then the
+ * If the buffer size @count is less than the data message size, the
  * message is kept on the input queue and @has_more_data is set to 1.
- * If the message data has been entirely written, the message is removed from
+ * If all message data has been written, the message is removed from
  * the input queue.
  *
  * The function returns the number of bytes written to the terminal, zero if
  * there are no pending data messages available or if there is no established
  * IUCV path.
  * If the IUCV path has been severed, then -EPIPE is returned to cause a
- * hang up (that is issued by the HVC console layer).
+ * hang up (that is issued by the HVC layer).
  */
 static int hvc_iucv_write(struct hvc_iucv_private *priv,
 			  char *buf, int count, int *has_more_data)
@@ -212,12 +205,12 @@
 	int written;
 	int rc;

-	/* Immediately return if there is no IUCV connection */
+	/* immediately return if there is no IUCV connection */
 	if (priv->iucv_state == IUCV_DISCONN)
 		return 0;

-	/* If the IUCV path has been severed, return -EPIPE to inform the
-	 * hvc console layer to hang up the tty device. */
+	/* if the IUCV path has been severed, return -EPIPE to inform the
+	 * HVC layer to hang up the tty device. */
 	if (priv->iucv_state == IUCV_SEVERED)
 		return -EPIPE;

@@ -225,7 +218,7 @@
 	if (list_empty(&priv->tty_inqueue))
 		return 0;

-	/* receive a iucv message and flip data to the tty (ldisc) */
+	/* receive an iucv message and flip data to the tty (ldisc) */
 	rb = list_first_entry(&priv->tty_inqueue, struct iucv_tty_buffer, list);

 	written = 0;
@@ -268,7 +261,7 @@
 	case MSG_TYPE_WINSIZE:
 		if (rb->mbuf->datalen != sizeof(struct winsize))
 			break;
-		hvc_resize(priv->hvc, *((struct winsize *)rb->mbuf->data));
+		hvc_resize(priv->hvc, *((struct winsize *) rb->mbuf->data));
 		break;

 	case MSG_TYPE_ERROR:	/* ignored ... */
@@ -292,10 +285,9 @@
  * @buf:	Pointer to a buffer to store data
  * @count:	Size of buffer available for writing
  *
- * The hvc_console thread calls this method to read characters from
- * the terminal backend. If an IUCV communication path has been established,
- * pending IUCV messages are received and data is copied into buffer @buf
- * up to @count bytes.
+ * The HVC thread calls this method to read characters from the back-end.
+ * If an IUCV communication path has been established, pending IUCV messages
+ * are received and data is copied into buffer @buf up to @count bytes.
  *
  * Locking:	The routine gets called under an irqsave() spinlock; and
  *		the routine locks the struct hvc_iucv_private->lock to call
@@ -332,17 +324,17 @@
  * @count:	Size of buffer and amount of data to send.
  *
  * The function queues data for sending. To actually send the buffered data,
- * a work queue function is * scheduled (with QUEUE_SNDBUF_DELAY).
+ * a work queue function is scheduled (with QUEUE_SNDBUF_DELAY).
  * The function returns the number of data bytes that has been buffered.
  *
  * If the device is not connected, data is ignored and the function returns
  * @count.
  * If the buffer is full, the function returns 0.
- * If an existing IUCV communicaton path has been severed, the function returns
- * -EPIPE (can be passed to HVC layer to cause a tty hangup).
+ * If an existing IUCV communicaton path has been severed, -EPIPE is returned
+ * (that can be passed to HVC layer to cause a tty hangup).
  */
 static int hvc_iucv_queue(struct hvc_iucv_private *priv, const char *buf,
-			 int count)
+			  int count)
 {
 	size_t len;

@@ -369,12 +361,10 @@
  * hvc_iucv_send() - Send an IUCV message containing terminal data.
  * @priv:	Pointer to struct hvc_iucv_private instance.
  *
- * If an IUCV communication path has been established, the queued data
- * for output are sent via an IUCV message.
- *
- * If there is no IUCV communication path established, the function returns 0.
- * If an existing IUCV communicaton path has been severed, the function returns
- * -EPIPE.
+ * If an IUCV communication path has been established, the buffered output data
+ * is sent via an IUCV message and the number of bytes sent is returned.
+ * Returns 0 if there is no established IUCV communication path or
+ * -EPIPE if an existing IUCV communicaton path has been severed.
  */
 static int hvc_iucv_send(struct hvc_iucv_private *priv)
 {
@@ -420,15 +410,14 @@
  * hvc_iucv_sndbuf_work() - Send buffered data over IUCV
  * @work:	Work structure.
  *
- * The function sends buffered output data over IUCV and, if necessary,
- * reschedules itself if not all buffered data could be sent.
+ * This work queue function sends buffered output data over IUCV and,
+ * if not all buffered data could be sent, reschedules itself.
  */
 static void hvc_iucv_sndbuf_work(struct work_struct *work)
 {
 	struct hvc_iucv_private *priv;

 	priv = container_of(work, struct hvc_iucv_private, sndbuf_work.work);
-
 	if (!priv)
 		return;

@@ -443,10 +432,8 @@
  * @buf:	Pointer to an buffer to read data from
  * @count:	Size of buffer available for reading
  *
- * The hvc_console thread calls this method to write characters from
- * to the terminal backend.
- * The function calls hvc_iucv_send() under the lock of the
- * struct hvc_iucv_private instance that corresponds to the tty @vtermno.
+ * The HVC thread calls this method to write characters to the back-end.
+ * The function calls hvc_iucv_queue() to queue terminal data for sending.
  *
  * Locking:	The method gets called under an irqsave() spinlock; and
  *		locks struct hvc_iucv_private->lock.
@@ -496,12 +483,8 @@
 }

 /**
- * hvc_iucv_cleanup() - Clean up function if the tty portion is finally closed.
+ * hvc_iucv_cleanup() - Clean up and reset a z/VM IUCV HVC instance.
  * @priv:	Pointer to the struct hvc_iucv_private instance.
- *
- * The functions severs the established IUCV communication path (if any), and
- * destroy struct iucv_tty_buffer elements from the in- and outqueue. Finally,
- * the functions resets the states to TTY_CLOSED and IUCV_DISCONN.
  */
 static void hvc_iucv_cleanup(struct hvc_iucv_private *priv)
 {
@@ -553,22 +536,19 @@
 }

 /**
- * hvc_iucv_notifier_hangup() - HVC notifier for tty hangups.
- * @hp: Pointer to the HVC device (struct hvc_struct)
- * @id: Additional data (originally passed to hvc_alloc): the index of an struct
- *	hvc_iucv_private instance.
- *
- * This routine notifies the HVC backend that a tty hangup (carrier loss,
+ * hvc_iucv_notifier_hangup() - HVC notifier for TTY hangups.
+ * @hp:		Pointer to the HVC device (struct hvc_struct)
+ * @id:		Additional data (originally passed to hvc_alloc):
+ *		the index of an struct hvc_iucv_private instance.
+ *
+ * This routine notifies the HVC back-end that a tty hangup (carrier loss,
  * virtual or otherwise) has occured.
- *
- * The HVC backend for z/VM IUCV ignores virtual hangups (vhangup()), to keep
- * an existing IUCV communication path established.
+ * The z/VM IUCV HVC device driver ignores virtual hangups (vhangup())
+ * to keep an existing IUCV communication path established.
  * (Background: vhangup() is called from user space (by getty or login) to
  *		disable writing to the tty by other applications).
- *
- * If the tty has been opened (e.g. getty) and an established IUCV path has been
- * severed (we caused the tty hangup in that case), then the functions invokes
- * hvc_iucv_cleanup() to clean up.
+ * If the tty has been opened and an established IUCV path has been severed
+ * (we caused the tty hangup), the function calls hvc_iucv_cleanup().
  *
  * Locking:	struct hvc_iucv_private->lock
  */
@@ -584,10 +564,8 @@

 	spin_lock_bh(&priv->lock);
 	/* NOTE: If the hangup was scheduled by ourself (from the iucv
-	 *	 path_servered callback [IUCV_SEVERED]), then we have to
-	 *	 finally clean up the tty backend structure and set state to
-	 *	 TTY_CLOSED.
-	 *
+	 *	 path_servered callback [IUCV_SEVERED]), we have to clean up
+	 *	 our structure and to set state to TTY_CLOSED.
 	 *	 If the tty was hung up otherwise (e.g. vhangup()), then we
 	 *	 ignore this hangup and keep an established IUCV path open...
 	 *	 (...the reason is that we are not able to connect back to the
@@ -605,10 +583,9 @@
  * @id:		Additional data (originally passed to hvc_alloc):
  *		the index of an struct hvc_iucv_private instance.
  *
- * This routine notifies the HVC backend that the last tty device file
- * descriptor has been closed.
- * The function calls hvc_iucv_cleanup() to clean up the struct hvc_iucv_private
- * instance.
+ * This routine notifies the HVC back-end that the last tty device fd has been
+ * closed.  The function calls hvc_iucv_cleanup() to clean up the struct
+ * hvc_iucv_private instance.
  *
  * Locking:	struct hvc_iucv_private->lock
  */
@@ -640,20 +617,18 @@
 /**
  * hvc_iucv_path_pending() - IUCV handler to process a connection request.
  * @path:	Pending path (struct iucv_path)
- * @ipvmid:	Originator z/VM system identifier
+ * @ipvmid:	z/VM system identifier of originator
  * @ipuser:	User specified data for this path
  *		(AF_IUCV: port/service name and originator port)
  *
- * The function uses the @ipuser data to check to determine if the pending
- * path belongs to a terminal managed by this HVC backend.
- * If the check is successful, then an additional check is done to ensure
- * that a terminal cannot be accessed multiple times (only one connection
- * to a terminal is allowed). In that particular case, the pending path is
- * severed. If it is the first connection, the pending path is accepted and
- * associated to the struct hvc_iucv_private. The iucv state is updated to
- * reflect that a communication path has been established.
- *
- * Returns 0 if the path belongs to a terminal managed by the this HVC backend;
+ * The function uses the @ipuser data to determine if the pending path belongs
+ * to a terminal managed by this device driver.
+ * If the path belongs to this driver, ensure that the terminal is not accessed
+ * multiple times (only one connection to a terminal is allowed).
+ * If the terminal is not yet connected, the pending path is accepted and is
+ * associated to the appropriate struct hvc_iucv_private instance.
+ *
+ * Returns 0 if @path belongs to a terminal managed by the this device driver;
  * otherwise returns -ENODEV in order to dispatch this path to other handlers.
  *
  * Locking:	struct hvc_iucv_private->lock
@@ -672,7 +647,6 @@
 			priv = hvc_iucv_table[i];
 			break;
 		}
-
 	if (!priv)
 		return -ENODEV;

@@ -719,8 +693,7 @@
  * sets the iucv state to IUCV_SEVERED for the associated struct
  * hvc_iucv_private instance. Later, the IUCV_SEVERED state triggers a tty
  * hangup (hvc_iucv_get_chars() / hvc_iucv_write()).
- *
- * If tty portion of the HVC is closed then clean up the outqueue in addition.
+ * If tty portion of the HVC is closed, clean up the outqueue.
  *
  * Locking:	struct hvc_iucv_private->lock
  */
@@ -755,9 +728,9 @@
  * @path:	Pending path (struct iucv_path)
  * @msg:	Pointer to the IUCV message
  *
- * The function stores an incoming message on the input queue for later
+ * The function puts an incoming message on the input queue for later
  * processing (by hvc_iucv_get_chars() / hvc_iucv_write()).
- * However, if the tty has not yet been opened, the message is rejected.
+ * If the tty has not yet been opened, the message is rejected.
  *
  * Locking:	struct hvc_iucv_private->lock
  */
@@ -772,6 +745,7 @@
 		iucv_message_reject(path, msg);
 		return;
 	}
+

 	spin_lock(&priv->lock);

@@ -791,7 +765,7 @@

 	list_add_tail(&rb->list, &priv->tty_inqueue);

-	hvc_kick();	/* wake up hvc console thread */
+	hvc_kick();	/* wake up hvc thread */

 unlock_return:
 	spin_unlock(&priv->lock);
@@ -802,10 +776,10 @@
  * @path:	Pending path (struct iucv_path)
  * @msg:	Pointer to the IUCV message
  *
- * The function is called upon completion of message delivery and the
- * message is removed from the outqueue. Additional delivery information
- * can be found in msg->audit: rejected messages (0x040000 (IPADRJCT)) and
- * purged messages (0x010000 (IPADPGNR)).
+ * The function is called upon completion of message delivery to remove the
+ * message from the outqueue. Additional delivery information can be found
+ * msg->audit: rejected messages (0x040000 (IPADRJCT)), and
+ *	       purged messages	 (0x010000 (IPADPGNR)).
  *
  * Locking:	struct hvc_iucv_private->lock
  */
@@ -841,8 +815,8 @@
  * hvc_iucv_alloc() - Allocates a new struct hvc_iucv_private instance
  * @id:	hvc_iucv_table index
  *
- * This function allocates a new hvc_iucv_private struct and put the
- * instance into hvc_iucv_table at index @id.
+ * This function allocates a new hvc_iucv_private structure and stores
+ * the instance in hvc_iucv_table at index @id.
  * Returns 0 on success; otherwise non-zero.
  */
 static int __init hvc_iucv_alloc(int id)
@@ -867,7 +841,7 @@
 		return -ENOMEM;
 	}

-	/* Finally allocate hvc */
+	/* finally allocate hvc */
 	priv->hvc = hvc_alloc(HVC_IUCV_MAGIC + id, /*		  PAGE_SIZE */
 			      HVC_IUCV_MAGIC + id, &hvc_iucv_ops, 256);
 	if (IS_ERR(priv->hvc)) {
@@ -877,7 +851,7 @@
 		return rc;
 	}

-	/* kick khvcd thread; instead of using polling */
+	/* notify HVC thread instead of using polling */
 	priv->hvc->irq_requested = 1;

 	/* setup iucv related information */
@@ -890,7 +864,7 @@
 }

 /**
- * hvc_iucv_init() - Initialization of HVC backend for z/VM IUCV
+ * hvc_iucv_init() - z/VM IUCV HVC device driver initialization
  */
 static int __init hvc_iucv_init(void)
 {
@@ -929,7 +903,7 @@
 		rc = hvc_iucv_alloc(i);
 		if (rc) {
 			pr_err("Creating a new HVC terminal device "
-				"failed	with error code=%d\n", rc);
+				"failed with error code=%d\n", rc);
 			goto out_error_hvc;
 		}
 	}


proc tty: switch stallion to ->proc_fops

Signed-off-by: Alexey Dobriyan <b99bff5923d24d2fb8e844db9dac7cd59203da1d@gmail.com>
Cc: Alan Cox <91e38e63b890fbb214c8914809fde03c73e7f24d@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- drivers/char/stallion.c
+++ drivers/char/stallion.c
@@ -32,6 +32,7 @@
 #include <linux/tty.h>
 #include <linux/tty_flip.h>
 #include <linux/serial.h>
+#include <linux/seq_file.h>
 #include <linux/cd1400.h>
 #include <linux/sc26198.h>
 #include <linux/comstats.h>
@@ -1379,52 +1380,47 @@
 		stl_putchar(tty, ch);
 }

-/*****************************************************************************/
-
-#define	MAXLINE		80
-
-/*
- *	Format info for a specified port. The line is deliberately limited
- *	to 80 characters. (If it is too long it will be truncated, if too
- *	short then padded with spaces).
- */
-
-static int stl_portinfo(struct stlport *portp, int portnr, char *pos)
-{
-	char	*sp;
-	int	sigs, cnt;
-
-	sp = pos;
-	sp += sprintf(sp, "%d: uart:%s tx:%d rx:%d",
+static void stl_portinfo(struct seq_file *m, struct stlport *portp, int portnr)
+{
+	int	sigs;
+	char sep;
+
+	seq_printf(m, "%d: uart:%s tx:%d rx:%d",
 		portnr, (portp->hwid == 1) ? "SC26198" : "CD1400",
 		(int) portp->stats.txtotal, (int) portp->stats.rxtotal);

 	if (portp->stats.rxframing)
-		sp += sprintf(sp, " fe:%d", (int) portp->stats.rxframing);
+		seq_printf(m, " fe:%d", (int) portp->stats.rxframing);
 	if (portp->stats.rxparity)
-		sp += sprintf(sp, " pe:%d", (int) portp->stats.rxparity);
+		seq_printf(m, " pe:%d", (int) portp->stats.rxparity);
 	if (portp->stats.rxbreaks)
-		sp += sprintf(sp, " brk:%d", (int) portp->stats.rxbreaks);
+		seq_printf(m, " brk:%d", (int) portp->stats.rxbreaks);
 	if (portp->stats.rxoverrun)
-		sp += sprintf(sp, " oe:%d", (int) portp->stats.rxoverrun);
+		seq_printf(m, " oe:%d", (int) portp->stats.rxoverrun);

 	sigs = stl_getsignals(portp);
-	cnt = sprintf(sp, "%s%s%s%s%s ",
-		(sigs & TIOCM_RTS) ? "|RTS" : "",
-		(sigs & TIOCM_CTS) ? "|CTS" : "",
-		(sigs & TIOCM_DTR) ? "|DTR" : "",
-		(sigs & TIOCM_CD) ? "|DCD" : "",
-		(sigs & TIOCM_DSR) ? "|DSR" : "");
-	*sp = ' ';
-	sp += cnt;
-
-	for (cnt = sp - pos; cnt < (MAXLINE - 1); cnt++)
-		*sp++ = ' ';
-	if (cnt >= MAXLINE)
-		pos[(MAXLINE - 2)] = '+';
-	pos[(MAXLINE - 1)] = '\n';
-
-	return MAXLINE;
+	sep = ' ';
+	if (sigs & TIOCM_RTS) {
+		seq_printf(m, "%c%s", sep, "RTS");
+		sep = '|';
+	}
+	if (sigs & TIOCM_CTS) {
+		seq_printf(m, "%c%s", sep, "CTS");
+		sep = '|';
+	}
+	if (sigs & TIOCM_DTR) {
+		seq_printf(m, "%c%s", sep, "DTR");
+		sep = '|';
+	}
+	if (sigs & TIOCM_CD) {
+		seq_printf(m, "%c%s", sep, "DCD");
+		sep = '|';
+	}
+	if (sigs & TIOCM_DSR) {
+		seq_printf(m, "%c%s", sep, "DSR");
+		sep = '|';
+	}
+	seq_putc(m, '\n');
 }

 /*****************************************************************************/
@@ -1433,30 +1429,17 @@
  *	Port info, read from the /proc file system.
  */

-static int stl_readproc(char *page, char **start, off_t off, int count, int *eof, void *data)
+static int stl_proc_show(struct seq_file *m, void *v)
 {
 	struct stlbrd	*brdp;
 	struct stlpanel	*panelp;
 	struct stlport	*portp;
 	unsigned int	brdnr, panelnr, portnr;
-	int		totalport, curoff, maxoff;
-	char		*pos;
-
-	pr_debug("stl_readproc(page=%p,start=%p,off=%lx,count=%d,eof=%p,"
-		"data=%p\n", page, start, off, count, eof, data);
-
-	pos = page;
+	int		totalport;
+
 	totalport = 0;
-	curoff = 0;
-
-	if (off == 0) {
-		pos += sprintf(pos, "%s: version %s", stl_drvtitle,
-			stl_drvversion);
-		while (pos < (page + MAXLINE - 1))
-			*pos++ = ' ';
-		*pos++ = '\n';
-	}
-	curoff =  MAXLINE;
+
+	seq_printf(m, "%s: version %s\n", stl_drvtitle, stl_drvversion);

 /*
  *	We scan through for each board, panel and port. The offset is
@@ -1469,45 +1452,36 @@
 		if (brdp->state == 0)
 			continue;

-		maxoff = curoff + (brdp->nrports * MAXLINE);
-		if (off >= maxoff) {
-			curoff = maxoff;
-			continue;
-		}
-
 		totalport = brdnr * STL_MAXPORTS;
 		for (panelnr = 0; panelnr < brdp->nrpanels; panelnr++) {
 			panelp = brdp->panels[panelnr];
 			if (panelp == NULL)
 				continue;

-			maxoff = curoff + (panelp->nrports * MAXLINE);
-			if (off >= maxoff) {
-				curoff = maxoff;
-				totalport += panelp->nrports;
-				continue;
-			}
-
 			for (portnr = 0; portnr < panelp->nrports; portnr++,
 			    totalport++) {
 				portp = panelp->ports[portnr];
 				if (portp == NULL)
 					continue;
-				if (off >= (curoff += MAXLINE))
-					continue;
-				if ((pos - page + MAXLINE) > count)
-					goto stl_readdone;
-				pos += stl_portinfo(portp, totalport, pos);
+				stl_portinfo(m, portp, totalport);
 			}
 		}
 	}
-
-	*eof = 1;
-
-stl_readdone:
-	*start = page;
-	return pos - page;
-}
+	return 0;
+}
+
+static int stl_proc_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, stl_proc_show, NULL);
+}
+
+static const struct file_operations stl_proc_fops = {
+	.owner		= THIS_MODULE,
+	.open		= stl_proc_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};

 /*****************************************************************************/

@@ -2566,9 +2540,9 @@
 	.break_ctl = stl_breakctl,
 	.wait_until_sent = stl_waituntilsent,
 	.send_xchar = stl_sendxchar,
-	.read_proc = stl_readproc,
 	.tiocmget = stl_tiocmget,
 	.tiocmset = stl_tiocmset,
+	.proc_fops = &stl_proc_fops,
 };

 static const struct tty_port_operations stl_port_ops = {


drivers/dma: handle sysfs errors

drivers/dma: handle sysfs errors

From: Jeff Garzik <f3e731dfa293c7a83119d8aacfa41b5d2d780be9@garzik.org>

Signed-off-by: Jeff Garzik <f3e731dfa293c7a83119d8aacfa41b5d2d780be9@garzik.org>
Signed-off-by: Chris Leech <ee586ba3ad011fd0b33a5d2fe017df0df3995481@intel.com>

--- drivers/dma/dmaengine.c
+++ drivers/dma/dmaengine.c
@@ -316,7 +316,7 @@
 int dma_async_device_register(struct dma_device *device)
 {
 	static int id;
-	int chancnt = 0;
+	int chancnt = 0, rc;
 	struct dma_chan* chan;

 	if (!device)
@@ -338,8 +338,15 @@
 		snprintf(chan->class_dev.class_id, BUS_ID_SIZE, "dma%dchan%d",
 		         device->dev_id, chan->chan_id);

+		rc = class_device_register(&chan->class_dev);
+		if (rc) {
+			chancnt--;
+			free_percpu(chan->local);
+			chan->local = NULL;
+			goto err_out;
+		}
+
 		kref_get(&device->refcount);
-		class_device_register(&chan->class_dev);
 	}

 	mutex_lock(&dma_list_mutex);
@@ -349,6 +356,17 @@
 	dma_chans_rebalance();

 	return 0;
+
+err_out:
+	list_for_each_entry(chan, &device->channels, device_node) {
+		if (chan->local == NULL)
+			continue;
+		kref_put(&device->refcount, dma_async_device_cleanup);
+		class_device_unregister(&chan->class_dev);
+		chancnt--;
+		free_percpu(chan->local);
+	}
+	return rc;
 }
 EXPORT_SYMBOL(dma_async_device_register);


firewire: ohci: reorder struct fw_ohci for better cache efficiency

The config_rom struct members are only accessed during relatively
infrequent self-ID-complete interrupts and only if the local config ROM
was changed, while the ar_, at_, ir_, it_ members are used very
frequently during I/O.  Hence move the config_rom members further down.

More importantly, make the huge self_id_buffer member the last one; this
is only accessed in self-ID-complete interrupts.

Signed-off-by: Stefan Richter <fbd796546fc801b34e01e453c6fd30283e012038@s5r6.in-berlin.de>

--- drivers/firewire/ohci.c
+++ drivers/firewire/ohci.c
@@ -166,9 +166,6 @@
 	struct fw_card card;

 	__iomem char *registers;
-	dma_addr_t self_id_bus;
-	__le32 *self_id_cpu;
-	struct tasklet_struct bus_reset_tasklet;
 	int node_id;
 	int generation;
 	int request_generation;	/* for timestamping incoming requests */
@@ -182,14 +179,6 @@
 	 * this driver with this lock held.
 	 */
 	spinlock_t lock;
-	u32 self_id_buffer[512];
-
-	/* Config rom buffers */
-	__be32 *config_rom;
-	dma_addr_t config_rom_bus;
-	__be32 *next_config_rom;
-	dma_addr_t next_config_rom_bus;
-	__be32 next_header;

 	struct ar_context ar_request_ctx;
 	struct ar_context ar_response_ctx;
@@ -201,6 +190,18 @@
 	u64 ir_context_channels;
 	u32 ir_context_mask;
 	struct iso_context *ir_context_list;
+
+	__be32    *config_rom;
+	dma_addr_t config_rom_bus;
+	__be32    *next_config_rom;
+	dma_addr_t next_config_rom_bus;
+	__be32     next_header;
+
+	__le32    *self_id_cpu;
+	dma_addr_t self_id_bus;
+	struct tasklet_struct bus_reset_tasklet;
+
+	u32 self_id_buffer[512];
 };

 static inline struct fw_ohci *fw_ohci(struct fw_card *card)