Improove debugging.

Improove debugging.

git-svn-id: d1790394607e06e2b90be8c532f5c99d80a2d557@440 119443c7-1b9e-41f8-b6fc-b9c35fce742c

--- ixml/src/ixmlparser.c
+++ ixml/src/ixmlparser.c
@@ -2438,112 +2438,150 @@
 	/*! [in] The Node to process. */
 	IXML_Node *node)
 {
-    char *strEndQuote = NULL;
-    int tlen = 0;
-    char *pCur = NULL;
-    char *pCurToken = NULL;
-
-    assert( xmlParser );
-    if( xmlParser == NULL ) {
-        return IXML_FAILED;
-    }
-
-    pCurToken = ( xmlParser->tokenBuf ).buf;
-    if( pCurToken == NULL ) {
-        return IXML_SYNTAX_ERR;
-    }
-
-    if( Parser_isNameChar( Parser_UTF8ToInt( pCurToken, &tlen ), FALSE ) ==
-        FALSE ) {
-        return IXML_SYNTAX_ERR;
-    }
-    // copy in the attribute name
-    node->nodeName = safe_strdup( pCurToken );
-    if( node->nodeName == NULL ) {
-        return IXML_INSUFFICIENT_MEMORY;
-    }
-    // read in the "=" sign
-    if( Parser_getNextToken( xmlParser ) == 0 ) {
-        return IXML_SYNTAX_ERR;
-    }
-
-    pCurToken = ( xmlParser->tokenBuf ).buf;
-    if( *pCurToken != EQUALS ) {
-        return IXML_SYNTAX_ERR;
-    }
-    // read in the single quote or double quote
-    if( Parser_getNextToken( xmlParser ) == 0 ) {
-        return IXML_SYNTAX_ERR;
-    }
-    // pCurToken is either quote or singlequote
-    pCurToken = ( xmlParser->tokenBuf ).buf;
-    if( ( *pCurToken != QUOTE ) && ( *pCurToken != SINGLEQUOTE ) ) {
-        return IXML_SYNTAX_ERR;
-    }
-
-    strEndQuote = strstr( xmlParser->curPtr, pCurToken );
-    if( strEndQuote == NULL ) {
-        return IXML_SYNTAX_ERR;
-    }
-    // check between curPtr and strEndQuote, whether there are illegal chars.
-    pCur = xmlParser->curPtr;
-    while( pCur < strEndQuote ) {
-        if( *pCur == '<' ) {
-            return IXML_SYNTAX_ERR;
-        }
-
-        if( *pCur == '&' ) {
-            Parser_parseReference( ++pCur );
-        }
-        pCur++;
-    }
-    //clear token buffer
-    Parser_clearTokenBuf( xmlParser );
-    if( strEndQuote != xmlParser->curPtr ) {
-        if( Parser_copyToken( xmlParser, xmlParser->curPtr,
-                              strEndQuote - xmlParser->curPtr ) !=
-            IXML_SUCCESS ) {
-            return IXML_SYNTAX_ERR;
-        }
-    }
-    // skip the ending quote
-    xmlParser->curPtr = strEndQuote + 1;
-
-    pCurToken = ( xmlParser->tokenBuf ).buf;
-    if( pCurToken != NULL ) {   // attribute has value, like a="c"
-        node->nodeValue = safe_strdup( pCurToken );
-        if( node->nodeValue == NULL ) {
-            return IXML_INSUFFICIENT_MEMORY;
-        }
-    }else{
-       // if attribute doesn't have value, like a=""
-        ///somewhere on other places is this copied
-       node->nodeValue = malloc(sizeof(char));
-       *(node->nodeValue) = '\0';
-    }
-    node->nodeType = eATTRIBUTE_NODE;
-
-    // check whether this is a new namespace definition
-    if( Parser_xmlNamespace( xmlParser, node ) != IXML_SUCCESS ) {
-        return IXML_FAILED;
-    }
-    // read ahead to see whether we have more attributes
-    xmlParser->savePtr = xmlParser->curPtr;
-    if( Parser_getNextToken( xmlParser ) == 0 ) {
-        return IXML_SYNTAX_ERR;
-    }
-
-    pCurToken = ( xmlParser->tokenBuf ).buf;
-    if( strcmp( pCurToken, "<" ) == 0 ) {
-        return IXML_FAILED;
-    } else if( strcmp( pCurToken, ">" ) != 0 )  // more attribute?
-    {                           // backup
-        xmlParser->curPtr = xmlParser->savePtr;
-    } else {
-        xmlParser->state = eCONTENT;
-    }
-
-    return IXML_SUCCESS;
+	int ret = IXML_SUCCESS;
+	int line = 0;
+	int tlen = 0;
+	char *strEndQuote = NULL;
+	char *pCur = NULL;
+	char *pCurToken = NULL;
+
+	assert(xmlParser);
+
+	if (xmlParser == NULL) {
+		ret = IXML_FAILED;
+		line = __LINE__;
+		goto ExitFunction;
+	}
+	pCurToken = xmlParser->tokenBuf.buf;
+	if (pCurToken == NULL) {
+		ret = IXML_SYNTAX_ERR;
+		line = __LINE__;
+		goto ExitFunction;
+	}
+	if (Parser_isNameChar(Parser_UTF8ToInt(pCurToken, &tlen), FALSE) == FALSE) {
+		ret = IXML_SYNTAX_ERR;
+		line = __LINE__;
+		goto ExitFunction;
+	}
+	/* copy in the attribute name */
+	node->nodeName = safe_strdup(pCurToken);
+	if (node->nodeName == NULL) {
+		ret = IXML_INSUFFICIENT_MEMORY;
+		line = __LINE__;
+		goto ExitFunction;
+	}
+	/* read in the "=" sign */
+	if (Parser_getNextToken(xmlParser) == 0) {
+		ret = IXML_SYNTAX_ERR;
+		line = __LINE__;
+		goto ExitFunction;
+	}
+
+	pCurToken = xmlParser->tokenBuf.buf;
+	if (*pCurToken != EQUALS) {
+		ret = IXML_SYNTAX_ERR;
+		line = __LINE__;
+		goto ExitFunction;
+	}
+	/* read in the single quote or double quote */
+	if (Parser_getNextToken(xmlParser) == 0) {
+		ret = IXML_SYNTAX_ERR;
+		line = __LINE__;
+		goto ExitFunction;
+	}
+	/* pCurToken is either quote or single quote */
+	pCurToken = ( xmlParser->tokenBuf ).buf;
+	if (*pCurToken != QUOTE && *pCurToken != SINGLEQUOTE) {
+		ret = IXML_SYNTAX_ERR;
+		line = __LINE__;
+		goto ExitFunction;
+	}
+	strEndQuote = strstr(xmlParser->curPtr, pCurToken);
+	if (strEndQuote == NULL) {
+		ret = IXML_SYNTAX_ERR;
+		line = __LINE__;
+		goto ExitFunction;
+	}
+	/* check between curPtr and strEndQuote,
+	 * whether there are illegal chars. */
+	pCur = xmlParser->curPtr;
+	while (pCur < strEndQuote) {
+		if (*pCur == '<') {
+			ret = IXML_SYNTAX_ERR;
+			line = __LINE__;
+			goto ExitFunction;
+		}
+		if (*pCur == '&') {
+			Parser_parseReference(++pCur);
+		}
+		pCur++;
+	}
+	/* clear token buffer */
+	Parser_clearTokenBuf(xmlParser);
+	if (strEndQuote != xmlParser->curPtr) {
+		ret = Parser_copyToken(
+			xmlParser,
+			xmlParser->curPtr,
+			strEndQuote - xmlParser->curPtr);
+		if(ret  != IXML_SUCCESS) {
+			ret = IXML_SYNTAX_ERR;
+			line = __LINE__;
+			goto ExitFunction;
+		}
+	}
+	/* skip the ending quote */
+	xmlParser->curPtr = strEndQuote + 1;
+	pCurToken = xmlParser->tokenBuf.buf;
+	if (pCurToken != NULL) {
+		/* attribute has value, like a="c" */
+		node->nodeValue = safe_strdup(pCurToken);
+		if (node->nodeValue == NULL) {
+			ret = IXML_INSUFFICIENT_MEMORY;
+			line = __LINE__;
+			goto ExitFunction;
+		}
+	} else {
+		/* if attribute doesn't have value, like a=""
+		 * somewhere on other places is this copied */
+		node->nodeValue = malloc(sizeof (char));
+		*(node->nodeValue) = '\0';
+	}
+	node->nodeType = eATTRIBUTE_NODE;
+
+	/* check whether this is a new namespace definition */
+	ret = Parser_xmlNamespace(xmlParser, node);
+	if (ret != IXML_SUCCESS) {
+		line = __LINE__;
+		goto ExitFunction;
+	}
+	/* read ahead to see whether we have more attributes */
+	xmlParser->savePtr = xmlParser->curPtr;
+	if (Parser_getNextToken(xmlParser) == 0) {
+		ret = IXML_SYNTAX_ERR;
+		line = __LINE__;
+		goto ExitFunction;
+	}
+
+	pCurToken = xmlParser->tokenBuf.buf;
+	if (strcmp(pCurToken, "<") == 0) {
+		ret = IXML_FAILED;
+		line = __LINE__;
+		goto ExitFunction;
+	} else if(strcmp(pCurToken, ">") != 0) {
+		/* more attribute? */
+		/* backup */
+		xmlParser->curPtr = xmlParser->savePtr;
+	} else {
+		xmlParser->state = eCONTENT;
+	}
+
+ExitFunction:
+	if (ret != IXML_SUCCESS && ret != IXML_FILE_DONE) {
+		IxmlPrintf("(%s::Parser_processAttribute): Error %d, line %d\n",
+			__FILE__, ret, line);
+	}
+
+	return ret;
 }

@@ -2566,7 +2604,7 @@
 	int line = 0;
 	int tokenLen = 0;

