remote: Clean up coding style and refactor remote connection opening

Remove spaces before function calls and some other coding nits in some
parts of the remote driver and refactor getting of URI argument
components into variables used by libvirt later on.

--- src/remote/remote_driver.c
+++ src/remote/remote_driver.c
@@ -346,6 +346,29 @@
     virMutexUnlock(&conn->lock);
 }

+/* helper macro to ease extraction of arguments from the URI */
+#define EXTRACT_URI_ARG_STR(ARG_NAME, ARG_VAR)          \
+    if (STRCASEEQ(var->name, ARG_NAME)) {               \
+        VIR_FREE(ARG_VAR);                              \
+        if (!(ARG_VAR = strdup(var->value)))            \
+            goto no_memory;                             \
+        var->ignore = 1;                                \
+        continue;                                       \
+    }
+
+#define EXTRACT_URI_ARG_BOOL(ARG_NAME, ARG_VAR)                             \
+    if (STRCASEEQ(var->name, ARG_NAME)) {                                   \
+        int tmp;                                                            \
+        if (virStrToLong_i(var->value, NULL, 10, &tmp) < 0) {               \
+            virReportError(VIR_ERR_INVALID_ARG,                             \
+                           _("Failed to parse value of URI component %s"),  \
+                           var->name);                                      \
+            goto failed;                                                    \
+        }                                                                   \
+        ARG_VAR = tmp == 0;                                                 \
+        var->ignore = 1;                                                    \
+        continue;                                                           \
+    }
 /*
  * URIs that this driver needs to handle:
  *
@@ -364,10 +387,10 @@
  *   - xxx:///                -> UNIX domain socket
  */
 static int
-doRemoteOpen (virConnectPtr conn,
-              struct private_data *priv,
-              virConnectAuthPtr auth ATTRIBUTE_UNUSED,
-              unsigned int flags)
+doRemoteOpen(virConnectPtr conn,
+             struct private_data *priv,
+             virConnectAuthPtr auth ATTRIBUTE_UNUSED,
+             unsigned int flags)
 {
     char *transport_str = NULL;
     enum {
@@ -381,7 +404,7 @@
     const char *daemonPath;
 #endif

-    /* We handle *ALL*  URIs here. The caller has rejected any
+    /* We handle *ALL* URIs here. The caller has rejected any
      * URIs we don't care about */

     if (conn->uri) {
@@ -394,7 +417,7 @@

             transport = trans_unix;
         } else {
-            transport_str = get_transport_from_scheme (conn->uri->scheme);
+            transport_str = get_transport_from_scheme(conn->uri->scheme);

             if (!transport_str) {
                 if (conn->uri->server)
@@ -402,9 +425,9 @@
                 else
                     transport = trans_unix;
             } else {
-                if (STRCASEEQ (transport_str, "tls"))
+                if (STRCASEEQ(transport_str, "tls"))
                     transport = trans_tls;
-                else if (STRCASEEQ (transport_str, "unix")) {
+                else if (STRCASEEQ(transport_str, "unix")) {
                     if (conn->uri->server) {
                         virReportError(VIR_ERR_INVALID_ARG,
                                        _("using unix socket and remote "
@@ -414,11 +437,11 @@
                     } else {
                         transport = trans_unix;
                     }
-                } else if (STRCASEEQ (transport_str, "ssh"))
+                } else if (STRCASEEQ(transport_str, "ssh"))
                     transport = trans_ssh;
-                else if (STRCASEEQ (transport_str, "ext"))
+                else if (STRCASEEQ(transport_str, "ext"))
                     transport = trans_ext;
-                else if (STRCASEEQ (transport_str, "tcp"))
+                else if (STRCASEEQ(transport_str, "tcp"))
                     transport = trans_tcp;
                 else {
                     virReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -446,26 +469,27 @@

     /* Remote server defaults to "localhost" if not specified. */
     if (conn->uri && conn->uri->port != 0) {
-        if (virAsprintf(&port, "%d", conn->uri->port) == -1) goto out_of_memory;
+        if (virAsprintf(&port, "%d", conn->uri->port) < 0)
+            goto no_memory;
     } else if (transport == trans_tls) {
-        port = strdup (LIBVIRTD_TLS_PORT);
-        if (!port) goto out_of_memory;
+        if (!(port = strdup(LIBVIRTD_TLS_PORT)))
+            goto no_memory;
     } else if (transport == trans_tcp) {
-        port = strdup (LIBVIRTD_TCP_PORT);
-        if (!port) goto out_of_memory;
-    } else
-        port = NULL; /* Port not used for unix, ext., default for ssh */
-
-
-    priv->hostname = strdup (conn->uri && conn->uri->server ?
-                             conn->uri->server : "localhost");
+        if (!(port = strdup(LIBVIRTD_TCP_PORT)))
+            goto no_memory;
+    } /* Port not used for unix, ext., default for ssh */
+
+    if (conn->uri && conn->uri->server)
+        priv->hostname = strdup(conn->uri->server);
+    else
+        priv->hostname = strdup("localhost");
+
     if (!priv->hostname)
-        goto out_of_memory;
-    if (conn->uri && conn->uri->user) {
-        username = strdup (conn->uri->user);
-        if (!username)
-            goto out_of_memory;
-    }
+        goto no_memory;
+
+    if (conn->uri && conn->uri->user &&
+        !(username = strdup (conn->uri->user)))
+        goto no_memory;

     /* Get the variables from the query string.
      * Then we need to reconstruct the query string (because
@@ -477,56 +501,26 @@
     if (conn->uri) {
         for (i = 0; i < conn->uri->paramsCount ; i++) {
             virURIParamPtr var = &conn->uri->params[i];
-            if (STRCASEEQ (var->name, "name")) {
-                VIR_FREE(name);
-                name = strdup (var->value);
-                if (!name) goto out_of_memory;
-                var->ignore = 1;
-            } else if (STRCASEEQ (var->name, "command")) {
-                VIR_FREE(command);
-                command = strdup (var->value);
-                if (!command) goto out_of_memory;
-                var->ignore = 1;
-            } else if (STRCASEEQ (var->name, "socket")) {
-                VIR_FREE(sockname);
-                sockname = strdup (var->value);
-                if (!sockname) goto out_of_memory;
-                var->ignore = 1;
-            } else if (STRCASEEQ (var->name, "auth")) {
-                VIR_FREE(authtype);
-                authtype = strdup (var->value);
-                if (!authtype) goto out_of_memory;
-                var->ignore = 1;
-            } else if (STRCASEEQ (var->name, "netcat")) {
-                VIR_FREE(netcat);
-                netcat = strdup (var->value);
-                if (!netcat) goto out_of_memory;
-                var->ignore = 1;
-            } else if (STRCASEEQ (var->name, "keyfile")) {
-                VIR_FREE(keyfile);
-                keyfile = strdup (var->value);
-                if (!keyfile) goto out_of_memory;
-            } else if (STRCASEEQ (var->name, "no_sanity")) {
-                sanity = atoi(var->value) == 0;
-                var->ignore = 1;
-            } else if (STRCASEEQ (var->name, "no_verify")) {
-                verify = atoi (var->value) == 0;
-                var->ignore = 1;
-            } else if (STRCASEEQ (var->name, "no_tty")) {
-                tty = atoi (var->value) == 0;
-                var->ignore = 1;
-            } else if (STRCASEEQ(var->name, "pkipath")) {
-                VIR_FREE(pkipath);
-                pkipath = strdup(var->value);
-                if (!pkipath) goto out_of_memory;
-                var->ignore = 1;
-            } else if (STRCASEEQ(var->name, "authfile")) {
+            EXTRACT_URI_ARG_STR("name", name);
+            EXTRACT_URI_ARG_STR("command", command);
+            EXTRACT_URI_ARG_STR("socket", sockname);
+            EXTRACT_URI_ARG_STR("auth", authtype);
+            EXTRACT_URI_ARG_STR("netcat", netcat);
+            EXTRACT_URI_ARG_STR("keyfile", keyfile);
+            EXTRACT_URI_ARG_STR("pkipath", pkipath);
+
+            EXTRACT_URI_ARG_BOOL("no_sanity", sanity);
+            EXTRACT_URI_ARG_BOOL("no_verify", verify);
+            EXTRACT_URI_ARG_BOOL("no_tty", tty);
+
+            if (STRCASEEQ(var->name, "authfile")) {
                 /* Strip this param, used by virauth.c */
                 var->ignore = 1;
-            } else {
-                VIR_DEBUG("passing through variable '%s' ('%s') to remote end",
-                      var->name, var->value);
+                continue;
             }
+
+            VIR_DEBUG("passing through variable '%s' ('%s') to remote end",
+                       var->name, var->value);
         }

         /* Construct the original name. */
@@ -536,7 +530,7 @@
                  STRPREFIX(conn->uri->scheme, "remote+"))) {
                 /* Allow remote serve to probe */
                 if (!(name = strdup("")))
-                    goto out_of_memory;
+                    goto no_memory;
             } else {
                 virURI tmpuri = {
                     .scheme = conn->uri->scheme,
@@ -547,7 +541,7 @@

                 /* Evil, blank out transport scheme temporarily */
                 if (transport_str) {
-                    assert (transport_str[-1] == '+');
+                    assert(transport_str[-1] == '+');
                     transport_str[-1] = '\0';
                 }

@@ -566,7 +560,7 @@
     } else {
         /* Probe URI server side */
         if (!(name = strdup("")))
-            goto out_of_memory;
+            goto no_memory;
     }

     VIR_DEBUG("proceeding with name = %s", name);
@@ -577,7 +571,6 @@
                        _("remote_open: for 'ext' transport, command is required"));
         goto failed;
     }
-

     VIR_DEBUG("Connecting with transport %d", transport);
     /* Connect to the remote service. */
@@ -615,7 +608,7 @@

                 if (virAsprintf(&sockname, "%s/" LIBVIRTD_USER_UNIX_SOCKET, userdir) < 0) {
                     VIR_FREE(userdir);
-                    goto out_of_memory;
+                    goto no_memory;
                 }
                 VIR_FREE(userdir);
             } else {
@@ -624,7 +617,7 @@
                 else
                     sockname = strdup(LIBVIRTD_PRIV_UNIX_SOCKET);
                 if (sockname == NULL)
-                    goto out_of_memory;
+                    goto no_memory;
             }
             VIR_DEBUG("Proceeding with sockname %s", sockname);
         }
@@ -643,17 +636,16 @@
         break;

     case trans_ssh:
-        command = command ? command : strdup ("ssh");
-        if (command == NULL)
-            goto out_of_memory;
+        if (!command && !(command = strdup("ssh")))
+            goto no_memory;

         if (!sockname) {
             if (flags & VIR_DRV_OPEN_REMOTE_RO)
                 sockname = strdup(LIBVIRTD_PRIV_UNIX_SOCKET_RO);
             else
                 sockname = strdup(LIBVIRTD_PRIV_UNIX_SOCKET);
-            if (sockname == NULL)
-                goto out_of_memory;
+            if (!sockname)
+                goto no_memory;
         }

         if (!(priv->client = virNetClientNewSSH(priv->hostname,
@@ -743,9 +735,9 @@
         remote_open_args args = { &name, flags };

         VIR_DEBUG("Trying to open URI %s", name);
-        if (call (conn, priv, 0, REMOTE_PROC_OPEN,
-                  (xdrproc_t) xdr_remote_open_args, (char *) &args,
-                  (xdrproc_t) xdr_void, (char *) NULL) == -1)
+        if (call(conn, priv, 0, REMOTE_PROC_OPEN,
+                 (xdrproc_t) xdr_remote_open_args, (char *) &args,
+                 (xdrproc_t) xdr_void, (char *) NULL) == -1)
             goto failed;
     }

@@ -754,11 +746,11 @@
         remote_get_uri_ret uriret;

         VIR_DEBUG("Trying to query remote URI");
-        memset (&uriret, 0, sizeof(uriret));
-        if (call (conn, priv, 0,
-                  REMOTE_PROC_GET_URI,
-                  (xdrproc_t) xdr_void, (char *) NULL,
-                  (xdrproc_t) xdr_remote_get_uri_ret, (char *) &uriret) < 0)
+        memset(&uriret, 0, sizeof(uriret));
+        if (call(conn, priv, 0,
+                 REMOTE_PROC_GET_URI,
+                 (xdrproc_t) xdr_void, (char *) NULL,
+                 (xdrproc_t) xdr_remote_get_uri_ret, (char *) &uriret) < 0)
             goto failed;

         VIR_DEBUG("Auto-probed URI is %s", uriret.uri);
@@ -788,7 +780,7 @@

     return retcode;

- out_of_memory:
+no_memory:
     virReportOOMError();

  failed:
@@ -801,6 +793,8 @@
     VIR_FREE(priv->hostname);
     goto cleanup;
 }
+#undef EXTRACT_URI_ARG_STR
+#undef EXTRACT_URI_ARG_BOOL

 static struct private_data *
 remoteAllocPrivateData(void)
@@ -924,23 +918,23 @@

 /* In a string "driver+transport" return a pointer to "transport". */
 static char *
-get_transport_from_scheme (char *scheme)
-{
-    char *p = strchr (scheme, '+');
-    return p ? p+1 : 0;
+get_transport_from_scheme(char *scheme)
+{
+    char *p = strchr(scheme, '+');
+    return p ? p + 1 : NULL;
 }

 /*----------------------------------------------------------------------*/

 static int
-doRemoteClose (virConnectPtr conn, struct private_data *priv)
+doRemoteClose(virConnectPtr conn, struct private_data *priv)
 {
     int ret = 0;

-    if (call (conn, priv, 0, REMOTE_PROC_CLOSE,
-              (xdrproc_t) xdr_void, (char *) NULL,
-              (xdrproc_t) xdr_void, (char *) NULL) == -1)
+    if (call(conn, priv, 0, REMOTE_PROC_CLOSE,
+             (xdrproc_t) xdr_void, (char *) NULL,
+             (xdrproc_t) xdr_void, (char *) NULL) == -1)
         ret = -1;

     virObjectUnref(priv->tls);
@@ -965,7 +959,7 @@
 }

 static int
-remoteClose (virConnectPtr conn)
+remoteClose(virConnectPtr conn)
 {
     int ret = 0;
     struct private_data *priv = conn->privateData;
@@ -995,7 +989,7 @@
  * http://www.redhat.com/archives/libvir-list/2007-February/msg00096.html
  */
 static const char *
-remoteType (virConnectPtr conn)
+remoteType(virConnectPtr conn)
 {
     char *rv = NULL;
     remote_get_type_ret ret;
@@ -1009,10 +1003,10 @@
         goto done;
     }

-    memset (&ret, 0, sizeof(ret));
-    if (call (conn, priv, 0, REMOTE_PROC_GET_TYPE,
-              (xdrproc_t) xdr_void, (char *) NULL,
-              (xdrproc_t) xdr_remote_get_type_ret, (char *) &ret) == -1)
+    memset(&ret, 0, sizeof(ret));
+    if (call(conn, priv, 0, REMOTE_PROC_GET_TYPE,
+             (xdrproc_t) xdr_void, (char *) NULL,
+             (xdrproc_t) xdr_remote_get_type_ret, (char *) &ret) == -1)
         goto done;

     /* Stash. */
@@ -1030,10 +1024,10 @@
     remote_is_secure_ret ret;
     remoteDriverLock(priv);

-    memset (&ret, 0, sizeof(ret));
-    if (call (conn, priv, 0, REMOTE_PROC_IS_SECURE,
-              (xdrproc_t) xdr_void, (char *) NULL,
-              (xdrproc_t) xdr_remote_is_secure_ret, (char *) &ret) == -1)
+    memset(&ret, 0, sizeof(ret));
+    if (call(conn, priv, 0, REMOTE_PROC_IS_SECURE,
+             (xdrproc_t) xdr_void, (char *) NULL,
+             (xdrproc_t) xdr_remote_is_secure_ret, (char *) &ret) == -1)
         goto done;

     /* We claim to be secure, if the remote driver
@@ -1059,10 +1053,10 @@
     remote_is_secure_ret ret;
     remoteDriverLock(priv);

-    memset (&ret, 0, sizeof(ret));
-    if (call (conn, priv, 0, REMOTE_PROC_IS_SECURE,
-              (xdrproc_t) xdr_void, (char *) NULL,
-              (xdrproc_t) xdr_remote_is_secure_ret, (char *) &ret) == -1)
+    memset(&ret, 0, sizeof(ret));
+    if (call(conn, priv, 0, REMOTE_PROC_IS_SECURE,
+             (xdrproc_t) xdr_void, (char *) NULL,
+             (xdrproc_t) xdr_remote_is_secure_ret, (char *) &ret) == -1)
         goto done;

     if (virNetClientIsEncrypted(priv->client))
@@ -1084,10 +1078,10 @@
 }

 static int
-remoteNodeGetCPUStats (virConnectPtr conn,
-                       int cpuNum,
-                       virNodeCPUStatsPtr params, int *nparams,
-                       unsigned int flags)
+remoteNodeGetCPUStats(virConnectPtr conn,
+                      int cpuNum,
+                      virNodeCPUStatsPtr params, int *nparams,
+                      unsigned int flags)
 {
     int rv = -1;
     remote_node_get_cpu_stats_args args;
@@ -1101,12 +1095,12 @@
     args.cpuNum = cpuNum;
     args.flags = flags;

-    memset (&ret, 0, sizeof(ret));
-    if (call (conn, priv, 0, REMOTE_PROC_NODE_GET_CPU_STATS,
-              (xdrproc_t) xdr_remote_node_get_cpu_stats_args,
-              (char *) &args,
-              (xdrproc_t) xdr_remote_node_get_cpu_stats_ret,
-              (char *) &ret) == -1)
+    memset(&ret, 0, sizeof(ret));
+    if (call(conn, priv, 0, REMOTE_PROC_NODE_GET_CPU_STATS,
+             (xdrproc_t) xdr_remote_node_get_cpu_stats_args,
+             (char *) &args,
+             (xdrproc_t) xdr_remote_node_get_cpu_stats_ret,
+             (char *) &ret) == -1)
         goto done;

     /* Check the length of the returned list carefully. */
@@ -1142,18 +1136,18 @@
     rv = 0;

 cleanup:
-    xdr_free ((xdrproc_t) xdr_remote_node_get_cpu_stats_ret,
-              (char *) &ret);
+    xdr_free((xdrproc_t) xdr_remote_node_get_cpu_stats_ret, (char *) &ret);
 done:
     remoteDriverUnlock(priv);
     return rv;
 }

 static int
-remoteNodeGetMemoryStats (virConnectPtr conn,
-                          int cellNum,
-                          virNodeMemoryStatsPtr params, int *nparams,
-                          unsigned int flags)
+remoteNodeGetMemoryStats(virConnectPtr conn,
+                         int cellNum,
+                         virNodeMemoryStatsPtr params,
+                         int *nparams,
+                         unsigned int flags)
 {
     int rv = -1;
     remote_node_get_memory_stats_args args;
@@ -1168,9 +1162,9 @@
     args.flags = flags;

     memset (&ret, 0, sizeof(ret));
-    if (call (conn, priv, 0, REMOTE_PROC_NODE_GET_MEMORY_STATS,
-              (xdrproc_t) xdr_remote_node_get_memory_stats_args, (char *) &args,
-              (xdrproc_t) xdr_remote_node_get_memory_stats_ret, (char *) &ret) == -1)
+    if (call(conn, priv, 0, REMOTE_PROC_NODE_GET_MEMORY_STATS,
+             (xdrproc_t) xdr_remote_node_get_memory_stats_args, (char *) &args,
+             (xdrproc_t) xdr_remote_node_get_memory_stats_ret, (char *) &ret) == -1)
         goto done;

     /* Check the length of the returned list carefully. */
@@ -1206,8 +1200,7 @@
     rv = 0;

 cleanup:
-    xdr_free ((xdrproc_t) xdr_remote_node_get_memory_stats_ret,
-              (char *) &ret);
+    xdr_free((xdrproc_t) xdr_remote_node_get_memory_stats_ret, (char *) &ret);
 done:
     remoteDriverUnlock(priv);
     return rv;
@@ -1215,9 +1208,9 @@

 static int
 remoteNodeGetCellsFreeMemory(virConnectPtr conn,
-                            unsigned long long *freeMems,
-                            int startCell,
-                            int maxCells)
+                             unsigned long long *freeMems,
+                             int startCell,
+                             int maxCells)
 {
     int rv = -1;
     remote_node_get_cells_free_memory_args args;
@@ -1237,10 +1230,10 @@
     args.startCell = startCell;
     args.maxcells = maxCells;

-    memset (&ret, 0, sizeof(ret));
-    if (call (conn, priv, 0, REMOTE_PROC_NODE_GET_CELLS_FREE_MEMORY,
-              (xdrproc_t) xdr_remote_node_get_cells_free_memory_args, (char *)&args,
-              (xdrproc_t) xdr_remote_node_get_cells_free_memory_ret, (char *)&ret) == -1)
+    memset(&ret, 0, sizeof(ret));
+    if (call(conn, priv, 0, REMOTE_PROC_NODE_GET_CELLS_FREE_MEMORY,
+             (xdrproc_t) xdr_remote_node_get_cells_free_memory_args, (char *)&args,
+             (xdrproc_t) xdr_remote_node_get_cells_free_memory_ret, (char *)&ret) == -1)
         goto done;

     for (i = 0 ; i < ret.cells.cells_len ; i++)
@@ -1256,7 +1249,7 @@
 }

 static int
-remoteListDomains (virConnectPtr conn, int *ids, int maxids)
+remoteListDomains(virConnectPtr conn, int *ids, int maxids)
 {
     int rv = -1;
     int i;
@@ -1274,10 +1267,10 @@
     }
     args.maxids = maxids;

-    memset (&ret, 0, sizeof(ret));
-    if (call (conn, priv, 0, REMOTE_PROC_LIST_DOMAINS,
-              (xdrproc_t) xdr_remote_list_domains_args, (char *) &args,
-              (xdrproc_t) xdr_remote_list_domains_ret, (char *) &ret) == -1)
+    memset(&ret, 0, sizeof(ret));
+    if (call(conn, priv, 0, REMOTE_PROC_LIST_DOMAINS,
+             (xdrproc_t) xdr_remote_list_domains_args, (char *) &args,
+             (xdrproc_t) xdr_remote_list_domains_ret, (char *) &ret) == -1)
         goto done;

     if (ret.ids.ids_len > maxids) {
@@ -1293,7 +1286,7 @@
     rv = ret.ids.ids_len;

 cleanup:
-    xdr_free ((xdrproc_t) xdr_remote_list_domains_ret, (char *) &ret);
+    xdr_free((xdrproc_t) xdr_remote_list_domains_ret, (char *) &ret);

 done:
     remoteDriverUnlock(priv);


Give more detailed error message when the argument count isn't right.

--- Python/ceval.c
+++ Python/ceval.c
@@ -454,8 +454,9 @@
 		}
 		if (argcount > co->co_argcount) {
 			if (!(co->co_flags & CO_VARARGS)) {
-				PyErr_SetString(PyExc_TypeError,
-						"too many arguments");
+				PyErr_Format(PyExc_TypeError,
+				"too many arguments; expected %d, got %d",
+					     co->co_argcount, argcount);
 				goto fail;
 			}
 			n = co->co_argcount;
@@ -513,8 +514,9 @@
 			int m = co->co_argcount - defcount;
 			for (i = argcount; i < m; i++) {
 				if (GETLOCAL(i) == NULL) {
-					PyErr_SetString(PyExc_TypeError,
-						   "not enough arguments");
+					PyErr_Format(PyExc_TypeError,
+				"not enough arguments; expected %d, got %d",
+						     m, i);
 					goto fail;
 				}
 			}


remote: Fix memory leak on error path when deserializing bulk stats

The 'elem' variable along with the domain object would be leaked when
taking the error path.

Found by coverity.

--- src/remote/remote_driver.c
+++ src/remote/remote_driver.c
@@ -7730,7 +7730,7 @@
     size_t i;
     remote_connect_get_all_domain_stats_args args;
     remote_connect_get_all_domain_stats_ret ret;
-
+    virDomainStatsRecordPtr elem = NULL;
     virDomainStatsRecordPtr *tmpret = NULL;

     if (ndoms) {
@@ -7769,7 +7769,6 @@
         goto cleanup;

     for (i = 0; i < ret.retStats.retStats_len; i++) {
-        virDomainStatsRecordPtr elem;
         remote_domain_stats_record *rec = ret.retStats.retStats_val + i;

         if (VIR_ALLOC(elem) < 0)
@@ -7786,6 +7785,7 @@
             goto cleanup;

         tmpret[i] = elem;
+        elem = NULL;
     }

     *retStats = tmpret;
@@ -7793,6 +7793,10 @@
     rv = ret.retStats.retStats_len;

  cleanup:
+    if (elem) {
+        virObjectUnref(elem->dom);
+        VIR_FREE(elem);
+    }
     virDomainStatsRecordListFree(tmpret);
     xdr_free((xdrproc_t)xdr_remote_connect_get_all_domain_stats_ret,
              (char *) &ret);


Added implementation for CFType_traits where is_CFType=false.

--- QCTypeTraits.h
+++ QCTypeTraits.h
@@ -13,7 +13,7 @@

 #include <tr1/type_traits>

-#include "CFRaiiCommon.h"
+#include "QCMacrosInternal.h"

 // MARK: -
 // MARK: Is Core Foundation type trait
@@ -258,7 +258,9 @@

 // MARK: public-facing is_CFType<> interface
 template <class T>
-/* we need to remove_cv in order to ensure matching the above template specialization */
+/* we need to remove_cv (from the pointer-to-opaque-CF-type)
+ * in order to ensure matching the above template specialization
+ */
 struct is_CFType : public _is_CFType < typename std::tr1::remove_cv<T>::type >
 { };

@@ -266,15 +268,19 @@
 // MARK: -
 // MARK: CFType_traits

-// only implement CFType_traits iff is_CFType is true
 template < class CF, bool = is_CFType<CF>::value >
-struct CFType_traits;
-
+struct CFType_traits
+{
+	static bool const is_CFType = false;
+};
+
+// partial specialization for is_CFType
 template <class CF>
 struct CFType_traits <CF, true>
 {
 	static bool const is_CFType = true;
 	typedef CF value_type;
+	static CFTypeID typeID(CF const &obj) { return CFGetTypeID(obj); }
 	static value_type get(CF const &obj) { return obj; }
 };


ditto

ditto

--- vc/src/io/HDF5DataShare.h
+++ vc/src/io/HDF5DataShare.h
@@ -33,6 +33,8 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+#include <unistd.h>
+
 #include "VCSimulation.h"
 #include "HDF5Data.h"


fix memleak on error in globus_i_gsi_callback_check_critical_extensions

--- gsi/callback/source/library/globus_gsi_callback.c
+++ gsi/callback/source/library/globus_gsi_callback.c
@@ -1134,6 +1134,8 @@
                     &ext_data->data,
                     ext_data->length)) == NULL)
             {
+                ASN1_OCTET_STRING_free(ext_data);
+                proxycertinfo = NULL;
                 GLOBUS_GSI_CALLBACK_OPENSSL_ERROR_RESULT(
                     result,
                     GLOBUS_GSI_CALLBACK_ERROR_VERIFY_CRED,


remote: Avoid coverity[leaked_storage] message.

Upon successful return of virNetClientStreamEventAddCallback() the
allocated cbdata field will be freed by virNetClientStreamEventRemoveCallback()
as cbOpaque using the free function remoteStreamCallbackFree().

--- src/remote/remote_driver.c
+++ src/remote/remote_driver.c
@@ -4816,6 +4816,7 @@

 cleanup:
     remoteDriverUnlock(priv);
+    /* coverity[leaked_storage] - cbdata is not leaked */
     return ret;
 }


Another original Cscore example converted for Csound 5.

error: pathspec 'examples/cscore/test.c' did not match any file(s) known to git

--- examples/cscore/test.c
+++ examples/cscore/test.c
@@ -0,0 +1,70 @@
+/*
+    test.c: for cscore
+
+    Copyright (C) 19xx Barry Vercoe, John ffitch
+
+    This file is part of Csound.
+
+    Csound 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.
+
+    Csound is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with Csound; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+#include "cscore.h"                                  /* CSCORE_TEST.C */
+
+void cscore(CSOUND* cs)  /* callable from Csound or standalone cscore */
+{
+	EVENT *e, **p;
+	EVLIST *a, *b, *c;
+	int  n;
+
+	e = cscoreCreateEvent(cs,5); 		/* alloc p0-5 and init pcnt */
+	e->op = 'f';
+	e->p[1] = 1;            		/* construct an event */
+	e->p[2] = 0;
+	e->p[3] = 256;
+	e->p[4] = 10;
+	e->p[5] = 1;
+	cscorePutEvent(cs,e);			/* and write it out */
+	cscoreFreeEvent(cs,e);
+	cscorePutString(cs,"s");
+
+	a = cscoreListGetSection(cs);		/* read sect from score */
+	cscoreListPut(cs,a);			/* write it out as is */
+	cscorePutString(cs,"s");
+
+	cscoreListSort(cs,a);
+	cscoreListPut(cs,a);			/* write out a sorted version */
+	cscorePutString(cs,"s");
+
+	c = cscoreListSeparateTWF(cs,a);	/* separate t,w & f's from notes */
+	b = cscoreListCopyEvents(cs,a); 	/* duplicate the notes */
+	n = b->nevents;
+	p = &b->e[1];				/* point at first one */
+	while (n--)
+	   (*p++)->p[2] += 2.0; 		/* delay each by two beats */
+	c = cscoreListAppendList(cs,c,a);
+	c = cscoreListAppendList(cs,c,b);	/* combine and sort all three sets */
+	cscoreListSort(cs,c);
+	cscoreListPut(cs,c);			/* and write out */
+	cscoreListFreeEvents(cs,c);		/* release all of these notes */
+	cscorePutString(cs,"s");
+
+	e = cscoreDefineEvent(cs,"f 2 0 256 10 5 6 ");
+	a = cscoreListCreate(cs,1);
+      a = cscoreListAppendEvent(cs,a,e);
+	cscoreListPut(cs,a);
+	cscoreListFreeEvents(cs,a);
+	cscorePutString(cs,"e");
+
+	return;
+}


fix new fallthrough handling

fix new fallthrough handling

[r20793]

--- ir/be/ia32/ia32_emitter.c
+++ ir/be/ia32/ia32_emitter.c
@@ -841,7 +841,6 @@
 	const ir_node *proj_true;
 	const ir_node *proj_false;
 	const ir_node *block;
-	const ir_node *next_block;
 	pn_Cmp         pnc = get_ia32_condcode(node);

 	pnc = determine_final_pnc(node, 0, pnc);
@@ -890,7 +889,7 @@
 			case pn_Cmp_Le:
 				/* we need a local label if the false proj is a fallthrough
 				 * as the falseblock might have no label emitted then */
-				if (get_cfop_target_block(proj_false) == next_block) {
+				if (can_be_fallthrough(proj_false)) {
 					need_parity_label = 1;
 					be_emit_cstring("\tjp 1f");
 				} else {
@@ -926,7 +925,7 @@
 	}

 	/* the second Proj might be a fallthrough */
-	if (get_cfop_target_block(proj_false) != next_block) {
+	if (! can_be_fallthrough(proj_false)) {
 		be_emit_cstring("\tjmp ");
 		ia32_emit_cfop_target(proj_false);
 		be_emit_finish_line_gas(proj_false);
@@ -2039,7 +2038,6 @@
 static void ia32_emit_block_header(ir_node *block)
 {
 	ir_graph     *irg = current_ir_graph;
-	int           n_cfgpreds;
 	bool          need_label = block_needs_label(block);
 	int           i, arity;
 	ir_exec_freq *exec_freq = cg->birg->exec_freq;
@@ -2058,9 +2056,9 @@
 			/* if the predecessor block has no fall-through,
 			   we can always align the label. */
 			int      i;
-			bool     has_fallthrough = false;;
-
-			for (i = n_cfgpreds - 1; i >= 0; --i) {
+			bool     has_fallthrough = false;
+
+			for (i = get_Block_n_cfgpreds(block) - 1; i >= 0; --i) {
 				ir_node *cfg_pred = get_Block_cfgpred(block, i);
 				if (can_be_fallthrough(cfg_pred)) {
 					has_fallthrough = true;


efivar-dp.h: Make __attribute__((__packed__)) into an easier to type macro.

Signed-off-by: Peter Jones <2e0a021e603479ff81838c00c3b770daca4e0214@redhat.com>

--- src/include/efivar/efivar-dp.h
+++ src/include/efivar/efivar-dp.h
@@ -26,12 +26,14 @@
 #define efidp_decode_bitfield_(value, name, shift, mask)		\
 	({ (name) = ((value) & (mask)) >> (shift); })

+#define EFIVAR_PACKED __attribute__((__packed__))
+
 /* Generic device path header */
 typedef struct {
 	uint8_t type;
 	uint8_t subtype;
 	uint16_t length;
-} __attribute__((__packed__)) efidp_header;
+} EFIVAR_PACKED efidp_header;

 /* A little bit of housekeeping... */
 typedef uint8_t efidp_boolean;
@@ -50,7 +52,7 @@
 	efidp_header	header;
 	uint8_t		function;
 	uint8_t		device;
-} __attribute__((__packed__)) efidp_pci;
+} EFIVAR_PACKED efidp_pci;
 extern ssize_t efidp_make_pci(uint8_t *buf, ssize_t size, uint8_t device,
 			      uint8_t function);

@@ -58,7 +60,7 @@
 typedef struct {
 	efidp_header	header;
 	uint8_t		function;
-} __attribute__((__packed__)) efidp_pccard;
+} EFIVAR_PACKED efidp_pccard;

 #define EFIDP_HW_MMIO		0x03
 typedef struct {
@@ -66,14 +68,14 @@
 	uint32_t	memory_type;
 	uint64_t	starting_address;
 	uint64_t	ending_address;
-} __attribute__((__packed__)) efidp_mmio;
+} EFIVAR_PACKED efidp_mmio;

 #define EFIDP_HW_VENDOR		0x04
 typedef struct {
 	efidp_header	header;
 	efi_guid_t	vendor_guid;
 	uint8_t		vendor_data[0];
-} __attribute__((__packed__)) efidp_hw_vendor;
+} EFIVAR_PACKED efidp_hw_vendor;
 typedef efidp_hw_vendor efidp_vendor_hw;
 #define efidp_make_hw_vendor(buf, size, guid, data, data_size)		\
 	efidp_make_vendor(buf, size, EFIDP_HARDWARE_TYPE,		\
@@ -85,7 +87,7 @@
 	efidp_header	header;
 	efi_guid_t	vendor_guid;
 	uint32_t	hardware_device;
-} __attribute__((__packed__)) efidp_edd10;
+} EFIVAR_PACKED efidp_edd10;
 extern ssize_t efidp_make_edd10(uint8_t *buf, ssize_t size,
 				uint32_t hardware_device);

@@ -93,14 +95,14 @@
 typedef struct {
 	efidp_header	header;
 	uint32_t	controller;
-} __attribute__((__packed__)) efidp_controller;
+} EFIVAR_PACKED efidp_controller;

 #define EFIDP_HW_BMC		0x06
 typedef struct {
 	efidp_header	header;
 	uint8_t		interface_type;
 	uint64_t	base_addr;
-} __attribute__((__packed__)) efidp_bmc;
+} EFIVAR_PACKED efidp_bmc;

 #define EFIDP_BMC_UNKNOWN	0x00
 #define EFIDP_BMC_KEYBOARD	0x01