-	// endof file reached?
+	/* endof file reached? */
 	if (*(xmlParser->curPtr) == '\0') {
 		*bETag = TRUE;
 		line = __LINE__;
@@ -2584,7 +2622,7 @@
 		if (tokenLen == 0 &&
 		    xmlParser->pCurElement == NULL &&
 		    *(xmlParser->curPtr) == '\0') {
-			// comments after the xml doc
+			/* comments after the xml doc */
 			line = __LINE__;
 			ret = IXML_SUCCESS;
 			goto ExitFunction;
@@ -2600,7 +2638,7 @@
 			ret = IXML_SUCCESS;
 			goto ExitFunction;
 		} else if (strcmp(pCurToken, ENDTAG) == 0) {
-			//  we got </, read next element
+			/* we got </, read next element */
 			line = __LINE__;
 			ret = Parser_processETag(xmlParser, node, bETag);
 			goto ExitFunction;
@@ -2616,8 +2654,8 @@
 				goto ExitFunction;
 			}

-			node->nodeName = safe_strdup( lastElement );
-			if( node->nodeName == NULL ) {
+			node->nodeName = safe_strdup(lastElement);
+			if (node->nodeName == NULL) {
 				line = __LINE__;
 				ret = IXML_INSUFFICIENT_MEMORY;
 				goto ExitFunction;
@@ -2629,7 +2667,7 @@
 			ret = IXML_SUCCESS;
 			goto ExitFunction;
 		} else if (xmlParser->state == eATTRIBUTE && xmlParser->pCurElement != NULL) {
-			if(Parser_processAttribute( xmlParser, node ) != IXML_SUCCESS) {
+			if (Parser_processAttribute(xmlParser, node) != IXML_SUCCESS) {
 				line = __LINE__;
 				ret = IXML_SYNTAX_ERR;
 				goto ExitFunction;


add RAW level to output the contents of read and written buffers

--- xio/src/globus_xio_system_select.c
+++ xio/src/globus_xio_system_select.c
@@ -9,6 +9,9 @@
 #define GlobusXIOSystemDebugPrintf(level, message)                          \
     GlobusDebugPrintf(GLOBUS_XIO_SYSTEM, level, message)

+#define GlobusXIOSystemDebugFwrite(level, buffer, size, count)              \
+    GlobusDebugFwrite(GLOBUS_XIO_SYSTEM, level, buffer, size, count)
+
 #define GlobusXIOSystemDebugEnter()                                         \
     GlobusXIOSystemDebugPrintf(                                             \
         GLOBUS_L_XIO_SYSTEM_DEBUG_TRACE,                                    \
@@ -39,11 +42,60 @@
         GLOBUS_L_XIO_SYSTEM_DEBUG_TRACE,                                    \
         ("[%s] fd=%d, Exiting with error\n", _xio_name, (fd)))

+#define GlobusXIOSystemDebugRawBuffer(nbytes, buffer)                       \
+    do                                                                      \
+    {                                                                       \
+        GlobusXIOSystemDebugPrintf(                                         \
+            GLOBUS_L_XIO_SYSTEM_DEBUG_RAW,                                  \
+            ("[%s] Begin RAW data ************\n", _xio_name));             \
+        GlobusXIOSystemDebugFwrite(                                         \
+            GLOBUS_L_XIO_SYSTEM_DEBUG_RAW, buffer, 1, nbytes);              \
+        GlobusXIOSystemDebugPrintf(                                         \
+            GLOBUS_L_XIO_SYSTEM_DEBUG_RAW,                                  \
+            ("\n[%s] End RAW data ************\n", _xio_name));             \
+    } while(0)
+
+#define GlobusXIOSystemDebugRawIovec(nbytes, iovec)                         \
+    do                                                                      \
+    {                                                                       \
+        if(GlobusDebugTrue(                                                 \
+            GLOBUS_XIO_SYSTEM, GLOBUS_L_XIO_SYSTEM_DEBUG_RAW))              \
+        {                                                                   \
+            globus_size_t               _bytes = nbytes;                    \
+            int                         _i = 0;                             \
+                                                                            \
+            while(_bytes > 0)                                               \
+            {                                                               \
+                globus_size_t           _len = (iovec)[_i].iov_len;         \
+                                                                            \
+                if(_bytes < _len)                                           \
+                {                                                           \
+                    _len = _bytes;                                          \
+                }                                                           \
+                _bytes -= _len;                                             \
+                                                                            \
+                GlobusDebugMyPrintf(                                        \
+                    GLOBUS_XIO_SYSTEM,                                      \
+                    ("[%s] Begin RAW data %i ************\n",               \
+                    _xio_name, _i));                                        \
+                GlobusDebugMyFwrite(                                        \
+                    GLOBUS_XIO_SYSTEM,                                      \
+                    (iovec)[_i].iov_base, 1, _len);                         \
+                GlobusDebugMyPrintf(                                        \
+                    GLOBUS_XIO_SYSTEM,                                      \
+                    ("\n[%s] End RAW data %i ************\n",               \
+                    _xio_name, _i));                                        \
+                _i++;                                                       \
+            }                                                               \
+        }                                                                   \
+    } while(0)
+
 enum globus_l_xio_error_levels
 {
     GLOBUS_L_XIO_SYSTEM_DEBUG_TRACE     = 1,
     GLOBUS_L_XIO_SYSTEM_DEBUG_DATA      = 2,
-    GLOBUS_L_XIO_SYSTEM_DEBUG_INFO      = 4
+    GLOBUS_L_XIO_SYSTEM_DEBUG_INFO      = 4,
+    GLOBUS_L_XIO_SYSTEM_DEBUG_RAW       = 8
 };

 #ifdef HAVE_SYSCONF
@@ -360,7 +412,7 @@
     globus_reltime_t                    period;
     GlobusXIOName(globus_l_xio_system_activate);

-    GlobusDebugInit(GLOBUS_XIO_SYSTEM, TRACE DATA INFO);
+    GlobusDebugInit(GLOBUS_XIO_SYSTEM, TRACE DATA INFO RAW);
     GlobusXIOSystemDebugEnter();

     if(globus_module_activate(GLOBUS_XIO_MODULE) != GLOBUS_SUCCESS)
@@ -1034,6 +1086,8 @@
         GlobusXIOSystemDebugPrintf(
             GLOBUS_L_XIO_SYSTEM_DEBUG_DATA,
             ("[%s] Read %d bytes (buflen = %d)\n", _xio_name, rc, buflen));
+
+        GlobusXIOSystemDebugRawBuffer(rc, buf);
     }

     *nbytes = rc;
@@ -1090,7 +1144,9 @@
     GlobusXIOSystemDebugPrintf(
         GLOBUS_L_XIO_SYSTEM_DEBUG_DATA,
         ("[%s] Read %d bytes\n", _xio_name, rc));
-
+
+    GlobusXIOSystemDebugRawIovec(rc, iov);
+
     GlobusXIOSystemDebugExitFD(fd);
     return GLOBUS_SUCCESS;

@@ -1144,7 +1200,9 @@
     GlobusXIOSystemDebugPrintf(
         GLOBUS_L_XIO_SYSTEM_DEBUG_DATA,
         ("[%s] Read %d bytes\n", _xio_name, rc));
-
+
+    GlobusXIOSystemDebugRawBuffer(rc, buf);
+
     GlobusXIOSystemDebugExitFD(fd);
     return GLOBUS_SUCCESS;

@@ -1207,7 +1265,9 @@
     GlobusXIOSystemDebugPrintf(
         GLOBUS_L_XIO_SYSTEM_DEBUG_DATA,
         ("[%s] Read %d bytes\n", _xio_name, rc));
-
+
+    GlobusXIOSystemDebugRawBuffer(rc, buf);
+
     GlobusXIOSystemDebugExitFD(fd);
     return GLOBUS_SUCCESS;

@@ -1260,7 +1320,9 @@
     GlobusXIOSystemDebugPrintf(
         GLOBUS_L_XIO_SYSTEM_DEBUG_DATA,
         ("[%s] Read %d bytes\n", _xio_name, rc));
-
+
+    GlobusXIOSystemDebugRawIovec(rc, msghdr->msg_iov);
+
     GlobusXIOSystemDebugExitFD(fd);
     return GLOBUS_SUCCESS;

@@ -1312,7 +1374,9 @@
     GlobusXIOSystemDebugPrintf(
         GLOBUS_L_XIO_SYSTEM_DEBUG_DATA,
         ("[%s] Wrote %d bytes\n", _xio_name, rc));
-
+
+    GlobusXIOSystemDebugRawBuffer(rc, buf);
+
     GlobusXIOSystemDebugExitFD(fd);
     return GLOBUS_SUCCESS;

@@ -1359,7 +1423,9 @@
     GlobusXIOSystemDebugPrintf(
         GLOBUS_L_XIO_SYSTEM_DEBUG_DATA,
         ("[%s] Wrote %d bytes\n", _xio_name, rc));
-
+
+    GlobusXIOSystemDebugRawIovec(rc, iov);
+
     GlobusXIOSystemDebugExitFD(fd);
     return GLOBUS_SUCCESS;

@@ -1407,7 +1473,9 @@
     GlobusXIOSystemDebugPrintf(
         GLOBUS_L_XIO_SYSTEM_DEBUG_DATA,
         ("[%s] Wrote %d bytes\n", _xio_name, rc));
-
+
+    GlobusXIOSystemDebugRawBuffer(rc, buf);
+
     GlobusXIOSystemDebugExitFD(fd);
     return GLOBUS_SUCCESS;

@@ -1462,7 +1530,9 @@
     GlobusXIOSystemDebugPrintf(
         GLOBUS_L_XIO_SYSTEM_DEBUG_DATA,
         ("[%s] Wrote %d bytes\n", _xio_name, rc));
-
+
+    GlobusXIOSystemDebugRawBuffer(rc, buf);
+
     GlobusXIOSystemDebugExitFD(fd);
     return GLOBUS_SUCCESS;

@@ -1509,7 +1579,9 @@
     GlobusXIOSystemDebugPrintf(
         GLOBUS_L_XIO_SYSTEM_DEBUG_DATA,
         ("[%s] Wrote %d bytes\n", _xio_name, rc));
-
+
+    GlobusXIOSystemDebugRawIovec(rc, msghdr->msg_iov);
+
     GlobusXIOSystemDebugExitFD(fd);
     return GLOBUS_SUCCESS;


i2c: qrd7627a: set i2c1 gpios to minimum strength

Rapid GPIO current change cause glitches on i2c lines.
it sets i2c GPIOs drive strength to 2ma.

Change-Id: I3d789c21095ca32e0e864eb334519be9c7b8f454
CRs-Fixed: 429515
Signed-off-by: Alok Chauhan <a781eab460d0b8de6413720f3ae4346867408d60@codeaurora.org>

--- arch/arm/mach-msm/board-qrd7627a.c
+++ arch/arm/mach-msm/board-qrd7627a.c
@@ -93,9 +93,9 @@
 		"qup_scl" },
 	{ GPIO_CFG(61, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
 		"qup_sda" },
-	{ GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
+	{ GPIO_CFG(131, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
 		"qup_scl" },
-	{ GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
+	{ GPIO_CFG(132, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
 		"qup_sda" },
 };

@@ -104,9 +104,9 @@
 		"qup_scl" },
 	{ GPIO_CFG(61, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
 		"qup_sda" },
-	{ GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
+	{ GPIO_CFG(131, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
 		"qup_scl" },
-	{ GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA),
+	{ GPIO_CFG(132, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
 		"qup_sda" },
 };


ARM: OMAP3: cm-t35: enable audio

ARM: OMAP3: cm-t35: enable audio

TWL4030 audio codec is not being registered if no platform data is
supplied. Provide platform data for the TWL4030 audio codec.

Signed-off-by: Igor Grinberg <9e6f8d6081ce24a2c1d8f777071cb7290aaf46a3@compulab.co.il>
[1001e8702733cced254345e193c88aaa47a4f5de@atomide.com: updated subject]
Signed-off-by: Tony Lindgren <1001e8702733cced254345e193c88aaa47a4f5de@atomide.com>

--- arch/arm/mach-omap2/board-cm-t35.c
+++ arch/arm/mach-omap2/board-cm-t35.c
@@ -477,7 +477,8 @@
 static void __init cm_t35_init_i2c(void)
 {
 	omap3_pmic_get_config(&cm_t35_twldata, TWL_COMMON_PDATA_USB,
-			TWL_COMMON_REGULATOR_VDAC);
+			      TWL_COMMON_REGULATOR_VDAC |
+			      TWL_COMMON_PDATA_AUDIO);

 	omap3_pmic_init("tps65930", &cm_t35_twldata);
 }


powerpc/85xx: Add support for 85xx cpu type detection

Add this file to help detect cpu type in runtime.
These macros will be more favorable for driver
to apply errata and workaround to specified cpu type.

Signed-off-by: Haijun Zhang <a51cc5d70893987996fbde2a524b2bbb3b4a812f@freescale.com>
Signed-off-by: Zhao Chenhui <07d9f5a554d4415975845fb521b9fecbb531a839@freescale.com>
Signed-off-by: Scott Wood <b77916c2feab81a70245e7b5671f4f02730ebf64@freescale.com>

error: pathspec 'arch/powerpc/include/asm/mpc85xx.h' did not match any file(s) known to git

--- arch/powerpc/include/asm/mpc85xx.h
+++ arch/powerpc/include/asm/mpc85xx.h
@@ -0,0 +1,92 @@
+/*
+ * MPC85xx cpu type detection
+ *
+ * Copyright 2011-2012 Freescale Semiconductor, Inc.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __ASM_PPC_MPC85XX_H
+#define __ASM_PPC_MPC85XX_H
+
+#define SVR_REV(svr)	((svr) & 0xFF)		/* SOC design resision */
+#define SVR_MAJ(svr)	(((svr) >>  4) & 0xF)	/* Major revision field*/
+#define SVR_MIN(svr)	(((svr) >>  0) & 0xF)	/* Minor revision field*/
+
+/* Some parts define SVR[0:23] as the SOC version */
+#define SVR_SOC_VER(svr) (((svr) >> 8) & 0xFFF7FF)	/* SOC Version fields */
+
+#define SVR_8533	0x803400
+#define SVR_8535	0x803701
+#define SVR_8536	0x803700
+#define SVR_8540	0x803000
+#define SVR_8541	0x807200
+#define SVR_8543	0x803200
+#define SVR_8544	0x803401
+#define SVR_8545	0x803102
+#define SVR_8547	0x803101
+#define SVR_8548	0x803100
+#define SVR_8555	0x807100
+#define SVR_8560	0x807000
+#define SVR_8567	0x807501
+#define SVR_8568	0x807500
+#define SVR_8569	0x808000
+#define SVR_8572	0x80E000
+#define SVR_P1010	0x80F100
+#define SVR_P1011	0x80E500
+#define SVR_P1012	0x80E501
+#define SVR_P1013	0x80E700
+#define SVR_P1014	0x80F101
+#define SVR_P1017	0x80F700
+#define SVR_P1020	0x80E400
+#define SVR_P1021	0x80E401
+#define SVR_P1022	0x80E600
+#define SVR_P1023	0x80F600
+#define SVR_P1024	0x80E402
+#define SVR_P1025	0x80E403
+#define SVR_P2010	0x80E300
+#define SVR_P2020	0x80E200
+#define SVR_P2040	0x821000
+#define SVR_P2041	0x821001
+#define SVR_P3041	0x821103
+#define SVR_P4040	0x820100
+#define SVR_P4080	0x820000
+#define SVR_P5010	0x822100
+#define SVR_P5020	0x822000
+#define SVR_P5021	0X820500
+#define SVR_P5040	0x820400
+#define SVR_T4240	0x824000
+#define SVR_T4120	0x824001
+#define SVR_T4160	0x824100
+#define SVR_C291	0x850000
+#define SVR_C292	0x850020
+#define SVR_C293	0x850030
+#define SVR_B4860	0X868000
+#define SVR_G4860	0x868001
+#define SVR_G4060	0x868003
+#define SVR_B4440	0x868100
+#define SVR_G4440	0x868101
+#define SVR_B4420	0x868102
+#define SVR_B4220	0x868103
+#define SVR_T1040	0x852000
+#define SVR_T1041	0x852001
+#define SVR_T1042	0x852002
+#define SVR_T1020	0x852100
+#define SVR_T1021	0x852101
+#define SVR_T1022	0x852102
+
+#define SVR_8610	0x80A000
+#define SVR_8641	0x809000
+#define SVR_8641D	0x809001
+
+#define SVR_9130	0x860001
+#define SVR_9131	0x860000
+#define SVR_9132	0x861000
+#define SVR_9232	0x861400
+
+#define SVR_Unknown	0xFFFFFF
+
+#endif


perf_counter: Remove unused variables

perf_counter: Remove unused variables

Fix a gcc unused variables warning.

Signed-off-by: Peter Zijlstra <645ca7d3a8d3d4f60557176cd361ea8351edc32b@chello.nl>

--- arch/x86/kernel/cpu/perf_counter.c
+++ arch/x86/kernel/cpu/perf_counter.c
@@ -1570,8 +1570,6 @@

 static int p6_pmu_init(void)
 {
-	int high, low;
-
 	switch (boot_cpu_data.x86_model) {
 	case 1:
 	case 3:  /* Pentium Pro */


server/red_dispatcher: fix wrong resolution set for tablet

when changing resolutions due to the new async code paths the surface
creation command was kept by reference, and later, when the red_worker
signaled completion by calling async_complete the mouse mode was updated
using the reference. This caused the wrong values to be read resulting in wrong
resolutions set and a non working mouse pointer. Fix this by keeping a copy of
the surface creation command instead of a reference.

No bz. Found in testing.

--- server/red_dispatcher.c
+++ server/red_dispatcher.c
@@ -56,7 +56,7 @@
     RedDispatcher *next;
     RedWorkerMessage async_message;
     pthread_mutex_t  async_lock;
-    QXLDevSurfaceCreate *surface_create;
+    QXLDevSurfaceCreate surface_create;
 };

 typedef struct RedWorkeState {
@@ -382,7 +382,7 @@

 static void red_dispatcher_create_primary_surface_complete(RedDispatcher *dispatcher)
 {
-    QXLDevSurfaceCreate *surface = dispatcher->surface_create;
+    QXLDevSurfaceCreate *surface = &dispatcher->surface_create;

     dispatcher->x_res = surface->width;
     dispatcher->y_res = surface->height;
@@ -390,7 +390,7 @@
     dispatcher->primary_active = TRUE;

     update_client_mouse_allowed();
-    dispatcher->surface_create = NULL;
+    memset(&dispatcher->surface_create, sizeof(QXLDevSurfaceCreate), 0);
 }

 static void
@@ -408,7 +408,7 @@
     } else {
         message = RED_WORKER_MESSAGE_CREATE_PRIMARY_SURFACE;
     }
-    dispatcher->surface_create = surface;
+    dispatcher->surface_create = *surface;

     write_message(dispatcher->channel, &message);
     if (async) {


secmds - fixed the -v option to display version properly

2003/11/20 21:29:24-00:00 !mayerf
Updated make process, and secmds, to manage default files from the top-level make file

2003/11/10 18:26:43-00:00 !mayerf

Added new command line tools directory (secmds), as well as the first tool (seinfo, which displays various information about a policy).  Also updated, cleaned up, and reoginzed libapol and the build process to accomodate this new tool.  Various other minor updates.

(Logical change 1.3)

--- setools/secmds/seinfo.c
+++ setools/secmds/seinfo.c
@@ -0,0 +1,453 @@
+/* Copyright (C) 2003 Tresys Technology, LLC
+ * see file 'COPYING' for use and warranty information */
+
+/*
+ * Author: mayerf@tresys.com
+ */
+
+/* seinfo: command line tool for looking at a SE Linux policy,
+ * and getting various component elements and statics.
+ */
+
+/* libapol */
+#include <policy.h>
+#include <policy-io.h>
+
+/* other */
+#include <stdlib.h>
+#include <stdio.h>
+#define _GNU_SOURCE
+#include <getopt.h>
+
+#define VERSION_INFO "Copyright (C) 2003 Tresys Technology, LLC (Version 1.0)"
+/* DEFAULT_POLICY should be defined in the make environment */
+#ifndef DEFAULT_POLICY
+	#define DEFAULT_POLICY "/etc/security/selinux/src/policy.conf"
+#endif
+
+char *policy_file;
+
+static struct option const longopts[] =
+{
+  {"classes", optional_argument, NULL, 'c'},
+  {"types", optional_argument, NULL, 't'},
+  {"attribs", optional_argument, NULL, 'a'},
+  {"roles", optional_argument, NULL, 'r'},
+  {"users", optional_argument, NULL, 'u'},
+  {"stats", no_argument, NULL, 's'},
+  {"all", no_argument, NULL, 'A'},
+  {"expand", no_argument, NULL, 'x'},
+  {"help", no_argument, NULL, 'h'},
+  {"version", no_argument, NULL, 'v'},
+  {NULL, 0, NULL, 0}
+};
+
+void usage(const char *program_name, int brief)
+{
+	printf("Usage: %s [OPTIONS] [POLICY_FILE]\n", program_name);
+	if(brief) {
+		printf("\n   Try %s --help for more help.\n\n", program_name);
+		return;
+	}
+	fputs("\n\
+Print requested information about an SELinux policy.\n\
+  -c[NAME], --classes[=NAME] print a list of object classes\n\
+  -t[NAME], --types[=NAME]   print a list of types identifiers\n\
+  -a[NAME], --attribs[=NAME] print a list of type attributes\n\
+  -r[NAME], --roles[=NAME]   print a list of roles\n\
+  -u[NAME], --users[=NAME]   print a list of users\n\
+  -A, --all                  print all of the above\n\
+  -x, --expand               show additional info for -ctaruA\n\
+  -s, --stats                print useful policy statics\n\
+  -h, --help                 display this help and exit\n\
+  -v, --version              output version information and exit\n\
+", stdout);
+  	fputs("\n\
+For -ctaru, if NAME is provided, then only show info for NAME.\n\
+Specifying a name is most useful when used with the -x option.\n\
+If no option is provided, display useful policy statics (-s).\n\n\
+If no POLICY_FILE is provided, the default policy will be used:\n\
+", stdout);
+	printf("      %s\n\n", DEFAULT_POLICY);
+
+	return;
+}
+
+
+int print_stats(FILE *fp, policy_t *policy)
+{
+	fprintf(fp, "\nStatistics for policy file: %s\n", policy_file);
+	fprintf(fp, "   Classes:    %7d    Permissions:  %7d\n", policy->num_obj_classes, policy->num_perms);
+	/* subtract 1 from types to remove the pseudo type "self" */
+	fprintf(fp, "   Types:      %7d    Attributes:   %7d\n", policy->num_types-1, policy->num_attribs);
+	fprintf(fp, "   Users:      %7d    Roles:        %7d\n", policy->rule_cnt[RULE_USER], policy->num_roles);
+	fprintf(fp, "   Allow:      %7d    Neverallow:   %7d\n", policy->rule_cnt[RULE_TE_ALLOW], policy->rule_cnt[RULE_NEVERALLOW]);
+	fprintf(fp, "   Auditallow: %7d    Dontaudit:    %7d\n", policy->rule_cnt[RULE_AUDITALLOW], policy->rule_cnt[RULE_AUDITDENY] + policy->rule_cnt[RULE_DONTAUDIT]);
+	fprintf(fp, "   Type_trans: %7d    Type_change:  %7d\n", policy->rule_cnt[RULE_TE_TRANS], policy->rule_cnt[RULE_TE_CHANGE]);
+	fprintf(fp, "   Role allow: %7d    Role trans:   %7d\n", policy->rule_cnt[RULE_ROLE_ALLOW], policy->rule_cnt[RULE_ROLE_TRANS]);
+	fprintf(fp, "\n");
+
+	return 0;
+}
+
+int print_classes(FILE *fp, const char *name, int expand, policy_t *policy)
+{
+	int i, j, idx, *perms = NULL, num_perms = 0, rt;
+	char *cls_name = NULL, *perm_name = NULL;
+
+	if(name != NULL) {
+		idx = get_obj_class_idx(name, policy);
+		if(idx < 0) {
+			fprintf(fp, "Provided class (%s) is not a valid class name.\n", name);
+			return -1;
+		}
+	}
+	else
+		idx = 0;
+
+	if(name == NULL)
+		fprintf(fp, "Object classes: %d\n", num_obj_classes(policy));
+
+	for(i = idx; is_valid_obj_class_idx(i, policy); i++)  {
+		rt = get_obj_class_name(i, &cls_name, policy);
+		if(rt != 0) {
+			fprintf(fp, "Unexpected error getting class name\n\n");
+			return -1;
+		}
+		fprintf(fp, "   %s\n", cls_name);
+		free(cls_name);
+		if(expand) {
+			rt = get_obj_class_perms(i, &num_perms, &perms, policy);
+			if(rt != 0) {
+				fprintf(fp, "Unexpected error expanding permissions\n\n");
+				return -1;
+			}
+			for(j = 0; j < num_perms; j++) {
+				rt = get_perm_name(perms[j], &perm_name, policy);
+				if(rt != 0) {
+					free(perms);
+					fprintf(fp, "Unexpected error getting permission name\n\n");
+					return -1;
+				}
+				fprintf(fp, "      %s\n", perm_name);
+				free(perm_name);
+			}
+			free(perms);
+		}
+		/* if a name was provided, return as we only print the one asked for */
+		if(name != NULL)
+			break;
+	}
+	return 0;
+}
+
+int print_types(FILE *fp, const char *name, int expand, policy_t *policy)
+{
+	int i, j, idx, rt, num_attribs = 0, *attribs = NULL;
+	char *type_name = NULL, *attrib_name = NULL;
+
+	if(name != NULL) {
+		idx = get_type_idx(name, policy);
+		if(idx < 0) {
+			fprintf(fp, "Provided type (%s) is not a valid type name.\n", name);
+			return -1;
+		}
+	}
+	else
+		/* If we're looking for all, we start at 1 since idx==0 is the pseudo type "self" */
+		idx = 1;
+
+	if(name == NULL)
+		/* use num_types(policy)-1 to factor out the pseudo type "self" */
+		fprintf(fp, "\nTypes: %d\n", num_types(policy)-1);
+
+	for(i = idx; is_valid_type_idx(i, policy); i++)  {
+		rt = get_type_name(i, &type_name, policy);
+		if(rt != 0) {
+			fprintf(fp, "Unexpected error getting type name\n\n");
+			return -1;
+		}
+		fprintf(fp, "   %s\n", type_name);
+		free(type_name);
+		if(expand) {
+			rt = get_type_attribs(i, &num_attribs, &attribs, policy);
+			if(rt != 0) {
+				fprintf(fp, "Unexpected error expanding attributes\n\n");
+				return -1;
+			}
+			for(j = 0; j < num_attribs; j++) {
+				rt = get_attrib_name(attribs[j], &attrib_name, policy);
+				if(rt != 0) {
+					free(attribs);
+					fprintf(fp, "Unexpected error getting attribute name\n\n");
+					return -1;
+				}
+				fprintf(fp, "      %s\n", attrib_name);
+				free(attrib_name);
+			}
+			free(attribs);
+		}
+		/* if a name was provided, return as we only print the one asked for */
+		if(name != NULL)
+			break;
+	}
+	return 0;
+}
+
+int print_attribs(FILE *fp, const char *name, int expand, policy_t *policy)
+{
+	int i, j, idx, rt, num_types = 0, *types = NULL;
+	char *type_name = NULL, *attrib_name = NULL;
+
+	if(name != NULL) {
+		idx = get_attrib_idx(name, policy);
+		if(idx < 0) {
+			fprintf(fp, "Provided attribute (%s) is not a valid attribute name.\n", name);
+			return -1;
+		}
+	}
+	else
+		idx = 0;
+
+	if(name == NULL)
+		fprintf(fp, "\nAttributes: %d\n", num_attribs(policy));
+
+	for(i = idx; is_valid_attrib_idx(i, policy); i++)  {
+		rt = get_attrib_name(i, &attrib_name, policy);
+		if(rt != 0) {
+			fprintf(fp, "Unexpected error getting attribute name\n\n");
+			return -1;
+		}
+		fprintf(fp, "   %s\n", attrib_name);
+		free(attrib_name);
+		if(expand) {
+			rt = get_attrib_types(i, &num_types, &types, policy);
+			if(rt != 0) {
+				fprintf(fp, "Unexpected error expanding types\n\n");
+				return -1;
+			}
+			for(j = 0; j < num_types; j++) {
+				rt = get_type_name(types[j], &type_name, policy);
+				if(rt != 0) {
+					free(types);
+					fprintf(fp, "Unexpected error getting type name\n\n");
+					return -1;
+				}
+				fprintf(fp, "      %s\n", type_name);
+				free(type_name);
+			}
+			free(types);
+		}
+		/* if a name was provided, return as we only print the one asked for */
+		if(name != NULL)
+			break;
+	}
+	return 0;
+}
+
+
+int print_roles(FILE *fp, const char *name, int expand, policy_t *policy)
+{
+	int i, j, idx, rt, num_types = 0, *types = NULL;
+	char *type_name = NULL, *role_name = NULL;
+
+	if(name != NULL) {
+		idx = get_role_idx(name, policy);
+		if(idx < 0) {
+			fprintf(fp, "Provided role (%s) is not a valid role name.\n", name);
+			return -1;
+		}
+	}
+	else
+		idx = 0;
+
+	if(name == NULL)
+		fprintf(fp, "\nRoles: %d\n", num_roles(policy));
+
+	for(i = idx; is_valid_role_idx(i, policy); i++)  {
+		rt = get_role_name(i, &role_name, policy);
+		if(rt != 0) {
+			fprintf(fp, "Unexpected error getting role name\n\n");
+			return -1;
+		}
+		fprintf(fp, "   %s\n", role_name);
+		free(role_name);
+		if(expand) {
+			rt = get_role_types(i, &num_types, &types, policy);
+			if(rt != 0) {
+				fprintf(fp, "Unexpected error expanding types\n\n");
+				return -1;
+			}
+			for(j = 0; j < num_types; j++) {
+				rt = get_type_name(types[j], &type_name, policy);
+				if(rt != 0) {
+					free(types);
+					fprintf(fp, "Unexpected error getting type name\n\n");
+					return -1;
+				}
+				fprintf(fp, "      %s\n", type_name);
+				free(type_name);
+			}
+			free(types);
+		}
+		/* if a name was provided, return as we only print the one asked for */
+		if(name != NULL)
+			break;
+	}
+	return 0;
+}
+
+
+int print_users(FILE *fp, const char *name, int expand, policy_t *policy)
+{
+	int rt, *roles= NULL;
+	char *user_name = NULL, *role_name = NULL;
+	user_item_t *user = NULL, *u;
+	ta_item_t *role;
+
+	if(name != NULL) {
+		rt = get_user_by_name(name, &user, policy);
+		if(rt < 0) {
+			fprintf(fp, "Provided user (%s) is not a valid user name.\n", name);
+			return -1;
+		}
+	}
+	else
+		user = get_first_user_ptr(policy);
+
+	if(name == NULL)
+		fprintf(fp, "\nUsers: %d\n", num_users(policy));
+
+	for(u = user; u != NULL; u = u->next)  {
+		rt = get_user_name(u, &user_name);
+		if(rt != 0) {
+			fprintf(fp, "Unexpected error getting user name\n\n");
+			return -1;
+		}
+		fprintf(fp, "   %s\n", user_name);
+		free(user_name);
+		if(expand) {
+			for(role = get_user_first_role_ptr(u); role != NULL; role = get_user_next_role_ptr(role)) {
+				rt = get_ta_item_name(role, &role_name, policy);
+				if(rt != 0) {
+					free(roles);
+					fprintf(fp, "Unexpected error getting role name\n\n");
+					return -1;
+				}
+				fprintf(fp, "      %s\n", role_name);
+				free(role_name);
+			}
+		}
+		/* if a name was provided, return as we only print the one asked for */
+		if(name != NULL)
+			break;
+	}
+	return 0;
+}
+
+
+int main (int argc, char **argv)
+{
+	int classes, types, attribs, roles, users, all, expand, stats, rt, optc;
+	unsigned int open_opts = 0;
+	policy_t *policy;
+	char *class_name, *type_name, *attrib_name, *role_name, *user_name;
+
+	class_name = type_name = attrib_name = role_name = user_name = NULL;
+	classes = types = attribs = roles = users = all = expand = stats = 0;
+	while ((optc = getopt_long (argc, argv, "c::t::a::r::u::sAxhv", longopts, NULL)) != -1)  {
+		switch (optc) {
+		case 0:
+	  		break;
+	  	case 'c': /* classes */
+	  		classes = 1;
+	  		open_opts |= POLOPT_CLASSES;
+	  		if(optarg != 0)
+	  			class_name = optarg;
+	  		break;
+	  	case 't': /* types */
+	  		types = 1;
+	  		open_opts |= POLOPT_TYPES;
+	  		if(optarg != 0)
+	  			type_name = optarg;
+	  		break;
+	  	case 'a': /* attributes */
+	  		attribs = 1;
+	  		open_opts |= POLOPT_TYPES;
+	  		if(optarg != 0)
+	  			attrib_name = optarg;
+	  		break;
+	  	case 'r': /* roles */
+	  		roles = 1;
+	  		open_opts |= POLOPT_ROLES;
+	  		if(optarg != 0)
+	  			role_name = optarg;
+	  		break;
+	  	case 'u': /* users */
+	  		users = 1;
+	  		open_opts |= POLOPT_USERS;
+	  		if(optarg != 0)
+	  			user_name = optarg;
+	  		break;
+	  	case 'A': /* all */
+	  		all = 1;
+	  		open_opts = POLOPT_ALL;
+	  		break;
+	  	case 'x': /* expand */
+	  		expand = 1;
+	  		open_opts = POLOPT_ALL;
+	  		break;
+	  	case 's': /* stats */
+	  		stats = 1;
+	  		open_opts |= POLOPT_ALL;
+	  		break;
+	  	case 'h': /* help */
+	  		usage(argv[0], 0);
+	  		exit(0);
+	  	case 'v': /* version */
+	  		printf("\n%s\n\n", VERSION_INFO);
+	  		exit(0);
+	  	default:
+	  		usage(argv[0], 1);
+	  		exit(1);
+		}
+	}
+	/* if no options, then show stats */
+	if(classes + types + attribs + roles + users + all < 1) {
+		open_opts |= POLOPT_ALL;
+		stats = 1;
+	}
+
+	if (argc - optind > 1) {
+		usage(argv[0], 1);
+		exit(1);
+	}
+	else if(argc - optind < 1)
+		policy_file = DEFAULT_POLICY;
+	else
+		policy_file = argv[optind];
+
+	/* attempt to open the policy */
+	rt = open_partial_policy(policy_file, open_opts, &policy);
+	if(rt != 0)
+		exit(1);
+
+	/* display requested info */
+	if(stats || all)
+		print_stats(stdout, policy);
+	if(classes || all)
+		print_classes(stdout, class_name, expand, policy);
+	if(types || all)
+		print_types(stdout, type_name, expand, policy);
+	if(attribs|| all)
+		print_attribs(stdout, attrib_name, expand, policy);
+	if(roles|| all)
+		print_roles(stdout, role_name, expand, policy);
+	if(users || all)
+		print_users(stdout, user_name, expand, policy);
+
+	close_policy(policy);
+	exit(0);
+}
+
+


Put cond rule at end of te rules that have them

(Logical change 1.628)

--- setools/sediff/sediff.c
+++ setools/sediff/sediff.c
@@ -758,6 +758,18 @@
 		append_str(buf,sz,")");
 		free(rule);
 	}
+
+	if (cur->flags & AVH_FLAG_COND) {
+		if (get_cond_bool_name(cur->cond_expr,&rule,policy) < 0)
+			return -1;
+		append_str(buf,sz," [ ");
+		append_str(buf,sz,rule);
+		append_str(buf,sz," ] ");
+//		g_string_printf(string," [ %s ]",rule);
+//		gtk_text_buffer_insert_with_tags(txt, iter, string->str, -1, colortag, NULL);
+		free(rule);
+	}
+
 	append_str(buf,sz,"\n");
 	return 0;
 }


Put in a function to print stats

Put in a function to print stats

(Logical change 1.618)

--- setools/sediff/sediff.c
+++ setools/sediff/sediff.c
@@ -31,7 +31,6 @@

 #define COPYRIGHT_INFO "Copyright (C) 2004 Tresys Technology, LLC"
 #define SEDIFF_GUI_PROG	"sediffx"
-

 char *p1_file, *p2_file;

@@ -130,6 +129,20 @@

 int print_diff_stats(FILE *fp, apol_diff_result_t *diff)
 {
+	if (fp == NULL || diff == NULL)
+		return -1;
+	fprintf(fp,"Total Differences:\n\tClasses & Permissions %d \n "
+		"\tTypes %d \n\tAttributes %d \n\tRoles %d  \n\tUsers %d  \n\tBooleans %d"
+		" \n\tTE Rules %d  \n\tRbac %d  \n",
+		(diff->diff1->num_classes + diff->diff1->num_common_perms + diff->diff1->num_perms +
+		 diff->diff2->num_classes + diff->diff2->num_common_perms + diff->diff2->num_perms),
+		(diff->diff1->num_types + diff->diff2->num_types),
+		(diff->diff1->num_attribs + diff->diff2->num_attribs),
+		(diff->diff1->num_roles + diff->diff2->num_roles),
+		(diff->diff1->num_users + diff->diff2->num_users),
+		(diff->diff1->num_booleans + diff->diff2->num_booleans),
+		(diff->diff1->te.num + diff->diff2->te.num),
+		(diff->diff1->num_role_allow + diff->diff2->num_role_allow));
 	return 0;
 }

@@ -1179,6 +1192,9 @@
 		print_rbac_diffs(stdout, diff);
 		printf("\n");
 	}
+	if(stats || all) {
+		print_diff_stats(stdout, diff);
+	}

 	apol_free_diff_result(1, diff);
 	exit(0);


Added comparison, logical and bitwise operators to expression parser and evaluator.

--- src/expression.c
+++ src/expression.c
@@ -112,6 +112,22 @@
     { "hzToMidi", 1, hzToMidi },
 };

+typedef enum {
+    OP_EQUAL,
+    OP_NOT_EQUAL,
+    OP_LESS_THAN,
+    OP_LESS_THAN_OR_EQUAL,
+    OP_GREATER_THAN,
+    OP_GREATER_THAN_OR_EQUAL,
+    OP_LEFT_BIT_SHIFT,
+    OP_RIGHT_BIT_SHIFT,
+    OP_BITWISE_AND,
+    OP_BITWISE_OR,
+    OP_BITWISE_XOR,
+    OP_LOGICAL_AND,
+    OP_LOGICAL_OR,
+} extra_ops;
+
 typedef float func_float_arity0();
 typedef float func_float_arity1(float);
 typedef float func_float_arity2(float,float);
@@ -222,8 +238,85 @@
     case '*':
     case '%':
     case '=':
+        // could be '=', '=='
         tok->type = TOK_OP;
         tok->op = c;
+        ++*str;
+        c = **str;
+        if (c == '=') {
+            tok->op = OP_EQUAL;
+            ++*str;
+        }
+        return 0;
+    case '<':
+        // could be '<', '<=', '<<'
+        tok->type = TOK_OP;
+        tok->op = OP_LESS_THAN;
+        ++*str;
+        c = **str;
+        if (c == '=') {
+            tok->op = OP_LESS_THAN_OR_EQUAL;
+            ++*str;
+        }
+        else if (c == '<') {
+            tok->op = OP_LEFT_BIT_SHIFT;
+            ++*str;
+        }
+        return 0;
+    case '>':
+        // could be '>', '>=', '>>'
+        tok->type = TOK_OP;
+        tok->op = OP_GREATER_THAN;
+        ++*str;
+        c = **str;
+        if (c == '=') {
+            tok->op = OP_GREATER_THAN_OR_EQUAL;
+            ++*str;
+        }
+        else if (c == '>') {
+            tok->op = OP_RIGHT_BIT_SHIFT;
+            ++*str;
+        }
+        return 0;
+    case '!':
+        // could be '!', '!='
+        // will handle factorial case later
+        tok->type = TOK_OP;
+        //tok->op = c;
+        ++*str;
+        c = **str;
+        if (c == '=') {
+            tok->op = OP_NOT_EQUAL;
+            ++*str;
+            return 0;
+        }
+        break;
+    case '&':
+        // could be '&', '&&'
+        tok->type = TOK_OP;
+        tok->op = OP_BITWISE_AND;
+        ++*str;
+        c = **str;
+        if (c == '&') {
+            tok->op = OP_LOGICAL_AND;
+            ++*str;
+        }
+        return 0;
+    case '|':
+        // could be '|', '||'
+        tok->type = TOK_OP;
+        tok->op = OP_BITWISE_OR;
+        ++*str;
+        c = **str;
+        if (c == '|') {
+            tok->op = OP_LOGICAL_OR;
+            ++*str;
+        }
+        return 0;
+    case '^':
+        // bitwise XOR
+        tok->type = TOK_OP;
+        tok->op = OP_BITWISE_XOR;
         ++*str;
         return 0;
     case '(':
@@ -655,7 +748,21 @@
         case EXPR_RIGHT:
             if (tok.type == TOK_OP) {
                 POP();
-                if (tok.op == '+' || tok.op == '-') {
+                // TODO: this doesn't properly handle order-of-operations
+                if (tok.op == '+' || tok.op == '-' ||
+                    tok.op == OP_EQUAL ||
+                    tok.op == OP_NOT_EQUAL ||
+                    tok.op == OP_LESS_THAN ||
+                    tok.op == OP_LESS_THAN_OR_EQUAL ||
+                    tok.op == OP_GREATER_THAN ||
+                    tok.op == OP_GREATER_THAN_OR_EQUAL ||
+                    tok.op == OP_LEFT_BIT_SHIFT ||
+                    tok.op == OP_RIGHT_BIT_SHIFT ||
+                    tok.op == OP_BITWISE_AND ||
+                    tok.op == OP_BITWISE_OR ||
+                    tok.op == OP_BITWISE_XOR ||
+                    tok.op == OP_LOGICAL_AND ||
+                    tok.op == OP_LOGICAL_OR) {
                     APPEND_OP(tok);
                     PUSHSTATE(EXPR);
                     next_token = 1;
@@ -991,6 +1098,12 @@
                 stack[i][top].i32 = (int)stack[i][top].f;
             break;
         case TOK_OP:
+                    /*
+                    OP_BITWISE_AND,
+                    OP_BITWISE_OR,
+                    OP_BITWISE_XOR,
+                    OP_LOGICAL_AND,
+                    OP_LOGICAL_OR,*/
             --top;
             for (i = 0; i < to->length; i++) {
                 if (node->is_float) {
@@ -1001,6 +1114,19 @@
                     case '*': stack[i][top].f = stack[i][top].f * stack[i][top + 1].f; break;
                     case '/': stack[i][top].f = stack[i][top].f / stack[i][top + 1].f; break;
                     case '%': stack[i][top].f = fmod(stack[i][top].f, stack[i][top + 1].f); break;
+                    case OP_EQUAL: stack[i][top].f = stack[i][top].f == stack[i][top + 1].f; break;
+                    case OP_NOT_EQUAL: stack[i][top].f = stack[i][top].f != stack[i][top + 1].f; break;
+                    case OP_LESS_THAN: stack[i][top].f = stack[i][top].f < stack[i][top + 1].f; break;
+                    case OP_LESS_THAN_OR_EQUAL: stack[i][top].f = stack[i][top].f <= stack[i][top + 1].f; break;
+                    case OP_GREATER_THAN: stack[i][top].f = stack[i][top].f > stack[i][top + 1].f; break;
+                    case OP_GREATER_THAN_OR_EQUAL: stack[i][top].f = stack[i][top].f >= stack[i][top + 1].f; break;
+                    case OP_LEFT_BIT_SHIFT: stack[i][top].f = (float)((int)stack[i][top].f << (int)stack[i][top + 1].f); break;
+                    case OP_RIGHT_BIT_SHIFT: stack[i][top].f = (float)((int)stack[i][top].f >> (int)stack[i][top + 1].f); break;
+                    case OP_BITWISE_AND: stack[i][top].f = (float)((int)stack[i][top].f & (int)stack[i][top + 1].f); break;
+                    case OP_BITWISE_OR: stack[i][top].f = (float)((int)stack[i][top].f | (int)stack[i][top + 1].f); break;
+                    case OP_BITWISE_XOR: stack[i][top].f = (float)((int)stack[i][top].f ^ (int)stack[i][top + 1].f); break;
+                    case OP_LOGICAL_AND: stack[i][top].f = stack[i][top].f && stack[i][top + 1].f; break;
+                    case OP_LOGICAL_OR: stack[i][top].f = stack[i][top].f || stack[i][top + 1].f; break;
                     default: goto error;
                     }
                     trace_eval("%f\n", stack[i][top].f);
@@ -1012,6 +1138,19 @@
                     case '*': stack[i][top].i32 = stack[i][top].i32 * stack[i][top + 1].i32; break;
                     case '/': stack[i][top].i32 = stack[i][top].i32 / stack[i][top + 1].i32; break;
                     case '%': stack[i][top].i32 = stack[i][top].i32 % stack[i][top + 1].i32; break;
+                    case OP_EQUAL: stack[i][top].i32 = stack[i][top].i32 == stack[i][top + 1].i32; break;
+                    case OP_NOT_EQUAL: stack[i][top].i32 = stack[i][top].i32 != stack[i][top + 1].i32; break;
+                    case OP_LESS_THAN: stack[i][top].i32 = stack[i][top].i32 < stack[i][top + 1].i32; break;
+                    case OP_LESS_THAN_OR_EQUAL: stack[i][top].i32 = stack[i][top].i32 <= stack[i][top + 1].i32; break;
+                    case OP_GREATER_THAN: stack[i][top].i32 = stack[i][top].i32 > stack[i][top + 1].i32; break;
+                    case OP_GREATER_THAN_OR_EQUAL: stack[i][top].i32 = stack[i][top].i32 >= stack[i][top + 1].i32; break;
+                    case OP_LEFT_BIT_SHIFT: stack[i][top].i32 = stack[i][top].i32 << stack[i][top + 1].i32; break;
+                    case OP_RIGHT_BIT_SHIFT: stack[i][top].i32 = stack[i][top].i32 >> stack[i][top + 1].i32; break;
+                    case OP_BITWISE_AND: stack[i][top].i32 = stack[i][top].i32 & stack[i][top + 1].i32; break;
+                    case OP_BITWISE_OR: stack[i][top].i32 = stack[i][top].i32 | stack[i][top + 1].i32; break;
+                    case OP_BITWISE_XOR: stack[i][top].i32 = stack[i][top].i32 ^ stack[i][top + 1].i32; break;
+                    case OP_LOGICAL_AND: stack[i][top].i32 = stack[i][top].i32 && stack[i][top + 1].i32; break;
+                    case OP_LOGICAL_OR: stack[i][top].i32 = stack[i][top].i32 || stack[i][top + 1].i32; break;
                     default: goto error;
                     }
                     trace_eval("%d\n", stack[i][top].i32);


add clipping accum and array indexing to scene format

--- core/engine/format.h
+++ core/engine/format.h
@@ -43,6 +43,8 @@

 #define RT_REL_MINUS_INNER                 -1 /* subtract srf inner subspace */
 #define RT_REL_MINUS_OUTER                 +1 /* subtract srf outer subspace */
+#define RT_REL_MINUS_ACCUM                  2 /* subtract accum subspace */
+#define RT_REL_INDEX_ARRAY                  3 /* next index in sub-array */

 struct rt_RELATION
 {


Expanded gateway example adv_int

Expanded gateway example adv_int

--- examples/BLE_Gateway/nrf_adv_conn.c
+++ examples/BLE_Gateway/nrf_adv_conn.c
@@ -48,7 +48,7 @@
 #include <string.h>
 #include <stdio.h>

-#define BLE_ADV_INTERVAL_150MS 0x00F0
+#define BLE_ADV_INTERVAL_750MS (800)

 /*****************************************************************************
 * Static Globals
@@ -63,7 +63,7 @@
     NULL,                      /* Not used for this type of advertisement */
     BLE_GAP_ADV_FP_ANY,        /* Don't filter */
     NULL,                      /* Whitelist not in use */
-    BLE_ADV_INTERVAL_150MS,    /* Advertising interval set to intentionally disrupt the timeslot example */
+    BLE_ADV_INTERVAL_750MS,       /* Advertising interval set to intentionally disrupt the timeslot example */
     0                          /* Timeout in seconds */
 };


including time constraints verification

including time constraints verification


libc: netdb: Fix bugs in lib_gethostbynamer.c

This fix sets h_name in struct hostent returned by gethostbyname()

This patch comes from Nuttx community.
Commit id: 6ccc01ad

Change-Id: I8a92e862081e62ec2fa09c378eb86bb7c5736182
Signed-off-by: EunBong Song <1a7e7e98e070490e67aa35ab67fbf9fdda8f48ac@samsung.com>

--- lib/libc/netdb/lib_gethostbynamer.c
+++ lib/libc/netdb/lib_gethostbynamer.c
@@ -220,6 +220,11 @@
 	}

 	strncpy(ptr, name, buflen);
+
+	/* Set the address to h_name */
+
+	host->h_name = ptr;
+
 	return 0;
 }

@@ -300,6 +305,10 @@
 		}

 		strncpy(dest, name, buflen);
+
+		/* Set the address to h_name */
+
+		host->h_name = dest;
 		return 0;
 	}

@@ -408,6 +417,10 @@
 	}

 	strncpy(ptr, name, buflen);
+
+	/* Set the address to h_name */
+
+	host->h_name = ptr;
 	return OK;
 }
 #endif							/* CONFIG_NETDB_DNSCLIENT */
@@ -544,6 +557,10 @@
 		}

 		strncpy(ptr, name, buflen);
+
+		/* Set the address to h_name */
+
+		host->h_name = ptr;
 		return OK;
 	}


vfio: remove incorrect experimental tag

vfio: remove incorrect experimental tag

The incriminated commit promoted this symbol as stable but the
definition still has the tag.

Fixes: 787ae736a3d9 ("vfio: remove experimental tag")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <f28529695cfa9e3e1eb84e7072aa626af4abb18e@redhat.com>
Acked-by: Adrien Mazarguil <9d39ea493ca46c560334f650ac5d4b5ffbcb5cf0@6wind.com>
Acked-by: Stephen Hemminger <06fa905d7f2aaced6dc72e9511c71a2a51e8aead@networkplumber.org>
Acked-by: Neil Horman <3316dc2d77df57653443c0391a5296176d6ca9c3@tuxdriver.com>

--- lib/librte_eal/linux/eal/eal_vfio.c
+++ lib/librte_eal/linux/eal/eal_vfio.c
@@ -1834,7 +1834,7 @@
 	return vfio_cfgs[i].vfio_container_fd;
 }