@@ -114,7 +116,7 @@
 	efidp_header	header;
 	uint32_t	hid;
 	uint32_t	uid;
-} __attribute__((__packed__)) efidp_acpi_hid;
+} EFIVAR_PACKED efidp_acpi_hid;
 extern ssize_t efidp_make_acpi_hid(uint8_t *buf, ssize_t size, uint32_t hid,
 				   uint32_t uid);

@@ -126,7 +128,7 @@
 	uint32_t	cid;
 	/* three ascii string fields follow */
 	char		hidstr[];
-} __attribute__((__packed__)) efidp_acpi_hid_ex;
+} EFIVAR_PACKED efidp_acpi_hid_ex;
 extern ssize_t efidp_make_acpi_hid_ex(uint8_t *buf, ssize_t size, uint32_t hid,
 				      uint32_t uid, uint32_t cid, char *hidstr,
 				      char *uidstr, char *cidstr)
@@ -153,7 +155,7 @@
 typedef struct {
 	efidp_header	header;
 	uint32_t	adr[];
-} __attribute__((__packed__)) efidp_acpi_adr;
+} EFIVAR_PACKED efidp_acpi_adr;

 #define EFIDP_ACPI_ADR_DEVICE_ID_SCHEME_MASK		0x80000000
 #define EFIDP_ACPI_ADR_DEVICE_ID_SCHEME_SHIFT		31
@@ -257,7 +259,7 @@
 	uint8_t		primary;
 	uint8_t		slave;
 	uint16_t	lun;
-} __attribute__((__packed__)) efidp_atapi;
+} EFIVAR_PACKED efidp_atapi;
 extern ssize_t efidp_make_atapi(uint8_t *buf, ssize_t size, uint16_t primary,
 		uint16_t slave, uint16_t lun);

@@ -266,7 +268,7 @@
 	efidp_header	header;
 	uint16_t	target;
 	uint16_t	lun;
-} __attribute__((__packed__)) efidp_scsi;
+} EFIVAR_PACKED efidp_scsi;
 extern ssize_t efidp_make_scsi(uint8_t *buf, ssize_t size, uint16_t target,
 			       uint16_t lun);

@@ -276,7 +278,7 @@
 	uint32_t	reserved;
 	uint64_t	wwn;
 	uint64_t	lun;
-} __attribute__((__packed__)) efidp_fc;
+} EFIVAR_PACKED efidp_fc;

 #define EFIDP_MSG_FIBRECHANNELEX 0x15
 typedef struct {
@@ -284,21 +286,21 @@
 	uint32_t	reserved;
 	uint8_t		wwn[8];
 	uint8_t		lun[8];
-} __attribute__((__packed__)) efidp_fcex;
+} EFIVAR_PACKED efidp_fcex;

 #define EFIDP_MSG_1394		0x04
 typedef struct {
 	efidp_header	header;
 	uint32_t	reserved;
 	uint64_t	guid;
-} __attribute__((__packed__)) efidp_1394;
+} EFIVAR_PACKED efidp_1394;

 #define EFIDP_MSG_USB		0x05
 typedef struct {
 	efidp_header	header;
 	uint8_t		parent_port;
 	uint8_t		interface;
-} __attribute__((__packed__)) efidp_usb;
+} EFIVAR_PACKED efidp_usb;

 #define EFIDP_MSG_USB_CLASS	0x0f
 typedef struct {
@@ -308,7 +310,7 @@
 	uint8_t		device_class;
 	uint8_t		device_subclass;
 	uint8_t		device_protocol;
-} __attribute__((__packed__)) efidp_usb_class;
+} EFIVAR_PACKED efidp_usb_class;

 #define EFIDP_USB_CLASS_AUDIO		0x01
 #define EFIDP_USB_CLASS_CDC_CONTROL	0x02
@@ -334,13 +336,13 @@
 	uint16_t	vendor_id;
 	uint16_t	product_id;
 	uint16_t	serial_number[];
-} __attribute__((__packed__)) efidp_usb_wwid;
+} EFIVAR_PACKED efidp_usb_wwid;

 #define EFIDP_MSG_LUN		0x11
 typedef struct {
 	efidp_header	header;
 	uint8_t		lun;
-} __attribute__((__packed__)) efidp_lun;
+} EFIVAR_PACKED efidp_lun;

 #define EFIDP_MSG_SATA		0x12
 typedef struct {
@@ -348,7 +350,7 @@
 	uint16_t	hba_port;
 	uint16_t	port_multiplier_port;
 	uint16_t	lun;
-} __attribute__((__packed__)) efidp_sata;
+} EFIVAR_PACKED efidp_sata;
 #define SATA_HBA_DIRECT_CONNECT_FLAG	0x8000
 extern ssize_t efidp_make_sata(uint8_t *buf, ssize_t size, uint16_t hba_port,
 			       int16_t port_multiplier_port, uint16_t lun);
@@ -357,14 +359,14 @@
 typedef struct {
 	efidp_header	header;
 	uint32_t	target;
-} __attribute__((__packed__)) efidp_i2o;
+} EFIVAR_PACKED efidp_i2o;

 #define EFIDP_MSG_MAC_ADDR	0x0b
 typedef struct {
 	efidp_header	header;
 	uint8_t		mac_addr[32];
 	uint8_t		if_type;
-} __attribute__((__packed__)) efidp_mac_addr;
+} EFIVAR_PACKED efidp_mac_addr;
 extern ssize_t efidp_make_mac_addr(uint8_t *buf, ssize_t size,
 				   uint8_t if_type,
 				   const uint8_t * const mac_addr,
@@ -382,7 +384,7 @@
 	efidp_boolean	static_ip_addr;
 	uint8_t		gateway[4];
 	uint8_t		netmask[4];
-} __attribute__((__packed__)) efidp_ipv4_addr;
+} EFIVAR_PACKED efidp_ipv4_addr;
 /* everything here is in host byte order */
 extern ssize_t efidp_make_ipv4(uint8_t *buf, ssize_t size,
 			       uint32_t local, uint32_t remote,
@@ -404,7 +406,7 @@
 	uint8_t		ip_addr_origin;
 	uint8_t		prefix_length;
 	uint8_t		gateway_ipv6_addr;
-} __attribute__((__packed__)) efidp_ipv6_addr;
+} EFIVAR_PACKED efidp_ipv6_addr;

 #define EFIDP_IPv6_ORIGIN_MANUAL	0x00
 #define EFIDP_IPv6_ORIGIN_AUTOCONF	0x01
@@ -414,7 +416,7 @@
 typedef struct {
 	efidp_header	header;
 	uint16_t	vlan_id;
-} __attribute__((__packed__)) efidp_vlan;
+} EFIVAR_PACKED efidp_vlan;

 #define EFIDP_MSG_INFINIBAND	0x09
 typedef struct {
@@ -427,7 +429,7 @@
 	};
 	uint64_t	target_port_id;
 	uint64_t	device_id;
-} __attribute__((__packed__)) efidp_infiniband;
+} EFIVAR_PACKED efidp_infiniband;

 #define EFIDP_INFINIBAND_RESOURCE_IOC_SERVICE	0x01
 #define EFIDP_INFINIBAND_RESOURCE_EXTENDED_BOOT	0x02
@@ -443,7 +445,7 @@
 	uint8_t		data_bits;
 	uint8_t		parity;
 	uint8_t		stop_bits;
-} __attribute__((__packed__)) efidp_uart;
+} EFIVAR_PACKED efidp_uart;

 #define EFIDP_UART_PARITY_DEFAULT	0x00
 #define EFIDP_UART_PARITY_NONE		0x01
@@ -471,7 +473,7 @@
 	efidp_header	header;
 	efi_guid_t	vendor_guid;
 	uint8_t		vendor_data[0];
-} __attribute__((__packed__)) efidp_msg_vendor;
+} EFIVAR_PACKED efidp_msg_vendor;
 typedef efidp_msg_vendor efidp_vendor_msg;
 #define efidp_make_msg_vendor(buf, size, guid, data, data_size)		\
 	efidp_make_vendor(buf, size, EFIDP_MESSAGE_TYPE,		\
@@ -484,7 +486,7 @@
 	efidp_header	header;
 	efi_guid_t	vendor_guid;
 	uint32_t	flow_control_map;
-} __attribute__((__packed__)) efidp_uart_flow_control;
+} EFIVAR_PACKED efidp_uart_flow_control;

 #define EFIDP_UART_FLOW_CONTROL_HARDWARE	0x1
 #define EFIDP_UART_FLOW_CONTROL_XONXOFF		0x2
@@ -500,7 +502,7 @@
 	uint8_t		device_topology_info;
 	uint8_t		drive_bay_id; /* If EFIDP_SAS_TOPOLOGY_NEXTBYTE set */
 	uint16_t	rtp;
-} __attribute__((__packed__)) efidp_sas;
+} EFIVAR_PACKED efidp_sas;
 extern ssize_t efidp_make_sas(uint8_t *buf, ssize_t size, uint64_t sas_address);

 /* device_topology_info Bits 0:3 (enum) */
@@ -531,7 +533,7 @@
 	uint8_t		device_topology_info;
 	uint8_t		drive_bay_id; /* If EFIDP_SAS_TOPOLOGY_NEXTBYTE set */
 	uint16_t	rtp;
-} __attribute__((__packed__)) efidp_sas_ex;
+} EFIVAR_PACKED efidp_sas_ex;

 #define EFIDP_MSG_DEBUGPORT_GUID \
 	EFI_GUID(0xEBA4E8D2,0x3858,0x41EC,0xA281,0x26,0x47,0xBA,0x96,0x60,0xD0)
@@ -544,7 +546,7 @@
 	uint8_t		lun[8];
 	uint16_t	tpgt;
 	uint8_t		target_name[0];
-} __attribute__((__packed__)) efidp_iscsi;
+} EFIVAR_PACKED efidp_iscsi;

 /* options bits 0:1 */
 #define EFIDP_ISCSI_HEADER_DIGEST_SHIFT	0
@@ -576,7 +578,7 @@
 	efidp_header	header;
 	uint32_t	namespace_id;
 	uint8_t		ieee_eui_64[8];
-} __attribute__((__packed__)) efidp_nvme;
+} EFIVAR_PACKED efidp_nvme;
 extern ssize_t efidp_make_nvme(uint8_t *buf, ssize_t size,
 			       uint32_t namespace_id, uint8_t *ieee_eui_64);

@@ -584,20 +586,20 @@
 typedef struct {
 	efidp_header	header;
 	uint8_t		uri[0];
-} __attribute__((__packed__)) efidp_uri;
+} EFIVAR_PACKED efidp_uri;

 #define EFIDP_MSG_UFS		0x19
 typedef struct {
 	efidp_header	header;
 	uint8_t		target_id;
 	uint8_t		lun;
-} __attribute__((__packed__)) efidp_ufs;
+} EFIVAR_PACKED efidp_ufs;

 #define EFIDP_MSG_SD		0x1a
 typedef struct {
 	efidp_header	header;
 	uint8_t		slot_number;
-} __attribute__((__packed__)) efidp_sd;
+} EFIVAR_PACKED efidp_sd;

 /* Each media subtype */
 #define EFIDP_MEDIA_HD		0x1