-int __rte_experimental
+int
 rte_vfio_container_destroy(int container_fd)
 {
 	struct vfio_config *vfio_cfg;


missing change

missing change

--- platform/shared/common/RhodesApp.h
+++ platform/shared/common/RhodesApp.h
@@ -357,7 +357,7 @@
 int rho_http_get_port();

 #ifdef OS_MACOSX
-const char* rho_http_direct_request( const char* method, const char* uri, const char* query, const void* headers, const char* body );
+const char* rho_http_direct_request( const char* method, const char* uri, const char* query, const void* headers, const char* body, int* responseLength );
 void rho_http_free_response( const char* data );

 void* rho_http_init_headers_list();


port: fix allocation check in ring SWX

port: fix allocation check in ring SWX

Fix logically dead code in ring port.

Coverity issue: 369664
Fixes: 77a413017c2d ("port: add ring SWX port")

Signed-off-by: Cristian Dumitrescu <25468b8a3698eeb3c368247f8635924bb4a1ce2c@intel.com>

--- lib/librte_port/rte_swx_port_ring.c
+++ lib/librte_port/rte_swx_port_ring.c
@@ -195,7 +195,7 @@
 		goto error;

 	p->params.name = strdup(params->name);
-	if (!p)
+	if (!p->params.name)
 		goto error;

 	p->pkts = calloc(params->burst_size, sizeof(struct rte_mbuf *));


fix command line parsing.

fix command line parsing.

--- bin/synthpod_jack.c
+++ bin/synthpod_jack.c
@@ -1277,9 +1277,10 @@
 					"   %s [OPTIONS] [BUNDLE_PATH]\n"
 					"\n"
 					"OPTIONS\n"
-					"   [-v]    print version and license information\n"
-					"   [-h]    print usage information\n"
-					"   [-s]    connect to named JACK daemon\n\n"
+					"   [-v]                 print version and license information\n"
+					"   [-h]                 print usage information\n"
+					"   [-n] server-name     connect to named JACK daemon\n"
+					"   [-s] sequence-size   minimum sequence size\n\n"
 					, argv[0]);
 				return 0;
 			case 'n':