@@ -612,7 +614,7 @@
 #ifdef __ia64
 	uint8_t		padding[6]; /* Emperically needed */
 #endif
-} __attribute__((__packed__)) __attribute__((__packed__)) efidp_hd;
+} EFIVAR_PACKED EFIVAR_PACKED efidp_hd;
 extern ssize_t efidp_make_hd(uint8_t *buf, ssize_t size, uint32_t num,
 			     uint64_t part_start, uint64_t part_size,
 			     uint8_t *signature, uint8_t format,
@@ -631,14 +633,14 @@
 	uint32_t	boot_catalog_entry;
 	uint64_t	partition_rba;
 	uint64_t	sectors;
-} __attribute__((__packed__)) efidp_cdrom;
+} EFIVAR_PACKED efidp_cdrom;

 #define EFIDP_MEDIA_VENDOR	0x3
 typedef struct {
 	efidp_header	header;
 	efi_guid_t	vendor_guid;
 	uint8_t		vendor_data[0];
-} __attribute__((__packed__)) efidp_media_vendor;
+} EFIVAR_PACKED efidp_media_vendor;
 typedef efidp_media_vendor efidp_vendor_media;
 #define efidp_make_media_vendor(buf, size, guid, data, data_size)	\
 	efidp_make_vendor(buf, size, EFIDP_MEDIA_TYPE,			\
@@ -648,26 +650,26 @@
 typedef struct {
 	efidp_header	header;
 	uint16_t	name[];
-} __attribute__((__packed__)) efidp_file;
+} EFIVAR_PACKED efidp_file;
 extern ssize_t efidp_make_file(uint8_t *buf, ssize_t size, char *filename);

 #define EFIDP_MEDIA_PROTOCOL	0x5
 typedef struct {
 	efidp_header	header;
 	efi_guid_t	protocol_guid;
-} __attribute__((__packed__)) efidp_protocol;
+} EFIVAR_PACKED efidp_protocol;

 #define EFIDP_MEDIA_FIRMWARE_FILE	0x6
 typedef struct {
 	efidp_header	header;
 	uint8_t		pi_info[0];
-} __attribute__((__packed__)) efidp_firmware_file;
+} EFIVAR_PACKED efidp_firmware_file;

 #define EFIDP_MEDIA_FIRMWARE_VOLUME	0x7
 typedef struct {
 	efidp_header	header;
 	uint8_t		pi_info[0];
-} __attribute__((__packed__)) efidp_firmware_volume;
+} EFIVAR_PACKED efidp_firmware_volume;

 #define EFIDP_MEDIA_RELATIVE_OFFSET	0x8
 typedef struct {
@@ -675,7 +677,7 @@
 	uint32_t	reserved;
 	uint64_t	first_byte;
 	uint64_t	last_byte;
-} __attribute__((__packed__)) efidp_relative_offset;
+} EFIVAR_PACKED efidp_relative_offset;

 #define EFIDP_MEDIA_RAMDISK	0x9
 typedef struct {
@@ -684,7 +686,7 @@
 	uint64_t	end_addr;
 	efi_guid_t	disk_type_guid;
 	uint16_t	instance_number;
-} __attribute__((__packed__)) efidp_ramdisk;
+} EFIVAR_PACKED efidp_ramdisk;

 #define EFIDP_VIRTUAL_DISK_GUID \
 	EFI_GUID(0x77AB535A,0x45FC,0x624B,0x5560,0xF7,0xB2,0x81,0xD1,0xF9,0x6E)
@@ -702,7 +704,7 @@
 	uint16_t	device_type;
 	uint16_t	status;
 	uint8_t		description[0];
-} __attribute__((__packed__)) efidp_bios_boot;
+} EFIVAR_PACKED efidp_bios_boot;

 #define EFIDP_BIOS_BOOT_DEVICE_TYPE_FLOPPY	1
 #define EFIDP_BIOS_BOOT_DEVICE_TYPE_HD		2
@@ -768,7 +770,7 @@
 	efidp_relative_offset relative_offset;
 	efidp_ramdisk ramdisk;
 	efidp_bios_boot bios_boot;
-} __attribute__((__packed__)) efidp_data;
+} EFIVAR_PACKED efidp_data;
 typedef efidp_data *efidp;
 typedef const efidp_data *const_efidp;


docs: mark some enums values as deprecated

--- gtk/deprecated/gtkrc.h
+++ gtk/deprecated/gtkrc.h
@@ -210,46 +210,46 @@

 /**
  * GtkRcTokenType:
- * @GTK_RC_TOKEN_INVALID:
- * @GTK_RC_TOKEN_INCLUDE:
- * @GTK_RC_TOKEN_NORMAL:
- * @GTK_RC_TOKEN_ACTIVE:
- * @GTK_RC_TOKEN_PRELIGHT:
- * @GTK_RC_TOKEN_SELECTED:
- * @GTK_RC_TOKEN_INSENSITIVE:
- * @GTK_RC_TOKEN_FG:
- * @GTK_RC_TOKEN_BG:
- * @GTK_RC_TOKEN_TEXT:
- * @GTK_RC_TOKEN_BASE:
- * @GTK_RC_TOKEN_XTHICKNESS:
- * @GTK_RC_TOKEN_YTHICKNESS:
- * @GTK_RC_TOKEN_FONT:
- * @GTK_RC_TOKEN_FONTSET:
- * @GTK_RC_TOKEN_FONT_NAME:
- * @GTK_RC_TOKEN_BG_PIXMAP:
- * @GTK_RC_TOKEN_PIXMAP_PATH:
- * @GTK_RC_TOKEN_STYLE:
- * @GTK_RC_TOKEN_BINDING:
- * @GTK_RC_TOKEN_BIND:
- * @GTK_RC_TOKEN_WIDGET:
- * @GTK_RC_TOKEN_WIDGET_CLASS:
- * @GTK_RC_TOKEN_CLASS:
- * @GTK_RC_TOKEN_LOWEST:
- * @GTK_RC_TOKEN_GTK:
- * @GTK_RC_TOKEN_APPLICATION:
- * @GTK_RC_TOKEN_THEME:
- * @GTK_RC_TOKEN_RC:
- * @GTK_RC_TOKEN_HIGHEST:
- * @GTK_RC_TOKEN_ENGINE:
- * @GTK_RC_TOKEN_MODULE_PATH:
- * @GTK_RC_TOKEN_IM_MODULE_PATH:
- * @GTK_RC_TOKEN_IM_MODULE_FILE:
- * @GTK_RC_TOKEN_STOCK:
- * @GTK_RC_TOKEN_LTR:
- * @GTK_RC_TOKEN_RTL:
- * @GTK_RC_TOKEN_COLOR:
- * @GTK_RC_TOKEN_UNBIND:
- * @GTK_RC_TOKEN_LAST:
+ * @GTK_RC_TOKEN_INVALID: Deprecated
+ * @GTK_RC_TOKEN_INCLUDE: Deprecated
+ * @GTK_RC_TOKEN_NORMAL: Deprecated
+ * @GTK_RC_TOKEN_ACTIVE: Deprecated
+ * @GTK_RC_TOKEN_PRELIGHT: Deprecated
+ * @GTK_RC_TOKEN_SELECTED: Deprecated
+ * @GTK_RC_TOKEN_INSENSITIVE: Deprecated
+ * @GTK_RC_TOKEN_FG: Deprecated
+ * @GTK_RC_TOKEN_BG: Deprecated
+ * @GTK_RC_TOKEN_TEXT: Deprecated
+ * @GTK_RC_TOKEN_BASE: Deprecated
+ * @GTK_RC_TOKEN_XTHICKNESS: Deprecated
+ * @GTK_RC_TOKEN_YTHICKNESS: Deprecated
+ * @GTK_RC_TOKEN_FONT: Deprecated
+ * @GTK_RC_TOKEN_FONTSET: Deprecated
+ * @GTK_RC_TOKEN_FONT_NAME: Deprecated
+ * @GTK_RC_TOKEN_BG_PIXMAP: Deprecated
+ * @GTK_RC_TOKEN_PIXMAP_PATH: Deprecated
+ * @GTK_RC_TOKEN_STYLE: Deprecated
+ * @GTK_RC_TOKEN_BINDING: Deprecated
+ * @GTK_RC_TOKEN_BIND: Deprecated
+ * @GTK_RC_TOKEN_WIDGET: Deprecated
+ * @GTK_RC_TOKEN_WIDGET_CLASS: Deprecated
+ * @GTK_RC_TOKEN_CLASS: Deprecated
+ * @GTK_RC_TOKEN_LOWEST: Deprecated
+ * @GTK_RC_TOKEN_GTK: Deprecated
+ * @GTK_RC_TOKEN_APPLICATION: Deprecated
+ * @GTK_RC_TOKEN_THEME: Deprecated
+ * @GTK_RC_TOKEN_RC: Deprecated
+ * @GTK_RC_TOKEN_HIGHEST: Deprecated
+ * @GTK_RC_TOKEN_ENGINE: Deprecated
+ * @GTK_RC_TOKEN_MODULE_PATH: Deprecated
+ * @GTK_RC_TOKEN_IM_MODULE_PATH: Deprecated
+ * @GTK_RC_TOKEN_IM_MODULE_FILE: Deprecated
+ * @GTK_RC_TOKEN_STOCK: Deprecated
+ * @GTK_RC_TOKEN_LTR: Deprecated
+ * @GTK_RC_TOKEN_RTL: Deprecated
+ * @GTK_RC_TOKEN_COLOR: Deprecated
+ * @GTK_RC_TOKEN_UNBIND: Deprecated
+ * @GTK_RC_TOKEN_LAST: Deprecated
  *
  * The #GtkRcTokenType enumeration represents the tokens
  * in the RC file. It is exposed so that theme engines


[C]: fix guaranteed short counted sends on each SM sent.

--- aeron-driver/src/main/c/media/aeron_receive_channel_endpoint.c
+++ aeron-driver/src/main/c/media/aeron_receive_channel_endpoint.c
@@ -182,17 +182,18 @@

 int aeron_receive_channel_endpoint_sendmsg(aeron_receive_channel_endpoint_t *endpoint, struct msghdr *msghdr)
 {
+    int min_bytes_sent = msghdr->msg_iov->iov_len;
+
     for (size_t i = 0, len = endpoint->destinations.length; i < len; i++)
     {
         aeron_receive_destination_t *destination = endpoint->destinations.array[i].destination;
-
-        if (destination->data_paths->sendmsg_func(destination->data_paths, &destination->transport, msghdr) < 0)
-        {
-            return -1;
-        }
-    }
-
-    return 0;
+        const int sendmsg_result =
+            destination->data_paths->sendmsg_func(destination->data_paths, &destination->transport, msghdr);
+
+        min_bytes_sent = sendmsg_result < min_bytes_sent ? sendmsg_result : min_bytes_sent;
+    }
+
+    return min_bytes_sent;
 }

 int aeron_receive_channel_endpoint_send_sm(


TODO-1038: switching back to attempted propoprtional valve control

--- content/OTRadioLink/OTV0p2_CONFIG_REV7.h
+++ content/OTRadioLink/OTV0p2_CONFIG_REV7.h
@@ -116,7 +116,7 @@
 // IF DEFINED: try to trim bandwidth as may be especially expensive/scarce.
 #undef ENABLE_TRIMMED_BANDWIDTH
 // If DEFINED: attempt proportional (rather than cruder, eg, on/off, control of TRV or other heat source).
-#undef ENABLE_PROPORTIONAL_VALVE_CONTROL
+#define ENABLE_PROPORTIONAL_VALVE_CONTROL
 // IF DEFINED: support one on and one off time per day (possibly in conjunction with 'learn' button).
 #undef ENABLE_SINGLETON_SCHEDULE
 // IF DEFINED: use active-low LEARN button(s).  Needs ENABLE_SINGLETON_SCHEDULE.


emit correct condition codes for xmm compares

--- ir/be/ia32/ia32_emitter.c
+++ ir/be/ia32/ia32_emitter.c
@@ -720,12 +720,12 @@
   { "ne",              pn_Cmp_Lg },     /* != */
   { "ordered",         pn_Cmp_Leg },    /* Floating point: ordered */
   { "unordered",       pn_Cmp_Uo },     /* FLoting point: unordered */
-  { "unordered or ==", pn_Cmp_Ue },     /* Floating point: unordered or == */
-  { "unordered or <",  pn_Cmp_Ul },     /* Floating point: unordered or < */
-  { "unordered or <=", pn_Cmp_Ule },    /* Floating point: unordered or <= */
-  { "unordered or >",  pn_Cmp_Ug },     /* Floating point: unordered or > */
-  { "unordered or >=", pn_Cmp_Uge },    /* Floating point: unordered or >= */
-  { "unordered or !=", pn_Cmp_Ne },     /* Floating point: unordered or != */
+  { "e",               pn_Cmp_Ue },     /* Floating point: unordered or == */
+  { "b",               pn_Cmp_Ul },     /* Floating point: unordered or < */
+  { "be",              pn_Cmp_Ule },    /* Floating point: unordered or <= */
+  { "a",               pn_Cmp_Ug },     /* Floating point: unordered or > */
+  { "ae",              pn_Cmp_Uge },    /* Floating point: unordered or >= */
+  { "ne",              pn_Cmp_Ne },     /* Floating point: unordered or != */
   { NULL,              pn_Cmp_True },   /* always true */
 };

@@ -742,12 +742,12 @@
 	{ "ne",              pn_Cmp_Lg },     /* != */
 	{ "ordered",         pn_Cmp_Leg },    /* Floating point: ordered */
 	{ "unordered",       pn_Cmp_Uo },     /* FLoting point: unordered */
-	{ "unordered or ==", pn_Cmp_Ue },     /* Floating point: unordered or == */
-	{ "unordered or <",  pn_Cmp_Ul },     /* Floating point: unordered or < */
-	{ "unordered or <=", pn_Cmp_Ule },    /* Floating point: unordered or <= */
-	{ "unordered or >",  pn_Cmp_Ug },     /* Floating point: unordered or > */
-	{ "unordered or >=", pn_Cmp_Uge },    /* Floating point: unordered or >= */
-	{ "unordered or !=", pn_Cmp_Ne },     /* Floating point: unordered or != */
+	{ "e",               pn_Cmp_Ue },     /* Floating point: unordered or == */
+	{ "b",               pn_Cmp_Ul },     /* Floating point: unordered or < */
+	{ "be",              pn_Cmp_Ule },    /* Floating point: unordered or <= */
+	{ "a",               pn_Cmp_Ug },     /* Floating point: unordered or > */
+	{ "ae",              pn_Cmp_Uge },    /* Floating point: unordered or >= */
+	{ "ne",              pn_Cmp_Ne },     /* Floating point: unordered or != */
 	{ NULL,              pn_Cmp_True },   /* always true */
 };

@@ -815,6 +815,7 @@
 	char buf[SNPRINTF_BUF_LEN];
 	char cmd_buf[SNPRINTF_BUF_LEN];
 	char cmnt_buf[SNPRINTF_BUF_LEN];
+	int is_unsigned;

 	/* get both Proj's */
 	proj1 = get_proj(irn, pn_Cond_true);
@@ -837,16 +838,16 @@
 	}

 	/* the first Proj must always be created */