@@ -1392,8 +1393,7 @@
 #endif

 	// NSM init
-	handle.nsm = synthpod_nsm_new(argv[0], argc > 1 ? argv[argc-1] : NULL,
-		&nsm_driver, &handle); //TODO check
+	handle.nsm = synthpod_nsm_new(argv[0], argv[optind], &nsm_driver, &handle); //TODO check

 	// init semaphores
 	eina_semaphore_new(&handle.worker_sem, 0);


sched: Remove AFFINE_WAKEUPS feature flag

Commit beac4c7e4a1c ("sched: Remove AFFINE_WAKEUPS feature") removed
use of the flag but left the definition. Get rid of it.

Signed-off-by: Namhyung Kim <5c915a589b3ddf58cebf14bec41bcc143b37ac3c@kernel.org>
Signed-off-by: Peter Zijlstra <645ca7d3a8d3d4f60557176cd361ea8351edc32b@chello.nl>
Cc: Mike Galbraith <3cfa3897b7f55b5396b7a47c83b66325184bc9b4@gmx.de>
Link: http://lkml.kernel.org/r/1345090865-20851-1-git-send-email-5c915a589b3ddf58cebf14bec41bcc143b37ac3c@kernel.org
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@kernel.org>

--- kernel/sched/features.h
+++ kernel/sched/features.h
@@ -10,14 +10,6 @@
  * tasks
  */
 SCHED_FEAT(START_DEBIT, true)