+	is_unsigned = mode_is_float(mode) || ! mode_is_signed(mode);
 	if (get_Proj_proj(proj1) == pn_Cond_true) {
 		snprintf(cmd_buf, SNPRINTF_BUF_LEN, "j%s %s",
-					get_cmp_suffix(get_ia32_pncode(irn), ! mode_is_signed(get_irn_mode(get_irn_n(irn, 0)))),
+					get_cmp_suffix(get_ia32_pncode(irn), is_unsigned),
 					get_cfop_target(proj1, buf));
 		snprintf(cmnt_buf, SNPRINTF_BUF_LEN, "/* cmp(a, b) == TRUE */");
 	}
 	else  {
 		snprintf(cmd_buf, SNPRINTF_BUF_LEN, "j%s %s",
-					get_cmp_suffix(get_negated_pnc(get_ia32_pncode(irn), mode),
-					! mode_is_signed(get_irn_mode(get_irn_n(irn, 0)))),
+					get_cmp_suffix(get_negated_pnc(get_ia32_pncode(irn), mode), is_unsigned),
 					get_cfop_target(proj1, buf));
 		snprintf(cmnt_buf, SNPRINTF_BUF_LEN, "/* cmp(a, b) == FALSE */");
 	}
@@ -1005,7 +1006,9 @@
 static void CMov_emitter(ir_node *irn, ia32_emit_env_t *env) {
 	FILE               *F       = env->out;
 	const lc_arg_env_t *arg_env = ia32_get_arg_env();
-	const char *cmp_suffix = get_cmp_suffix(get_ia32_pncode(irn), ! mode_is_signed(get_irn_mode(get_irn_n(irn, 0))));
+	ir_mode    *mode       = get_irn_mode(get_irn_n(irn, 0));
+	int        is_unsigned = mode_is_float(mode) || ! mode_is_signed(mode);
+	const char *cmp_suffix = get_cmp_suffix(get_ia32_pncode(irn), is_unsigned);
 	int is_PsiCondCMov     = is_ia32_PsiCondCMov(irn);

 	char cmd_buf[SNPRINTF_BUF_LEN];
@@ -1043,7 +1046,7 @@
 		set_irn_n(irn, 2, get_irn_n(irn, 3));
 		set_irn_n(irn, 3, t);

-		cmp_suffix = get_cmp_suffix(get_inversed_pnc(get_ia32_pncode(irn)), ! mode_is_signed(get_irn_mode(get_irn_n(irn, 0))));
+		cmp_suffix  = get_cmp_suffix(get_inversed_pnc(get_ia32_pncode(irn)), is_unsigned);

 	}
 	else {
@@ -1073,7 +1076,9 @@
 static void Set_emitter(ir_node *irn, ia32_emit_env_t *env) {
 	FILE               *F       = env->out;
 	const lc_arg_env_t *arg_env = ia32_get_arg_env();
-	const char *cmp_suffix = get_cmp_suffix(get_ia32_pncode(irn), ! mode_is_signed(get_irn_mode(get_irn_n(irn, 0))));
+	ir_mode    *mode       = get_irn_mode(get_irn_n(irn, 0));
+	int        is_unsigned = mode_is_float(mode) || ! mode_is_signed(mode);
+	const char *cmp_suffix = get_cmp_suffix(get_ia32_pncode(irn), is_unsigned);
 	const char *instr      = "xor";
 	const char *reg8bit;


Remove unused structs

Remove unused structs

Signed-off-by: Federico Mena Quintero <4999915a961edfd7686112c2935288e1266eae14@gnome.org>

--- gtk/gtkplacessidebar.c
+++ gtk/gtkplacessidebar.c
@@ -80,14 +80,6 @@
 struct _GtkPlacesSidebarClass {
 	GtkScrolledWindowClass parent;
 };
-
-typedef struct {
-        GObject parent;
-} GtkPlacesSidebarProvider;
-
-typedef struct {
-        GObjectClass parent;
-} GtkPlacesSidebarProviderClass;

 enum {
 	PLACES_SIDEBAR_COLUMN_ROW_TYPE,


anv/formats: Advertise blit support for stencil

Thanks to advances in the blit code, we can do this now.

Reviewed-by: Nanley Chery <d78cd5d33e98a5581566f188959f731bd0b1c0fd@intel.com>

--- src/intel/vulkan/anv_formats.c
+++ src/intel/vulkan/anv_formats.c
@@ -381,13 +381,11 @@
    VkFormatFeatureFlags linear = 0, tiled = 0, buffer = 0;
    if (anv_format_is_depth_or_stencil(&anv_formats[format])) {
       tiled |= VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
-      if (physical_device->info->gen >= 8) {
+      if (physical_device->info->gen >= 8)
          tiled |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
-         tiled |= VK_FORMAT_FEATURE_BLIT_SRC_BIT;
-      }
-      if (anv_formats[format].has_depth) {
-         tiled |= VK_FORMAT_FEATURE_BLIT_DST_BIT;
-      }
+
+      tiled |= VK_FORMAT_FEATURE_BLIT_SRC_BIT |
+               VK_FORMAT_FEATURE_BLIT_DST_BIT;
    } else {
       enum isl_format linear_fmt, tiled_fmt;
       struct anv_format_swizzle linear_swizzle, tiled_swizzle;


RDKB-42916: dibbler server is restarting on each renewal

Reason for change: Restart dibbler server based on global ip change.

Test Procedure: Check phyStatus.

Risks: Low

Priority: P1

Signed-off-by: Satheesh Babu <20d2cd0ee34ee995131618c5f5efba70d148a762@sky.uk>
(cherry picked from commit 9d8a1ca00db3f883c3b9e2842c2efde999cddd01)
Change-Id: I259fd5ae43ad12270561c168848bace8e2d4b48d

--- source-arm/TR-181/board_sbapi/cosa_dhcpv6_apis.c
+++ source-arm/TR-181/board_sbapi/cosa_dhcpv6_apis.c
@@ -8948,8 +8948,6 @@
 #endif
                         g_dhcpv6_server_prefix_ready = TRUE;

-                        CosaDmlDHCPv6sTriggerRestart(FALSE);
-
                         /*We need get a global ip addres */
 #if defined(_COSA_BCM_ARM_) || defined(INTEL_PUMA7)
 #ifndef _HUB4_PRODUCT_REQ_
@@ -9007,6 +9005,11 @@

                             CcspTraceWarning(("%s: setting lan-restart\n", __FUNCTION__));
                             commonSyseventSet("lan-restart", "1");
+                        }
+                        if(bRestartLan)
+                        {
+                            CcspTraceWarning(("Restart lan%s:%d\n", __func__,__LINE__));
+                            CosaDmlDHCPv6sTriggerRestart(FALSE);
                         }
 #endif


tests: cast output of malloc() to goal type

clang++ did not like casting void* to char* implicitly.

git-svn-id: caee63afe878fe2ec7dbba394a86c9654d9110ca@1185 64e312b2-a51f-0410-8e61-82d0ca0eb02a

--- tests/check_check_master.c
+++ tests/check_check_master.c
@@ -282,7 +282,7 @@
 char * escape_percent(const char *original, size_t original_size)
 {
   /* In the worst case every character is a %*/
-  char *result = malloc(original_size*2);
+  char *result = (char*)malloc(original_size*2);

   size_t read_index;
   size_t write_index;


fixed bug in saiz compute - cf #824

fixed bug in saiz compute - cf #824

--- src/isomedia/movie_fragments.c
+++ src/isomedia/movie_fragments.c
@@ -1887,8 +1887,19 @@

 		gf_list_add(senc->samp_aux_info, sai);
 		if (sai->subsample_count) senc->flags = 0x00000002;
-		//this assumes that we don't have a cenc sample info with subsamples indicated and subsample_count=0
-		gf_isom_cenc_set_saiz_saio(senc, NULL, traf, IsEncrypted ? IV_size + (2+6)*sai->subsample_count : 0);
+
+		//not encrypted, saiz is 0
+		if (!IsEncrypted) {
+			gf_isom_cenc_set_saiz_saio(senc, NULL, traf, 0);
+		}
+		//no subsample (not NAL-based data), saiz is IV size only
+		else if (! sai->subsample_count) {
+			gf_isom_cenc_set_saiz_saio(senc, NULL, traf, IV_size);
+		}
+		// subsamples ( NAL-based data), saiz is IV size + nb subsamples (2 bytes) + 6 bytes per subsample
+		else {
+			gf_isom_cenc_set_saiz_saio(senc, NULL, traf, IV_size + 2+6*sai->subsample_count);
+		}
 	}

 	return GF_OK;


"Added MAX_NML_STR"

"Added MAX_NML_STR"

--- inc/nml.h
+++ inc/nml.h
@@ -50,6 +50,18 @@

 //max string length for options
 #define NML_MAX_STR 1024
+
+static const TCHAR g_achFD_CLR[] = _T("FD_CLR");
+int l_FD_CLR(lua_State* L);
+
+static const TCHAR g_achFD_ISSET[] = _T("FD_ISSET");
+int l_FD_ISSET(lua_State* L);
+
+static const TCHAR g_achFD_SET[] = _T("FD_SET");
+int l_FD_SET(lua_State* L);
+
+static const TCHAR g_achFD_ZERO[] = _T("FD_ZERO");
+int l_FD_ZERO(lua_State* L);

 static const TCHAR g_achselect[] = _T("select");
 int l_select(lua_State* L);
@@ -134,7 +146,8 @@
 	{g_achgetsockopt, l_getsockopt}, {g_achbind, l_bind}, {g_achconnect, l_connect}, {g_achshutdown, l_shutdown}, {g_achsend, l_send},
 	{g_achrecv, l_recv}, {g_achsendmsg, l_sendmsg}, {g_achrecvmsg, l_recvmsg}, {g_achallocmsg, l_allocmsg}, {g_achfreemsg, l_freemsg},
 	{g_achcmsg, l_cmsg}, {g_achpoll, l_poll}, {g_acherrno, l_errno}, {g_achstrerror, l_strerror}, {g_achsymbol, l_symbol}, {g_achsymbolinfo, l_symbolinfo},
-	{g_achdevice, l_device}, {g_achterm, l_term}, {g_achsleep, l_sleep}};
+	{g_achdevice, l_device}, {g_achterm, l_term}, {g_achsleep, l_sleep}, {g_achselect, l_select},
+	{g_achFD_CLR, l_FD_CLR}, {g_achFD_ISSET, l_FD_ISSET}, {g_achFD_SET, l_FD_SET}, {g_achFD_ZERO, l_FD_ZERO}};
 static const int g_inmlApis = sizeof(g_apchApi)/sizeof(g_apchApi[0]);

 int dump_stack(lua_State *L, const char * msg);


Use regex_t only if ENABLE_REGEX is defined

--- tests/check_check_master.c
+++ tests/check_check_master.c
@@ -477,10 +477,12 @@
   char emsg[MAXSTR];
   const char *msg_type_str;
   char *emsg_escaped;
-  regex_t re;
   int reg_err;
   char err_text[256];
   TestResult *tr;
+#if ENABLE_REGEX
+  regex_t re;
+#endif

   for (i = 0; i < sub_ntests; i++) {
     master_test_t *master_test = &master_tests[i];
@@ -679,10 +681,12 @@
   char emsg[MAXSTR];
   const char *msg_type_str;
   char err_text[256];
-  regex_t re;
   int reg_err
   unsigned char not_equal = 0;
   char *emsg_escaped;
+#if ENABLE_REGEX
+  regex_t re;
+#endif

   switch (master_test->msg_type) {
   case CK_MSG_TEXT:


ecross energy

ecross energy

--- PWG4/UserTasks/EmcalTasks/AliAnalysisTaskEMCALPi0PbPb.h
+++ PWG4/UserTasks/EmcalTasks/AliAnalysisTaskEMCALPi0PbPb.h
@@ -327,7 +327,7 @@
 {
  public:
   AliStaCluster() : TObject(),
-                    fE(0), fR(0), fEta(0), fPhi(0), fN(0), fN1(0), fN3(0), fIdMax(-1), fSM(-1), fEmax(0), fE2max(0),
+                    fE(0), fR(0), fEta(0), fPhi(0), fN(0), fN1(0), fN3(0), fIdMax(-1), fSM(-1), fEmax(0), fE2max(0), fEcross(0),
                     fTmax(0), fDbc(-1), fDisp(-1), fM20(-1), fM02(-1), fEcc(-1), fSig(-1), fSigEtaEta(-1), fSigPhiPhi(-1),
                     fIsTrackM(0), fTrDz(0), fTrDr(-1), fTrEp(0), fTrDedx(0), fTrIso(0), fTrIso1(0), fTrIso2(0),
                     fTrIsoD1(0), fTrIso1D1(0), fTrIso2D1(0), fTrIsoD3(0), fTrIso1D3(0), fTrIso2D3(0),
@@ -350,6 +350,7 @@
   Char_t        fSM;               //         super module number (from maximum cell)
   Double32_t    fEmax;             //[0,0,16] energy of maximum cell
   Double32_t    fE2max;            //[0,0,16] energy of second maximum cell
+  Double32_t    fEcross;           //[0,0,16] energy of the 4 adjacent cells around the seed
   Double32_t    fTmax;             //[0,0,16] time of maximum cell
   Double32_t    fDbc;              //[0,0,16] distance to nearest bad channel
   Double32_t    fDisp;             //[0,0,16] cluster dispersion, for shape analysis
@@ -392,7 +393,7 @@
   Short_t       fMcLabel;          //         index of closest MC particle
   Double32_t    fEmbE;             //[0,0,16] sum of energy of embedded (MC) cells in cluster

-  ClassDef(AliStaCluster,9) // Cluster class
+  ClassDef(AliStaCluster,10) // Cluster class
 };

 class AliStaTrigger : public TObject


return an error if the region is already being closed in omx__user_region_deregister

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

--- driver/linux/omx_reg.c
+++ driver/linux/omx_reg.c
@@ -206,11 +206,15 @@
 	return ret;
 }

-static void
+static int
 omx__user_region_deregister(struct omx_endpoint * endpoint,
 			    struct omx_user_region * region)
 {
+	int err;
+
 	write_lock_bh(&region->lock);
+
+	err = -EINVAL;
 	if (unlikely(region->status != OMX_USER_REGION_STATUS_OK))
 		goto out_with_region_lock;

@@ -222,10 +226,11 @@
 	/* release our refcount now that other users cannot use again */
 	kref_put(&region->refcount, __omx_user_region_last_release);

-	return;
+	return 0;

  out_with_region_lock:
 	write_unlock_bh(&region->lock);
+	return err;
 }

 int
@@ -261,7 +266,10 @@
 		goto out_with_endpoint_lock;
 	}

-	omx__user_region_deregister(endpoint, region);
+	ret = omx__user_region_deregister(endpoint, region);
+	if (ret < 0)
+		goto out_with_endpoint_lock;
+
 	endpoint->user_regions[cmd.id] = NULL;
 	write_unlock_bh(&endpoint->user_regions_lock);


ata_piix: disallow UDMA 133 on ICH5 & ICH7

There is another outstanding issue with ata_piix.c.  Intel has never
officially supported anything faster than PATA 100MB/s.

But, the ata_piix.c driver "define" the ICH5 & ICH7 as UDMA6 (aka 133MB/s)
capable.  [ Well, no one has probably noticed it before, because there is bug
in do_pata_set_dmamode...  Just look at
libata_atapiix_enable_real_udma133.patch and you'll see what wrong with it.  ]

Here are Intel's datasheets for the affected chipsets: ICH5 Datasheet:
http://www.intel.com/design/chipsets/datashts/252516.htm (See note on page
183: "...  the ICH5 supports reads at the maximum rate of 100MB/s.")

ICH7 Datasheet: http://www.intel.com/design/chipsets/datashts/307013.htm (See
first note on page 190: "...  the ICH7 supports reads at the maximum rate of
100MB/s.")

They are two different ways to deal with it:

- Either -

1. replace all ich_pata_133 with ich_pata_100.
   (libata_atapiix_disable_udma6.diff - diff from 2.6.22 )

- Or -

2. keep all ich_pata_133 and fix the bug in "do_pata_set_dmamode".
   (libata_atapiix_enable_real_udma133.patch - diff from 2.6.22) If there are
   any concerns about the safety of the patch patch:
   http://lkml.org/lkml/2007/7/6/292 (It was already tested by an Intel
   employee, but I guess a bit more user input is necessary here...  )