-
-/*
- * Based on load and program behaviour, see if it makes sense to place
- * a newly woken task on the same cpu as the task that woke it --
- * improve cache locality. Typically used with SYNC wakeups as
- * generated by pipes and the like, see also SYNC_WAKEUPS.
- */
-SCHED_FEAT(AFFINE_WAKEUPS, true)

 /*
  * Prefer to schedule the task we woke last (assuming it failed


blktrace: fix blk_probes_ref chaos

blktrace: fix blk_probes_ref chaos

Impact: fix mixed ioctl and ftrace-plugin blktrace use refcount bugs

ioctl-based blktrace allocates bt and registers tracepoints when
ioctl(BLKTRACESETUP), and do all cleanups when ioctl(BLKTRACETEARDOWN).

while ftrace-based blktrace allocates/frees bt when:
  # echo 1/0 > /sys/block/sda/sda1/trace/enable

and registers/unregisters tracepoints when:
  # echo blk/nop > /debugfs/tracing/current_tracer
or
  # echo 1/0 > /debugfs/tracing/tracing_enable

The separatation of allocation and registeration causes 2 problems:

  1. current user-space blktrace still calls ioctl(TEARDOWN) when
     ioctl(SETUP) failed:
       # echo 1 > /sys/block/sda/sda1/trace/enable
       # blktrace /dev/sda
         BLKTRACESETUP: Device or resource busy
         ^C
     and now blk_probes_ref == -1

  2. Another way to make blk_probes_ref == -1:
     # plugin sdb && mount sdb1
     # echo 1 > /sys/block/sdb/sdb1/trace/enable
     # remove sdb

This patch does the allocation and registeration when writing
sdaX/trace/enable.

Signed-off-by: Li Zefan <5dc16b054e85ffba6c8d314d8e55ae95dcab12a5@cn.fujitsu.com>
Acked-by: Jens Axboe <165ab144a3ccfd9429d5c6466b275f24fafdb114@oracle.com>
Cc: Arnaldo Carvalho de Melo <293abb6b76d7791c0732cc517d38c4b5c734b87f@redhat.com>
Cc: Steven Rostedt <43232e92d70cc7aa53504ad0397085ee47bad87f@goodmis.org>
Cc: Frederic Weisbecker <e8a1bf9163cb25e93cfd6540f223b3872ea7ee55@gmail.com>
Signed-off-by: Ingo Molnar <9dbbbf0688fedc85ad4da37637f1a64b8c718ee2@elte.hu>

--- kernel/trace/blktrace.c
+++ kernel/trace/blktrace.c
@@ -478,7 +478,7 @@
 		goto err;
 	}

-	if (atomic_add_return(1, &blk_probes_ref) == 1)
+	if (atomic_inc_return(&blk_probes_ref) == 1)
 		blk_register_tracepoints();

 	return 0;
@@ -1091,8 +1091,6 @@

 static void blk_tracer_start(struct trace_array *tr)
 {
-	if (atomic_add_return(1, &blk_probes_ref) == 1)
-		blk_register_tracepoints();
 	trace_flags &= ~TRACE_ITER_CONTEXT_INFO;
 }

@@ -1107,15 +1105,10 @@
 static void blk_tracer_stop(struct trace_array *tr)
 {
 	trace_flags |= TRACE_ITER_CONTEXT_INFO;
-	if (atomic_dec_and_test(&blk_probes_ref))
-		blk_unregister_tracepoints();
 }

 static void blk_tracer_reset(struct trace_array *tr)
 {
-	if (!atomic_read(&blk_probes_ref))
-		return;
-
 	blk_tracer_enabled = false;
 	blk_tracer_stop(tr);
 }
@@ -1254,6 +1247,9 @@
 	if (bt == NULL)
 		return -EINVAL;

+	if (atomic_dec_and_test(&blk_probes_ref))
+		blk_unregister_tracepoints();
+
 	kfree(bt);
 	return 0;
 }
@@ -1279,6 +1275,9 @@
 		kfree(bt);
 		return -EBUSY;
 	}
+
+	if (atomic_inc_return(&blk_probes_ref) == 1)
+		blk_register_tracepoints();

 	return 0;
 }


Fix no-ec

Fix no-ec

Reviewed-by: Rich Salz <c04971a99e5a9ee80eaab4b1deb37e845b0bd697@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6437)


core/host/disabled.c: Format with clang-format

BUG=b:236386294
BRANCH=none
TEST=none

Change-Id: I4027981884a1a9c16f4b173b170b190e13022334
Signed-off-by: Jack Rosenthal <d3f605bef1867f59845d4ce6e4f83b8dc9e4e0ae@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3729838
Reviewed-by: Jeremy Bettis <4df7b5147fee087dca33c181f288ee7dbf56e022@chromium.org>

--- core/host/disabled.c
+++ core/host/disabled.c
@@ -5,6 +5,9 @@

 /* Disabled functions */

-#define DISABLED(proto) proto { }
+#define DISABLED(proto) \
+	proto           \
+	{               \
+	}

 DISABLED(void clock_init(void));


Cleanup

Cleanup

--- kernel/cpu.c
+++ kernel/cpu.c
@@ -11,7 +11,7 @@
 static const char* CONSOLE_TAG = "CPU";

 /* Relocate the local apic memory address */
-apic_local_reg_map_t*
+static apic_local_reg_map_t*
 remap_local_apic_reg()
 {
     console_start("Remaping local apic register");
@@ -23,16 +23,13 @@
         console_puts("NO ALLOC!");
         PANIC();
     }
-
-    console_putq(mem);
-
     apic_set_base_msr(mem);

     console_ok();
     return (apic_local_reg_map_t*)KERNEL_VADDR(mem);
 }

-void
+static void
 enable_local_apic_timer(apic_local_reg_map_t* map)
 {
     /* Enable the spurious interrupt vector */
@@ -43,7 +40,7 @@
     /* __asm__("int $32\n"); */
 }

-void
+static void
 update_kdata_from_local_reg_map(apic_local_reg_map_t* map)
 {
     kdata_t* kdata = kdata_get();
@@ -63,7 +60,7 @@
     }
 }

-void
+static void
 check_bsp_sanity()
 {
     uint64_t apic_base = apic_get_base_msr();
@@ -80,7 +77,7 @@
     }
 }

-void
+static void
 bsp_init()
 {
     console_start("Initializing the BSP");


move pageDirectory

move pageDirectory

--- kernel/mmu.c
+++ kernel/mmu.c
@@ -5,8 +5,6 @@
 #include <kernel/regs.h>
 #include <kernel/isr.h>
 #include <kernel/mmu.h>
-
-mmu_directory_t *pageDirectory = (mmu_directory_t *)MMU_PAGE_DIRECTORY_ADDRESS;

 void mmu_handler(registers_t *r)
 {
@@ -66,9 +64,11 @@
 void mmu_init()
 {

-    mmu_init_directory(pageDirectory);
-    mmu_set_directory(pageDirectory, 0x0, 0x400000, MMU_PAGE_DIRECTORY_FLAG_PRESENT | MMU_PAGE_DIRECTORY_FLAG_WRITEABLE);
-    mmu_flush(pageDirectory);
+    mmu_directory_t *directory = (mmu_directory_t *)MMU_PAGE_DIRECTORY_ADDRESS;
+
+    mmu_init_directory(directory);
+    mmu_set_directory(directory, 0x0, 0x400000, MMU_PAGE_DIRECTORY_FLAG_PRESENT | MMU_PAGE_DIRECTORY_FLAG_WRITEABLE);
+    mmu_flush(directory);

 }


fix --kmz creation to not have absolute paths -- patch courtesy of Michael Wood-Vasey

git-svn-id: a4967eeb46e72ec0d67de3341f099b34cc11cf18@10373 03a3cea6-2c03-0410-ac9b-9271b1c66c29

--- blind/solve-field.c
+++ blind/solve-field.c
@@ -148,9 +148,12 @@
     char* pngfn = NULL;
     char* kmlfn = NULL;
     char* warpedpngfn = NULL;
+    char* basekmlfn = NULL;
+    char* basewarpedpngfn = NULL;
     char* tmpdir;
     char* cmd = NULL;
     sl* cmdline = sl_new(16);
+    char* wcsbase = NULL;

     tmpdir = create_temp_dir("kmz", tempdir);
     if (!tmpdir) {
@@ -179,17 +182,24 @@
     }
     free(cmd);

-    kmlfn       = sl_appendf(tempfiles, "%s/%s", tmpdir, "doc.kml");
-    warpedpngfn = sl_appendf(tempfiles, "%s/%s", tmpdir, "warped.png");
+    basekmlfn       = "doc.kml";
+    basewarpedpngfn = "warped.png";
+    kmlfn       = sl_appendf(tempfiles, "%s/%s", tmpdir, basekmlfn);
+    warpedpngfn = sl_appendf(tempfiles, "%s/%s", tmpdir, basewarpedpngfn);
+    // delete the wcs we create with "cp" below.
+    wcsbase = basename_safe(axy->wcsfn);
+    sl_appendf(tempfiles, "%s/%s", tmpdir, wcsbase);
+    free(wcsbase);

     logverb("Trying to run wcs2kml to generate KMZ output.\n");
+    sl_appendf(cmdline, "cp %s %s; cd %s; ", axy->wcsfn, tmpdir, tmpdir);
     sl_append(cmdline, "wcs2kml");
     // FIXME - if parity?
     sl_append(cmdline, "--input_image_origin_is_upper_left");
     appendf_escape(cmdline, "--fitsfile=%s", axy->wcsfn);
     appendf_escape(cmdline, "--imagefile=%s", pngfn);
-    appendf_escape(cmdline, "--kmlfile=%s", kmlfn);
-    appendf_escape(cmdline, "--outfile=%s", warpedpngfn);
+    appendf_escape(cmdline, "--kmlfile=%s", basekmlfn);
+    appendf_escape(cmdline, "--outfile=%s", basewarpedpngfn);
     // run it
     cmd = sl_implode(cmdline, " ");
     sl_remove_all(cmdline);


scale value

scale value

--- kernel/rgb.c
+++ kernel/rgb.c
@@ -46,6 +46,8 @@
 	}
 }

+#define SCALE 80			/* gives ~50Hz duty cycle */
+
 void
 pwm(void *arg)
 {
@@ -63,13 +65,13 @@
 		/* on */
 		if (t) {
 			PORTB |= _BV(a->pin);
-			sleep(0, t * 80);
+			sleep(0, t * SCALE);
 		}

 		/* off */
 		if ((t = UINT8_MAX - t)) {
 			PORTB &= ~_BV(a->pin);
-			sleep(0, t * 80);
+			sleep(0, t * SCALE);
 		}
 	}
 }


prctl: more prctl(PR_SET_MM_*) checks

prctl: more prctl(PR_SET_MM_*) checks

Individual prctl(PR_SET_MM_*) calls do some checking to maintain a
consistent view of mm->arg_start et al fields, but not enough.  In
particular PR_SET_MM_ARG_START/PR_SET_MM_ARG_END/ R_SET_MM_ENV_START/
PR_SET_MM_ENV_END only check that the address lies in an existing VMA,
but don't check that the start address is lower than the end address _at
all_.

Consolidate all consistency checks, so there will be no difference in
the future between PR_SET_MM_MAP and individual PR_SET_MM_* calls.

The program below makes both ARGV and ENVP areas be reversed.  It makes
/proc/$PID/cmdline show garbage (it doesn't oops by luck).

#include <sys/mman.h>
#include <sys/prctl.h>
#include <unistd.h>

enum {PAGE_SIZE=4096};

int main(void)
{
	void *p;

	p = mmap(NULL, PAGE_SIZE, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);

#define PR_SET_MM               35
#define PR_SET_MM_ARG_START     8
#define PR_SET_MM_ARG_END       9
#define PR_SET_MM_ENV_START     10
#define PR_SET_MM_ENV_END       11
	prctl(PR_SET_MM, PR_SET_MM_ARG_START, (unsigned long)p + PAGE_SIZE - 1, 0, 0);
	prctl(PR_SET_MM, PR_SET_MM_ARG_END,   (unsigned long)p, 0, 0);
	prctl(PR_SET_MM, PR_SET_MM_ENV_START, (unsigned long)p + PAGE_SIZE - 1, 0, 0);
	prctl(PR_SET_MM, PR_SET_MM_ENV_END,   (unsigned long)p, 0, 0);

	pause();
	return 0;
}

[5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org: tidy code, tweak comment]
Signed-off-by: Alexey Dobriyan <b99bff5923d24d2fb8e844db9dac7cd59203da1d@gmail.com>
Acked-by: Cyrill Gorcunov <7a1ea01eee6961eb1e372e3508c2670446d086f4@openvz.org>
Cc: Jarod Wilson <14059c7158912dcae849c377925c87d46da48cdf@redhat.com>
Cc: Jan Stancek <1cdc26788c5bb66f1c315a7f9f8b93926cbf61a9@redhat.com>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>


Fixed bugs in vga driver related to scrolling. Difference calculation between y_cursor and end of screen fixed. Last row being properly cleared now.

--- kernel/vga.c
+++ kernel/vga.c
@@ -18,7 +18,7 @@

 // Address of VGA memory buffer
 static uint16_t *_vga_memptr = (uint16_t*)0xB8000;
-static uint8_t _attribute = 0x0F;
+static uint8_t _attribute = VGA_ATTRIB(VGA_COLOR_WHITE, VGA_COLOR_BLACK);
 static int _cursor_x = 0;
 static int _cursor_y = 0;

@@ -124,7 +124,9 @@

 static void _vga_scroll(void)
 {
+    int i;
     int diff;
+    int last_row_index = VGA_SCREEN_WIDTH*(VGA_SCREEN_HEIGHT-1);
     uint16_t space = VGA_WORD( VGA_ATTRIB( VGA_COLOR_BLACK,
                                            VGA_COLOR_BLACK), ' ');

@@ -132,7 +134,7 @@
     if (_cursor_y >= VGA_SCREEN_HEIGHT)
     {
         // Calculate how far the cursor passes screen height
-        diff = _cursor_y - VGA_SCREEN_HEIGHT - 1;
+        diff = _cursor_y - (VGA_SCREEN_HEIGHT - 1);

         // Shift every row from the first row until the row before the cursor
         // up by one row
@@ -140,9 +142,10 @@
                 VGA_SCREEN_WIDTH*(VGA_SCREEN_HEIGHT-diff)*sizeof(uint16_t));

         // Clear the new last row
-        memset( _vga_memptr+VGA_SCREEN_WIDTH*(VGA_SCREEN_HEIGHT-1),
-                space,
-                VGA_SCREEN_WIDTH);
+        for (i=0; i<VGA_SCREEN_WIDTH; i++)
+        {
+            _vga_memptr[last_row_index+i] = space;
+        }

         // Move cursor to last row
         _cursor_y = VGA_SCREEN_HEIGHT - 1;


[PATCH] cfq-iosched: cleanups, fixes, dead code removal

A collection of little fixes and cleanups:

- We don't use the 'queued' sysfs exported attribute, since the
  may_queue() logic was rewritten. So kill it.

- Remove dead defines.

- cfq_set_active_queue() can be rewritten cleaner with else if conditions.

- Several places had cfq_exit_cfqq() like logic, abstract that out and
  use that.

- Annotate the cfqq kmem_cache_alloc() so the allocator knows that this
  is a repeat allocation if it fails with __GFP_WAIT set. Allows the
  allocator to start freeing some memory, if needed. CFQ already loops for
  this condition, so might as well pass the hint down.

- Remove cfqd->rq_starved logic. It's not needed anymore after we dropped
  the crq allocation in cfq_set_request().

- Remove uneeded parameter passing.

Signed-off-by: Jens Axboe <cd8c6775e60d6f67a6984377324e5290df3d5358@suse.de>

--- block/cfq-iosched.c
+++ block/cfq-iosched.c
@@ -17,7 +17,6 @@
  * tunables
  */
 static const int cfq_quantum = 4;		/* max queue in one round of service */
-static const int cfq_queued = 8;		/* minimum rq allocate limit per-queue*/
 static const int cfq_fifo_expire[2] = { HZ / 4, HZ / 8 };
 static const int cfq_back_max = 16 * 1024;	/* maximum backwards seek, in KiB */
 static const int cfq_back_penalty = 2;		/* penalty of a backwards seek */
@@ -54,7 +53,6 @@

 #define CFQ_PRIO_LISTS		IOPRIO_BE_NR
 #define cfq_class_idle(cfqq)	((cfqq)->ioprio_class == IOPRIO_CLASS_IDLE)
-#define cfq_class_be(cfqq)	((cfqq)->ioprio_class == IOPRIO_CLASS_BE)
 #define cfq_class_rt(cfqq)	((cfqq)->ioprio_class == IOPRIO_CLASS_RT)

 #define ASYNC			(0)
@@ -99,9 +97,6 @@
 	int hw_tag;

 	/*
-	 * schedule slice state info
-	 */
-	/*
 	 * idle window management
 	 */
 	struct timer_list idle_slice_timer;
@@ -117,13 +112,10 @@
 	sector_t last_sector;
 	unsigned long last_end_request;

-	unsigned int rq_starved;
-
 	/*
 	 * tunables, see top of file
 	 */
 	unsigned int cfq_quantum;
-	unsigned int cfq_queued;
 	unsigned int cfq_fifo_expire[2];
 	unsigned int cfq_back_penalty;
 	unsigned int cfq_back_max;
@@ -484,12 +476,14 @@
 {
 	struct task_struct *tsk = current;
 	pid_t key = cfq_queue_pid(tsk, bio_data_dir(bio));
-	sector_t sector = bio->bi_sector + bio_sectors(bio);
 	struct cfq_queue *cfqq;

 	cfqq = cfq_find_cfq_hash(cfqd, key, tsk->ioprio);
-	if (cfqq)
+	if (cfqq) {
+		sector_t sector = bio->bi_sector + bio_sectors(bio);
+
 		return elv_rb_find(&cfqq->sort_list, sector);
+	}

 	return NULL;
 }
@@ -699,26 +693,25 @@
 {
 	struct cfq_queue *cfqq = NULL;

-	/*
-	 * if current list is non-empty, grab first entry. if it is empty,
-	 * get next prio level and grab first entry then if any are spliced
-	 */
-	if (!list_empty(&cfqd->cur_rr) || cfq_get_next_prio_level(cfqd) != -1)
+	if (!list_empty(&cfqd->cur_rr) || cfq_get_next_prio_level(cfqd) != -1) {
+		/*
+		 * if current list is non-empty, grab first entry. if it is
+		 * empty, get next prio level and grab first entry then if any
+		 * are spliced
+		 */
 		cfqq = list_entry_cfqq(cfqd->cur_rr.next);
-
-	/*
-	 * If no new queues are available, check if the busy list has some
-	 * before falling back to idle io.
-	 */
-	if (!cfqq && !list_empty(&cfqd->busy_rr))
+	} else if (!list_empty(&cfqd->busy_rr)) {
+		/*
+		 * If no new queues are available, check if the busy list has
+		 * some before falling back to idle io.
+		 */
 		cfqq = list_entry_cfqq(cfqd->busy_rr.next);
-
-	/*
-	 * if we have idle queues and no rt or be queues had pending
-	 * requests, either allow immediate service if the grace period
-	 * has passed or arm the idle grace timer
-	 */
-	if (!cfqq && !list_empty(&cfqd->idle_rr)) {
+	} else if (!list_empty(&cfqd->idle_rr)) {
+		/*
+		 * if we have idle queues and no rt or be queues had pending
+		 * requests, either allow immediate service if the grace period
+		 * has passed or arm the idle grace timer
+		 */
 		unsigned long end = cfqd->last_end_request + CFQ_IDLE_GRACE;

 		if (time_after_eq(jiffies, end))
@@ -793,18 +786,19 @@
 {
 	struct cfq_data *cfqd = cfqq->cfqd;
 	struct request *rq;
+	int fifo;

 	if (cfq_cfqq_fifo_expire(cfqq))
 		return NULL;
-
-	if (!list_empty(&cfqq->fifo)) {
-		int fifo = cfq_cfqq_class_sync(cfqq);
-
-		rq = rq_entry_fifo(cfqq->fifo.next);
-		if (time_after(jiffies, rq->start_time + cfqd->cfq_fifo_expire[fifo])) {
-			cfq_mark_cfqq_fifo_expire(cfqq);
-			return rq;
-		}
+	if (list_empty(&cfqq->fifo))
+		return NULL;
+
+	fifo = cfq_cfqq_class_sync(cfqq);
+	rq = rq_entry_fifo(cfqq->fifo.next);
+
+	if (time_after(jiffies, rq->start_time + cfqd->cfq_fifo_expire[fifo])) {
+		cfq_mark_cfqq_fifo_expire(cfqq);
+		return rq;
 	}

 	return NULL;
@@ -1096,40 +1090,48 @@
 	cfq_free_io_context(ioc);
 }

-/*
- * Called with interrupts disabled
- */
-static void cfq_exit_single_io_context(struct cfq_io_context *cic)
-{
-	struct cfq_data *cfqd = cic->key;
-	request_queue_t *q;
-
-	if (!cfqd)
-		return;
-
-	q = cfqd->queue;
-
-	WARN_ON(!irqs_disabled());
-
-	spin_lock(q->queue_lock);
-
+static void cfq_exit_cfqq(struct cfq_data *cfqd, struct cfq_queue *cfqq)
+{
+	if (unlikely(cfqq == cfqd->active_queue))
+		__cfq_slice_expired(cfqd, cfqq, 0);
+
+	cfq_put_queue(cfqq);
+}
+
+static void __cfq_exit_single_io_context(struct cfq_data *cfqd,
+					 struct cfq_io_context *cic)
+{
 	if (cic->cfqq[ASYNC]) {
-		if (unlikely(cic->cfqq[ASYNC] == cfqd->active_queue))
-			__cfq_slice_expired(cfqd, cic->cfqq[ASYNC], 0);
-		cfq_put_queue(cic->cfqq[ASYNC]);
+		cfq_exit_cfqq(cfqd, cic->cfqq[ASYNC]);
 		cic->cfqq[ASYNC] = NULL;
 	}

 	if (cic->cfqq[SYNC]) {
-		if (unlikely(cic->cfqq[SYNC] == cfqd->active_queue))
-			__cfq_slice_expired(cfqd, cic->cfqq[SYNC], 0);
-		cfq_put_queue(cic->cfqq[SYNC]);
+		cfq_exit_cfqq(cfqd, cic->cfqq[SYNC]);
 		cic->cfqq[SYNC] = NULL;
 	}

 	cic->key = NULL;
 	list_del_init(&cic->queue_list);
-	spin_unlock(q->queue_lock);
+}
+
+
+/*
+ * Called with interrupts disabled
+ */
+static void cfq_exit_single_io_context(struct cfq_io_context *cic)
+{
+	struct cfq_data *cfqd = cic->key;
+
+	WARN_ON(!irqs_disabled());
+
+	if (cfqd) {
+		request_queue_t *q = cfqd->queue;
+
+		spin_lock(q->queue_lock);
+		__cfq_exit_single_io_context(cfqd, cic);
+		spin_unlock(q->queue_lock);
+	}
 }

 static void cfq_exit_io_context(struct io_context *ioc)
@@ -1286,8 +1288,14 @@
 			cfqq = new_cfqq;
 			new_cfqq = NULL;
 		} else if (gfp_mask & __GFP_WAIT) {
+			/*
+			 * Inform the allocator of the fact that we will
+			 * just repeat this allocation if it fails, to allow
+			 * the allocator to do whatever it needs to attempt to
+			 * free memory.
+			 */
 			spin_unlock_irq(cfqd->queue->queue_lock);
-			new_cfqq = kmem_cache_alloc(cfq_pool, gfp_mask);
+			new_cfqq = kmem_cache_alloc(cfq_pool, gfp_mask|__GFP_NOFAIL);
 			spin_lock_irq(cfqd->queue->queue_lock);
 			goto retry;
 		} else {
@@ -1739,9 +1747,7 @@
 		cfq_resort_rr_list(cfqq, 0);
 }

-static inline int
-__cfq_may_queue(struct cfq_data *cfqd, struct cfq_queue *cfqq,
-		struct task_struct *task, int rw)
+static inline int __cfq_may_queue(struct cfq_queue *cfqq)
 {
 	if ((cfq_cfqq_wait_request(cfqq) || cfq_cfqq_must_alloc(cfqq)) &&
 	    !cfq_cfqq_must_alloc_slice(cfqq)) {
@@ -1769,25 +1775,10 @@
 		cfq_init_prio_data(cfqq);
 		cfq_prio_boost(cfqq);

-		return __cfq_may_queue(cfqd, cfqq, tsk, rw);
+		return __cfq_may_queue(cfqq);
 	}

 	return ELV_MQUEUE_MAY;
-}
-
-static void cfq_check_waiters(request_queue_t *q, struct cfq_queue *cfqq)
-{
-	struct cfq_data *cfqd = q->elevator->elevator_data;
-
-	if (unlikely(cfqd->rq_starved)) {
-		struct request_list *rl = &q->rq;
-
-		smp_mb();
-		if (waitqueue_active(&rl->wait[READ]))
-			wake_up(&rl->wait[READ]);
-		if (waitqueue_active(&rl->wait[WRITE]))
-			wake_up(&rl->wait[WRITE]);
-	}
 }

 /*
@@ -1808,7 +1799,6 @@
 		rq->elevator_private = NULL;
 		rq->elevator_private2 = NULL;

-		cfq_check_waiters(q, cfqq);
 		cfq_put_queue(cfqq);
 	}
 }
@@ -1848,7 +1838,6 @@

 	cfqq->allocated[rw]++;
 	cfq_clear_cfqq_must_alloc(cfqq);
-	cfqd->rq_starved = 0;
 	atomic_inc(&cfqq->ref);

 	spin_unlock_irqrestore(q->queue_lock, flags);
@@ -1860,12 +1849,7 @@
 queue_fail:
 	if (cic)
 		put_io_context(cic->ioc);
-	/*
-	 * mark us rq allocation starved. we need to kickstart the process
-	 * ourselves if there are no pending requests that can do it for us.
-	 * that would be an extremely rare OOM situation
-	 */
-	cfqd->rq_starved = 1;
+
 	cfq_schedule_dispatch(cfqd);
 	spin_unlock_irqrestore(q->queue_lock, flags);
 	return 1;
@@ -1874,25 +1858,9 @@
 static void cfq_kick_queue(void *data)
 {
 	request_queue_t *q = data;
-	struct cfq_data *cfqd = q->elevator->elevator_data;
 	unsigned long flags;

 	spin_lock_irqsave(q->queue_lock, flags);
-
-	if (cfqd->rq_starved) {
-		struct request_list *rl = &q->rq;
-
-		/*
-		 * we aren't guaranteed to get a request after this, but we
-		 * have to be opportunistic
-		 */
-		smp_mb();
-		if (waitqueue_active(&rl->wait[READ]))
-			wake_up(&rl->wait[READ]);
-		if (waitqueue_active(&rl->wait[WRITE]))
-			wake_up(&rl->wait[WRITE]);
-	}
-
 	blk_remove_plug(q);
 	q->request_fn(q);
 	spin_unlock_irqrestore(q->queue_lock, flags);
@@ -1987,16 +1955,8 @@
 		struct cfq_io_context *cic = list_entry(cfqd->cic_list.next,
 							struct cfq_io_context,
 							queue_list);
-		if (cic->cfqq[ASYNC]) {
-			cfq_put_queue(cic->cfqq[ASYNC]);
-			cic->cfqq[ASYNC] = NULL;
-		}
-		if (cic->cfqq[SYNC]) {
-			cfq_put_queue(cic->cfqq[SYNC]);
-			cic->cfqq[SYNC] = NULL;
-		}
-		cic->key = NULL;
-		list_del_init(&cic->queue_list);
+
+		__cfq_exit_single_io_context(cfqd, cic);
 	}

 	spin_unlock_irq(q->queue_lock);
@@ -2047,7 +2007,6 @@

 	INIT_WORK(&cfqd->unplug_work, cfq_kick_queue, q);

-	cfqd->cfq_queued = cfq_queued;
 	cfqd->cfq_quantum = cfq_quantum;
 	cfqd->cfq_fifo_expire[0] = cfq_fifo_expire[0];
 	cfqd->cfq_fifo_expire[1] = cfq_fifo_expire[1];
@@ -2119,7 +2078,6 @@
 	return cfq_var_show(__data, (page));				\
 }
 SHOW_FUNCTION(cfq_quantum_show, cfqd->cfq_quantum, 0);
-SHOW_FUNCTION(cfq_queued_show, cfqd->cfq_queued, 0);
 SHOW_FUNCTION(cfq_fifo_expire_sync_show, cfqd->cfq_fifo_expire[1], 1);
 SHOW_FUNCTION(cfq_fifo_expire_async_show, cfqd->cfq_fifo_expire[0], 1);
 SHOW_FUNCTION(cfq_back_seek_max_show, cfqd->cfq_back_max, 0);
@@ -2147,7 +2105,6 @@
 	return ret;							\
 }
 STORE_FUNCTION(cfq_quantum_store, &cfqd->cfq_quantum, 1, UINT_MAX, 0);
-STORE_FUNCTION(cfq_queued_store, &cfqd->cfq_queued, 1, UINT_MAX, 0);
 STORE_FUNCTION(cfq_fifo_expire_sync_store, &cfqd->cfq_fifo_expire[1], 1, UINT_MAX, 1);
 STORE_FUNCTION(cfq_fifo_expire_async_store, &cfqd->cfq_fifo_expire[0], 1, UINT_MAX, 1);
 STORE_FUNCTION(cfq_back_seek_max_store, &cfqd->cfq_back_max, 0, UINT_MAX, 0);
@@ -2163,7 +2120,6 @@

 static struct elv_fs_entry cfq_attrs[] = {
 	CFQ_ATTR(quantum),
-	CFQ_ATTR(queued),
 	CFQ_ATTR(fifo_expire_sync),
 	CFQ_ATTR(fifo_expire_async),
 	CFQ_ATTR(back_seek_max),


Add virtual for ~FileMonitor().

Add virtual for ~FileMonitor().

--- source/core/common/file-monitor/FileMonitor.h
+++ source/core/common/file-monitor/FileMonitor.h
@@ -20,7 +20,7 @@
 {
 public:
     FileMonitor();
-    ~FileMonitor();
+    virtual ~FileMonitor();

     bool addWatch(const std::string& path, uint32_t mask);


Optimized Phalcon\Paginator\Adapter\NativeArray

--- ext/paginator/adapter/nativearray.c
+++ ext/paginator/adapter/nativearray.c
@@ -70,7 +70,7 @@
 	PHALCON_REGISTER_CLASS(Phalcon\\Paginator\\Adapter, NativeArray, paginator_adapter_nativearray, phalcon_paginator_adapter_nativearray_method_entry, 0);

 	zend_declare_property_null(phalcon_paginator_adapter_nativearray_ce, SL("_limitRows"), ZEND_ACC_PROTECTED TSRMLS_CC);
-	zend_declare_property_null(phalcon_paginator_adapter_nativearray_ce, SL("_config"), ZEND_ACC_PROTECTED TSRMLS_CC);
+	zend_declare_property_null(phalcon_paginator_adapter_nativearray_ce, SL("_data"), ZEND_ACC_PROTECTED TSRMLS_CC);
 	zend_declare_property_null(phalcon_paginator_adapter_nativearray_ce, SL("_page"), ZEND_ACC_PROTECTED TSRMLS_CC);

 	zend_class_implements(phalcon_paginator_adapter_nativearray_ce TSRMLS_CC, 1, phalcon_paginator_adapterinterface_ce);
@@ -85,26 +85,29 @@
  */
 PHP_METHOD(Phalcon_Paginator_Adapter_NativeArray, __construct){

-	zval *config, *limit, *page;
+	zval *config, *limit, *page, *data;

-	PHALCON_MM_GROW();
-
-	phalcon_fetch_params(1, 1, 0, &config);
+	phalcon_fetch_params(0, 1, 0, &config);

-	phalcon_update_property_this(this_ptr, SL("_config"), config TSRMLS_CC);
-	if (phalcon_array_isset_string(config, SS("limit"))) {
-		PHALCON_OBS_VAR(limit);
-		phalcon_array_fetch_string(&limit, config, SL("limit"), PH_NOISY);
+	if (phalcon_array_isset_string_fetch(&limit, config, SS("limit"))) {
 		phalcon_update_property_this(this_ptr, SL("_limitRows"), limit TSRMLS_CC);
 	}

-	if (phalcon_array_isset_string(config, SS("page"))) {
-		PHALCON_OBS_VAR(page);
-		phalcon_array_fetch_string(&page, config, SL("page"), PH_NOISY);
+	if (phalcon_array_isset_string_fetch(&page, config, SS("page"))) {
 		phalcon_update_property_this(this_ptr, SL("_page"), page TSRMLS_CC);
 	}
-
-	PHALCON_MM_RESTORE();
+
+	if (!phalcon_array_isset_string_fetch(&data, config, SS("data"))) {
+		PHALCON_THROW_EXCEPTION_STRW(phalcon_paginator_exception_ce, "Parameter 'data' is required");
+		return;
+	}
+
+	if (Z_TYPE_P(data) != IS_ARRAY) {
+		PHALCON_THROW_EXCEPTION_STRW(phalcon_paginator_exception_ce, "'data' should be an array");
+		return;
+	}
+
+	phalcon_update_property_this(this_ptr, SL("_data"), data TSRMLS_CC);
 }

 /**
@@ -114,11 +117,12 @@
  */
 PHP_METHOD(Phalcon_Paginator_Adapter_NativeArray, setCurrentPage){

-	zval *page;
+	zval **current_page;

-	phalcon_fetch_params(0, 1, 0, &page);
+	phalcon_fetch_params_ex(1, 0, &current_page);
+	PHALCON_ENSURE_IS_LONG(current_page);

-	phalcon_update_property_this(this_ptr, SL("_page"), page TSRMLS_CC);
+	phalcon_update_property_this(this_ptr, SL("_page"), *current_page TSRMLS_CC);
 	RETURN_THISW();
 }

@@ -129,86 +133,57 @@
  */
 PHP_METHOD(Phalcon_Paginator_Adapter_NativeArray, getPaginate){

-	zval *z_one, *config, *items, *show, *page_number = NULL, *page;
-	zval *number, *rounded_total, *total_pages, *before_page_number;
-	zval *start, *slice, *next = NULL, *before = NULL;
+	zval *items, *limit, *number_page, *lim;
+	zval *start, *slice = NULL;
+	long int i_limit, i_number_page, i_number, i_before, i_rowcount;
+	long int i_total_pages, i_next;
+	ldiv_t tp;

-	PHALCON_MM_GROW();
-
-	/**
-	 * TODO: Rewrite the whole method!
-	 */
-	z_one = PHALCON_GLOBAL(z_one);
-
-	PHALCON_OBS_VAR(config);
-	phalcon_read_property_this(&config, this_ptr, SL("_config"), PH_NOISY_CC);
-
-	PHALCON_OBS_VAR(items);
-	phalcon_array_fetch_string(&items, config, SL("data"), PH_NOISY);
-	if (Z_TYPE_P(items) != IS_ARRAY) {
-		PHALCON_THROW_EXCEPTION_STR(phalcon_paginator_exception_ce, "Invalid data for paginator");
+	items = phalcon_fetch_nproperty_this(this_ptr, SL("_data"), PH_NOISY TSRMLS_CC);
+	if (UNEXPECTED(Z_TYPE_P(items) != IS_ARRAY)) {
+		PHALCON_THROW_EXCEPTION_STRW(phalcon_paginator_exception_ce, "Invalid data for paginator");
 		return;
 	}
+
+	limit         = phalcon_fetch_nproperty_this(this_ptr, SL("_limitRows"), PH_NOISY_CC);
+	number_page   = phalcon_fetch_nproperty_this(this_ptr, SL("_page"), PH_NOISY_CC);
+	i_limit       = phalcon_get_intval(limit);
+	i_number_page = phalcon_get_intval(number_page);
+
+	if (i_limit < 1) {
+		/* This should never happen unless someone deliberately modified the properties of the object */
+		i_limit = 10;
+	}
+
+	if (!i_number_page) {
+		i_number_page = 1;
+	}
+
+	i_number      = (i_number_page - 1) * i_limit;
+	i_before      = (i_number_page == 1) ? 1 : (i_number_page - 1);
+	i_rowcount    = zend_hash_num_elements(Z_ARRVAL_P(items));
+	tp            = ldiv(i_rowcount, i_limit);
+	i_total_pages = tp.quot + (tp.rem ? 1 : 0);
+	i_next        = (i_number_page < i_total_pages) ? (i_number_page + 1) : i_total_pages;
+
+	PHALCON_ALLOC_GHOST_ZVAL(start);
+	PHALCON_ALLOC_GHOST_ZVAL(lim);
+	ZVAL_LONG(start, i_number);
+	ZVAL_LONG(lim, i_limit);
+	phalcon_call_func_params(slice, &slice, SL("array_slice") TSRMLS_CC, 3, items, start, lim);
+	if (UNEXPECTED(EG(exception) != NULL)) {
+		return;
+	}
+
+	Z_DELREF_P(slice);

-	PHALCON_OBS_VAR(show);
-	phalcon_read_property_this(&show, this_ptr, SL("_limitRows"), PH_NOISY_CC);
-
-	PHALCON_OBS_VAR(page_number);
-	phalcon_read_property_this(&page_number, this_ptr, SL("_page"), PH_NOISY_CC);
-	if (!zend_is_true(page_number)) {
-		PHALCON_CPY_WRT_CTOR(page_number, z_one);
-	}
-
-	PHALCON_INIT_VAR(page);
-	object_init(page);
-
-	PHALCON_INIT_VAR(number);
-	phalcon_fast_count(number, items TSRMLS_CC);
-
-	PHALCON_INIT_VAR(rounded_total);
-	div_function(rounded_total, number, show TSRMLS_CC);
-
-	PHALCON_INIT_VAR(total_pages);
-	ZVAL_LONG(total_pages, phalcon_get_intval(rounded_total));
-
-	/**
-	 * Increase total_pages if wasn't integer
-	 */
-	if (!PHALCON_IS_EQUAL(total_pages, rounded_total)) {
-		phalcon_increment(total_pages);
-	}
-
-	PHALCON_INIT_VAR(before_page_number);
-	sub_function(before_page_number, page_number, z_one TSRMLS_CC);
-
-	PHALCON_INIT_VAR(start);
-	mul_function(start, show, before_page_number TSRMLS_CC);
-
-	PHALCON_INIT_VAR(slice);
-	phalcon_call_func_p3(slice, "array_slice", items, start, show);
-	phalcon_update_property_zval(page, SL("items"), slice TSRMLS_CC);
-	if (PHALCON_LT(page_number, total_pages)) {
-		PHALCON_INIT_VAR(next);
-		phalcon_add_function(next, page_number, z_one TSRMLS_CC);
-	} else {
-		PHALCON_CPY_WRT(next, total_pages);
-	}
-
-	phalcon_update_property_zval(page, SL("next"), next TSRMLS_CC);
-	if (PHALCON_GT(page_number, z_one)) {
-		PHALCON_INIT_VAR(before);
-		sub_function(before, page_number, z_one TSRMLS_CC);
-	} else {
-		PHALCON_CPY_WRT_CTOR(before, z_one);
-	}
-
-	phalcon_update_property_zval(page, SL("first"), z_one TSRMLS_CC);
-	phalcon_update_property_zval(page, SL("before"), before TSRMLS_CC);
-	phalcon_update_property_zval(page, SL("current"), page_number TSRMLS_CC);
-	phalcon_update_property_zval(page, SL("last"), total_pages TSRMLS_CC);
-	phalcon_update_property_zval(page, SL("total_pages"), total_pages TSRMLS_CC);
-	phalcon_update_property_zval(page, SL("total_items"), number TSRMLS_CC);
-
-	RETURN_CTOR(page);
+	object_init(return_value);
+	phalcon_update_property_zval(return_value, SL("items"),       slice TSRMLS_CC);
+	phalcon_update_property_long(return_value, SL("before"),      i_before TSRMLS_CC);
+	phalcon_update_property_long(return_value, SL("first"),       1 TSRMLS_CC);
+	phalcon_update_property_long(return_value, SL("next"),        i_next TSRMLS_CC);
+	phalcon_update_property_long(return_value, SL("last"),        i_total_pages TSRMLS_CC);
+	phalcon_update_property_long(return_value, SL("current"),     i_number_page TSRMLS_CC);
+	phalcon_update_property_long(return_value, SL("total_pages"), i_total_pages TSRMLS_CC);
+	phalcon_update_property_long(return_value, SL("total_items"), i_rowcount TSRMLS_CC);
 }
-


[PATCH] cfq-iosched: tighten allow merge criteria

The logic in cfq_allow_merge() wasn't clear enough - basically allow
merging for the same queues only.  Do a fast check for 'rq and bio both
sync/async' before doing the cfqq hash lookup.

This is verified to work with the fixed elv_try_merge() from commit
bb4067e34159648d394943d5e2a011f838bff22f.

Signed-off-by: Jens Axboe <165ab144a3ccfd9429d5c6466b275f24fafdb114@oracle.com>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@osdl.org>

--- block/cfq-iosched.c
+++ block/cfq-iosched.c
@@ -577,25 +577,20 @@
 	pid_t key;

 	/*
-	 * If bio is async or a write, always allow merge
-	 */
-	if (!bio_sync(bio) || rw == WRITE)
+	 * Disallow merge, if bio and rq aren't both sync or async
+	 */
+	if (!!bio_sync(bio) != !!rq_is_sync(rq))
+		return 0;
+
+	/*
+	 * Lookup the cfqq that this bio will be queued with. Allow
+	 * merge only if rq is queued there.
+	 */
+	key = cfq_queue_pid(current, rw, bio_sync(bio));
+	cfqq = cfq_find_cfq_hash(cfqd, key, current->ioprio);
+
+	if (cfqq == RQ_CFQQ(rq))
 		return 1;
-
-	/*
-	 * bio is sync. if request is not, disallow.
-	 */
-	if (!rq_is_sync(rq))
-		return 0;
-
-	/*
-	 * Ok, both bio and request are sync. Allow merge if they are
-	 * from the same queue.
-	 */
-	key = cfq_queue_pid(current, rw, 1);
-	cfqq = cfq_find_cfq_hash(cfqd, key, current->ioprio);
-	if (cfqq != RQ_CFQQ(rq))
-		return 0;

 	return 1;
 }


extend epoch around the full set of events from epoll

The observation was that a mixture of timer and fd events coming back in
a batch would operate on the same job; one would cause the underlying
data to be ph_job_free()'d and reaped by the time the second one was
dispatched.

The equivalent to this should also be applied to the other nbio
implementations.

Also: fix missing mask assignment in the removal case.

--- corelib/nbio/epoll.c
+++ corelib/nbio/epoll.c
@@ -130,11 +130,21 @@
       ph_thread_epoch_poll();
       continue;
     }
+
+    if (n == 0) {
+      continue;
+    }
+
+    ph_thread_epoch_begin();
     for (i = 0; i < n; i++) {
       ph_iomask_t mask = 0;
       ph_job_t *job = event[i].data.ptr;

-      ph_thread_epoch_begin();
+      if (job->mask == 0) {
+        // Ignore: disabled for now
+        continue;
+      }
+
       switch (event[i].events & (EPOLLIN|EPOLLOUT|EPOLLERR|EPOLLHUP)) {
         case EPOLLIN:
           mask = PH_IOMASK_READ;
@@ -156,10 +166,10 @@
       if (ph_job_have_deferred_items(thread)) {
         ph_job_pool_apply_deferred_items(thread);
       }
-      ph_thread_epoch_end();
-      ph_job_collector_emitter_call(emitter);
-      ph_thread_epoch_poll();
-    }
+    }
+    ph_thread_epoch_end();
+    ph_job_collector_emitter_call(emitter);
+    ph_thread_epoch_poll();
   }

   free(event);
@@ -193,6 +203,8 @@
   }

   if (want_mask == 0) {
+    job->mask = 0;
+    job->kmask = 0;
     res = epoll_ctl(emitter->io_fd, EPOLL_CTL_DEL, job->fd, &evt);
     if (res < 0 && errno == ENOENT) {
       res = 0;


bloog: add SKU IDs

bloog: add SKU IDs

BUG=b:132037233
BRANCH=octopus
TEST=make buildall -j

Change-Id: Ifd2d9fdc8c9e9a8a003564d4fb0fa561d3668c5c
Signed-off-by: Devin Lu <052fe648504800b810f29702ef4f3db83fad68bf@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/1598388
Commit-Ready: ChromeOS CL Exonerator Bot <fa429e5907f00867f797423aea74327bb02c91b6@appspot.gserviceaccount.com>
Reviewed-by: Marco Chen <cddf73c2eeb445eb5022e73c23b1c49a27aefb07@chromium.org>

--- board/bloog/board.c
+++ board/bloog/board.c
@@ -211,12 +211,13 @@
 int board_is_convertible(void)
 {
 	/*
-	 * Bloog: 33, 34, 35
-	 * Blooguard: 49, 50
+	 * Bloog: 33, 34, 35, 36
+	 * Blooguard: 49, 50, 51, 52
 	 * Unprovisioned: 255
 	 */
-	return sku_id == 33 || sku_id == 34 || sku_id == 35 || sku_id == 49
-		|| sku_id == 50 || sku_id == 255;
+	return sku_id == 33 || sku_id == 34 || sku_id == 35 || sku_id == 36
+		|| sku_id == 49 || sku_id == 50 || sku_id == 51 || sku_id == 52
+		|| sku_id == 255;
 }

 static void board_update_sensor_config_from_sku(void)
@@ -312,7 +313,7 @@
 	/*
 	 * Remove keyboard backlight feature for devices that don't support it.
 	 */
-	if (sku_id == 33)
+	if (sku_id == 33 || sku_id == 36 || sku_id == 51 || sku_id == 52)
 		return (flags0 & ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB));
 	else
 		return flags0;


board/dooly/board.h: Format with clang-format

BUG=b:236386294
BRANCH=none
TEST=none

Change-Id: Id7cc49ca9abb3de56ddc8d1a2634d443382605a0
Signed-off-by: Jack Rosenthal <d3f605bef1867f59845d4ce6e4f83b8dc9e4e0ae@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3726417
Reviewed-by: Jeremy Bettis <4df7b5147fee087dca33c181f288ee7dbf56e022@chromium.org>

--- board/dooly/board.h
+++ board/dooly/board.h
@@ -15,13 +15,13 @@
  * By default, enable all console messages except HC, ACPI and event:
  * The sensor stack is generating a lot of activity.
  */
-#define CC_DEFAULT     (CC_ALL & ~(CC_MASK(CC_EVENTS) | CC_MASK(CC_LPC)))
+#define CC_DEFAULT (CC_ALL & ~(CC_MASK(CC_EVENTS) | CC_MASK(CC_LPC)))
 #undef CONFIG_HOSTCMD_DEBUG_MODE
 #define CONFIG_HOSTCMD_DEBUG_MODE HCDEBUG_OFF

 /* NPCX7 config */
-#define NPCX7_PWM1_SEL    0  /* GPIO C2 is not used as PWM1. */
-#define NPCX_UART_MODULE2 1  /* GPIO64/65 are used as UART pins. */
+#define NPCX7_PWM1_SEL 0 /* GPIO C2 is not used as PWM1. */
+#define NPCX_UART_MODULE2 1 /* GPIO64/65 are used as UART pins. */

 /* Internal SPI flash on NPCX796FC is 512 kB */
 #define CONFIG_FLASH_SIZE_BYTES (512 * 1024)
@@ -49,14 +49,13 @@

 /* TCS3400 ALS */
 #define CONFIG_ALS
-#define ALS_COUNT	1
+#define ALS_COUNT 1
 #define CONFIG_ALS_TCS3400
-#define CONFIG_ALS_TCS3400_INT_EVENT\
+#define CONFIG_ALS_TCS3400_INT_EVENT \
 	TASK_EVENT_MOTION_SENSOR_INTERRUPT(CLEAR_ALS)

 /* Sensors without hardware FIFO are in forced mode */
-#define CONFIG_ACCEL_FORCE_MODE_MASK \
-	(BIT(SCREEN_ACCEL) | BIT(CLEAR_ALS))
+#define CONFIG_ACCEL_FORCE_MODE_MASK (BIT(SCREEN_ACCEL) | BIT(CLEAR_ALS))

 /* EC Defines */
 #define CONFIG_ADC
@@ -74,7 +73,7 @@
 #undef CONFIG_HIBERNATE
 #define CONFIG_HOST_INTERFACE_ESPI
 #define CONFIG_LED_COMMON
-#undef  CONFIG_LID_SWITCH
+#undef CONFIG_LID_SWITCH
 #define CONFIG_LTO
 #define CONFIG_PWM
 #define CONFIG_VBOOT_EFS2
@@ -82,7 +81,6 @@
 #define CONFIG_VSTORE
 #define CONFIG_VSTORE_SLOT_COUNT 1
 #define CONFIG_SHA256
-

 /* EC Commands */
 #define CONFIG_CMD_BUTTON
@@ -120,7 +118,7 @@
 #define CONFIG_CPU_PROCHOT_ACTIVE_LOW

 /* Dedicated barreljack charger port */
-#undef  CONFIG_DEDICATED_CHARGE_PORT_COUNT
+#undef CONFIG_DEDICATED_CHARGE_PORT_COUNT
 #define CONFIG_DEDICATED_CHARGE_PORT_COUNT 1
 #define DEDICATED_CHARGE_PORT 2

@@ -141,15 +139,15 @@
 #define CONFIG_INA3221

 /* b/143501304 */
-#define PD_POWER_SUPPLY_TURN_ON_DELAY	4000	/* us */
-#define PD_POWER_SUPPLY_TURN_OFF_DELAY	2000	/* us */
+#define PD_POWER_SUPPLY_TURN_ON_DELAY 4000 /* us */
+#define PD_POWER_SUPPLY_TURN_OFF_DELAY 2000 /* us */
 #undef CONFIG_USBC_VCONN_SWAP_DELAY_US
-#define CONFIG_USBC_VCONN_SWAP_DELAY_US		8000	/* us */
-
-#define PD_OPERATING_POWER_MW	CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
-#define PD_MAX_POWER_MW		100000
-#define PD_MAX_CURRENT_MA	5000
-#define PD_MAX_VOLTAGE_MV	20000
+#define CONFIG_USBC_VCONN_SWAP_DELAY_US 8000 /* us */
+
+#define PD_OPERATING_POWER_MW CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
+#define PD_MAX_POWER_MW 100000
+#define PD_MAX_CURRENT_MA 5000
+#define PD_MAX_VOLTAGE_MV 20000

 /* Fan and temp. */
 #define CONFIG_FANS 1
@@ -173,7 +171,7 @@
 #define CONFIG_USB_PD_DECODE_SOP
 #undef CONFIG_USB_CHARGER
 #define CONFIG_USB_POWER_DELIVERY
-#define CONFIG_USB_PID		0x5040
+#define CONFIG_USB_PID 0x5040
 #define CONFIG_USB_PD_ALT_MODE
 #define CONFIG_USB_PD_ALT_MODE_DFP
 #define CONFIG_USB_PD_DISCHARGE_PPC
@@ -193,10 +191,10 @@
 #define CONFIG_USBC_VCONN
 #define CONFIG_USBC_VCONN_SWAP

-#define USB_PD_PORT_TCPC_0	0
+#define USB_PD_PORT_TCPC_0 0
 #define BOARD_TCPC_C0_RESET_HOLD_DELAY ANX74XX_RESET_HOLD_MS
 #define BOARD_TCPC_C0_RESET_POST_DELAY ANX74XX_RESET_HOLD_MS
-#define USB_PD_PORT_TCPC_1	1
+#define USB_PD_PORT_TCPC_1 1
 #define BOARD_TCPC_C1_RESET_HOLD_DELAY ANX74XX_RESET_HOLD_MS
 #define BOARD_TCPC_C1_RESET_POST_DELAY ANX74XX_RESET_HOLD_MS

@@ -208,16 +206,16 @@
 /* I2C Bus Configuration */
 #define CONFIG_I2C
 #define CONFIG_I2C_CONTROLLER
-#define I2C_PORT_INA		NPCX_I2C_PORT0_0
-#define I2C_PORT_SENSORS	NPCX_I2C_PORT0_0
-#define I2C_PORT_PPC0		NPCX_I2C_PORT1_0
-#define I2C_PORT_PPC1		NPCX_I2C_PORT2_0
-#define I2C_PORT_TCPC0		NPCX_I2C_PORT3_0
-#define I2C_PORT_TCPC1		NPCX_I2C_PORT4_1
-#define I2C_PORT_POWER		NPCX_I2C_PORT5_0
-#define I2C_PORT_EEPROM		NPCX_I2C_PORT7_0
-#define I2C_ADDR_EEPROM_FLAGS	0x50
-#define I2C_PORT_BACKLIGHT	NPCX_I2C_PORT7_0
+#define I2C_PORT_INA NPCX_I2C_PORT0_0
+#define I2C_PORT_SENSORS NPCX_I2C_PORT0_0
+#define I2C_PORT_PPC0 NPCX_I2C_PORT1_0
+#define I2C_PORT_PPC1 NPCX_I2C_PORT2_0
+#define I2C_PORT_TCPC0 NPCX_I2C_PORT3_0
+#define I2C_PORT_TCPC1 NPCX_I2C_PORT4_1
+#define I2C_PORT_POWER NPCX_I2C_PORT5_0
+#define I2C_PORT_EEPROM NPCX_I2C_PORT7_0
+#define I2C_ADDR_EEPROM_FLAGS 0x50
+#define I2C_PORT_BACKLIGHT NPCX_I2C_PORT7_0

 /*
  * LED backlight controller
@@ -239,11 +237,11 @@
 };

 enum adc_channel {
-	ADC_SNS_PP3300,     /* ADC2 */
-	ADC_SNS_PP1050,     /* ADC7 */
-	ADC_VBUS,           /* ADC4 */
-	ADC_PPVAR_IMON,     /* ADC9 */
-	ADC_TEMP_SENSOR_1,  /* ADC0 */
+	ADC_SNS_PP3300, /* ADC2 */
+	ADC_SNS_PP1050, /* ADC7 */
+	ADC_VBUS, /* ADC4 */
+	ADC_PPVAR_IMON, /* ADC9 */
+	ADC_TEMP_SENSOR_1, /* ADC0 */
 	/* Number of ADC channels */
 	ADC_CH_COUNT
 };
@@ -268,10 +266,7 @@
 	MFT_CH_COUNT,
 };

-enum temp_sensor_id {
-	TEMP_SENSOR_1,
-	TEMP_SENSOR_COUNT
-};
+enum temp_sensor_id { TEMP_SENSOR_1, TEMP_SENSOR_COUNT };

 enum sensor_id {
 	SCREEN_ACCEL = 0,
@@ -286,7 +281,6 @@
 	SSFC_LED_COUNT,
 };

-
 /* Board specific handlers */
 void board_reset_pd_mcu(void);
 void board_set_tcpc_power_mode(int port, int mode);
@@ -299,20 +293,20 @@
 /*
  * Barrel-jack power (4 bits).
  */
-#define EC_CFG_BJ_POWER_L		0
-#define EC_CFG_BJ_POWER_H		3
+#define EC_CFG_BJ_POWER_L 0
+#define EC_CFG_BJ_POWER_H 3
 #define EC_CFG_BJ_POWER_MASK GENMASK(EC_CFG_BJ_POWER_H, EC_CFG_BJ_POWER_L)
 /*
  * USB Connector 4 not present (1 bit) (not used).
  */
-#define EC_CFG_NO_USB4_L		4
-#define EC_CFG_NO_USB4_H		4
+#define EC_CFG_NO_USB4_L 4
+#define EC_CFG_NO_USB4_H 4
 #define EC_CFG_NO_USB4_MASK GENMASK(EC_CFG_NO_USB4_H, EC_CFG_NO_USB4_L)
 /*
  * Thermal solution config (3 bits).
  */
-#define EC_CFG_THERMAL_L		5
-#define EC_CFG_THERMAL_H		7
+#define EC_CFG_THERMAL_L 5
+#define EC_CFG_THERMAL_H 7
 #define EC_CFG_THERMAL_MASK GENMASK(EC_CFG_THERMAL_H, EC_CFG_THERMAL_L)

 /*
@@ -321,10 +315,9 @@
 /*
  * Led driver IC (2 bits).
  */
-#define EC_SSFC_LED_L		0
-#define EC_SSFC_LED_H		1
+#define EC_SSFC_LED_L 0
+#define EC_SSFC_LED_H 1
 #define EC_SSFC_LED_MASK GENMASK(EC_SSFC_LED_H, EC_SSFC_LED_L)
-

 unsigned int ec_config_get_bj_power(void);
 unsigned int ec_config_get_thermal_solution(void);
@@ -335,31 +328,31 @@
 #endif /* !__ASSEMBLER__ */

 /* Pin renaming */
-#define GPIO_WP_L               GPIO_EC_WP_ODL
-#define GPIO_PP5000_A_PG_OD     GPIO_PG_PP5000_A_OD
-#define GPIO_EN_PP5000		GPIO_EN_PP5000_A
-#define GPIO_RECOVERY_L         GPIO_EC_RECOVERY_BTN_ODL
-#define GPIO_POWER_BUTTON_L	GPIO_H1_EC_PWR_BTN_ODL
-#define GPIO_VOLUME_UP_L	GPIO_EC_VOLUP_BTN_ODL
-#define GPIO_VOLUME_DOWN_L	GPIO_EC_VOLDN_BTN_ODL
-#define GPIO_PCH_WAKE_L		GPIO_EC_PCH_WAKE_ODL
-#define GPIO_PCH_PWRBTN_L	GPIO_EC_PCH_PWR_BTN_ODL
-#define GPIO_ENTERING_RW	GPIO_EC_ENTERING_RW
-#define GPIO_SYS_RESET_L	GPIO_SYS_RST_ODL
-#define GPIO_PCH_RSMRST_L	GPIO_EC_PCH_RSMRST_L
-#define GPIO_CPU_PROCHOT	GPIO_EC_PROCHOT_ODL
-#define GPIO_PCH_RTCRST		GPIO_EC_PCH_RTCRST
-#define GPIO_PCH_SYS_PWROK	GPIO_EC_PCH_SYS_PWROK
-#define GPIO_PCH_SLP_S0_L	GPIO_SLP_S0_L
-#define GPIO_PCH_SLP_S3_L	GPIO_SLP_S3_L
-#define GPIO_PCH_SLP_S4_L	GPIO_SLP_S4_L
-#define GPIO_TEMP_SENSOR_POWER	GPIO_EN_ROA_RAILS
-#define GPIO_AC_PRESENT		GPIO_BJ_ADP_PRESENT_L
+#define GPIO_WP_L GPIO_EC_WP_ODL
+#define GPIO_PP5000_A_PG_OD GPIO_PG_PP5000_A_OD
+#define GPIO_EN_PP5000 GPIO_EN_PP5000_A
+#define GPIO_RECOVERY_L GPIO_EC_RECOVERY_BTN_ODL
+#define GPIO_POWER_BUTTON_L GPIO_H1_EC_PWR_BTN_ODL
+#define GPIO_VOLUME_UP_L GPIO_EC_VOLUP_BTN_ODL
+#define GPIO_VOLUME_DOWN_L GPIO_EC_VOLDN_BTN_ODL
+#define GPIO_PCH_WAKE_L GPIO_EC_PCH_WAKE_ODL
+#define GPIO_PCH_PWRBTN_L GPIO_EC_PCH_PWR_BTN_ODL
+#define GPIO_ENTERING_RW GPIO_EC_ENTERING_RW
+#define GPIO_SYS_RESET_L GPIO_SYS_RST_ODL
+#define GPIO_PCH_RSMRST_L GPIO_EC_PCH_RSMRST_L
+#define GPIO_CPU_PROCHOT GPIO_EC_PROCHOT_ODL
+#define GPIO_PCH_RTCRST GPIO_EC_PCH_RTCRST
+#define GPIO_PCH_SYS_PWROK GPIO_EC_PCH_SYS_PWROK
+#define GPIO_PCH_SLP_S0_L GPIO_SLP_S0_L
+#define GPIO_PCH_SLP_S3_L GPIO_SLP_S3_L
+#define GPIO_PCH_SLP_S4_L GPIO_SLP_S4_L
+#define GPIO_TEMP_SENSOR_POWER GPIO_EN_ROA_RAILS
+#define GPIO_AC_PRESENT GPIO_BJ_ADP_PRESENT_L

 /*
  * There is no RSMRST input, so alias it to the output. This short-circuits
  * common_intel_x86_handle_rsmrst.
  */
-#define GPIO_PG_EC_RSMRST_ODL	GPIO_PCH_RSMRST_L
+#define GPIO_PG_EC_RSMRST_ODL GPIO_PCH_RSMRST_L

 #endif /* __CROS_EC_BOARD_H */


UART fix

UART fix

--- board_driver/uart.h
+++ board_driver/uart.h
@@ -3,8 +3,11 @@

 #include <stm32f4xx_hal.h>

+#define B1  0
+#define C10 0
+#define C6  1

-#if 1
+#if B1

 #define USARTx                           USART3
 #define USARTx_CLK_ENABLE()              __HAL_RCC_USART3_CLK_ENABLE()
@@ -32,7 +35,7 @@
 #define USARTx_DMA_TX_IRQHandler         DMA1_Stream3_IRQHandler
 #define USARTx_DMA_TX_IRQn               DMA1_Stream3_IRQn

-#else
+#elif C10

 #define USARTx                           UART4
 #define USARTx_CLK_ENABLE()              __HAL_RCC_UART4_CLK_ENABLE()
@@ -54,6 +57,28 @@
 #define USARTx_IRQn                      UART4_IRQn
 #define USARTx_IRQHandler                UART4_IRQHandler

+#elif C6
+
+#define USARTx                           USART6
+#define USARTx_CLK_ENABLE()              __HAL_RCC_USART6_CLK_ENABLE()
+#define USARTx_RX_GPIO_CLK_ENABLE()      __HAL_RCC_GPIOC_CLK_ENABLE()
+#define USARTx_TX_GPIO_CLK_ENABLE()      __HAL_RCC_GPIOC_CLK_ENABLE()
+
+#define USARTx_FORCE_RESET()             __HAL_RCC_USART6_FORCE_RESET()
+#define USARTx_RELEASE_RESET()           __HAL_RCC_USART6_RELEASE_RESET()
+
+/* Definition for UARTx Pins */
+#define USARTx_TX_PIN                    GPIO_PIN_6
+#define USARTx_TX_GPIO_PORT              GPIOC
+#define USARTx_TX_AF                     GPIO_AF8_USART6
+#define USARTx_RX_PIN                    GPIO_PIN_7
+#define USARTx_RX_GPIO_PORT              GPIOC
+#define USARTx_RX_AF                     GPIO_AF8_USART6
+
+/* Definition for UARTx's NVIC */
+#define USARTx_IRQn                      USART6_IRQn
+#define USARTx_IRQHandler                USART6_IRQHandler
+
 #endif


cpu/esp32: fix heap command output

cpu/esp32: fix heap command output

The heap command output has to have an output format that is compatible with the test.

--- cpu/esp32/syscalls.c
+++ cpu/esp32/syscalls.c
@@ -271,7 +271,7 @@

 void heap_stats(void)
 {
-    printf("heap: %u (used %u free %u)\n", (unsigned)(&_eheap - &_sheap),
+    printf("heap: %u (used %u, free %u) [bytes]\n", (unsigned)(&_eheap - &_sheap),
            &_eheap - &_sheap - get_free_heap_size(), get_free_heap_size());
 }