This patch implements 1.

Cc: Alan Cox <91e38e63b890fbb214c8914809fde03c73e7f24d@lxorguk.ukuu.org.uk>
Cc: Jeff Garzik <f3e731dfa293c7a83119d8aacfa41b5d2d780be9@garzik.org>
Cc: Tejun Heo <ccfba69985e72fbcd9ba8bbb6db43d42971ad06d@gmail.com>
Signed-off-by: Christian Lamparter <2b86d4915b352c348b09e5d907edf5d041a1585c@web.de>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Jeff Garzik <f3e731dfa293c7a83119d8aacfa41b5d2d780be9@garzik.org>

--- drivers/ata/ata_piix.c
+++ drivers/ata/ata_piix.c
@@ -123,7 +123,7 @@
 	ich_pata_33		= 1,	/* ICH up to UDMA 33 only */
 	ich_pata_66		= 2,	/* ICH up to 66 Mhz */
 	ich_pata_100		= 3,	/* ICH up to UDMA 100 */
-	ich_pata_133		= 4,	/* ICH up to UDMA 133 */
+	/* ICH up to UDMA 133 is not supported */
 	ich5_sata		= 5,
 	ich6_sata		= 6,
 	ich6_sata_ahci		= 7,
@@ -199,7 +199,7 @@
 	{ 0x8086, 0x24CA, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
 	{ 0x8086, 0x24CB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
 	/* Intel ICH5 */
-	{ 0x8086, 0x24DB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_133 },
+	{ 0x8086, 0x24DB, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
 	/* C-ICH (i810E2) */
 	{ 0x8086, 0x245B, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
 	/* ESB (855GME/875P + 6300ESB) UDMA 100  */
@@ -207,7 +207,7 @@
 	/* ICH6 (and 6) (i915) UDMA 100 */
 	{ 0x8086, 0x266F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
 	/* ICH7/7-R (i945, i975) UDMA 100*/
-	{ 0x8086, 0x27DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_133 },
+	{ 0x8086, 0x27DF, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
 	{ 0x8086, 0x269E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
 	/* ICH8 Mobile PATA Controller */
 	{ 0x8086, 0x2850, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich_pata_100 },
@@ -505,7 +505,7 @@
 		.port_ops	= &ich_pata_ops,
 	},

-	/* ich_pata_133: 4 	ICH with full UDMA6 */
+	/* ich_pata_133: 4 - Not supported - */
 	{
 		.sht		= &piix_sht,
 		.flags		= PIIX_PATA_FLAGS | PIIX_FLAG_CHECKINTR,


drivers: can: mcan: allow sjw == CAN_SJW_NO_CHANGE

Take CAN_SJW_NO_CHANGE into account when bounds checking the sjw timing
parameter values.

Fixes: #44482

Signed-off-by: Henrik Brix Andersen <24a3f13c22635bab658e39fc5f1e63c575328aae@vestas.com>

--- drivers/can/can_mcan.c
+++ drivers/can/can_mcan.c
@@ -133,7 +133,8 @@
 				timing->phase_seg2 > 0);
 		__ASSERT_NO_MSG(timing->prescaler <= 0x200 &&
 				timing->prescaler > 0);
-		__ASSERT_NO_MSG(timing->sjw <= 0x80 && timing->sjw > 0);
+		__ASSERT_NO_MSG(timing->sjw == CAN_SJW_NO_CHANGE ||
+				(timing->sjw <= 0x80 && timing->sjw > 0));

 		can->nbtp = (((uint32_t)timing->phase_seg1 - 1UL) & 0xFF) <<
 				CAN_MCAN_NBTP_NTSEG1_POS |
@@ -161,8 +162,8 @@
 				timing_data->phase_seg2 > 0);
 		__ASSERT_NO_MSG(timing_data->prescaler <= 20 &&
 				timing_data->prescaler > 0);
-		__ASSERT_NO_MSG(timing_data->sjw <= 0x80 &&
-				timing_data->sjw > 0);
+		__ASSERT_NO_MSG(timing_data->sjw == CAN_SJW_NO_CHANGE ||
+				(timing_data->sjw <= 0x80 && timing_data->sjw > 0));

 		can->dbtp = (((uint32_t)timing_data->phase_seg1 - 1UL) & 0x1F) <<
 				CAN_MCAN_DBTP_DTSEG1_POS |


tpm: don't use flush_scheduled_work()

tpm: don't use flush_scheduled_work()

flush_scheduled_work() is deprecated and scheduled to be removed.
Directly flush chip->work instead.

Signed-off-by: Tejun Heo <546b05909706652891a87f7bfe385ae147f61f91@kernel.org>
Cc: Debora Velarde <8899fd2ac36a87c253e2df5fab23bd7ece93f0cc@linux.vnet.ibm.com>
Cc: Rajiv Andrade <3cd4580e3c128af73a5b4375e865c34e65fd90b2@linux.vnet.ibm.com>

--- drivers/char/tpm/tpm.c
+++ drivers/char/tpm/tpm.c
@@ -986,7 +986,7 @@
 	struct tpm_chip *chip = file->private_data;

 	del_singleshot_timer_sync(&chip->user_read_timer);
-	flush_scheduled_work();
+	flush_work_sync(&chip->work);
 	file->private_data = NULL;
 	atomic_set(&chip->data_pending, 0);
 	kfree(chip->data_buffer);
@@ -1038,7 +1038,7 @@
 	ssize_t ret_size;

 	del_singleshot_timer_sync(&chip->user_read_timer);
-	flush_scheduled_work();
+	flush_work_sync(&chip->work);
 	ret_size = atomic_read(&chip->data_pending);
 	atomic_set(&chip->data_pending, 0);
 	if (ret_size > 0) {	/* relay data */


[Wii] added support for Wii U Pro Controller & fixed in-game support for 3rd party Classic Controllers with invalid calibration data (continued)

error: pathspec 'gx/utils/wrap_wiiuse.c' did not match any file(s) known to git

--- gx/utils/wrap_wiiuse.c
+++ gx/utils/wrap_wiiuse.c
@@ -0,0 +1,189 @@
+/****************************************************************************
+ *  wrap_wiiuse.c
+ *
+ *  libwiiuse wrapper for 3rd-party Classic Controller & Wii U Pro Controller support
+ *
+ *  Copyright (C) 2015 Eke-Eke, based on technical info & code from Tueidj
+ *
+ *  Redistribution and use in source and binary forms, with or without modification,
+ *  are permitted provided that the following conditions are met:
+ *
+ *  1. Redistributions of source code must retain the above copyright notice,
+ *     this list of conditions and the following disclaimer.
+ *
+ *  2. Redistributions in binary form must reproduce the above copyright notice,
+ *     this list of conditions and the following disclaimer in the documentation and/or
+ *     other materials provided with the distribution.
+ *
+ *  3. The name of the author may not be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ *  POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************************/
+
+#ifdef HW_RVL
+
+#include <string.h>
+#include <wiiuse/wiiuse.h>
+
+#define WM_EXP_MEM_BASE   0x04A40000
+
+#define WM_CTRL_STATUS_BYTE1_ATTACHMENT   0x02
+
+#define WIIMOTE_STATE_WIIU_PRO_FOUND      0x00002
+#define WIIMOTE_STATE_HANDSHAKE           0x00004
+#define WIIMOTE_STATE_HANDSHAKE_COMPLETE  0x00008
+
+extern void __real_wiiuse_handshake(struct wiimote_t *wm,ubyte *data,uword len);
+extern void __real_wiiuse_set_ir(struct wiimote_t *wm,int status);
+extern int __real_classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, ubyte* data, uword len);
+
+static ubyte id[2];
+
+void __wrap_wiiuse_handshake(struct wiimote_t *wm,ubyte *data,uword len)
+{
+  if (!wm->handshake_state)
+  {
+    if (len==0)
+    {
+      /* 1st step : read wiimote status (this will also starts expansion handshake if one is connected) */
+      wiiuse_set_leds(wm,WIIMOTE_LED_NONE,NULL);
+      wiiuse_status(wm,__wrap_wiiuse_handshake);
+      return;
+    }
+
+    if (len > 2)
+    {
+      /* 2nd step: read expansion controller ID (if connected) */
+      if (data[2]&WM_CTRL_STATUS_BYTE1_ATTACHMENT)
+      {
+        wiiuse_read_data(wm,id,WM_EXP_MEM_BASE+0xFE,2,__wrap_wiiuse_handshake);
+        return;
+      }
+    }
+    else
+    {
+      /* 3rd step: finish handshake without trying to read internal memory if Wii U pro controller is detected */
+      if ((data[0]==0x01) && (data[1]==0x20))
+      {
+        int *state = (int *)&wm->state;
+        WIIUSE_EVENT_TYPE *event = (WIIUSE_EVENT_TYPE *)&wm->event;
+        *state &= ~WIIMOTE_STATE_HANDSHAKE;
+        *state |= (WIIMOTE_STATE_HANDSHAKE_COMPLETE | WIIMOTE_STATE_WIIU_PRO_FOUND);
+        *event = WIIUSE_CONNECT;
+        wiiuse_status(wm,NULL);
+			  return;
+      }
+    }
+  }
+
+  /* proceed with default handshake sequence */
+  __real_wiiuse_handshake(wm,data,len);
+}
+
+void __wrap_wiiuse_set_ir(struct wiimote_t *wm,int status)
+{
+  /* do not enable IR on Wii U Pro Controller */
+  if (wm->state & WIIMOTE_STATE_WIIU_PRO_FOUND)
+  {
+    /* this will force data report modes 0x34 or 0x35 */
+    wiiuse_status(wm,NULL);
+    return;
+  }
+
+  __real_wiiuse_set_ir(wm,status);
+}
+
+int __wrap_classic_ctrl_handshake(struct wiimote_t* wm, struct classic_ctrl_t* cc, ubyte* data, uword len)
+{
+  /* detect Wii U Pro Controller */
+  if ((len > 223) && (data[222] == 0x01) && (data[223] == 0x20))
+  {
+    /* set default calibration values */
+    cc->btns = 0;
+    cc->btns_held = 0;
+    cc->btns_released = 0;
+    cc->ljs.max.x = cc->ljs.max.y = cc->rjs.max.x = cc->rjs.max.y = 255;
+    cc->ljs.min.x = cc->ljs.min.y = cc->rjs.min.x = cc->rjs.min.y = 0;
+    cc->ljs.center.x = cc->ljs.center.y = cc->rjs.center.x = cc->rjs.center.y = 128;
+
+    /* finish expansion handshake */
+    int *type = (int *)&wm->exp.type;
+    *type = EXP_CLASSIC;
+    return 1;
+  }
+
+  /* sometimes the first 16 bytes are invalid but the next 16 bytes are ok (?) */
+  if (data[0] == 0xFF)
+  {
+    if (data[16] != 0xFF)
+      data += 16;
+  }
+
+  /* some 3rd-party classic controllers return invalid factory calibration data */
+  if ((data[0] <= data[2]) || (data[1] >= data[2]) || (data[3] <= data[5]) || (data[4] >= data[5]) ||
+      (data[6] <= data[8]) || (data[7] >= data[8]) || (data[9] <= data[11]) || (data[10] >= data[11]))
+  {
+    /* this will reset to default values */
+    memset(data, 0, 16);
+  }
+
+  return __real_classic_ctrl_handshake(wm, cc, data, len);
+}
+
+void __wrap_classic_ctrl_event(struct classic_ctrl_t* cc, ubyte* msg)
+{
+	/* save previously pressed buttons */
+	cc->btns_last = cc->btns;
+
+  /* detect Wii U pro controller */
+  if (cc->rjs.max.x == 0xFF)
+  {
+    /* pressed buttons (0 is active, 1 is inactive) */
+	  cc->btns = ~((msg[8] << 8) | msg[9]) & CLASSIC_CTRL_BUTTON_ALL;
+
+    /* convert 12-bit little endian analog joysticks position to 8-bit values */
+    cc->ljs.pos.x = (msg[0] >> 4) | (msg[1] << 4);
+    cc->rjs.pos.x = (msg[2] >> 4) | (msg[3] << 4);
+    cc->ljs.pos.y = (msg[4] >> 4) | (msg[5] << 4);
+    cc->rjs.pos.y = (msg[6] >> 4) | (msg[7] << 4);
+
+	  /* left/right triggers (not analog) */
+    cc->ls_raw = cc->btns & CLASSIC_CTRL_BUTTON_FULL_L ? 0x1F : 0;
+    cc->rs_raw = cc->btns & CLASSIC_CTRL_BUTTON_FULL_R ? 0x1F : 0;
+  }
+  else
+  {
+    /* pressed buttons (0 is active, 1 is inactive) */
+	  cc->btns = ~((msg[4] << 8) | msg[5]) & CLASSIC_CTRL_BUTTON_ALL;
+
+    /* analog joysticks position */
+    cc->ljs.pos.x = (msg[0] & 0x3F);
+    cc->ljs.pos.y = (msg[1] & 0x3F);
+    cc->rjs.pos.x = ((msg[0] & 0xC0) >> 3) | ((msg[1] & 0xC0) >> 5) | ((msg[2] & 0x80) >> 7);
+    cc->rjs.pos.y = (msg[2] & 0x1F);
+
+    /* left/right triggers (analog) */
+    cc->ls_raw = (((msg[2] & 0x60) >> 2) | ((msg[3] & 0xE0) >> 5));
+    cc->rs_raw = (msg[3] & 0x1F);
+  }
+
+	/* held buttons */
+	cc->btns_held = (cc->btns & cc->btns_last);
+
+	/* released buttons */
+	cc->btns_released = (~cc->btns & cc->btns_last);
+}
+
+#endif


dmaengine: at_xdmac: simplify channel configuration stuff

This patch simplifies the channel configuration register management.
Relying on a "software snapshot" of the configuration is not safe and
too complex.

Multiple dwidths will be introduced for slave transfers. In this case,
it becomes quite difficult to have an accurate snapshot of the channel
configuration register in the way it is done. Using the channel
configuration available in the lli descriptor simplifies this stuff.

Signed-off-by: Ludovic Desroches <627575320a9526cb6c91021c9940202b0e84c416@atmel.com>
Signed-off-by: Vinod Koul <5cf69c63beb17bf38d63aa0e923ee8256af0e205@intel.com>

--- drivers/dma/at_xdmac.c
+++ drivers/dma/at_xdmac.c
@@ -191,10 +191,9 @@
 	struct dma_chan			chan;
 	void __iomem			*ch_regs;
 	u32				mask;		/* Channel Mask */
-	u32				cfg[3];		/* Channel Configuration Register */
-	#define	AT_XDMAC_CUR_CFG	0		/* Current channel conf */
-	#define	AT_XDMAC_DEV_TO_MEM_CFG	1		/* Predifined dev to mem channel conf */
-	#define	AT_XDMAC_MEM_TO_DEV_CFG	2		/* Predifined mem to dev channel conf */
+	u32				cfg[2];		/* Channel Configuration Register */
+	#define	AT_XDMAC_DEV_TO_MEM_CFG	0		/* Predifined dev to mem channel conf */
+	#define	AT_XDMAC_MEM_TO_DEV_CFG	1		/* Predifined mem to dev channel conf */
 	u8				perid;		/* Peripheral ID */
 	u8				perif;		/* Peripheral Interface */
 	u8				memif;		/* Memory Interface */
@@ -358,14 +357,7 @@
 	 */
 	if (is_slave_direction(first->direction)) {
 		reg = AT_XDMAC_CNDC_NDVIEW_NDV1;
-		if (first->direction == DMA_MEM_TO_DEV)
-			atchan->cfg[AT_XDMAC_CUR_CFG] =
-				atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG];
-		else
-			atchan->cfg[AT_XDMAC_CUR_CFG] =
-				atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG];
-		at_xdmac_chan_write(atchan, AT_XDMAC_CC,
-				    atchan->cfg[AT_XDMAC_CUR_CFG]);
+		at_xdmac_chan_write(atchan, AT_XDMAC_CC, first->lld.mbr_cfg);
 	} else {
 		/*
 		 * No need to write AT_XDMAC_CC reg, it will be done when the
@@ -569,7 +561,6 @@
 	struct at_xdmac_desc	*first = NULL, *prev = NULL;
 	struct scatterlist	*sg;
 	int			i;
-	u32			cfg;
 	unsigned int		xfer_size = 0;

 	if (!sgl)
@@ -616,17 +607,17 @@
 		if (direction == DMA_DEV_TO_MEM) {
 			desc->lld.mbr_sa = atchan->per_src_addr;
 			desc->lld.mbr_da = mem;
-			cfg = atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG];
+			desc->lld.mbr_cfg = atchan->cfg[AT_XDMAC_DEV_TO_MEM_CFG];
 		} else {
 			desc->lld.mbr_sa = mem;
 			desc->lld.mbr_da = atchan->per_dst_addr;
-			cfg = atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG];
+			desc->lld.mbr_cfg = atchan->cfg[AT_XDMAC_MEM_TO_DEV_CFG];
 		}
-		desc->lld.mbr_ubc = AT_XDMAC_MBR_UBC_NDV1		/* next descriptor view */
-			| AT_XDMAC_MBR_UBC_NDEN				/* next descriptor dst parameter update */
-			| AT_XDMAC_MBR_UBC_NSEN				/* next descriptor src parameter update */
-			| (i == sg_len - 1 ? 0 : AT_XDMAC_MBR_UBC_NDE)	/* descriptor fetch */
-			| len / (1 << at_xdmac_get_dwidth(cfg));	/* microblock length */
+		desc->lld.mbr_ubc = AT_XDMAC_MBR_UBC_NDV1			/* next descriptor view */
+			| AT_XDMAC_MBR_UBC_NDEN					/* next descriptor dst parameter update */
+			| AT_XDMAC_MBR_UBC_NSEN					/* next descriptor src parameter update */
+			| (i == sg_len - 1 ? 0 : AT_XDMAC_MBR_UBC_NDE)		/* descriptor fetch */
+			| len / (1 << at_xdmac_get_dwidth(desc->lld.mbr_cfg));	/* microblock length */
 		dev_dbg(chan2dev(chan),
 			 "%s: lld: mbr_sa=%pad, mbr_da=%pad, mbr_ubc=0x%08x\n",
 			 __func__, &desc->lld.mbr_sa, &desc->lld.mbr_da, desc->lld.mbr_ubc);
@@ -890,7 +881,7 @@
 	enum dma_status		ret;
 	int			residue;
 	u32			cur_nda, mask, value;
-	u8			dwidth = at_xdmac_get_dwidth(atchan->cfg[AT_XDMAC_CUR_CFG]);
+	u8			dwidth = 0;

 	ret = dma_cookie_status(chan, cookie, txstate);
 	if (ret == DMA_COMPLETE)
@@ -920,7 +911,7 @@
 	 */
 	mask = AT_XDMAC_CC_TYPE | AT_XDMAC_CC_DSYNC;
 	value = AT_XDMAC_CC_TYPE_PER_TRAN | AT_XDMAC_CC_DSYNC_PER2MEM;
-	if ((atchan->cfg[AT_XDMAC_CUR_CFG] & mask) == value) {
+	if ((desc->lld.mbr_cfg & mask) == value) {
 		at_xdmac_write(atxdmac, AT_XDMAC_GSWF, atchan->mask);
 		while (!(at_xdmac_chan_read(atchan, AT_XDMAC_CIS) & AT_XDMAC_CIS_FIS))
 			cpu_relax();
@@ -934,6 +925,7 @@
 	 */
 	descs_list = &desc->descs_list;
 	list_for_each_entry_safe(desc, _desc, descs_list, desc_node) {
+		dwidth = at_xdmac_get_dwidth(desc->lld.mbr_cfg);
 		residue -= (desc->lld.mbr_ubc & 0xffffff) << dwidth;
 		if ((desc->lld.mbr_nda & 0xfffffffc) == cur_nda)
 			break;


I/OAT: do not set DCACTRL_CMPL_WRITE_ENABLE for I/OAT ver.3

Flag DCACTRL_CMPL_WRITE_ENABLE is valid only for I/OAT ver.2
so it should not be set for I/OAT ver.3.

Signed-off-by: Maciej Sosnowski <a6d933f4cf474de3a01bcf87cdc350f7c76eff48@intel.com>
Signed-off-by: Shannon Nelson <14bbe8f00ad7c6d888a504d41f5500c00531af99@intel.com>
Acked-by: Jeff Kirsher <87e35f5be20bb3e67f4ba6b86f5f6be3085b1b3a@intel.com>
Signed-off-by: Dan Williams <24ee2bf0bd8ac766c348bf1f0639943bac1535c6@intel.com>

--- drivers/dma/ioat_dma.c
+++ drivers/dma/ioat_dma.c
@@ -189,11 +189,13 @@
 		ioat_chan->xfercap = xfercap;
 		ioat_chan->desccount = 0;
 		INIT_DELAYED_WORK(&ioat_chan->work, ioat_dma_chan_reset_part2);
-		if (ioat_chan->device->version != IOAT_VER_1_2) {
-			writel(IOAT_DCACTRL_CMPL_WRITE_ENABLE
-					| IOAT_DMA_DCA_ANY_CPU,
-				ioat_chan->reg_base + IOAT_DCACTRL_OFFSET);
-		}
+		if (ioat_chan->device->version == IOAT_VER_2_0)
+			writel(IOAT_DCACTRL_CMPL_WRITE_ENABLE |
+			       IOAT_DMA_DCA_ANY_CPU,
+			       ioat_chan->reg_base + IOAT_DCACTRL_OFFSET);
+		else if (ioat_chan->device->version == IOAT_VER_3_0)
+			writel(IOAT_DMA_DCA_ANY_CPU,
+			       ioat_chan->reg_base + IOAT_DCACTRL_OFFSET);
 		spin_lock_init(&ioat_chan->cleanup_lock);
 		spin_lock_init(&ioat_chan->desc_lock);
 		INIT_LIST_HEAD(&ioat_chan->free_desc);


drivers/dma: Eliminate a NULL pointer dereference

If td_desc is NULL, just skip both kfrees.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@r exists@
expression E,E1;
identifier f;
statement S1,S2,S3;
@@

if ((E == NULL && ...) || ...)
{
  ... when != if (...) S1 else S2
      when != E = E1
* E->f
  ... when any
  return ...;
}
else S3
// </smpl>

Signed-off-by: Julia Lawall <b43b0ad1e8108e7ab870d7a54feac93ae8b8600e@diku.dk>
Signed-off-by: Dan Williams <24ee2bf0bd8ac766c348bf1f0639943bac1535c6@intel.com>

--- drivers/dma/timb_dma.c
+++ drivers/dma/timb_dma.c
@@ -382,7 +382,7 @@
 	td_desc = kzalloc(sizeof(struct timb_dma_desc), GFP_KERNEL);
 	if (!td_desc) {
 		dev_err(chan2dev(chan), "Failed to alloc descriptor\n");
-		goto err;
+		goto out;
 	}

 	td_desc->desc_list_len = td_chan->desc_elems * TIMB_DMA_DESC_SIZE;
@@ -410,7 +410,7 @@
 err:
 	kfree(td_desc->desc_list);
 	kfree(td_desc);
-
+out:
 	return NULL;

 }


ide: use ->tf_load in SELECT_DRIVE()

ide: use ->tf_load in SELECT_DRIVE()

Convert SELECT_DRIVE() to use ->tf_load instead of ->OUTB.

There should be no functional changes caused by this patch.

Signed-off-by: Bartlomiej Zolnierkiewicz <248de9df611a028e5eceb9d893a2ed6c24c89ef4@gmail.com>

--- drivers/ide/ide-iops.c
+++ drivers/ide/ide-iops.c
@@ -88,11 +88,15 @@
 {
 	ide_hwif_t *hwif = drive->hwif;
 	const struct ide_port_ops *port_ops = hwif->port_ops;
+	ide_task_t task;

 	if (port_ops && port_ops->selectproc)
 		port_ops->selectproc(drive);

-	hwif->OUTB(drive->select.all, hwif->io_ports.device_addr);
+	memset(&task, 0, sizeof(task));
+	task.tf_flags = IDE_TFLAG_OUT_DEVICE;
+
+	drive->hwif->tf_load(drive, &task);
 }

 void SELECT_MASK(ide_drive_t *drive, int mask)


ieee1394: speed up of dma_region_sync_for_cpu

when attempting to find the 'last' part of the dma region continue the
search from where we left off, instead of starting the search over.

Signed-off-by: Jim Westfall <09bc2be9ee0bb66d3707c85d6acc5be82eb72b1c@surrealistic.net>
Signed-off-by: Ben Collins <313d575bc822fefc4b8f5cef37aa7dabeb604115@ubuntu.com>

--- drivers/ieee1394/dma.c
+++ drivers/ieee1394/dma.c
@@ -145,12 +145,12 @@
 /* find the scatterlist index and remaining offset corresponding to a
    given offset from the beginning of the buffer */
 static inline int dma_region_find(struct dma_region *dma, unsigned long offset,
-				  unsigned long *rem)
+				  unsigned int start, unsigned long *rem)
 {
 	int i;
 	unsigned long off = offset;

-	for (i = 0; i < dma->n_dma_pages; i++) {
+	for (i = start; i < dma->n_dma_pages; i++) {
 		if (off < sg_dma_len(&dma->sglist[i])) {
 			*rem = off;
 			break;
@@ -170,7 +170,7 @@
 	unsigned long rem = 0;

 	struct scatterlist *sg =
-	    &dma->sglist[dma_region_find(dma, offset, &rem)];
+	    &dma->sglist[dma_region_find(dma, offset, 0, &rem)];
 	return sg_dma_address(sg) + rem;
 }

@@ -178,13 +178,13 @@
 			     unsigned long len)
 {
 	int first, last;
-	unsigned long rem;
+	unsigned long rem = 0;

 	if (!len)
 		len = 1;

-	first = dma_region_find(dma, offset, &rem);
-	last = dma_region_find(dma, offset + len - 1, &rem);
+	first = dma_region_find(dma, offset, 0, &rem);
+	last = dma_region_find(dma, rem + len - 1, first, &rem);

 	pci_dma_sync_sg_for_cpu(dma->dev, &dma->sglist[first], last - first + 1,
 				dma->direction);
@@ -194,13 +194,13 @@
 				unsigned long len)
 {
 	int first, last;
-	unsigned long rem;
+	unsigned long rem = 0;

 	if (!len)
 		len = 1;

-	first = dma_region_find(dma, offset, &rem);
-	last = dma_region_find(dma, offset + len - 1, &rem);
+	first = dma_region_find(dma, offset, 0, &rem);
+	last = dma_region_find(dma, rem + len - 1, first, &rem);

 	pci_dma_sync_sg_for_device(dma->dev, &dma->sglist[first],
 				   last - first + 1, dma->direction);


mfd: max77693: Make of_device_id array const

Array of struct of_device_id may be be const as expected by
of_match_table field.

Signed-off-by: Krzysztof Kozlowski <1a8531307367602b8284517edb33d53d54e5ce8e@samsung.com>
Reviewed-by: Chanwoo Choi <42eed19c0f56a8d487deac90c6d19d6364b7ba73@samsung.com>
Signed-off-by: Lee Jones <630e34333487a351a857f6b705e04d30b37c1629@linaro.org>

--- drivers/mfd/max77693.c
+++ drivers/mfd/max77693.c
@@ -243,7 +243,7 @@
 };

 #ifdef CONFIG_OF
-static struct of_device_id max77693_dt_match[] = {
+static const struct of_device_id max77693_dt_match[] = {
 	{ .compatible = "maxim,max77693" },
 	{},
 };


mfd: Revert "mfd: Always assign of_node in mfd_add_device()"

This reverts commit 68044bee13770918e0b28dd44aa98c889ec7558f.

We've had confirmed reports of this patch causing unforeseen issues
with existing MFD users. It has been agreed by the original author
and myself that reversion is the best solution.

Acked-by: Stephen Warren <5ef2a23ba3aff51d1cfc8c113c1ec34b608b3b13@nvidia.com>
Signed-off-by: Lee Jones <630e34333487a351a857f6b705e04d30b37c1629@linaro.org>

--- drivers/mfd/mfd-core.c
+++ drivers/mfd/mfd-core.c
@@ -117,8 +117,6 @@
 			}
 		}
 	}
-	if (!pdev->dev.of_node)
-		pdev->dev.of_node = parent->of_node;

 	if (cell->pdata_size) {
 		ret = platform_device_add_data(pdev,


mfd: sec-core: Make of_device_id array const

Array of struct of_device_id may be be const as expected by both
of_match_table field and of_match_node() call.

Signed-off-by: Krzysztof Kozlowski <1a8531307367602b8284517edb33d53d54e5ce8e@samsung.com>
Signed-off-by: Lee Jones <630e34333487a351a857f6b705e04d30b37c1629@linaro.org>

--- drivers/mfd/sec-core.c
+++ drivers/mfd/sec-core.c
@@ -90,7 +90,7 @@
 };

 #ifdef CONFIG_OF
-static struct of_device_id sec_dt_match[] = {
+static const struct of_device_id sec_dt_match[] = {
 	{	.compatible = "samsung,s5m8767-pmic",
 		.data = (void *)S5M8767X,
 	}, {


mfd: Remove the parsing of dt info for tps65910 gpio

Remove the parsing of device node information for sub devices
from core file.
The sub devices will parse the information as per the sub-devices
specific information.

Signed-off-by: Laxman Dewangan <8ef6cd53fa4ede16d655e2562b753173823989c1@nvidia.com>
Signed-off-by: Samuel Ortiz <0ba86cb3f08bbb861958e54bd3438887adb4263c@linux.intel.com>

--- drivers/mfd/tps65910.c
+++ drivers/mfd/tps65910.c
@@ -146,9 +146,7 @@
 	struct tps65910_board *board_info;
 	unsigned int prop;
 	const struct of_device_id *match;
-	unsigned int prop_array[TPS6591X_MAX_NUM_GPIO];
 	int ret = 0;
-	int idx;

 	match = of_match_device(tps65910_of_match, &client->dev);
 	if (!match) {
@@ -177,21 +175,8 @@
 	else if (*chip_id == TPS65911)
 		dev_warn(&client->dev, "VMBCH2-Threshold not specified");

-	ret = of_property_read_u32_array(np, "ti,en-gpio-sleep",
-				   prop_array, TPS6591X_MAX_NUM_GPIO);
-	if (!ret)
-		for (idx = 0; idx < ARRAY_SIZE(prop_array); idx++)
-			board_info->en_gpio_sleep[idx] = (prop_array[idx] != 0);
-	else if (ret != -EINVAL) {
-		dev_err(&client->dev,
-			"error reading property ti,en-gpio-sleep: %d\n.", ret);
-		return NULL;
-	}
-
-
 	board_info->irq = client->irq;
 	board_info->irq_base = -1;
-	board_info->gpio_base = -1;

 	return board_info;
 }


MEI: convert bus code to use dev_groups

MEI: convert bus code to use dev_groups

The dev_attrs field of struct bus_type is going away soon, dev_groups
should be used instead.  This converts the MEI bus code to use
the correct field.

Acked-by: Tomas Winkler <002a8af089113a6510dbc00453be711ac350fd80@intel.com>
Cc: Samuel Ortiz <0ba86cb3f08bbb861958e54bd3438887adb4263c@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/misc/mei/bus.c
+++ drivers/misc/mei/bus.c
@@ -108,11 +108,13 @@

 	return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
 }
-
-static struct device_attribute mei_cl_dev_attrs[] = {
-	__ATTR_RO(modalias),
-	__ATTR_NULL,
+static DEVICE_ATTR_RO(modalias);
+
+static struct attribute *mei_cl_dev_attrs[] = {
+	&dev_attr_modalias.attr,
+	NULL,
 };
+ATTRIBUTE_GROUPS(mei_cl_dev);

 static int mei_cl_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
@@ -124,7 +126,7 @@

 static struct bus_type mei_cl_bus_type = {
 	.name		= "mei",
-	.dev_attrs	= mei_cl_dev_attrs,
+	.dev_groups	= mei_cl_dev_groups,
 	.match		= mei_cl_device_match,
 	.probe		= mei_cl_device_probe,
 	.remove		= mei_cl_device_remove,


mei: use wrapper for simple hbm client message

Reduce few code lines by using wrappers for sending
simple hbm client messages

Signed-off-by: Tomas Winkler <002a8af089113a6510dbc00453be711ac350fd80@intel.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/misc/mei/hbm.c
+++ drivers/misc/mei/hbm.c
@@ -124,7 +124,7 @@
 /**
  * mei_hbm_cl_hdr - construct client hbm header
  *
- * @cl: - client
+ * @cl: client
  * @hbm_cmd: host bus message command
  * @buf: buffer for cl header
  * @len: buffer length
@@ -139,6 +139,26 @@
 	cmd->hbm_cmd = hbm_cmd;
 	cmd->host_addr = cl->host_client_id;
 	cmd->me_addr = cl->me_client_id;
+}
+
+/**
+ * mei_hbm_cl_write - write simple hbm client message
+ *
+ * @dev: the device structure
+ * @cl: client
+ * @hbm_cmd: host bus message command
+ * @len: buffer length
+ */
+static inline
+int mei_hbm_cl_write(struct mei_device *dev,
+		     struct mei_cl *cl, u8 hbm_cmd, size_t len)
+{
+	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
+
+	mei_hbm_hdr(mei_hdr, len);
+	mei_hbm_cl_hdr(cl, hbm_cmd, dev->wr_msg.data, len);
+
+	return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
 }

 /**
@@ -365,15 +385,9 @@
  */
 int mei_hbm_cl_flow_control_req(struct mei_device *dev, struct mei_cl *cl)
 {
-	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
 	const size_t len = sizeof(struct hbm_flow_control);
-
-	mei_hbm_hdr(mei_hdr, len);
-	mei_hbm_cl_hdr(cl, MEI_FLOW_CONTROL_CMD, dev->wr_msg.data, len);
-
 	cl_dbg(dev, cl, "sending flow control\n");
-
-	return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
+	return mei_hbm_cl_write(dev, cl, MEI_FLOW_CONTROL_CMD, len);
 }

 /**
@@ -452,13 +466,8 @@
  */
 int mei_hbm_cl_disconnect_req(struct mei_device *dev, struct mei_cl *cl)
 {
-	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
 	const size_t len = sizeof(struct hbm_client_connect_request);
-
-	mei_hbm_hdr(mei_hdr, len);
-	mei_hbm_cl_hdr(cl, CLIENT_DISCONNECT_REQ_CMD, dev->wr_msg.data, len);
-
-	return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
+	return mei_hbm_cl_write(dev, cl, CLIENT_DISCONNECT_REQ_CMD, len);
 }

 /**
@@ -471,13 +480,8 @@
  */
 int mei_hbm_cl_disconnect_rsp(struct mei_device *dev, struct mei_cl *cl)
 {
-	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
 	const size_t len = sizeof(struct hbm_client_connect_response);
-
-	mei_hbm_hdr(mei_hdr, len);
-	mei_hbm_cl_hdr(cl, CLIENT_DISCONNECT_RES_CMD, dev->wr_msg.data, len);
-
-	return mei_write_message(dev, mei_hdr, dev->wr_msg.data);
+	return mei_hbm_cl_write(dev, cl, CLIENT_DISCONNECT_RES_CMD, len);
 }

 /**
@@ -526,13 +530,8 @@
  */
 int mei_hbm_cl_connect_req(struct mei_device *dev, struct mei_cl *cl)
 {
-	struct mei_msg_hdr *mei_hdr = &dev->wr_msg.hdr;
 	const size_t len = sizeof(struct hbm_client_connect_request);
-
-	mei_hbm_hdr(mei_hdr, len);
-	mei_hbm_cl_hdr(cl, CLIENT_CONNECT_REQ_CMD, dev->wr_msg.data, len);
-
-	return mei_write_message(dev, mei_hdr,  dev->wr_msg.data);
+	return mei_hbm_cl_write(dev, cl, CLIENT_CONNECT_REQ_CMD, len);
 }

 /**


qseecom: Report address of secure app region to QSEE

QSEE verion 2 supports relocatable images. To support this
a chunk of contiguous memory in the first 256MB  bank is
reserved for loading the secure applications.  The location
and size of this memory region is defined in the device tree
data of the driver.

This patch
- Adds supports for retrieving the address and size of the
  memory region reserved for the secure app from the device
  tree data
- Adds a new command to issue to QSEE for notifying this
  app region information (retrieved from device tree)

Change-Id: I0310815bf42c3705e0f15bd69bd4b02c6f4c56b0
Signed-off-by: Mona Hossain <acf1f709dafbae362ae39414203bf1007742619a@codeaurora.org>

--- drivers/misc/qseecom.c
+++ drivers/misc/qseecom.c
@@ -49,6 +49,9 @@
 #define QSEOS_VERSION_13		0x13
 #define QSEOS_VERSION_14		0x14
 #define QSEEE_VERSION_00		0x400000
+#define QSEE_VERSION_01			0x401000
+#define QSEE_VERSION_02			0x402000
+

 #define QSEOS_CHECK_VERSION_CMD		0x00001803

@@ -75,6 +78,7 @@
 	QSEOS_GET_APP_STATE_COMMAND,
 	QSEOS_LOAD_SERV_IMAGE_COMMAND,
 	QSEOS_UNLOAD_SERV_IMAGE_COMMAND,
+	QSEOS_APP_REGION_NOTIFICATION,
 	QSEOS_CMD_MAX     = 0xEFFFFFFF
 };

@@ -87,6 +91,12 @@
 enum qseecom_clk_definitions {
 	CLK_DFAB = 0,
 	CLK_SFPB,
+};
+
+__packed  struct qsee_apps_region_info_ireq {
+	uint32_t qsee_cmd_id;
+	uint32_t addr;
+	uint32_t size;
 };

 __packed struct qseecom_check_app_ireq {
@@ -2558,6 +2568,32 @@
 		}
 		qseecom_platform_support = (struct msm_bus_scale_pdata *)
 						msm_bus_cl_get_pdata(pdev);
+		if (qseecom.qsee_version >= (QSEE_VERSION_02)) {
+			struct resource *resource = NULL;
+			struct qsee_apps_region_info_ireq req;
+			struct qseecom_command_scm_resp resp;
+
+			resource = platform_get_resource_byname(pdev,
+					IORESOURCE_MEM, "secapp-region");
+			if (resource) {
+				req.qsee_cmd_id = QSEOS_APP_REGION_NOTIFICATION;
+				req.addr = resource->start;
+				req.size = resource_size(resource);
+				pr_warn("secure app region addr=0x%x size=0x%x",
+							req.addr, req.size);
+			} else {
+				pr_err("Fail to get secure app region info\n");
+				rc = -EINVAL;
+				goto err;
+			}
+			rc = scm_call(SCM_SVC_TZSCHEDULER, 1, &req, sizeof(req),
+							&resp, sizeof(resp));
+			if (rc) {
+				pr_err("Failed to send secapp region info %d\n",
+									rc);
+				goto err;
+			}
+		}
 	} else {
 		qseecom_platform_support = (struct msm_bus_scale_pdata *)
 						pdev->dev.platform_data;


UBI: vtbl: Use ubi_eba_atomic_leb_change()

This is more a cosmetic change than a fix.
By using ubi_eba_atomic_leb_change()
we can guarantee that the first VTBL record is always
correct and we don't really need the second one anymore.
But we have to keep the second one to not break anything.

Artem: add a comment

Signed-off-by: Richard Weinberger <320bca71fc381a4a025636043ca86e734e31cf8b@nod.at>
Signed-off-by: Artem Bityutskiy <2f96f8cd3e2780a209d0ab27d1b44624d0019d3f@linux.intel.com>

--- drivers/mtd/ubi/vtbl.c
+++ drivers/mtd/ubi/vtbl.c
@@ -30,9 +30,12 @@
  * eraseblock stores one volume table copy, i.e. LEB 0 and LEB 1 duplicate each
  * other. This redundancy guarantees robustness to unclean reboots. The volume
  * table is basically an array of volume table records. Each record contains
- * full information about the volume and protected by a CRC checksum.
- *
- * The volume table is changed, it is first changed in RAM. Then LEB 0 is
+ * full information about the volume and protected by a CRC checksum. Note,
+ * nowadays we use the atomic LEB change operation when updating the volume
+ * table, so we do not really need 2 LEBs anymore, but we preserve the older
+ * design for the backward compatibility reasons.
+ *
+ * When the volume table is changed, it is first changed in RAM. Then LEB 0 is
  * erased, and the updated volume table is written back to LEB 0. Then same for
  * LEB 1. This scheme guarantees recoverability from unclean reboots.
  *
@@ -96,12 +99,8 @@

 	memcpy(&ubi->vtbl[idx], vtbl_rec, sizeof(struct ubi_vtbl_record));
 	for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) {
-		err = ubi_eba_unmap_leb(ubi, layout_vol, i);
-		if (err)
-			return err;
-
-		err = ubi_eba_write_leb(ubi, layout_vol, i, ubi->vtbl, 0,
-					ubi->vtbl_size);
+		err = ubi_eba_atomic_leb_change(ubi, layout_vol, i, ubi->vtbl,
+						ubi->vtbl_size);
 		if (err)
 			return err;
 	}
@@ -148,12 +147,8 @@

 	layout_vol = ubi->volumes[vol_id2idx(ubi, UBI_LAYOUT_VOLUME_ID)];
 	for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) {
-		err = ubi_eba_unmap_leb(ubi, layout_vol, i);
-		if (err)
-			return err;
-
-		err = ubi_eba_write_leb(ubi, layout_vol, i, ubi->vtbl, 0,
-					ubi->vtbl_size);
+		err = ubi_eba_atomic_leb_change(ubi, layout_vol, i, ubi->vtbl,
+						ubi->vtbl_size);
 		if (err)
 			return err;
 	}


UBI: use own macros for the layout volume

This is a minor nicification: UBI_LAYOUT_VOLUME_TYPE and
UBI_LAYOUT_VOLUME_ALIGN are currently defined but not used -
use them.

Signed-off-by: Richard Weinberger <320bca71fc381a4a025636043ca86e734e31cf8b@nod.at>
Signed-off-by: Artem Bityutskiy <19b5733dcea388885746d36043d3568bba5b4df7@linux.intel.com>

--- drivers/mtd/ubi/vtbl.c
+++ drivers/mtd/ubi/vtbl.c
@@ -322,7 +322,7 @@
 		goto out_free;
 	}

-	vid_hdr->vol_type = UBI_VID_DYNAMIC;
+	vid_hdr->vol_type = UBI_LAYOUT_VOLUME_TYPE;
 	vid_hdr->vol_id = cpu_to_be32(UBI_LAYOUT_VOLUME_ID);
 	vid_hdr->compat = UBI_LAYOUT_VOLUME_COMPAT;
 	vid_hdr->data_size = vid_hdr->used_ebs =
@@ -632,7 +632,7 @@
 		return -ENOMEM;

 	vol->reserved_pebs = UBI_LAYOUT_VOLUME_EBS;
-	vol->alignment = 1;
+	vol->alignment = UBI_LAYOUT_VOLUME_ALIGN;
 	vol->vol_type = UBI_DYNAMIC_VOLUME;
 	vol->name_len = sizeof(UBI_LAYOUT_VOLUME_NAME) - 1;
 	memcpy(vol->name, UBI_LAYOUT_VOLUME_NAME, vol->name_len + 1);


amd8111e big-endian fix

amd8111e big-endian fix

amd8111e_calc_coalesce() ends up with insane values of tx_data_rate since
->tx_bytes increments missing conversion from little- to host-endian

Signed-off-by: Al Viro <de609eb4d5d70b1d38ec6642adbfc33a2781f63c@zeniv.linux.org.uk>
Signed-off-by: Jeff Garzik <f3e731dfa293c7a83119d8aacfa41b5d2d780be9@garzik.org>

--- drivers/net/amd8111e.c
+++ drivers/net/amd8111e.c
@@ -709,7 +709,8 @@
 		lp->tx_complete_idx++;
 		/*COAL update tx coalescing parameters */
 		lp->coal_conf.tx_packets++;
-		lp->coal_conf.tx_bytes += lp->tx_ring[tx_index].buff_count;
+		lp->coal_conf.tx_bytes +=
+			le16_to_cpu(lp->tx_ring[tx_index].buff_count);

 		if (netif_queue_stopped(dev) &&
 			lp->tx_complete_idx > lp->tx_idx - NUM_TX_BUFFERS +2){


fixed really slow svrg sum gradient model method

--- src/Updater/SVRGUpdater.h
+++ src/Updater/SVRGUpdater.h
@@ -91,25 +91,24 @@
 	    for (auto & v : nu)
 		std::fill(v.begin(), v.end(), 0);
 	    std::fill(mu.begin(), mu.end(), 0);
+	    std::fill(grad->coeffs.begin(), grad->coeffs.end(), 0);

 	    model->PrecomputeCoefficients(datapoint, grad, model->ModelData());

 	    // Compute the origial sgd gradients needed in order to sum them.
-	    for (int i = 0; i < datapoint->GetCoordinates().size(); i++) {
-		int index = datapoint->GetCoordinates()[i];
-		model->Mu(index, mu[index], model->ModelData());
-		model->Nu(index, nu[index], model->ModelData());
-		model->H(index, h[index], grad, model->ModelData());
+	    //for (int i = 0; i < datapoint->GetCoordinates().size(); i++) {
+	    for (int i = 0; i < n_coords; i++) {
+		model->Mu(i, mu[i], model->ModelData());
+		model->Nu(i, nu[i], model->ModelData());
+		model->H(i, h[i], grad, model->ModelData());
 	    }

 	    // Calc the gradients.
 	    for (int i = 0; i < n_coords; i++) {
 		for (int j = 0; j < coordinate_size; j++) {
-		    g[i][j] += (mu[i] * model_copy[i*coordinate_size+j] + nu[i][j] + h[i][j]) / datapoints.size();
+		    g[i][j] += (mu[i] * model_copy[i*coordinate_size+j] - nu[i][j] - h[i][j]) / datapoints.size();
 		}
 	    }
-
-	    // Sum the gradients now
 	}
     }
 };