macvlan: receive multicast with local address

When implementing VRRP v2 using macvlan several problems were
discovered.  VRRP is weird in that all routers participating
in a redundant group use the same virtual MAC address.
Macvlan is a natural driver to use for this but it doesn't
work.  The problem is that packets with a macvlan device's
source address are not received.

The problem is actually a regression that date back almost 2 years now.
The original problems started with:

commit 618e1b7482f7a8a4c6c6e8ccbe140e4c331df4e9
Author: Arnd Bergmann <arnd@arndb.de>
Date:   Thu Nov 26 06:07:10 2009 +0000

    macvlan: implement bridge, VEPA and private mode

This patches restores the original 2.6.32 behavior. Allowing multicast
packets received with the VRRP source address to be received.

Signed-off-by: Stephen Hemminger <a072e933f45880fe04500ea083d5c7f6e81a06f0@vyatta.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/macvlan.c
+++ drivers/net/macvlan.c
@@ -192,6 +192,13 @@
 			 */
 			macvlan_broadcast(skb, port, src->dev,
 					  MACVLAN_MODE_VEPA);
+		else {
+			/* forward to original port. */
+			vlan = src;
+			ret = macvlan_broadcast_one(skb, vlan, eth, 0);
+			goto out;
+		}
+
 		return RX_HANDLER_PASS;
 	}


drm/radeon: add WAIT_UNTIL to evergreen VM safe reg list

It's used in a recent mesa commit:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=24b1206ab2dcd506aaac3ef656aebc8bc20cd27a
and there may be some other cases in the future where it's required.

Signed-off-by: Alex Deucher <08dc22c6156113f2deff178e35e3ed9b24d6af9e@amd.com>
Reviewed-by: Jerome Glisse <0620d428a1bd3756b1319066bf466b3b8be0b2b2@redhat.com>
Cc: 4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org

--- drivers/gpu/drm/radeon/evergreen_cs.c
+++ drivers/gpu/drm/radeon/evergreen_cs.c
@@ -3316,6 +3316,7 @@

 	/* check config regs */
 	switch (reg) {
+	case WAIT_UNTIL:
 	case GRBM_GFX_INDEX:
 	case CP_STRMOUT_CNTL:
 	case CP_COHER_CNTL:


tools/blobtool: Add selectable compression algorithms in tar mode

- Add support for compressing/decompressing tarballs with LZF, LZMA, or
the gzip compression built into libarchive

- By default, autodetect compression algorithm on untar

--- tools/blobtool.c
+++ tools/blobtool.c
@@ -59,6 +59,9 @@
 static enum isrcry_padding padding = ISRCRY_PADDING_PKCS5;
 static enum isrcry_hash hash = ISRCRY_HASH_SHA1;
 static unsigned hashlen = 20;
+static gboolean detect_compress = TRUE;		/* Only for decode */
+static gboolean use_internal_compress = FALSE;	/* If false, use gzip */
+static enum isrcry_compress compress;

 /* Command-line parameters */
 static int keyroot_fd;
@@ -66,6 +69,7 @@
 static const char *infile;
 static const char *outfile;
 static const char *parent_dir;
+static const char *compress_alg;
 static gboolean encode = TRUE;
 static gboolean want_encrypt;
 static gboolean want_hash;
@@ -427,6 +431,105 @@
 	}
 }

+/** Compression **************************************************************/
+
+static const struct compress_desc {
+	const char *name;
+	gboolean internal;
+	enum isrcry_compress type;
+	unsigned magiclen;
+	const char magic[6];
+} compress_algs[] = {
+	{"gzip", FALSE},
+	{"lzf", TRUE, ISRCRY_COMPRESS_LZF_STREAM, 2, "ZV"},
+	{"lzma", TRUE, ISRCRY_COMPRESS_LZMA, 6, {0xfd, '7', 'z', 'X', 'Z', 0}},
+	{NULL}
+};
+
+static void parse_compress_alg(void)
+{
+	const struct compress_desc *desc;
+
+	if (compress_alg == NULL)
+		return;  /* Use defaults */
+	detect_compress = FALSE;
+	for (desc = compress_algs; desc->name != NULL; desc++) {
+		if (!strcmp(compress_alg, desc->name)) {
+			use_internal_compress = desc->internal;
+			compress = desc->type;
+			return;
+		}
+	}
+	die("Unknown compression algorithm: %s", compress_alg);
+}
+
+static void detect_compression(const char *in, unsigned inlen)
+{
+	const struct compress_desc *desc;
+
+	detect_compress = FALSE;
+	for (desc = compress_algs; desc->name != NULL; desc++) {
+		if (!desc->internal || inlen < desc->magiclen)
+			continue;
+		if (!memcmp(in, desc->magic, desc->magiclen)) {
+			use_internal_compress = TRUE;
+			compress = desc->type;
+			break;
+		}
+	}
+}
+
+static void run_compression(const char *in, unsigned inlen, GString *out,
+			gboolean final)
+{
+	static struct isrcry_compress_ctx *ctx;
+	unsigned in_offset = 0;
+	unsigned in_count;
+	unsigned out_offset = 0;
+	unsigned out_count;
+	enum isrcry_result ret;
+
+	if (ctx == NULL) {
+		ctx = isrcry_compress_alloc(compress);
+		if (ctx == NULL)
+			die("Couldn't allocate compression algorithm");
+		ret = isrcry_compress_init(ctx, encode ? ISRCRY_ENCODE :
+					ISRCRY_DECODE, 0);
+		if (ret)
+			die("Couldn't initialize compression: %s",
+						isrcry_strerror(ret));
+	}
+
+	do {
+		in_count = inlen - in_offset;
+		out_count = BUFSZ;
+		g_string_set_size(out, out_offset + BUFSZ);
+		ret = isrcry_compress_process(ctx, in + in_offset, &in_count,
+					out->str + out_offset, &out_count);
+		if (ret)
+			die("Compression failed: %s", isrcry_strerror(ret));
+		in_offset += in_count;
+		out_offset += out_count;
+	} while (in_offset < inlen);
+
+	if (final) {
+		do {
+			in_count = 0;
+			out_count = BUFSZ;
+			g_string_set_size(out, out_offset + BUFSZ);
+			ret = isrcry_compress_final(ctx, NULL, &in_count,
+						out->str + out_offset,
+						&out_count);
+			out_offset += out_count;
+		} while (ret == ISRCRY_BUFFER_OVERFLOW);
+		if (ret)
+			die("Finalizing compression failed: %s",
+						isrcry_strerror(ret));
+	}
+
+	g_string_set_size(out, out_offset);
+}
+
 /** Generic control **********************************************************/

 #define action(name) do { \
@@ -435,8 +538,23 @@
 	} while (0)
 static void run_buffer(struct iodata *iod, gboolean final)
 {
-	if (want_encrypt)
-		action(cipher);
+	if (encode) {
+		if (want_tar && use_internal_compress)
+			action(compression);
+		if (want_encrypt)
+			action(cipher);
+	} else {
+		if (want_encrypt)
+			action(cipher);
+		if (want_tar) {
+			/* detect_compression() just peeks in the input
+			   buffer, so we don't use action() */
+			if (detect_compress)
+				detect_compression(iod->in->str, iod->in->len);
+			if (use_internal_compress)
+				action(compression);
+		}
+	}
 	if (want_hash)
 		action(hash);
 	/* Now the output is positioned as the input buffer.  Fix this with
@@ -543,7 +661,8 @@
 		die("Couldn't read archive read object");
 	if (archive_read_support_format_tar(arch))
 		die("Enabling tar format: %s", archive_error_string(arch));
-	if (archive_read_support_compression_gzip(arch))
+	if (!use_internal_compress &&
+				archive_read_support_compression_gzip(arch))
 		die("Enabling gzip format: %s", archive_error_string(arch));
 	if (archive_read_open(arch, iod, NULL, archive_read, NULL))
 		die("Opening archive: %s", archive_error_string(arch));
@@ -666,7 +785,8 @@
 		die("Couldn't read archive write object");
 	if (archive_write_set_format_pax_restricted(arch))
 		die("Setting tar format: %s", archive_error_string(arch));
-	if (archive_write_set_compression_gzip(arch))
+	if (!use_internal_compress &&
+				archive_write_set_compression_gzip(arch))
 		die("Setting compression format: %s",
 					archive_error_string(arch));
 	if (archive_write_set_bytes_in_last_block(arch, 1))
@@ -711,7 +831,8 @@
 };

 static GOptionEntry tar_options[] = {
-	{"tar", 't', 0, G_OPTION_ARG_NONE, &want_tar, "Generate or extract a gzipped tar archive", NULL},
+	{"tar", 't', 0, G_OPTION_ARG_NONE, &want_tar, "Generate or extract a compressed tar archive", NULL},
+	{"compression", 'c', 0, G_OPTION_ARG_STRING, &compress_alg, "Compress with ALG (gzip, lzf, lzma)", "ALG"},
 	{"directory", 'C', 0, G_OPTION_ARG_FILENAME, &parent_dir, "Change to DIR before tarring/untarring files", "DIR"},
 	{NULL}
 };
@@ -741,6 +862,10 @@
 				NULL, NULL);
 	g_option_group_add_entries(grp, tar_options);
 	g_option_context_add_group(ctx, grp);
+
+	g_option_context_set_description(ctx, "tar defaults to gzip on "
+				"encode and auto-detected compression on "
+				"decode.");

 	return ctx;
 }
@@ -760,6 +885,7 @@
 	if (!g_option_context_parse(octx, &argc, &argv, &err))
 		die("%s", err->message);
 	g_option_context_free(octx);
+	parse_compress_alg();
 	if (want_tar && want_hash)
 		die("--tar is incompatible with --hash");
 	if (want_tar && encode && infile != NULL)


natsemi: Use round_jiffies() for slow timers

Unless we have failed to fill the RX ring the timer used by the natsemi
driver is not particularly urgent and can use round_jiffies() to allow
grouping with other timers.

Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@sirena.org.uk>
Signed-off-by: Jeff Garzik <f3e731dfa293c7a83119d8aacfa41b5d2d780be9@garzik.org>

--- drivers/net/natsemi.c
+++ drivers/net/natsemi.c
@@ -1576,7 +1576,7 @@

 	/* Set the timer to check for link beat. */
 	init_timer(&np->timer);
-	np->timer.expires = jiffies + NATSEMI_TIMER_FREQ;
+	np->timer.expires = round_jiffies(jiffies + NATSEMI_TIMER_FREQ);
 	np->timer.data = (unsigned long)dev;
 	np->timer.function = &netdev_timer; /* timer handler */
 	add_timer(&np->timer);
@@ -1856,7 +1856,11 @@
 			next_tick = 1;
 		}
 	}
-	mod_timer(&np->timer, jiffies + next_tick);
+
+	if (next_tick > 1)
+		mod_timer(&np->timer, round_jiffies(jiffies + next_tick));
+	else
+		mod_timer(&np->timer, jiffies + next_tick);
 }

 static void dump_ring(struct net_device *dev)
@@ -3331,7 +3335,7 @@
 		spin_unlock_irq(&np->lock);
 		enable_irq(dev->irq);

-		mod_timer(&np->timer, jiffies + 1*HZ);
+		mod_timer(&np->timer, round_jiffies(jiffies + 1*HZ));
 	}
 	netif_device_attach(dev);
 out:


drm/ttm: Fix memory leak in ttm_agp_backend.c

This patch fix a memory leak found by cppcheck.
[drivers/gpu/drm/ttm/ttm_agp_backend.c:129]:
(error) Memory leak: agp_be

Signed-off-by: Masanari Iida <f31bb8ac2957d045575b3081e813605474613a21@gmail.com>
Reviewed-by: Thomas Hellstrom <a26490dfbee4be3d38287ad6448444504f58193c@vmware.com>

--- drivers/gpu/drm/ttm/ttm_agp_backend.c
+++ drivers/gpu/drm/ttm/ttm_agp_backend.c
@@ -126,6 +126,7 @@
 	agp_be->ttm.func = &ttm_agp_func;

 	if (ttm_tt_init(&agp_be->ttm, bdev, size, page_flags, dummy_read_page)) {
+		kfree(agp_be);
 		return NULL;
 	}


pcnet32: update to net_device_ops

pcnet32: update to net_device_ops

Signed-off-by: Stephen Hemminger <a072e933f45880fe04500ea083d5c7f6e81a06f0@vyatta.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/pcnet32.c
+++ drivers/net/pcnet32.c
@@ -1567,6 +1567,22 @@
 	}
 	return err;
 }
+
+static const struct net_device_ops pcnet32_netdev_ops = {
+	.ndo_open		= pcnet32_open,
+	.ndo_stop 		= pcnet32_close,
+	.ndo_start_xmit		= pcnet32_start_xmit,
+	.ndo_tx_timeout		= pcnet32_tx_timeout,
+	.ndo_get_stats		= pcnet32_get_stats,
+	.ndo_set_multicast_list = pcnet32_set_multicast_list,
+	.ndo_do_ioctl		= pcnet32_ioctl,
+	.ndo_change_mtu		= eth_change_mtu,
+	.ndo_set_mac_address 	= eth_mac_addr,
+	.ndo_validate_addr	= eth_validate_addr,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+	.ndo_poll_controller	= pcnet32_poll_controller,
+#endif
+};

 /* pcnet32_probe1
  *  Called from both pcnet32_probe_vlbus and pcnet_probe_pci.
@@ -1934,19 +1950,9 @@
 	lp->watchdog_timer.function = (void *)&pcnet32_watchdog;

 	/* The PCNET32-specific entries in the device structure. */
-	dev->open = &pcnet32_open;
-	dev->hard_start_xmit = &pcnet32_start_xmit;
-	dev->stop = &pcnet32_close;
-	dev->get_stats = &pcnet32_get_stats;
-	dev->set_multicast_list = &pcnet32_set_multicast_list;
-	dev->do_ioctl = &pcnet32_ioctl;
+	dev->netdev_ops = &pcnet32_netdev_ops;
 	dev->ethtool_ops = &pcnet32_ethtool_ops;
-	dev->tx_timeout = pcnet32_tx_timeout;
 	dev->watchdog_timeo = (5 * HZ);
-
-#ifdef CONFIG_NET_POLL_CONTROLLER
-	dev->poll_controller = pcnet32_poll_controller;
-#endif

 	/* Fill in the generic fields of the device structure. */
 	if (register_netdev(dev))


gpu: ion: add missing parameter in secure CMA Ion heap

msm_iommu_map_extra recently gained another parameter. Add this
missing parameter to the secure CMA Ion heap which missed out on this
new parameter.

Change-Id: I25403acfeb4caf9356ecc290108dd47e84ebf418
Signed-off-by: Mitchel Humpherys <5070267e141ca308fc855217ddbeaf20e729a7bf@codeaurora.org>

--- drivers/gpu/ion/ion_cma_secure_heap.c
+++ drivers/gpu/ion/ion_cma_secure_heap.c
@@ -262,8 +262,9 @@

 	extra_iova_addr = data->iova_addr + buffer->size;
 	if (extra) {
-		ret = msm_iommu_map_extra(domain, extra_iova_addr, extra, SZ_4K,
-						prot);
+		unsigned long phys_addr = sg_phys(table->sgl);
+		ret = msm_iommu_map_extra(domain, extra_iova_addr, phys_addr,
+					extra, SZ_4K, prot);
 		if (ret)
 			goto out2;
 	}


tc35815: Fix double locking on NAPI

tc35815: Fix double locking on NAPI

Isolate spinlock for tx and rx to resolve double-locking.

This is potential bug while this controller does not exist on any
SMP platforms, but lockdep or rt-preempt reveals this bug.

Reported-by: Ralf Roesch <1760d3a86a833f02439ea3c394b9553ff80a342d@rw-gmbh.de>
Signed-off-by: Atsushi Nemoto <80aeab2fcc576fb9134b563f36af765199d49e90@mba.ocn.ne.jp>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>


cpumask: use new cpumask API in drivers/infiniband/hw/ehca

Impact: cleanup

We're moving from handing around cpumask_t's to handing around struct
cpumask *'s.  cpus_*, cpumask_t and cpu_*_map are deprecated: convert
to cpumask_*, cpu_*_mask.

Signed-off-by: Rusty Russell <df9728c9e5104131c08c7adb03af425394842596@rustcorp.com.au>
Acked-by: Hoang-Nam Nguyen <763627f3b610aea52a75097c4dd71d039738190a@de.ibm.com>
Tested-by: Hoang-Nam Nguyen <763627f3b610aea52a75097c4dd71d039738190a@de.ibm.com>
Cc: Christoph Raisch <403318c49f6456144761aaa42a66c28867e20455@de.ibm.com>

--- drivers/infiniband/hw/ehca/ehca_irq.c
+++ drivers/infiniband/hw/ehca/ehca_irq.c
@@ -659,12 +659,12 @@

 	WARN_ON_ONCE(!in_interrupt());
 	if (ehca_debug_level >= 3)
-		ehca_dmp(&cpu_online_map, sizeof(cpumask_t), "");
+		ehca_dmp(cpu_online_mask, cpumask_size(), "");

 	spin_lock_irqsave(&pool->last_cpu_lock, flags);
-	cpu = next_cpu_nr(pool->last_cpu, cpu_online_map);
+	cpu = cpumask_next(pool->last_cpu, cpu_online_mask);
 	if (cpu >= nr_cpu_ids)
-		cpu = first_cpu(cpu_online_map);
+		cpu = cpumask_first(cpu_online_mask);
 	pool->last_cpu = cpu;
 	spin_unlock_irqrestore(&pool->last_cpu_lock, flags);

@@ -855,7 +855,7 @@
 	case CPU_UP_CANCELED_FROZEN:
 		ehca_gen_dbg("CPU: %x (CPU_CANCELED)", cpu);
 		cct = per_cpu_ptr(pool->cpu_comp_tasks, cpu);
-		kthread_bind(cct->task, any_online_cpu(cpu_online_map));
+		kthread_bind(cct->task, cpumask_any(cpu_online_mask));
 		destroy_comp_task(pool, cpu);
 		break;
 	case CPU_ONLINE:
@@ -902,7 +902,7 @@
 		return -ENOMEM;

 	spin_lock_init(&pool->last_cpu_lock);
-	pool->last_cpu = any_online_cpu(cpu_online_map);
+	pool->last_cpu = cpumask_any(cpu_online_mask);

 	pool->cpu_comp_tasks = alloc_percpu(struct ehca_cpu_comp_task);
 	if (pool->cpu_comp_tasks == NULL) {


fix wrong argument of tc35815_read_plat_dev_addr()

Fix wrong argument of tc35815_read_plat_dev_addr()

Signed-off-by: Yoichi Yuasa <8cae077b43cb3823d7d0411bb74fef2b3d450859@tripeaks.co.jp>
Signed-off-by: Jeff Garzik <f3e731dfa293c7a83119d8aacfa41b5d2d780be9@garzik.org>

--- drivers/net/tc35815.c
+++ drivers/net/tc35815.c
@@ -626,7 +626,7 @@
 	return -ENODEV;
 }
 #else
-static int __devinit tc35815_read_plat_dev_addr(struct device *dev)
+static int __devinit tc35815_read_plat_dev_addr(struct net_device *dev)
 {
 	return -ENODEV;
 }


dm btree: fix leak of bufio-backed block in btree_split_beneath error path

btree_split_beneath()'s error path had an outstanding FIXME that speaks
directly to the potential for _not_ cleaning up a previously allocated
bufio-backed block.

Fix this by releasing the previously allocated bufio block using
unlock_block().

Reported-by: Mikulas Patocka <52f8f9962b7f38d8269c63c0859d68147c8d10f0@redhat.com>
Signed-off-by: Mike Snitzer <85e533f2e78486213c4d69f71462342ec0c62734@redhat.com>
Acked-by: Joe Thornber <d3bc001bc5072e9ebf02b97fd2952f313dd90e51@redhat.com>
Cc: 4fbacc2fa0ffdbb11bf1ad6925b886ebd08dd15f@vger.kernel.org


sys_log: replace old debug macros on K64 PSI driver

SPI drivers for K64 is now using system log.

Change-Id: Ifd0d321e2ff84c581261b7cb3a7a4485afbd67f6
Signed-off-by: Genaro Saucedo Tejada <f28ae731c4601dda3c8faf7a7ecac62865884fa6@intel.com>
JIRA: ZEP-311

--- drivers/spi/spi_k64.c
+++ drivers/spi/spi_k64.c
@@ -52,6 +52,8 @@
 #include <arch/cpu.h>

 #include <misc/__assert.h>
+#define SYS_LOG_LEVEL SYS_LOG_SPI_LEVEL
+#include <misc/sys_log.h>
 #include <board.h>
 #include <init.h>

@@ -61,19 +63,6 @@
 #include <spi.h>
 #include <spi/spi_k64.h>
 #include "spi_k64_priv.h"
-
-#ifndef CONFIG_SPI_DEBUG
-#define DBG(...) do { } while ((0))
-#else
-#if defined(CONFIG_STDOUT_CONSOLE)
-#include <stdio.h>
-#define DBG printf
-#else
-#include <misc/printk.h>
-#define DBG printk
-#endif /* CONFIG_STDOUT_CONSOLE */
-#endif /* CONFIG_SPI_DEBUG */
-

 /* SPI protocol frequency = K64 bus clock frequency, in hz */

@@ -128,7 +117,8 @@
 	sys_set_bit((info->regs + SPI_K64_REG_MCR), SPI_K64_MCR_HALT_BIT);

 	while (sys_read32(info->regs + SPI_K64_REG_SR) & SPI_K64_SR_TXRXS) {
-		DBG("SPI Controller dev %p is running.  Waiting for Halt.\n", dev);
+		SYS_LOG_DBG("SPI Controller dev %p is running.  Waiting for "
+			    "Halt.\n", dev);
 	}

 }
@@ -192,7 +182,7 @@
 	 * exceeding it.
 	 */

-	DBG("spi_k64_set_baud_rate - ");
+	SYS_LOG_DBG("spi_k64_set_baud_rate - ");

 	/*
 	 * Initialize the prescaler and scaler to their maximum values to calculate
@@ -206,9 +196,8 @@
 							baud_rate_prescaler[best_scaler]);

 	if (best_baud_rate > baud_rate) {
-
-		DBG("ERROR : Minimum baud rate %d is greater than desired rate %d\n",
-			best_baud_rate, baud_rate);
+		SYS_LOG_DBG("ERROR : Minimum baud rate %d is greater than "
+			    "desired rate %d\n", best_baud_rate, baud_rate);

 		return 0;
 	}
@@ -263,7 +252,7 @@

 	/* return the actual baud rate */

-	DBG("%d bps desired, %d bps set\n", baud_rate, best_baud_rate);
+	SYS_LOG_DBG("%d bps desired, %d bps set\n", baud_rate, best_baud_rate);

 	return best_baud_rate;
 }
@@ -298,7 +287,7 @@
 	volatile uint32_t best_delay;
 	uint32_t diff, min_diff;					/* difference values */

-	DBG("spi_k64_set_delay - ");
+	SYS_LOG_DBG("spi_k64_set_delay - ");

 	/*
 	 * This function can calculate the clocking and timing attribute register
@@ -311,7 +300,7 @@
 	if ((delay_id != DELAY_PCS_TO_SCK) && (delay_id != DELAY_AFTER_SCK) &&
 		(delay_id != DELAY_AFTER_XFER)) {

-		DBG("ERROR : Unknown delay type %d\n", delay_id);
+		SYS_LOG_DBG("ERROR : Unknown delay type %d\n", delay_id);

 		return 0;
 	}
@@ -327,9 +316,8 @@
 				 delay_scaler[best_scaler];

 	if (best_delay < delay_ns) {
-
-		DBG("ERROR : Maximum delay %d does meet desired minimum of %d\n",
-			best_delay, delay_ns);
+		SYS_LOG_DBG("ERROR : Maximum delay %d does meet desired minimum"
+			    " of %d\n", best_delay, delay_ns);

 		return 0;
 	}
@@ -394,19 +382,19 @@
 	case DELAY_PCS_TO_SCK:
 		*ctar_ptr = *ctar_ptr | SPI_K64_CTAR_PCSSCK_SET(best_prescaler) |
 					SPI_K64_CTAR_CSSCK_SET(best_scaler);
-		DBG("DELAY_PCS_TO_SCK: ");
+		SYS_LOG_DBG("DELAY_PCS_TO_SCK: ");
 		break;

 	case DELAY_AFTER_SCK:
 		*ctar_ptr = *ctar_ptr | SPI_K64_CTAR_PASC_SET(best_prescaler) |
 					SPI_K64_CTAR_ASC_SET(best_scaler);
-		DBG("DELAY_AFTER_SCK: ");
+		SYS_LOG_DBG("DELAY_AFTER_SCK: ");
 		break;

 	case DELAY_AFTER_XFER:
 		*ctar_ptr = *ctar_ptr | SPI_K64_CTAR_PDT_SET(best_prescaler) |
 					SPI_K64_CTAR_DT_SET(best_scaler);
-		DBG("DELAY_AFTER_XFER: ");
+		SYS_LOG_DBG("DELAY_AFTER_XFER: ");
 		break;

 	default:
@@ -416,7 +404,7 @@

 	/* return the actual delay */

-	DBG("%d delay desired, %d delay set\n", delay_ns, best_delay);
+	SYS_LOG_DBG("%d delay desired, %d delay set\n", delay_ns, best_delay);

 	return best_delay;
 }
@@ -438,9 +426,10 @@
 	uint32_t ctar = 0;	/* clocking and timing attributes, for CTAR */
 	uint32_t frame_sz;	/* frame size, in bits */

-	DBG("spi_k64_configure: dev %p (regs @ 0x%x), ", dev, info->regs);
-	DBG("config 0x%x, freq 0x%x",
-		config->config, config->max_sys_freq);
+	SYS_LOG_DBG("spi_k64_configure: dev %p (regs @ 0x%x), ", dev,
+		    info->regs);
+	SYS_LOG_DBG("config 0x%x, freq 0x%x",
+		    config->config, config->max_sys_freq);

 	 /* Disable transfer operations during configuration */

@@ -517,7 +506,7 @@
 	}

-	DBG("spi_k64_configure: MCR: 0x%x CTAR0: 0x%x\n", mcr, ctar);
+	SYS_LOG_DBG("spi_k64_configure: MCR: 0x%x CTAR0: 0x%x\n", mcr, ctar);

 	sys_write32(ctar, (info->regs + SPI_K64_REG_CTAR0));

@@ -559,7 +548,7 @@
 	 * - SPI2 uses PCS0-1;
 	 */

-	DBG("spi_k64_slave_select: slave 0x%x selected for dev %p\n",
+	SYS_LOG_DBG("spi_k64_slave_select: slave 0x%x selected for dev %p\n",
 		(uint8_t)slave, dev);

 	spi_data->pcs = (uint8_t)slave;
@@ -586,8 +575,9 @@
 	struct spi_k64_data *spi_data = dev->driver_data;
 	uint32_t int_config;	/* interrupt configuration */

-	DBG("spi_k64_transceive: dev %p, Tx buf %p, ", dev, tx_buf);
-	DBG("Tx len %u, Rx buf %p, Rx len %u\n", tx_buf_len, rx_buf, rx_buf_len);
+	SYS_LOG_DBG("spi_k64_transceive: dev %p, Tx buf %p, ", dev, tx_buf);
+	SYS_LOG_DBG("Tx len %u, Rx buf %p, Rx len %u\n", tx_buf_len, rx_buf,
+		    rx_buf_len);

 #ifdef CONFIG_SPI_DEBUG
 	__ASSERT(!((tx_buf_len && (tx_buf == NULL)) ||
@@ -600,7 +590,7 @@
 	if (tx_buf_len &&
 		((sys_read32(info->regs + SPI_K64_REG_SR) & SPI_K64_SR_TFFF) == 0)) {

-		DBG("spi_k64_transceive: Tx FIFO is already full\n");
+		SYS_LOG_DBG("spi_k64_transceive: Tx FIFO is already full\n");
 		return -EBUSY;
 	}

@@ -659,7 +649,7 @@
 {
 	struct spi_k64_config *info = dev->config->config_info;

-	DBG("spi_k64_suspend: %p\n", dev);
+	SYS_LOG_DBG("spi_k64_suspend: %p\n", dev);

 	/* disable module */

@@ -668,7 +658,8 @@
 	irq_disable(info->irq);

 	while (sys_read32(info->regs + SPI_K64_REG_SR) & SPI_K64_SR_TXRXS) {
-		DBG("SPI Controller dev %p is running.  Waiting to stop.\n", dev);
+		SYS_LOG_DBG("SPI Controller dev %p is running.  Waiting to "
+			    "stop.\n", dev);
 	}

 	return 0;
@@ -683,7 +674,7 @@
 {
 	struct spi_k64_config *info = dev->config->config_info;

-	DBG("spi_k64_resume: %p\n", dev);
+	SYS_LOG_DBG("spi_k64_resume: %p\n", dev);

 	/* enable module */

@@ -708,7 +699,7 @@
 	uint32_t cnt = 0;		/* # of bytes pushed */
 #endif

-	DBG("spi_k64_push_data - ");
+	SYS_LOG_DBG("spi_k64_push_data - ");

 	do {	/* initial status already checked by spi_k64_isr() */

@@ -767,7 +758,7 @@

 	} while (sys_read32(info->regs + SPI_K64_REG_SR) & SPI_K64_SR_TFFF);

-	DBG("pushed: %d\n", cnt);
+	SYS_LOG_DBG("pushed: %d\n", cnt);

 }

@@ -785,7 +776,7 @@
 	uint32_t cnt = 0;		/* # of bytes pulled */
 #endif

-	DBG("spi_k64_pull_data - ");
+	SYS_LOG_DBG("spi_k64_pull_data - ");

 	do {	/* initial status already checked by spi_k64_isr() */

@@ -829,7 +820,7 @@
 	} while (sys_read32(info->regs + SPI_K64_REG_SR) & SPI_K64_SR_RFDF);

-	DBG("pulled: %d\n", cnt);
+	SYS_LOG_DBG("pulled: %d\n", cnt);
 }

 /**
@@ -846,7 +837,7 @@

 	if (error) {

-		DBG("spi_k64_complete - ERROR condition\n");
+		SYS_LOG_DBG("spi_k64_complete - ERROR condition\n");

 		goto complete;
 	}
@@ -922,7 +913,7 @@

 	status = sys_read32(info->regs + SPI_K64_REG_SR);

-	DBG("spi_k64_isr: dev %p, status 0x%x\n", dev, status);
+	SYS_LOG_DBG("spi_k64_isr: dev %p, status 0x%x\n", dev, status);

 	if (status & (SPI_K64_SR_RFOF | SPI_K64_SR_TFUF)) {

@@ -972,35 +963,36 @@
 	 * (Clear MCR[MDIS] and set MCR[HALT].)
 	 */

-	DBG("halt\n");
+	SYS_LOG_DBG("halt\n");
 	mcr = SPI_K64_MCR_HALT;
 	sys_write32(mcr, (info->regs + SPI_K64_REG_MCR));

 	while (sys_read32(info->regs + SPI_K64_REG_SR) & SPI_K64_SR_TXRXS) {
-		DBG("SPI Controller dev %p is running.  Waiting for Halt.\n", dev);
+		SYS_LOG_DBG("SPI Controller dev %p is running.  Waiting for "
+			    "Halt.\n", dev);
 	}

 	/* Clear Tx and Rx FIFOs */

 	mcr |= (SPI_K64_MCR_CLR_RXF | SPI_K64_MCR_CLR_TXF);

-	DBG("fifo clr\n");
+	SYS_LOG_DBG("fifo clr\n");
 	sys_write32(mcr, (info->regs + SPI_K64_REG_MCR));

 	/* Set master mode */

 	mcr = SPI_K64_MCR_MSTR | SPI_K64_MCR_HALT;
-	DBG("master mode\n");
+	SYS_LOG_DBG("master mode\n");
 	sys_write32(mcr, (info->regs + SPI_K64_REG_MCR));

 	/* Disable SPI module interrupt generation */

-	DBG("irq disable\n");
+	SYS_LOG_DBG("irq disable\n");
 	sys_write32(0, (info->regs + SPI_K64_REG_RSER));

 	/* Clear status */

-	DBG("status clr\n");
+	SYS_LOG_DBG("status clr\n");
 	sys_write32((SPI_K64_SR_RFDF | SPI_K64_SR_RFOF | SPI_K64_SR_TFUF |
 				SPI_K64_SR_EOQF	| SPI_K64_SR_TCF),
 				(info->regs + SPI_K64_REG_SR));
@@ -1020,10 +1012,10 @@
 	 * Note that Tx underflow is only generated when in slave mode.
 	 */

-	DBG("rxfifo overflow enable\n");
+	SYS_LOG_DBG("rxfifo overflow enable\n");
 	sys_write32(SPI_K64_RSER_RFOF_RE, (info->regs + SPI_K64_REG_RSER));

-	DBG("K64 SPI Driver initialized on device: %p\n", dev);
+	SYS_LOG_DBG("K64 SPI Driver initialized on device: %p\n", dev);

 	/* operation remains disabled (MCR[HALT] = 1)*/


[media] dvb-pll: use DVBv5 parameters on set_params()

Instead of using DVBv3 parameters, rely on DVBv5 parameters to
set the tuner.

Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>

--- drivers/media/dvb/frontends/dvb-pll.c
+++ drivers/media/dvb/frontends/dvb-pll.c
@@ -61,8 +61,7 @@
 	u32  min;
 	u32  max;
 	u32  iffreq;
-	void (*set)(struct dvb_frontend *fe, u8 *buf,
-		    const struct dvb_frontend_parameters *params);
+	void (*set)(struct dvb_frontend *fe, u8 *buf);
 	u8   *initdata;
 	u8   *initdata2;
 	u8   *sleepdata;
@@ -93,10 +92,10 @@
 	},
 };

-static void thomson_dtt759x_bw(struct dvb_frontend *fe, u8 *buf,
-			       const struct dvb_frontend_parameters *params)
-{
-	if (BANDWIDTH_7_MHZ == params->u.ofdm.bandwidth)
+static void thomson_dtt759x_bw(struct dvb_frontend *fe, u8 *buf)
+{
+	u32 bw = fe->dtv_property_cache.bandwidth_hz;
+	if (bw == 7000000)
 		buf[3] |= 0x10;
 }

@@ -186,10 +185,10 @@
 /* Philips TDA6650/TDA6651
  * used in Panasonic ENV77H11D5
  */
-static void tda665x_bw(struct dvb_frontend *fe, u8 *buf,
-		       const struct dvb_frontend_parameters *params)
-{
-	if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ)
+static void tda665x_bw(struct dvb_frontend *fe, u8 *buf)
+{
+	u32 bw = fe->dtv_property_cache.bandwidth_hz;
+	if (bw == 8000000)
 		buf[3] |= 0x08;
 }

@@ -220,10 +219,10 @@
 /* Infineon TUA6034
  * used in LG TDTP E102P
  */
-static void tua6034_bw(struct dvb_frontend *fe, u8 *buf,
-		       const struct dvb_frontend_parameters *params)
-{
-	if (BANDWIDTH_7_MHZ != params->u.ofdm.bandwidth)
+static void tua6034_bw(struct dvb_frontend *fe, u8 *buf)
+{
+	u32 bw = fe->dtv_property_cache.bandwidth_hz;
+	if (bw == 7000000)
 		buf[3] |= 0x08;
 }

@@ -244,10 +243,10 @@
 /* ALPS TDED4
  * used in Nebula-Cards and USB boxes
  */
-static void tded4_bw(struct dvb_frontend *fe, u8 *buf,
-		     const struct dvb_frontend_parameters *params)
-{
-	if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ)
+static void tded4_bw(struct dvb_frontend *fe, u8 *buf)
+{
+	u32 bw = fe->dtv_property_cache.bandwidth_hz;
+	if (bw == 8000000)
 		buf[3] |= 0x04;
 }

@@ -319,11 +318,11 @@
 	},
 };

-static void opera1_bw(struct dvb_frontend *fe, u8 *buf,
-		      const struct dvb_frontend_parameters *params)
-{
+static void opera1_bw(struct dvb_frontend *fe, u8 *buf)
+{
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	struct dvb_pll_priv *priv = fe->tuner_priv;
-	u32 b_w  = (params->u.qpsk.symbol_rate * 27) / 32000;
+	u32 b_w  = (c->symbol_rate * 27) / 32000;
 	struct i2c_msg msg = {
 		.addr = priv->pll_i2c_address,
 		.flags = 0,
@@ -392,8 +391,7 @@
 	}
 };

-static void samsung_dtos403ih102a_set(struct dvb_frontend *fe, u8 *buf,
-		       const struct dvb_frontend_parameters *params)
+static void samsung_dtos403ih102a_set(struct dvb_frontend *fe, u8 *buf)
 {
 	struct dvb_pll_priv *priv = fe->tuner_priv;
 	struct i2c_msg msg = {
@@ -537,30 +535,29 @@
 /* code                                                        */

 static int dvb_pll_configure(struct dvb_frontend *fe, u8 *buf,
-			     const struct dvb_frontend_parameters *params)
+			     const u32 frequency)
 {
 	struct dvb_pll_priv *priv = fe->tuner_priv;
 	struct dvb_pll_desc *desc = priv->pll_desc;
 	u32 div;
 	int i;

-	if (params->frequency != 0 && (params->frequency < desc->min ||
-				       params->frequency > desc->max))
+	if (frequency && (frequency < desc->min || frequency > desc->max))
 		return -EINVAL;

 	for (i = 0; i < desc->count; i++) {
-		if (params->frequency > desc->entries[i].limit)
+		if (frequency > desc->entries[i].limit)
 			continue;
 		break;
 	}

 	if (debug)
 		printk("pll: %s: freq=%d | i=%d/%d\n", desc->name,
-		       params->frequency, i, desc->count);
+		       frequency, i, desc->count);
 	if (i == desc->count)
 		return -EINVAL;

-	div = (params->frequency + desc->iffreq +
+	div = (frequency + desc->iffreq +
 	       desc->entries[i].stepsize/2) / desc->entries[i].stepsize;
 	buf[0] = div >> 8;
 	buf[1] = div & 0xff;
@@ -568,7 +565,7 @@
 	buf[3] = desc->entries[i].cb;

 	if (desc->set)
-		desc->set(fe, buf, params);
+		desc->set(fe, buf);

 	if (debug)
 		printk("pll: %s: div=%d | buf=0x%02x,0x%02x,0x%02x,0x%02x\n",
@@ -614,6 +611,7 @@
 static int dvb_pll_set_params(struct dvb_frontend *fe,
 			      struct dvb_frontend_parameters *params)
 {
+	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
 	struct dvb_pll_priv *priv = fe->tuner_priv;
 	u8 buf[4];
 	struct i2c_msg msg =
@@ -625,7 +623,8 @@
 	if (priv->i2c == NULL)
 		return -EINVAL;

-	if ((result = dvb_pll_configure(fe, buf, params)) < 0)
+	result = dvb_pll_configure(fe, buf, c->frequency);
+	if (result < 0)
 		return result;
 	else
 		frequency = result;
@@ -637,7 +636,12 @@
 	}

 	priv->frequency = frequency;
-	priv->bandwidth = (fe->ops.info.type == FE_OFDM) ? params->u.ofdm.bandwidth : 0;
+	if (c->bandwidth_hz <= 6000000)
+		priv->bandwidth = BANDWIDTH_6_MHZ;
+	else if (c->bandwidth_hz <= 7000000)
+		priv->bandwidth = BANDWIDTH_7_MHZ;
+	if (c->bandwidth_hz <= 8000000)
+		priv->bandwidth = BANDWIDTH_8_MHZ;

 	return 0;
 }
@@ -653,7 +657,8 @@
 	if (buf_len < 5)
 		return -EINVAL;

-	if ((result = dvb_pll_configure(fe, buf+1, params)) < 0)
+	result = dvb_pll_configure(fe, buf + 1, params->frequency);
+	if (result < 0)
 		return result;
 	else
 		frequency = result;


drivers: spi_k64: Remove non existent CONFIG_SPI_DEBUG

Remove non existent CONFIG_SPI_DEBUG and replace cnt
with DBG_COUNTER_* macros.

Jira: ZEP-1351
Jira: ZEP-1352

Change-Id: I1fba7aaead1ad0b36297b069e5a83e25b7991588
Signed-off-by: Johann Fischer <b39b26e1812eb092eb217277792f3735321fa456@phytec.de>

--- drivers/spi/spi_k64.c
+++ drivers/spi/spi_k64.c
@@ -64,6 +64,19 @@
 #include <spi.h>
 #include <spi/spi_k64.h>
 #include "spi_k64_priv.h"
+
+#if (CONFIG_SYS_LOG_SPI_LEVEL == 4)
+#define DBG_COUNTER_INIT()	\
+	uint32_t __cnt = 0
+#define DBG_COUNTER_INC()	\
+	(__cnt++)
+#define DBG_COUNTER_RESULT()	\
+	(__cnt)
+#else
+#define DBG_COUNTER_INIT() {; }
+#define DBG_COUNTER_INC() {; }
+#define DBG_COUNTER_RESULT() 0
+#endif

 /* SPI protocol frequency = K64 bus clock frequency, in hz */

@@ -580,12 +593,6 @@
 	SYS_LOG_DBG("dev %p, txbuf %p txlen %u rxbuf %p rxlen %u",
 		    dev, tx_buf, tx_buf_len, rx_buf, rx_buf_len);

-#ifdef CONFIG_SPI_DEBUG
-	__ASSERT(!((tx_buf_len && (tx_buf == NULL)) ||
-				(rx_buf_len && (rx_buf == NULL))),
-			"spi_k64_transceive: ERROR - NULL buffer");
-#endif
-
 	/* Check Tx FIFO status */

 	if (tx_buf_len &&
@@ -658,9 +665,7 @@
 	const struct spi_k64_config *info = dev->config->config_info;
 	struct spi_k64_data *spi_data = dev->driver_data;
 	uint32_t data;
-#ifdef CONFIG_SPI_DEBUG
-	uint32_t cnt = 0;		/* # of bytes pushed */
-#endif
+	DBG_COUNTER_INIT();

 	SYS_LOG_DBG("");

@@ -676,20 +681,17 @@

 				spi_data->tx_buf += 2;
 				spi_data->tx_buf_len -= 2;
-
-#ifdef CONFIG_SPI_DEBUG
-				cnt += 2;
-#endif
+				DBG_COUNTER_INC();
+				DBG_COUNTER_INC();
+
 			} else {

 				data = (uint32_t)(*(spi_data->tx_buf));

 				spi_data->tx_buf++;
 				spi_data->tx_buf_len--;
-
-#ifdef CONFIG_SPI_DEBUG
-				cnt++;
-#endif
+				DBG_COUNTER_INC();
+
 			}

 			/* Write data to the selected slave */
@@ -721,9 +723,7 @@

 	} while (sys_read32(info->regs + SPI_K64_REG_SR) & SPI_K64_SR_TFFF);

-#ifdef CONFIG_SPI_DEBUG
-	SYS_LOG_DBG("pushed: %d", cnt);
-#endif
+	SYS_LOG_DBG("Pushed: %d", DBG_COUNTER_RESULT());
 }

 /**
@@ -736,9 +736,7 @@
 	const struct spi_k64_config *info = dev->config->config_info;
 	struct spi_k64_data *spi_data = dev->driver_data;
 	uint16_t data;
-#ifdef CONFIG_SPI_DEBUG
-	uint32_t cnt = 0;		/* # of bytes pulled */
-#endif
+	DBG_COUNTER_INIT();

 	SYS_LOG_DBG("");

@@ -755,19 +753,15 @@
 				*((uint16_t *)(spi_data->rx_buf)) = data;
 				spi_data->rx_buf += 2;
 				spi_data->rx_buf_len -= 2;
-
-#ifdef CONFIG_SPI_DEBUG
-				cnt += 2;
-#endif
+				DBG_COUNTER_INC();
+				DBG_COUNTER_INC();
+
 			} else {

 				*(spi_data->rx_buf) = (uint8_t)data;
 				spi_data->rx_buf++;
 				spi_data->rx_buf_len--;
-
-#ifdef CONFIG_SPI_DEBUG
-				cnt++;
-#endif
+				DBG_COUNTER_INC();
 			}

 			/* Clear interrupt */
@@ -783,10 +777,7 @@

 	} while (sys_read32(info->regs + SPI_K64_REG_SR) & SPI_K64_SR_RFDF);

-
-#ifdef CONFIG_SPI_DEBUG
-	SYS_LOG_DBG("pulled: %d", cnt);
-#endif
+	SYS_LOG_DBG("Pulled: %d", DBG_COUNTER_RESULT());
 }

 /**


V4L/DVB (3382): Fix stv0297 for qam128 on tt c1500 (saa7146)

I have a TT C1500 card (saa7146, STV0297) which had problems tuning
channels at QAM128 (like the ones in the Finnish HTV / Welho network).
A fix which seems to work perfectly so far is to change the delay for
QAM128 to the same values as for QAM256 in stv0297_set_frontend(),

Signed-off-by: Mattias Nordstrom <78ea14aba81c3dc5a4075429c2d11db6698983b8@realnode.com>
Signed-off-by: Michael Krufky <00524723a60798c74a43fcc620c25dd7b9ece078@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@infradead.org>

--- drivers/media/dvb/frontends/stv0297.c
+++ drivers/media/dvb/frontends/stv0297.c
@@ -393,10 +393,6 @@
 		break;

 	case QAM_128:
-		delay = 150;
-		sweeprate = 1000;
-		break;
-
 	case QAM_256:
 		delay = 200;
 		sweeprate = 500;


imxfb: Fix TFT mode

imxfb: Fix TFT mode

We read from the PCR reg to determine whether to use TFT mode or not.
This is not possible because it may not have been initialized with
the correct value yet. Select it using fbi->pcr instead.

Signed-off-by: Sascha Hauer <c00cbc2b736c26791a3822db86f8796fe9efff67@pengutronix.de>

--- drivers/video/imxfb.c
+++ drivers/video/imxfb.c
@@ -327,7 +327,7 @@
 		break;
 	case 16:
 	default:
-		if (readl(fbi->regs + LCDC_PCR) & PCR_TFT)
+		if (fbi->pcr & PCR_TFT)
 			rgb = &def_rgb_16_tft;
 		else
 			rgb = &def_rgb_16_stn;


[media] davinic: vpss: trivial cleanup

[media] davinic: vpss: trivial cleanup

this patch removes unnecessary header file inclusions and
fixes the typo's.

Signed-off-by: Lad, Prabhakar <b468bd3711e6074f1f3ca387583c4bfe5a29e9a6@gmail.com>
Signed-off-by: Hans Verkuil <3a513708f73c27e7d36ebc496aa41dad6a3153ea@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>

--- drivers/media/platform/davinci/vpss.c
+++ drivers/media/platform/davinci/vpss.c
@@ -17,13 +17,8 @@
  *
  * common vpss system module platform driver for all video drivers.
  */
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/init.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
-#include <linux/spinlock.h>
-#include <linux/compiler.h>
 #include <linux/io.h>
 #include <linux/pm_runtime.h>

@@ -101,7 +96,7 @@

 /*
  * vpss operations. Depends on platform. Not all functions are available
- * on all platforms. The api, first check if a functio is available before
+ * on all platforms. The api, first check if a function is available before
  * invoking it. In the probe, the function ptrs are initialized based on
  * vpss name. vpss name can be "dm355_vpss", "dm644x_vpss" etc.
  */
@@ -116,7 +111,7 @@
 	void (*set_sync_pol)(struct vpss_sync_pol);
 	/* set the PG_FRAME_SIZE register*/
 	void (*set_pg_frame_size)(struct vpss_pg_frame_size);
-	/* check and clear interrupt if occured */
+	/* check and clear interrupt if occurred */
 	int (*dma_complete_interrupt)(void);
 };

@@ -235,7 +230,7 @@

 /*
  *  dm355_enable_clock - Enable VPSS Clock
- *  @clock_sel: CLock to be enabled/disabled
+ *  @clock_sel: Clock to be enabled/disabled
  *  @en: enable/disable flag
  *
  *  This is called to enable or disable a vpss clock


fbdev/ps3fb: Fix section mismatch warning for ps3fb_probe

While cross-building for PPC64 I've got

WARNING: drivers/video/built-in.o(.text+0x9f9ca): Section mismatch in
reference from the function .ps3fb_probe() to th e variable
.init.data:ps3fb_fix The function .ps3fb_probe() references the
variable __initdata ps3fb_fix.  This is often because .ps3fb_probe
lacks a __initdata annotation or the annotation of ps3fb_fix is wrong.

WARNING: drivers/video/built-in.o(.text+0x9f9d2): Section mismatch in
reference from the function .ps3fb_probe() to the variable
.init.data:ps3fb_fix The function .ps3fb_probe() references the
variable __initdata ps3fb_fix.  This is often because .ps3fb_probe
lacks a __initdata annotation or the annotation of ps3fb_fix is wrong.

WARNING: drivers/built-in.o(.text+0xe222a): Section mismatch in
reference from the function .ps3fb_probe() to the variable
.init.data:ps3fb_fix The function .ps3fb_probe() references the
variable __initdata ps3fb_fix.  This is often because .ps3fb_probe
lacks a __initdata annotation or the annotation of ps3fb_fix is wrong.

WARNING: drivers/built-in.o(.text+0xe2232): Section mismatch in
reference from the function .ps3fb_probe() to the variable
.init.data:ps3fb_fix The function .ps3fb_probe() references the
variable __initdata ps3fb_fix.  This is often because .ps3fb_probe
lacks a __initdata annotation or the annotation of ps3fb_fix is wrong.

WARNING: vmlinux.o(.text+0x561d4a): Section mismatch in reference from
the function .ps3fb_probe() to the variable .init.data:ps3fb_fix The
function .ps3fb_probe() references the variable __initdata ps3fb_fix.
This is often because .ps3fb_probe lacks a __initdata annotation or
the annotation of ps3fb_fix is wrong.

Mismatch was introduced with 48c68c4f "Drivers: video: remove __dev*
attributes."

Remove __init data annotation from ps3fb_fix.

Signed-off-by: Vladimir Murzin <5f288aaedfa821c802c94cfb9a5501a50f315eee@gmail.com>
Signed-off-by: Benjamin Herrenschmidt <a7089bb6e7e92505d88aaff006cbdd60cc9120b6@kernel.crashing.org>

--- drivers/video/ps3fb.c
+++ drivers/video/ps3fb.c
@@ -952,7 +952,7 @@
 	.fb_compat_ioctl = ps3fb_ioctl
 };

-static struct fb_fix_screeninfo ps3fb_fix __initdata = {
+static struct fb_fix_screeninfo ps3fb_fix = {
 	.id =		DEVICE_NAME,
 	.type =		FB_TYPE_PACKED_PIXELS,
 	.visual =	FB_VISUAL_TRUECOLOR,


V4L/DVB (7271): cx88-cards: Fix powerangel gpio1

With this gpio, audio works properly.

Thanks to Daniel Fraga <fragabr@gmail.com> for helping on fixing the code for
Powerangel Real board.

Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@infradead.org>

--- drivers/media/video/cx88/cx88-cards.c
+++ drivers/media/video/cx88/cx88-cards.c
@@ -1494,7 +1494,7 @@
 		       .type   = CX88_VMUX_TELEVISION,
 		       .vmux   = 0,
 		       .gpio0 = 0x0400, /* pin 2:mute = 0 (off?) */
-		       .gpio1 = 0x0000,
+		       .gpio1 = 0xf35d,
 		       .gpio2 = 0x0800, /* pin 19:audio = 0 (tv) */
 	       }, {
 		       .type   = CX88_VMUX_COMPOSITE1,


[ARM] pxa: update pxafb.c to use 'struct dev_pm_ops'

Signed-off-by: Mike Rapoport <a17fed27eaa842282862ff7c1b9c8395a26ac320@compulab.co.il>
Signed-off-by: Eric Miao <60e376623d7bcedd53f4c51cbb2c060fb40a4887@gmail.com>


[media] mem2mem_testdev: remove V4L2_FL_LOCK_ALL_FOPS

Add proper locking to the file operations, allowing for the removal
of the V4L2_FL_LOCK_ALL_FOPS flag.

Signed-off-by: Hans Verkuil <3a513708f73c27e7d36ebc496aa41dad6a3153ea@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>

--- drivers/media/video/mem2mem_testdev.c
+++ drivers/media/video/mem2mem_testdev.c
@@ -891,10 +891,15 @@
 	struct m2mtest_dev *dev = video_drvdata(file);
 	struct m2mtest_ctx *ctx = NULL;
 	struct v4l2_ctrl_handler *hdl;
-
+	int rc = 0;
+
+	if (mutex_lock_interruptible(&dev->dev_mutex))
+		return -ERESTARTSYS;
 	ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
-	if (!ctx)
-		return -ENOMEM;
+	if (!ctx) {
+		rc = -ENOMEM;
+		goto open_unlock;
+	}

 	v4l2_fh_init(&ctx->fh, video_devdata(file));
 	file->private_data = &ctx->fh;
@@ -927,11 +932,11 @@
 	ctx->m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, ctx, &queue_init);

 	if (IS_ERR(ctx->m2m_ctx)) {
-		int ret = PTR_ERR(ctx->m2m_ctx);
+		rc = PTR_ERR(ctx->m2m_ctx);

 		v4l2_ctrl_handler_free(hdl);
 		kfree(ctx);
-		return ret;
+		goto open_unlock;
 	}

 	v4l2_fh_add(&ctx->fh);
@@ -939,6 +944,8 @@

 	dprintk(dev, "Created instance %p, m2m_ctx: %p\n", ctx, ctx->m2m_ctx);

+open_unlock:
+	mutex_unlock(&dev->dev_mutex);
 	return 0;
 }

@@ -952,7 +959,9 @@
 	v4l2_fh_del(&ctx->fh);
 	v4l2_fh_exit(&ctx->fh);
 	v4l2_ctrl_handler_free(&ctx->hdl);
+	mutex_lock(&dev->dev_mutex);
 	v4l2_m2m_ctx_release(ctx->m2m_ctx);
+	mutex_unlock(&dev->dev_mutex);
 	kfree(ctx);

 	atomic_dec(&dev->num_inst);
@@ -970,9 +979,15 @@

 static int m2mtest_mmap(struct file *file, struct vm_area_struct *vma)
 {
+	struct m2mtest_dev *dev = video_drvdata(file);
 	struct m2mtest_ctx *ctx = file2ctx(file);
-
-	return v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
+	int res;
+
+	if (mutex_lock_interruptible(&dev->dev_mutex))
+		return -ERESTARTSYS;
+	res = v4l2_m2m_mmap(file, ctx->m2m_ctx, vma);
+	mutex_unlock(&dev->dev_mutex);
+	return res;
 }

 static const struct v4l2_file_operations m2mtest_fops = {
@@ -1027,10 +1042,6 @@
 	}

 	*vfd = m2mtest_videodev;
-	/* Locking in file operations other than ioctl should be done
-	   by the driver, not the V4L2 core.
-	   This driver needs auditing so that this flag can be removed. */
-	set_bit(V4L2_FL_LOCK_ALL_FOPS, &vfd->flags);
 	vfd->lock = &dev->dev_mutex;

 	ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0);


drivers/w5100: do normal assignment instead of memcpy

--- drivers/w5100/w5100.c
+++ drivers/w5100/w5100.c
@@ -118,7 +118,7 @@
     dev->nd.context = dev;

     /* initialize the device descriptor */
-    memcpy(&dev->p, params, sizeof(w5100_params_t));
+    dev->p = *params;

     /* initialize the chip select pin and the external interrupt pin */
     spi_init_cs(dev->p.spi, dev->p.cs);


V4L/DVB (6218): V4L: Int if: Use -ENOIOCTLCMD for nonexistent ioctls

Signed-off-by: Sakari Ailus <8d98c2be02a446df653daa2c00496b87f3f016e4@nokia.com>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@infradead.org>

--- drivers/media/video/v4l2-int-device.c
+++ drivers/media/video/v4l2-int-device.c
@@ -143,7 +143,7 @@

 static int no_such_ioctl_0(struct v4l2_int_device *d)
 {
-	return -EINVAL;
+	return -ENOIOCTLCMD;
 }

 int v4l2_int_ioctl_0(struct v4l2_int_device *d, int cmd)
@@ -155,7 +155,7 @@

 static int no_such_ioctl_1(struct v4l2_int_device *d, void *arg)
 {
-	return -EINVAL;
+	return -ENOIOCTLCMD;
 }

 int v4l2_int_ioctl_1(struct v4l2_int_device *d, int cmd, void *arg)


xen/balloon: Simplify HVM integration

xen/balloon: Simplify HVM integration

Simplify HVM integration proposed by Stefano Stabellini
in 53d5522cad291a0e93a385e0594b6aea6b54a071.

Acked-by: Ian Campbell <9be92b3dbbd6611e3e4c9209fb3d04b4919e7cca@citrix.com>
Acked-by: Daniel De Graaf <91b6941f7a52f059591af5ff379e95543fa07ef9@tycho.nsa.gov>
Signed-off-by: Daniel Kiper <f87bce239c2d929a7b9d096e345809271dca1b0e@net-space.pl>
Signed-off-by: Konrad Rzeszutek Wilk <da3a51b335cef0eb0e2c329c5ef6bcd6acef687a@oracle.com>

--- drivers/xen/balloon.c
+++ drivers/xen/balloon.c
@@ -246,7 +246,7 @@
 		set_phys_to_machine(pfn, frame_list[i]);

 		/* Link back into the page tables if not highmem. */
-		if (!xen_hvm_domain() && !PageHighMem(page)) {
+		if (xen_pv_domain() && !PageHighMem(page)) {
 			int ret;
 			ret = HYPERVISOR_update_va_mapping(
 				(unsigned long)__va(pfn << PAGE_SHIFT),
@@ -293,7 +293,7 @@

 		scrub_page(page);

-		if (!xen_hvm_domain() && !PageHighMem(page)) {
+		if (xen_pv_domain() && !PageHighMem(page)) {
 			ret = HYPERVISOR_update_va_mapping(
 				(unsigned long)__va(pfn << PAGE_SHIFT),
 				__pte_ma(0), 0);
@@ -429,7 +429,7 @@

 static int __init balloon_init(void)
 {
- 	unsigned long pfn, nr_pages, extra_pfn_end;
+	unsigned long pfn, extra_pfn_end;
 	struct page *page;

 	if (!xen_domain())
@@ -437,11 +437,7 @@

 	pr_info("xen/balloon: Initialising balloon driver.\n");

- 	if (xen_pv_domain())
- 		nr_pages = xen_start_info->nr_pages;
- 	else
- 		nr_pages = max_pfn;
- 	balloon_stats.current_pages = min(nr_pages, max_pfn);
+	balloon_stats.current_pages = xen_pv_domain() ? min(xen_start_info->nr_pages, max_pfn) : max_pfn;
 	balloon_stats.target_pages  = balloon_stats.current_pages;
 	balloon_stats.balloon_low   = 0;
 	balloon_stats.balloon_high  = 0;


net: mvneta: fix race condition in mvneta_tx()

mvneta_tx() dereferences skb to get skb->len too late,
as hardware might have completed the transmit and TX completion
could have freed the skb from another cpu.

Fixes: 71f6d1b31fb1 ("net: mvneta: replace Tx timer with a real interrupt")
Signed-off-by: Eric Dumazet <312c7d941f03386814be517ffdb3e0eb6624e275@google.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/ethernet/marvell/mvneta.c
+++ drivers/net/ethernet/marvell/mvneta.c
@@ -1721,6 +1721,7 @@
 	u16 txq_id = skb_get_queue_mapping(skb);
 	struct mvneta_tx_queue *txq = &pp->txqs[txq_id];
 	struct mvneta_tx_desc *tx_desc;
+	int len = skb->len;
 	int frags = 0;
 	u32 tx_cmd;

@@ -1788,7 +1789,7 @@

 		u64_stats_update_begin(&stats->syncp);
 		stats->tx_packets++;
-		stats->tx_bytes  += skb->len;
+		stats->tx_bytes  += len;
 		u64_stats_update_end(&stats->syncp);
 	} else {
 		dev->stats.tx_dropped++;


fix drsys_init error in return value

fix drsys_init error in return value

SVN-Revision: 1140

--- drsyscall/drsyscall.c
+++ drsyscall/drsyscall.c
@@ -1624,7 +1624,7 @@
     /* handle multiple sets of init/exit calls */
     int count = dr_atomic_add32_return_sum(&drsys_init_count, 1);
     if (count > 1)
-        return true;
+        return DRMF_SUCCESS;

     res = drmf_check_version(client_id);
     if (res != DRMF_SUCCESS)


sh_eth: fix handling of no LINK signal

sh_eth: fix handling of no LINK signal

The code handling the absent LINK signal (or the absent PSR register -- which
reflects the state of this signal) is quite naive and has probably never really
worked.  It's probably enough to say that this code is executed only on the LINK
change interrupt (sic!) but even if we actually have the signal and choose to
ignore it (it might be connected to PHY's link/activity LED output as on the
Renesas BOCK-W board), sh_eth_adjust_link() on which this code relies to update
'mdp->link' gets executed later than the LINK change interrupt where it is
checked, and so RX/TX never get enabled via ECMR register.

So, ignore the LINK changed interrupt iff LINK signal is absent (or just chosen
not to be used) or PSR register is absent, and enable/disable RX/TX directly in
sh_eth_adjust_link() in this case.

Signed-off-by: Sergei Shtylyov <d8c69075be49b0738b690ec4af0e9025b8c97c9e@cogentembedded.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/ethernet/renesas/sh_eth.c
+++ drivers/net/ethernet/renesas/sh_eth.c
@@ -1216,10 +1216,7 @@
 		if (felic_stat & ECSR_LCHNG) {
 			/* Link Changed */
 			if (mdp->cd->no_psr || mdp->no_ether_link) {
-				if (mdp->link == PHY_DOWN)
-					link_stat = 0;
-				else
-					link_stat = PHY_ST_LINK;
+				goto ignore_link;
 			} else {
 				link_stat = (sh_eth_read(ndev, PSR));
 				if (mdp->ether_link_active_low)
@@ -1242,6 +1239,7 @@
 		}
 	}

+ignore_link:
 	if (intr_status & EESR_TWB) {
 		/* Write buck end. unused write back interrupt */
 		if (intr_status & EESR_TABT)	/* Transmit Abort int */
@@ -1392,12 +1390,16 @@
 				(sh_eth_read(ndev, ECMR) & ~ECMR_TXF), ECMR);
 			new_state = 1;
 			mdp->link = phydev->link;
+			if (mdp->cd->no_psr || mdp->no_ether_link)
+				sh_eth_rcv_snd_enable(ndev);
 		}
 	} else if (mdp->link) {
 		new_state = 1;
 		mdp->link = PHY_DOWN;
 		mdp->speed = 0;
 		mdp->duplex = -1;
+		if (mdp->cd->no_psr || mdp->no_ether_link)
+			sh_eth_rcv_snd_disable(ndev);
 	}

 	if (new_state && netif_msg_link(mdp))


sungem: sungem_phy.h moved

sungem: sungem_phy.h moved

Signed-off-by: Stephen Rothwell <4bf0fb350827ce8d86875e76c923a478597c3cef@canb.auug.org.au>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/ethernet/sun/sungem_phy.c
+++ drivers/net/ethernet/sun/sungem_phy.c
@@ -33,7 +33,7 @@
 #include <asm/prom.h>
 #endif

-#include "sungem_phy.h"
+#include <linux/sungem_phy.h>

 /* Link modes of the BCM5400 PHY */
 static const int phy_BCM5400_link_table[8][3] = {


net/vdev_netvsc: readlink inputs cannot be aliased

drivers/net/vdev_netvsc/vdev_netvsc.c:335:2:error:
passing argument 2 to restrict-qualified parameter aliases with argument 1
  ret = readlink(buf, buf, size);
  ^~~

Fixes: e7dc5d7becc5 ("net/vdev_netvsc: implement core functionality")
Cc: stable@dpdk.org

Signed-off-by: Andy Green <e3579b1e47f273529f0f929453e939a68ede9fd1@warmcat.com>
Acked-by: Pablo de Lara <28355d9cfe41bb8148aea0fb24f47aae8f4217a1@intel.com>

--- drivers/net/vdev_netvsc/vdev_netvsc.c
+++ drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -327,12 +327,15 @@
 vdev_netvsc_sysfs_readlink(char *buf, size_t size, const char *if_name,
 			   const char *relpath)
 {
+	struct vdev_netvsc_ctx *ctx;
+	char in[RTE_MAX(sizeof(ctx->yield), 256u)];
 	int ret;

-	ret = snprintf(buf, size, "/sys/class/net/%s/%s", if_name, relpath);
-	if (ret == -1 || (size_t)ret >= size)
+	ret = snprintf(in, sizeof(in) - 1, "/sys/class/net/%s/%s",
+		       if_name, relpath);
+	if (ret == -1 || (size_t)ret >= sizeof(in))
 		return -ENOBUFS;
-	ret = readlink(buf, buf, size);
+	ret = readlink(in, buf, size);
 	if (ret == -1)
 		return -errno;
 	if ((size_t)ret >= size - 1)


ath10k: enable multi-channel on supported devices

This effectively enables multi-channel operation
on qca6174 WLAN.RM.2.0-00073 (and possibly any
newer firmware release for qca6174).

This adds appopriate interface combinations and
initializes firmware channel scheduler.

Signed-off-by: Michal Kazior <956a8aa249cc11dbf2733fc41294eabd5c99981c@tieto.com>
Signed-off-by: Kalle Valo <7081a7d99b8c74c0698a728df19e3915a995d7e1@qca.qualcomm.com>


ath10k: fix sta_rc_update for non-ap iftype

The arsta structure wasn't initialized for
non-ap interfaces. This should fix related
warnings/crashes.

Reported-By: Ben Greear <a73a03e3b44aa05185cea6823d080c09a7808534@candelatech.com>
Signed-off-by: Michal Kazior <956a8aa249cc11dbf2733fc41294eabd5c99981c@tieto.com>
Signed-off-by: Kalle Valo <7081a7d99b8c74c0698a728df19e3915a995d7e1@qca.qualcomm.com>

--- drivers/net/wireless/ath/ath10k/mac.c
+++ drivers/net/wireless/ath/ath10k/mac.c
@@ -3179,6 +3179,13 @@
 	int max_num_peers;
 	int ret = 0;

+	if (old_state == IEEE80211_STA_NOTEXIST &&
+	    new_state == IEEE80211_STA_NONE) {
+		memset(arsta, 0, sizeof(*arsta));
+		arsta->arvif = arvif;
+		INIT_WORK(&arsta->update_wk, ath10k_sta_rc_update_wk);
+	}
+
 	/* cancel must be done outside the mutex to avoid deadlock */
 	if ((old_state == IEEE80211_STA_NONE &&
 	     new_state == IEEE80211_STA_NOTEXIST))
@@ -3207,10 +3214,6 @@
 		ath10k_dbg(ATH10K_DBG_MAC,
 			   "mac vdev %d peer create %pM (new sta) num_peers %d\n",
 			   arvif->vdev_id, sta->addr, ar->num_peers);
-
-		memset(arsta, 0, sizeof(*arsta));
-		arsta->arvif = arvif;
-		INIT_WORK(&arsta->update_wk, ath10k_sta_rc_update_wk);

 		ret = ath10k_peer_create(ar, arvif->vdev_id, sta->addr);
 		if (ret)


Make certain that random keys havethe correct parity, for interoperation with
MIT v4 implementations.

Submitted by: Reece R. Pollack <reece@eco.twg.com>

--- eBones/des/rand_key.c
+++ eBones/des/rand_key.c
@@ -2,7 +2,7 @@
 /* Copyright (C) 1993 Eric Young - see README for more details */

 /*-
- *	$Id: rand_key.c,v 1.2 1994/07/19 19:22:04 g89r4222 Exp $
+ *	$Id: rand_key.c,v 1.1.1.1 1994/09/30 14:49:51 csgr Exp $
  */

 #include "des_locl.h"
@@ -36,6 +36,7 @@
 	des_set_odd_parity((des_cblock *)key);
 	des_cbc_cksum((des_cblock *)key,(des_cblock *)key,
 		(long)sizeof(key),ks,(des_cblock *)data);
+	des_set_odd_parity((des_cblock *)key);

 	bcopy(key,ret,sizeof(key));
 	bzero(key,sizeof(key));


ath10k: add logging to better determine some VIF/STA creation failures

Not all errors were properly notified, fix that.

kvalo: use ath10k_warn() for all messages, cosmetic changes to some of the messages

Signed-off-by: Ben Greear <a73a03e3b44aa05185cea6823d080c09a7808534@candelatech.com>
Signed-off-by: Kalle Valo <7081a7d99b8c74c0698a728df19e3915a995d7e1@qca.qualcomm.com>


ath10k: fix device teardown

ath10k: fix device teardown

This fixes interrupt-related issue when no
interfaces were running thus the device was
considered powered down.

The power_down() function isn't really powering
down the device. It simply assumed it won't
interrupt. This wasn't true in some cases and
could lead to paging failures upon FW indication
interrupt (i.e. FW crash) because some structures
aren't allocated in that device state.

One reason for that was that ar_pci->started
wasn't reset. The other is interrupts should've
been masked when teardown starts.

The patch reorganized interrupt setup and makes
sure ar_pci->started is reset accordingly.

Reported-by: Ben Greear <a73a03e3b44aa05185cea6823d080c09a7808534@candelatech.com>
Signed-off-by: Michal Kazior <956a8aa249cc11dbf2733fc41294eabd5c99981c@tieto.com>
Signed-off-by: Kalle Valo <7081a7d99b8c74c0698a728df19e3915a995d7e1@qca.qualcomm.com>

--- drivers/net/wireless/ath/ath10k/pci.c
+++ drivers/net/wireless/ath/ath10k/pci.c
@@ -56,6 +56,8 @@
 static void ath10k_pci_stop_ce(struct ath10k *ar);
 static void ath10k_pci_device_reset(struct ath10k *ar);
 static int ath10k_pci_reset_target(struct ath10k *ar);
+static int ath10k_pci_start_intr(struct ath10k *ar);
+static void ath10k_pci_stop_intr(struct ath10k *ar);

 static const struct ce_attr host_ce_config_wlan[] = {
 	/* host->target HTC control and raw streams */
@@ -1254,9 +1256,24 @@
 	}
 }

+static void ath10k_pci_disable_irqs(struct ath10k *ar)
+{
+	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
+	int i;
+
+	for (i = 0; i < max(1, ar_pci->num_msi_intrs); i++)
+		disable_irq(ar_pci->pdev->irq + i);
+}
+
 static void ath10k_pci_hif_stop(struct ath10k *ar)
 {
+	struct ath10k_pci *ar_pci = ath10k_pci_priv(ar);
+
 	ath10k_dbg(ATH10K_DBG_PCI, "%s\n", __func__);
+
+	/* Irqs are never explicitly re-enabled. They are implicitly re-enabled
+	 * by ath10k_pci_start_intr(). */
+	ath10k_pci_disable_irqs(ar);

 	ath10k_pci_stop_ce(ar);

@@ -1267,6 +1284,8 @@
 	ath10k_pci_process_ce(ar);
 	ath10k_pci_cleanup_ce(ar);
 	ath10k_pci_buffer_cleanup(ar);
+
+	ar_pci->started = 0;
 }

 static int ath10k_pci_hif_exchange_bmi_msg(struct ath10k *ar,
@@ -1742,6 +1761,12 @@
 {
 	int ret;

+	ret = ath10k_pci_start_intr(ar);
+	if (ret) {
+		ath10k_err("could not start interrupt handling (%d)\n", ret);
+		goto err;
+	}
+
 	/*
 	 * Bring the target up cleanly.
 	 *
@@ -1756,7 +1781,7 @@

 	ret = ath10k_pci_reset_target(ar);
 	if (ret)
-		goto err;
+		goto err_irq;

 	if (ath10k_target_ps) {
 		ath10k_dbg(ATH10K_DBG_PCI, "on-chip power save enabled\n");
@@ -1787,12 +1812,15 @@
 err_ps:
 	if (!ath10k_target_ps)
 		ath10k_do_pci_sleep(ar);
+err_irq:
+	ath10k_pci_stop_intr(ar);
 err:
 	return ret;
 }

 static void ath10k_pci_hif_power_down(struct ath10k *ar)
 {
+	ath10k_pci_stop_intr(ar);
 	ath10k_pci_ce_deinit(ar);
 	if (!ath10k_target_ps)
 		ath10k_do_pci_sleep(ar);
@@ -2363,22 +2391,14 @@

 	ar_pci->cacheline_sz = dma_get_cache_alignment();

-	ret = ath10k_pci_start_intr(ar);
-	if (ret) {
-		ath10k_err("could not start interrupt handling (%d)\n", ret);
-		goto err_iomap;
-	}
-
 	ret = ath10k_core_register(ar);
 	if (ret) {
 		ath10k_err("could not register driver core (%d)\n", ret);
-		goto err_intr;
+		goto err_iomap;
 	}

 	return 0;

-err_intr:
-	ath10k_pci_stop_intr(ar);
 err_iomap:
 	pci_iounmap(pdev, mem);
 err_master:
@@ -2415,7 +2435,6 @@
 	tasklet_kill(&ar_pci->msi_fw_err);

 	ath10k_core_unregister(ar);
-	ath10k_pci_stop_intr(ar);

 	pci_set_drvdata(pdev, NULL);
 	pci_iounmap(pdev, ar_pci->mem);


ath5k: add possible wiphy interface combinations

Signed-off-by: Felix Fietkau <118ed6118e893d16e8c6e0776e0ebc290952c897@openwrt.org>

--- drivers/net/wireless/ath/ath5k/base.c
+++ drivers/net/wireless/ath/ath5k/base.c
@@ -2415,6 +2415,22 @@
 * Initialization routines *
 \*************************/

+static const struct ieee80211_iface_limit if_limits[] = {
+	{ .max = 2048,	.types = BIT(NL80211_IFTYPE_STATION) },
+	{ .max = 4,	.types =
+#ifdef CONFIG_MAC80211_MESH
+				 BIT(NL80211_IFTYPE_MESH_POINT) |
+#endif
+				 BIT(NL80211_IFTYPE_AP) },
+};
+
+static const struct ieee80211_iface_combination if_comb = {
+	.limits = if_limits,
+	.n_limits = ARRAY_SIZE(if_limits),
+	.max_interfaces = 2048,
+	.num_different_channels = 1,
+};
+
 int __devinit
 ath5k_init_ah(struct ath5k_hw *ah, const struct ath_bus_ops *bus_ops)
 {
@@ -2435,6 +2451,9 @@
 		BIT(NL80211_IFTYPE_STATION) |
 		BIT(NL80211_IFTYPE_ADHOC) |
 		BIT(NL80211_IFTYPE_MESH_POINT);
+
+	hw->wiphy->iface_combinations = &if_comb;
+	hw->wiphy->n_iface_combinations = 1;

 	/* SW support for IBSS_RSN is provided by mac80211 */
 	hw->wiphy->flags |= WIPHY_FLAG_IBSS_RSN;


ath9k: Fix RX debug statistics

ath9k: Fix RX debug statistics

The various error bits that ath_debug_stat_rx()
checks are valid only for the last descriptor for
a chained packet, handle this correctly.

Signed-off-by: Sujith Manoharan <1240f8b9a8d4f8f6d54c4d059a9fef2470495ad4@qca.qualcomm.com>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>

--- drivers/net/wireless/ath/ath9k/recv.c
+++ drivers/net/wireless/ath/ath9k/recv.c
@@ -1084,6 +1084,7 @@
 		return 0;

 	ath9k_process_tsf(rx_stats, rx_status, tsf);
+	ath_debug_stat_rx(sc, rx_stats);

 	/*
 	 * Process PHY errors and return so that the packet
@@ -1269,8 +1270,6 @@
 		if (ieee80211_is_data_present(hdr->frame_control) &&
 		    !ieee80211_is_qos_nullfunc(hdr->frame_control))
 			sc->rx.num_pkts++;
-
-		ath_debug_stat_rx(sc, &rs);

 		rxs = IEEE80211_SKB_RXCB(hdr_skb);
 		memset(rxs, 0, sizeof(struct ieee80211_rx_status));


b43: HT-PHY: Update values for frequency calibration

Previous values were extracted from MMIO dump of some old 5.x driver,
new ones should improve calibration. This also adds values for 5 GHz.

Signed-off-by: Rafał Miłecki <dced371c11179e2cb83b1e305b9d7b15f379452b@gmail.com>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>


iwlwifi: reverse DATA/INST section order

As the new MVM firmware files package the DATA section
first, and debugfs files want to access the DATA and
not INST section, reverse the order here. This is only
relevant for debugfs code that accesses the SRAM DATA
section and uses this constant to access the section.

Reviewed-by: Emmanuel Grumbach <643a80aaf16a8332d6a70921c14d4bb265446494@intel.com>
Signed-off-by: Johannes Berg <bff32994ff0f8d048f262a8388145a71b6071bfe@intel.com>

--- drivers/net/wireless/iwlwifi/iwl-fw.h
+++ drivers/net/wireless/iwlwifi/iwl-fw.h
@@ -106,11 +106,14 @@

 /*
  * enumeration of ucode section.
- * This enumeration is used for legacy tlv style (before 16.0 uCode).
+ * This enumeration is used directly for older firmware (before 16.0).
+ * For new firmware, there can be up to 4 sections (see below) but the
+ * first one packaged into the firmware file is the DATA section and
+ * some debugging code accesses that.
  */
 enum iwl_ucode_sec {
+	IWL_UCODE_SECTION_DATA,
 	IWL_UCODE_SECTION_INST,
-	IWL_UCODE_SECTION_DATA,
 };
 /*
  * For 16.0 uCode and above, there is no differentiation between sections,


mac80211 hwsim: fix endianness bug

mac80211 hwsim: fix endianness bug

Radiotap is entirely little endian. Found with sparse.

Signed-off-by: Johannes Berg <8398eb9892c5ab2ff439ca0b5e4b0706dd9ebef9@sipsolutions.net>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>

--- drivers/net/wireless/mac80211_hwsim.c
+++ drivers/net/wireless/mac80211_hwsim.c
@@ -126,7 +126,7 @@
 					  (1 << IEEE80211_RADIOTAP_CHANNEL));
 	hdr->rt_flags = 0;
 	hdr->rt_rate = txrate->bitrate / 5;
-	hdr->rt_channel = data->channel->center_freq;
+	hdr->rt_channel = cpu_to_le16(data->channel->center_freq);
 	flags = IEEE80211_CHAN_2GHZ;
 	if (txrate->flags & IEEE80211_RATE_ERP_G)
 		flags |= IEEE80211_CHAN_OFDM;


mac80211_hwsim: fix PS debugfs file locking

The functions called within the iterators must be called with
tasklets disabled, so use atomic iteration like the rest of
the code and disable tasklets around the whole operation.

Signed-off-by: Johannes Berg <bff32994ff0f8d048f262a8388145a71b6071bfe@intel.com>

--- drivers/net/wireless/mac80211_hwsim.c
+++ drivers/net/wireless/mac80211_hwsim.c
@@ -626,22 +626,22 @@
 	old_ps = data->ps;
 	data->ps = val;

+	local_bh_disable();
 	if (val == PS_MANUAL_POLL) {
-		ieee80211_iterate_active_interfaces(data->hw,
-						    IEEE80211_IFACE_ITER_NORMAL,
-						    hwsim_send_ps_poll, data);
+		ieee80211_iterate_active_interfaces_atomic(
+			data->hw, IEEE80211_IFACE_ITER_NORMAL,
+			hwsim_send_ps_poll, data);
 		data->ps_poll_pending = true;
 	} else if (old_ps == PS_DISABLED && val != PS_DISABLED) {
-		ieee80211_iterate_active_interfaces(data->hw,
-						    IEEE80211_IFACE_ITER_NORMAL,
-						    hwsim_send_nullfunc_ps,
-						    data);
+		ieee80211_iterate_active_interfaces_atomic(
+			data->hw, IEEE80211_IFACE_ITER_NORMAL,
+			hwsim_send_nullfunc_ps, data);
 	} else if (old_ps != PS_DISABLED && val == PS_DISABLED) {
-		ieee80211_iterate_active_interfaces(data->hw,
-						    IEEE80211_IFACE_ITER_NORMAL,
-						    hwsim_send_nullfunc_no_ps,
-						    data);
-	}
+		ieee80211_iterate_active_interfaces_atomic(
+			data->hw, IEEE80211_IFACE_ITER_NORMAL,
+			hwsim_send_nullfunc_no_ps, data);
+	}
+	local_bh_enable();

 	return 0;
 }


mwifiex: print sleep_confirm cmd/response and power save events

Sleep Confirm command is sent separately while other commands
are handled through cmd_pending_q. Print sleep_confirm cmd and
its response as well as power save events so that we have a
clearer picture of power save handshake in driver log.

Signed-off-by: Bing Zhao <abbaae6378dda6b8d65fe6bd0f8beb334a5e4c4f@marvell.com>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>


wl1251: add nvs file name to module firmware list

Add nvs file name to module firmware list

Signed-off-by: Pali Rohár <271b10744f2b592adf8fde144d536c86b011b93c@gmail.com>
Signed-off-by: Pavel Machek <2375fa63e2908bb2df59f606483a3aa92321db7a@ucw.cz>
Signed-off-by: John W. Linville <2a53bac7a5d324865ef46ec4c38b2c0fba1456b4@tuxdriver.com>

--- drivers/net/wireless/ti/wl1251/main.c
+++ drivers/net/wireless/ti/wl1251/main.c
@@ -1603,3 +1603,4 @@
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Kalle Valo <kvalo@adurom.com>");
 MODULE_FIRMWARE(WL1251_FW_NAME);
+MODULE_FIRMWARE(WL1251_NVS_NAME);


wl18xx: make driver operational again

wl18xx: make driver operational again

we have done updating the driver to the new fw
api, so make the driver operational again.

Signed-off-by: Eliad Peller <fdf5551f20996bc0613832b4b54eb06eecaffd38@wizery.com>
Signed-off-by: Luciano Coelho <d1ef580865f8eb2e1d1c65bc406aba322cc98f3e@ti.com>

--- drivers/net/wireless/ti/wl18xx/main.c
+++ drivers/net/wireless/ti/wl18xx/main.c
@@ -1415,10 +1415,6 @@
 	struct wl18xx_priv *priv = wl->priv;
 	int ret;

-	wl1271_error("driver is in transitional commit (due to fw api"
-		     "change) and can't be booted!");
-	return -EINVAL;
-
 	wl->rtable = wl18xx_rtable;
 	wl->num_tx_desc = WL18XX_NUM_TX_DESCRIPTORS;
 	wl->num_rx_desc = WL18XX_NUM_TX_DESCRIPTORS;


wl18xx: export pwr_limit_reference_11_abg value as a module parameter

Yet another temporary module parameter requested by the firmware team.
This will be replaced by the conf binary.

Signed-off-by: Luciano Coelho <d1ef580865f8eb2e1d1c65bc406aba322cc98f3e@ti.com>
Signed-off-by: Arik Nemtsov <1a5d131848a166677cc209f94fa988cee9378c32@wizery.com>

--- drivers/net/wireless/ti/wl18xx/main.c
+++ drivers/net/wireless/ti/wl18xx/main.c
@@ -53,6 +53,7 @@
 static int low_band_component_type = -1;
 static int high_band_component = -1;
 static int high_band_component_type = -1;
+static int pwr_limit_reference_11_abg = -1;

 static const u8 wl18xx_rate_to_idx_2ghz[] = {
 	/* MCS rates are used only with 11n */
@@ -1190,6 +1191,13 @@
 		priv->conf.phy.high_band_component_type =
 			high_band_component_type;

+	if (pwr_limit_reference_11_abg == -1)
+		pwr_limit_reference_11_abg =
+			priv->conf.phy.pwr_limit_reference_11_abg;
+	else
+		priv->conf.phy.pwr_limit_reference_11_abg =
+			pwr_limit_reference_11_abg;
+
 	if (!checksum_param) {
 		wl18xx_ops.set_rx_csum = NULL;
 		wl18xx_ops.init_vif = NULL;
@@ -1270,6 +1278,10 @@
 MODULE_PARM_DESC(high_band_component_type, "High band component type: u8 "
 		 "(default is 0x09)");

+module_param(pwr_limit_reference_11_abg, uint, S_IRUSR);
+MODULE_PARM_DESC(pwr_limit_reference_11_abg, "Power limit reference: u8 "
+		 "(default is 0xc8)");
+
 MODULE_LICENSE("GPL v2");
 MODULE_AUTHOR("Luciano Coelho <coelho@ti.com>");
 MODULE_FIRMWARE(WL18XX_FW_NAME);


Staging: comedi: s526: Get rid of global variable 'cmReg'.

Signed-off-by: Frank Mori Hess <298b610a35dd7dda4ea5d33c28e8a7d9dff2b9bf@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>

--- drivers/staging/comedi/drivers/s526.c
+++ drivers/staging/comedi/drivers/s526.c
@@ -126,10 +126,10 @@
 	unsigned short reserved:1;
 };

-union {
+union cmReg {
 	struct counter_mode_register_t reg;
 	unsigned short value;
-} cmReg;
+};

 #define MAX_GPCT_CONFIG_DATA 6

@@ -285,6 +285,7 @@
 	int i, n;
 /* short value; */
 /* int subdev_channel = 0; */
+	union cmReg cmReg;

 	printk("comedi%d: s526: ", dev->minor);

@@ -516,6 +517,7 @@
 	int subdev_channel = CR_CHAN(insn->chanspec);	/*  Unpack chanspec */
 	int i;
 	short value;
+	union cmReg cmReg;

 /* printk("s526: GPCT_INSN_CONFIG: Configuring Channel %d\n", subdev_channel); */

@@ -741,6 +743,7 @@
 {
 	int subdev_channel = CR_CHAN(insn->chanspec);	/*  Unpack chanspec */
 	short value;
+	union cmReg cmReg;

 	printk("s526: GPCT_INSN_WRITE on channel %d\n", subdev_channel);
 	cmReg.value = inw(ADDR_CHAN_REG(REG_C0M, subdev_channel));


staging: comedi: s626: remove forward declarations 6

Move the enc_private_data definition down to remove the need
for the forward declarations.

Signed-off-by: H Hartley Sweeten <382ff55d8e07d1082d179e669636cd1552da4f36@visionengravers.com>
Cc: Ian Abbott <9e6ba6483b6a3e14d61f7c987e72ecb5b46122d6@mev.co.uk>
Cc: Frank Mori Hess <298b610a35dd7dda4ea5d33c28e8a7d9dff2b9bf@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/staging/comedi/drivers/s626.c
+++ drivers/staging/comedi/drivers/s626.c
@@ -233,36 +233,8 @@
 static void s626_timer_load(struct comedi_device *dev, struct enc_private *k,
 			    int tick);
 static uint32_t ReadLatch(struct comedi_device *dev, struct enc_private *k);
-static void ResetCapFlags_A(struct comedi_device *dev, struct enc_private *k);
-static void ResetCapFlags_B(struct comedi_device *dev, struct enc_private *k);
-static uint16_t GetMode_A(struct comedi_device *dev, struct enc_private *k);
-static uint16_t GetMode_B(struct comedi_device *dev, struct enc_private *k);
-static void SetMode_A(struct comedi_device *dev, struct enc_private *k,
-		      uint16_t Setup, uint16_t DisableIntSrc);
-static void SetMode_B(struct comedi_device *dev, struct enc_private *k,
-		      uint16_t Setup, uint16_t DisableIntSrc);
-static void SetEnable_A(struct comedi_device *dev, struct enc_private *k,
-			uint16_t enab);
-static void SetEnable_B(struct comedi_device *dev, struct enc_private *k,
-			uint16_t enab);
-static uint16_t GetEnable_A(struct comedi_device *dev, struct enc_private *k);
-static uint16_t GetEnable_B(struct comedi_device *dev, struct enc_private *k);
 static void SetLatchSource(struct comedi_device *dev, struct enc_private *k,
 			   uint16_t value);
-static void SetLoadTrig_A(struct comedi_device *dev, struct enc_private *k,
-			  uint16_t Trig);
-static void SetLoadTrig_B(struct comedi_device *dev, struct enc_private *k,
-			  uint16_t Trig);
-static uint16_t GetLoadTrig_A(struct comedi_device *dev, struct enc_private *k);
-static uint16_t GetLoadTrig_B(struct comedi_device *dev, struct enc_private *k);
-static void SetIntSrc_B(struct comedi_device *dev, struct enc_private *k,
-			uint16_t IntSource);
-static void SetIntSrc_A(struct comedi_device *dev, struct enc_private *k,
-			uint16_t IntSource);
-static uint16_t GetIntSrc_A(struct comedi_device *dev, struct enc_private *k);
-static uint16_t GetIntSrc_B(struct comedi_device *dev, struct enc_private *k);
-static void PulseIndex_A(struct comedi_device *dev, struct enc_private *k);
-static void PulseIndex_B(struct comedi_device *dev, struct enc_private *k);
 static void Preload(struct comedi_device *dev, struct enc_private *k,
 		    uint32_t value);

@@ -275,106 +247,6 @@

 /*  Translation table to map IntSrc into equivalent RDMISC2 event flag  bits. */
 /* static const uint16_t EventBits[][4] = { EVBITS(0), EVBITS(1), EVBITS(2), EVBITS(3), EVBITS(4), EVBITS(5) }; */
-
-/* struct enc_private; */
-static struct enc_private enc_private_data[] = {
-	{
-	 .GetEnable = GetEnable_A,
-	 .GetIntSrc = GetIntSrc_A,
-	 .GetLoadTrig = GetLoadTrig_A,
-	 .GetMode = GetMode_A,
-	 .PulseIndex = PulseIndex_A,
-	 .SetEnable = SetEnable_A,
-	 .SetIntSrc = SetIntSrc_A,
-	 .SetLoadTrig = SetLoadTrig_A,
-	 .SetMode = SetMode_A,
-	 .ResetCapFlags = ResetCapFlags_A,
-	 .MyCRA = LP_CR0A,
-	 .MyCRB = LP_CR0B,
-	 .MyLatchLsw = LP_CNTR0ALSW,
-	 .MyEventBits = EVBITS(0),
-	 },
-	{
-	 .GetEnable = GetEnable_A,
-	 .GetIntSrc = GetIntSrc_A,
-	 .GetLoadTrig = GetLoadTrig_A,
-	 .GetMode = GetMode_A,
-	 .PulseIndex = PulseIndex_A,
-	 .SetEnable = SetEnable_A,
-	 .SetIntSrc = SetIntSrc_A,
-	 .SetLoadTrig = SetLoadTrig_A,
-	 .SetMode = SetMode_A,
-	 .ResetCapFlags = ResetCapFlags_A,
-	 .MyCRA = LP_CR1A,
-	 .MyCRB = LP_CR1B,
-	 .MyLatchLsw = LP_CNTR1ALSW,
-	 .MyEventBits = EVBITS(1),
-	 },
-	{
-	 .GetEnable = GetEnable_A,
-	 .GetIntSrc = GetIntSrc_A,
-	 .GetLoadTrig = GetLoadTrig_A,
-	 .GetMode = GetMode_A,
-	 .PulseIndex = PulseIndex_A,
-	 .SetEnable = SetEnable_A,
-	 .SetIntSrc = SetIntSrc_A,
-	 .SetLoadTrig = SetLoadTrig_A,
-	 .SetMode = SetMode_A,
-	 .ResetCapFlags = ResetCapFlags_A,
-	 .MyCRA = LP_CR2A,
-	 .MyCRB = LP_CR2B,
-	 .MyLatchLsw = LP_CNTR2ALSW,
-	 .MyEventBits = EVBITS(2),
-	 },
-	{
-	 .GetEnable = GetEnable_B,
-	 .GetIntSrc = GetIntSrc_B,
-	 .GetLoadTrig = GetLoadTrig_B,
-	 .GetMode = GetMode_B,
-	 .PulseIndex = PulseIndex_B,
-	 .SetEnable = SetEnable_B,
-	 .SetIntSrc = SetIntSrc_B,
-	 .SetLoadTrig = SetLoadTrig_B,
-	 .SetMode = SetMode_B,
-	 .ResetCapFlags = ResetCapFlags_B,
-	 .MyCRA = LP_CR0A,
-	 .MyCRB = LP_CR0B,
-	 .MyLatchLsw = LP_CNTR0BLSW,
-	 .MyEventBits = EVBITS(3),
-	 },
-	{
-	 .GetEnable = GetEnable_B,
-	 .GetIntSrc = GetIntSrc_B,
-	 .GetLoadTrig = GetLoadTrig_B,
-	 .GetMode = GetMode_B,
-	 .PulseIndex = PulseIndex_B,
-	 .SetEnable = SetEnable_B,
-	 .SetIntSrc = SetIntSrc_B,
-	 .SetLoadTrig = SetLoadTrig_B,
-	 .SetMode = SetMode_B,
-	 .ResetCapFlags = ResetCapFlags_B,
-	 .MyCRA = LP_CR1A,
-	 .MyCRB = LP_CR1B,
-	 .MyLatchLsw = LP_CNTR1BLSW,
-	 .MyEventBits = EVBITS(4),
-	 },
-	{
-	 .GetEnable = GetEnable_B,
-	 .GetIntSrc = GetIntSrc_B,
-	 .GetLoadTrig = GetLoadTrig_B,
-	 .GetMode = GetMode_B,
-	 .PulseIndex = PulseIndex_B,
-	 .SetEnable = SetEnable_B,
-	 .SetIntSrc = SetIntSrc_B,
-	 .SetLoadTrig = SetLoadTrig_B,
-	 .SetMode = SetMode_B,
-	 .ResetCapFlags = ResetCapFlags_B,
-	 .MyCRA = LP_CR2A,
-	 .MyCRB = LP_CR2B,
-	 .MyLatchLsw = LP_CNTR2BLSW,
-	 .MyEventBits = EVBITS(5),
-	 },
-};

 /*  enab/disable a function or test status bit(s) that are accessed */
 /*  through Main Control Registers 1 or 2. */
@@ -2681,6 +2553,100 @@
 		  (uint16_t) (value >> 16));
 }

+static struct enc_private enc_private_data[] = {
+	{
+		.GetEnable	= GetEnable_A,
+		.GetIntSrc	= GetIntSrc_A,
+		.GetLoadTrig	= GetLoadTrig_A,
+		.GetMode	= GetMode_A,
+		.PulseIndex	= PulseIndex_A,
+		.SetEnable	= SetEnable_A,
+		.SetIntSrc	= SetIntSrc_A,
+		.SetLoadTrig	= SetLoadTrig_A,
+		.SetMode	= SetMode_A,
+		.ResetCapFlags	= ResetCapFlags_A,
+		.MyCRA		= LP_CR0A,
+		.MyCRB		= LP_CR0B,
+		.MyLatchLsw	= LP_CNTR0ALSW,
+		.MyEventBits	= EVBITS(0),
+	}, {
+		.GetEnable	= GetEnable_A,
+		.GetIntSrc	= GetIntSrc_A,
+		.GetLoadTrig	= GetLoadTrig_A,
+		.GetMode	= GetMode_A,
+		.PulseIndex	= PulseIndex_A,
+		.SetEnable	= SetEnable_A,
+		.SetIntSrc	= SetIntSrc_A,
+		.SetLoadTrig	= SetLoadTrig_A,
+		.SetMode	= SetMode_A,
+		.ResetCapFlags	= ResetCapFlags_A,
+		.MyCRA		= LP_CR1A,
+		.MyCRB		= LP_CR1B,
+		.MyLatchLsw	= LP_CNTR1ALSW,
+		.MyEventBits	= EVBITS(1),
+	}, {
+		.GetEnable	= GetEnable_A,
+		.GetIntSrc	= GetIntSrc_A,
+		.GetLoadTrig	= GetLoadTrig_A,
+		.GetMode	= GetMode_A,
+		.PulseIndex	= PulseIndex_A,
+		.SetEnable	= SetEnable_A,
+		.SetIntSrc	= SetIntSrc_A,
+		.SetLoadTrig	= SetLoadTrig_A,
+		.SetMode	= SetMode_A,
+		.ResetCapFlags	= ResetCapFlags_A,
+		.MyCRA		= LP_CR2A,
+		.MyCRB		= LP_CR2B,
+		.MyLatchLsw	= LP_CNTR2ALSW,
+		.MyEventBits	= EVBITS(2),
+	}, {
+		.GetEnable	= GetEnable_B,
+		.GetIntSrc	= GetIntSrc_B,
+		.GetLoadTrig	= GetLoadTrig_B,
+		.GetMode	= GetMode_B,
+		.PulseIndex	= PulseIndex_B,
+		.SetEnable	= SetEnable_B,
+		.SetIntSrc	= SetIntSrc_B,
+		.SetLoadTrig	= SetLoadTrig_B,
+		.SetMode	= SetMode_B,
+		.ResetCapFlags	= ResetCapFlags_B,
+		.MyCRA		= LP_CR0A,
+		.MyCRB		= LP_CR0B,
+		.MyLatchLsw	= LP_CNTR0BLSW,
+		.MyEventBits	= EVBITS(3),
+	}, {
+		.GetEnable	= GetEnable_B,
+		.GetIntSrc	= GetIntSrc_B,
+		.GetLoadTrig	= GetLoadTrig_B,
+		.GetMode	= GetMode_B,
+		.PulseIndex	= PulseIndex_B,
+		.SetEnable	= SetEnable_B,
+		.SetIntSrc	= SetIntSrc_B,
+		.SetLoadTrig	= SetLoadTrig_B,
+		.SetMode	= SetMode_B,
+		.ResetCapFlags	= ResetCapFlags_B,
+		.MyCRA		= LP_CR1A,
+		.MyCRB		= LP_CR1B,
+		.MyLatchLsw	= LP_CNTR1BLSW,
+		.MyEventBits	= EVBITS(4),
+	}, {
+		.GetEnable	= GetEnable_B,
+		.GetIntSrc	= GetIntSrc_B,
+		.GetLoadTrig	= GetLoadTrig_B,
+		.GetMode	= GetMode_B,
+		.PulseIndex	= PulseIndex_B,
+		.SetEnable	= SetEnable_B,
+		.SetIntSrc	= SetIntSrc_B,
+		.SetLoadTrig	= SetLoadTrig_B,
+		.SetMode	= SetMode_B,
+		.ResetCapFlags	= ResetCapFlags_B,
+		.MyCRA		= LP_CR2A,
+		.MyCRB		= LP_CR2B,
+		.MyLatchLsw	= LP_CNTR2BLSW,
+		.MyEventBits	= EVBITS(5),
+	},
+};
+
 static void CountersInit(struct comedi_device *dev)
 {
 	int chan;


Staging: rtl8712: replace memcpy() by ether_addr_copy() using coccinelle and pack variable

This patch focuses on fixing the following warning generated
by checkpatch.pl for the file rtl871x_cmd.c

Prefer ether_addr_copy() over memcpy() if the Ethernet addresses
are __aligned(2)

@@ expression e1, e2; @@

- memcpy(e1, e2, ETH_ALEN);
+ ether_addr_copy(e1, e2);

struct _adapter {
        struct dvobj_priv          dvobjpriv;            /*     0    40*/
        struct mlme_priv           mlmepriv;             /*    40  1560*/
        /* --- cacheline 25 boundary (1600 bytes) --- */
        struct cmd_priv            cmdpriv;              /*  1600   136*/
        /* --- cacheline 27 boundary (1728 bytes) was 8 bytes ago --- */
        struct evt_priv            evtpriv;              /*  1736    96*/
        /* --- cacheline 28 boundary (1792 bytes) was 40 bytes ago --- * */
        struct io_queue *          pio_queue;            /*  1832     8*/
        struct xmit_priv           xmitpriv;             /*  1840   912*/
        /* --- cacheline 43 boundary (2752 bytes) --- */
        struct recv_priv           recvpriv;             /*  2752  1088*/
        /* --- cacheline 60 boundary (3840 bytes) --- */
        struct sta_priv            stapriv;              /*  3840   672*/
        /* --- cacheline 70 boundary (4480 bytes) was 32 bytes ago --- * */
        struct security_priv       securitypriv;         /*  4512  4816*/
        /* --- cacheline 145 boundary (9280 bytes) was 48 bytes ago --- * */
        struct registry_priv       registrypriv;         /*  9328   968*/
        /* --- cacheline 160 boundary (10240 bytes) was 56 bytes ago --- * */
        struct wlan_acl_pool       acl_list;             /* 10296  1536*/
        /* --- cacheline 184 boundary (11776 bytes) was 56 bytes ago --- * */
        struct pwrctrl_priv        pwrctrlpriv;          /* 11832   224*/
        /* --- cacheline 188 boundary (12032 bytes) was 24 bytes ago --- * */
        struct eeprom_priv         eeprompriv;           /* 12056   508*/

        /* XXX 4 bytes hole, try to pack */

        /* --- cacheline 196 boundary (12544 bytes) was 24 bytes ago --- * */
        struct hal_priv            halpriv;              /* 12568    88*/
        /* --- cacheline 197 boundary (12608 bytes) was 48 bytes ago --- * */
        struct led_priv            ledpriv;              /* 12656   304*/
        /* --- cacheline 202 boundary (12928 bytes) was 32 bytes ago --- * */
        struct mp_priv             mppriv;               /* 12960  1080*/
	 /* --- cacheline 219 boundary (14016 bytes) was 24 bytes ago * --- */
        s32                        bDriverStopped;       /* 14040     4*/
        s32                        bSurpriseRemoved;     /* 14044     4*/
        u32                        IsrContent;           /* 14048     4*/
        u32                        ImrContent;           /* 14052     4*/
        u8                         EepromAddressSize;    /* 14056     1*/
        u8                         hw_init_completed;    /* 14057     1*/

        /* XXX 6 bytes hole, try to pack */

        struct task_struct *       cmdThread;            /* 14064     8*/
        pid_t                      evtThread;            /* 14072     4*/

        /* XXX 4 bytes hole, try to pack */

        /* --- cacheline 220 boundary (14080 bytes) --- */
        struct task_struct *       xmitThread;           /* 14080     8*/
        pid_t                      recvThread;           /* 14088     4*/

        /* XXX 4 bytes hole, try to pack */

        uint                       (*dvobj_init)(struct _adapter *); /*14096     8 */
        void                       (*dvobj_deinit)(struct _adapter *);/* 14104     8 */
        struct net_device *        pnetdev;              /* 14112     8*/
        int                        bup;                  /* 14120     4*/

        /* XXX 4 bytes hole, try to pack */

        struct net_device_stats    stats;                /* 14128   184*/
        /* --- cacheline 223 boundary (14272 bytes) was 40 bytes ago --- * */
	 struct iw_statistics       iwstats;              /* 14312    32*/
        /* --- cacheline 224 boundary (14336 bytes) was 8 bytes ago --- * */
        int                        pid;                  /* 14344     4*/

        /* XXX 4 bytes hole, try to pack */

        struct work_struct         wkFilterRxFF0;        /* 14352    32*/
        u8                         blnEnableRxFF0Filter; /* 14384     1*/

        /* XXX 3 bytes hole, try to pack */

        spinlock_t                 lockRxFF0Filter;      /* 14388     4*/
        const struct firmware  *   fw;                   /* 14392     8*/
        /* --- cacheline 225 boundary (14400 bytes) --- */
        struct usb_interface *     pusb_intf;            /* 14400     8*/
        struct mutex               mutex_start;          /* 14408    40*/

        /* XXX last struct has 4 bytes of padding */

        struct completion          rtl8712_fw_ready;     /* 14448    32*/
        /* --- cacheline 226 boundary (14464 bytes) was 16 bytes ago --- * */

        /* size: 14480, cachelines: 227, members: 40 */
        /* sum members: 14451, holes: 7, sum holes: 29 */
        /* paddings: 1, sum paddings: 4 */
        /* last cacheline: 16 bytes */
};

Signed-off-by: Melike Yurtoglu <a089d050ee93efcaf2baabdcfe68b93ff1b49f2c@gmail.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>


staging: wilc1000: remove meaningless line

The current driver is calling skb_reserve function to align memory in
frmw_to_linux function. However, the wrong value is used as the input argument.
Besides, the process is not necessary because the address already is algined
in dev_alloc_skb function. So, this patch removes the line for dummy headroom.

Signed-off-by: Johnny Kim <f60f249efb89f15a49fef28dd33596598d2375c0@atmel.com>
Signed-off-by: Tony Cho <545cb41ca22b217ad08520fed1285c6bec9a869f@atmel.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/staging/wilc1000/linux_wlan.c
+++ drivers/staging/wilc1000/linux_wlan.c
@@ -2161,8 +2161,6 @@
 			return;
 		}

-		skb_reserve(skb, (unsigned int)skb->data & 0x3);
-
 		if (g_linux_wlan == NULL || wilc_netdev == NULL)
 			PRINT_ER("wilc_netdev in g_linux_wlan is NULL");
 		skb->dev = wilc_netdev;


USB: ti_usb_3410_5052: fix big-endian firmware handling

commit e877dd2f2581628b7119df707d4cf03d940cff49 upstream.

Fix endianess bugs in firmware handling introduced by commits cb7a7c6a
("ti_usb_3410_5052: add Multi-Tech modem support") and 05a3d905
("ti_usb_3410_5052: support alternate firmware") which made the driver
use the wrong firmware for certain devices on big-endian machines.

Signed-off-by: Johan Hovold <6a430eed381e126d51a8cce8db662f765ce314bc@gmail.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/usb/serial/ti_usb_3410_5052.c
+++ drivers/usb/serial/ti_usb_3410_5052.c
@@ -1536,14 +1536,15 @@
 	char buf[32];

 	/* try ID specific firmware first, then try generic firmware */
-	sprintf(buf, "ti_usb-v%04x-p%04x.fw", dev->descriptor.idVendor,
-	    dev->descriptor.idProduct);
+	sprintf(buf, "ti_usb-v%04x-p%04x.fw",
+			le16_to_cpu(dev->descriptor.idVendor),
+			le16_to_cpu(dev->descriptor.idProduct));
 	status = request_firmware(&fw_p, buf, &dev->dev);

 	if (status != 0) {
 		buf[0] = '\0';
-		if (dev->descriptor.idVendor == MTS_VENDOR_ID) {
-			switch (dev->descriptor.idProduct) {
+		if (le16_to_cpu(dev->descriptor.idVendor) == MTS_VENDOR_ID) {
+			switch (le16_to_cpu(dev->descriptor.idProduct)) {
 			case MTS_CDMA_PRODUCT_ID:
 				strcpy(buf, "mts_cdma.fw");
 				break;


Revert "backlight: fix memory leak on obscure error path"

This reverts commit 9ea3c498962bc63748e92c31c874169ab0726324.

'data' is being allocated by devm_kzalloc(), is it's actually
wrong to free() it in the error path, as it will be destroyed
properly later.

Reported-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Jiri Kosina <ed58f755cc8caaf10c3e8c731a8b86fb8f13d6cb@suse.cz>

--- drivers/video/backlight/88pm860x_bl.c
+++ drivers/video/backlight/88pm860x_bl.c
@@ -228,7 +228,6 @@
 	data->port = pdata->flags;
 	if (data->port < 0) {
 		dev_err(&pdev->dev, "wrong platform data is assigned");
-		kfree(data);
 		return -EINVAL;
 	}


OMAPDSS: DISPC: work-around for errata i631

Errata i631 description:

"When in YUV4:2:0 format in 1D burst, the DISPC DMA skips lines when
fetching Chroma sampling."

Workaround:

"If YUV4:2:0-1D burst is required: Set
DISPC_VIDp_ATTRIBUTES[22]DOUBLESTRIDE to 0x0 and
DISPC_VIDp_ATTRIBUTES[13:12]ROTATION to 0x1 or 0x3"

The description is somewhat confusing, but testing has shown that DSS
fetches extra rows from memory when using NV12 format in 1D mode. If the
memory after the framebuffer is inaccessible, this leads to OCP errors.

The driver always uses DOUBLESTRIDE=0 when using 1D mode, so we only
need to handle the ROTATION part.

The issue exist on all OMAP4 and OMAP5 based DSS IPs.

Signed-off-by: Tomi Valkeinen <e1ca4dbb8be1acaf20734fecd2da10ed1d46a9bb@ti.com>

--- drivers/video/fbdev/omap2/dss/dispc.c
+++ drivers/video/fbdev/omap2/dss/dispc.c
@@ -1741,6 +1741,15 @@
 			row_repeat = false;
 	}

+	/*
+	 * OMAP4/5 Errata i631:
+	 * NV12 in 1D mode must use ROTATION=1. Otherwise DSS will fetch extra
+	 * rows beyond the framebuffer, which may cause OCP error.
+	 */
+	if (color_mode == OMAP_DSS_COLOR_NV12 &&
+			rotation_type != OMAP_DSS_ROT_TILER)
+		vidrot = 1;
+
 	REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane), vidrot, 13, 12);
 	if (dss_has_feature(FEAT_ROWREPEATENABLE))
 		REG_FLD_MOD(DISPC_OVL_ATTRIBUTES(plane),


cvt_data: use .hword (consistent 2 bytes), offsets from ;.org

--- tools/cvt_data.c
+++ tools/cvt_data.c
@@ -138,7 +138,7 @@
   case DXT_BYTE:
     return ".byte";
   case DXT_WORD:
-    return ".word";
+    return ".hword";
   case DXT_DWORD:
     return ".long";
   case DXT_QUAD:
@@ -501,8 +501,18 @@
       asmln++;

       p = sskip(line);
-      if (*p == 0 || *p == ';')
+      if (*p == 0)
         continue;
+
+      if (*p == ';') {
+        if (IS_START(p, ";org") && sscanf(p + 5, "%Xh", &i) == 1) {
+          // ;org is only seen at section start, so assume . addr 0
+          i &= 0xfff;
+          if (i != 0)
+            fprintf(fout, "\t\t  .skip 0x%x\n", i);
+        }
+        continue;
+      }

       for (wordc = 0; wordc < ARRAY_SIZE(words); wordc++) {
         p = sskip(next_word_s(words[wordc], sizeof(words[0]), p));


added some debug code

added some debug code

--- tools/irrecord.c
+++ tools/irrecord.c
@@ -1,26 +1,4 @@
-/*      $Id: irrecord.c,v 5.1 1999/05/05 14:57:55 columbus Exp $      */
-
-/***************************************************************************
- ** This file is part of the lirc-0.5.4 package ****************************
- ** LIRC - Linux Infrared Remote Control ***********************************
- ***************************************************************************
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- */
-
+/*      $Id: irrecord.c,v 5.2 1999/05/07 17:48:10 columbus Exp $      */

 /****************************************************************************
  ** irrecord.c **************************************************************
@@ -71,6 +49,14 @@
 #define MAX_SIGNALS 200
 #define AEPS 100
 #define EPS 30
+
+/* some threshold values */
+
+#define TH_SPACE_ENC   80	/* I want less than 20% mismatches */
+#define TH_HEADER      90
+#define TH_TRAIL       90
+#define TH_IS_BIT      15
+

 struct lengths
 {
@@ -582,16 +568,28 @@
 			case SPACE_ENC:
 				if(-1==check_lengths(remotes))
 				{
+#                                       ifdef DEBUG
+					fprintf(stderr," check_lengths(%s) "
+						"failed\n",remotes->name);
+#                                       endif
 					return(-1);
 				}
 				if(-1==get_lengths(remotes))
 				{
+#                                       ifdef DEBUG
+					fprintf(stderr," get_lengths(%s) "
+						"failed\n",remotes->name);
+#                                       endif
 					return(-1);
 				}
 				remotes->flags&=~RAW_CODES;
 				remotes->flags|=SPACE_ENC;
 				if(-1==get_codes(remotes))
 				{
+#                                       ifdef DEBUG
+					fprintf(stderr," get_codes(%s) "
+						"failed\n",remotes->name);
+#                                       endif
 					remotes->flags&=~SPACE_ENC;
 					remotes->flags|=RAW_CODES;
 					return(-1);
@@ -645,8 +643,7 @@
 			if(codes[i].length==codes[j].length)
 			{
 				match++;
-				/* I want less than 20% mismatches */
-				if(match>=80*sum/100)
+				if(match>=TH_SPACE_ENC*sum/100)
 				{
 					/* this is not yet the
 					   number of bits */
@@ -795,13 +792,13 @@
 	plast=NULL;
 	while(p!=NULL)
 	{
-		if(p->count>=90*sum/100)
+		if(p->count>=TH_HEADER*sum/100)
 		{
 			s=*first_space;
 			slast=NULL;
 			while(s!=NULL)
 			{
-				if(s->count>=90*sum/100 &&
+				if(s->count>=TH_HEADER*sum/100 &&
 				   (p->count<=sum || s->count<=sum))
 				{

@@ -820,7 +817,7 @@
 							match++;
 						}
 					}
-					if(match>=sum*90/100)
+					if(match>=sum*TH_HEADER/100)
 					{
 						remote->phead=p->sum/p->count;
 						remote->shead=s->sum/s->count;
@@ -903,7 +900,7 @@
 	}
 	sum*=(remote->bits-1-(has_header(remote) ? 2:0));
 	sum/=2;
-	if(match>=20*sum/100)
+	if(match>=TH_IS_BIT*sum/100)
 	{
 		return(1);
 	}
@@ -995,7 +992,7 @@
 					match++;
 				}
 			}
-			if(match>=sum*90/100)
+			if(match>=sum*TH_TRAIL/100)
 			{
 				remote->ptrail=p->sum/p->count;
 				p->sum-=sum*p->sum/p->count;
@@ -1127,6 +1124,8 @@
 		}
 		else
 		{
+			fprintf(stderr," decode(%s) failed. current=%s\n",
+				remote->name,current->name);
 			return(-1);
 		}
 		codes++;


don't try to send events to non-existing window


correct if block logic

correct if block logic

--- traits/ctraits.c
+++ traits/ctraits.c
@@ -2170,10 +2170,9 @@
             if ( rc >= 0 ) {
                 return 0;
             }
-            else if ( PyErr_ExceptionMatches( PyExc_KeyError ) ) {
-                unknown_attribute_error( obj, name );
-            }
             else {
+                if ( PyErr_ExceptionMatches( PyExc_KeyError ) )
+                    unknown_attribute_error( obj, name );
                 return -1;
             }
         }


OgreAssert: include function name on compilers besides Borland (#230)

--- OgreMain/include/OgreException.h
+++ OgreMain/include/OgreException.h
@@ -41,21 +41,12 @@
 #   if OGRE_DEBUG_MODE
 #       define OgreAssert( a, b ) assert( (a) && (b) )
 #   else
-#       if OGRE_COMP != OGRE_COMPILER_BORL
-#           define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), "no function info")
-#       else
-#           define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNC__ )
-#       endif
+#       define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNCTION__ )
 #   endif

 // EXCEPTIONS mode
 #elif OGRE_ASSERT_MODE == 2
-#   if OGRE_COMP != OGRE_COMPILER_BORL
-#       define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), "no function info")
-#   else
-#       define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNC__ )
-#   endif
-
+#   define OgreAssert( a, b ) if( !(a) ) OGRE_EXCEPT( Ogre::Exception::ERR_RT_ASSERTION_FAILED, (b), __FUNCTION__ )
 // STANDARD mode
 #else
 #   define OgreAssert( a, b ) assert( (a) && (b) )


Remove unused include.

Remove unused include.

--- io/pipe/pipe_pair_simple.h
+++ io/pipe/pipe_pair_simple.h
@@ -26,7 +26,6 @@
 #ifndef	IO_PIPE_PIPE_PAIR_SIMPLE_H
 #define	IO_PIPE_PIPE_PAIR_SIMPLE_H

-#include <io/pipe/pipe_simple.h>
 #include <io/pipe/pipe_simple_wrapper.h>

 class PipePairSimple : public PipePair {


Bug 489287: Resolve a few remaining issues with NSS's new revocation flags

--- security/nss/lib/certdb/certt.h
+++ security/nss/lib/certdb/certt.h
@@ -1111,6 +1111,8 @@
  *     After the individual tests have been executed, we must have
  *     been able to find fresh information using at least one method.
  *     If we were unable to find fresh info, it's a failure.
+ *     This setting overrides the CERT_REV_M_FAIL_ON_MISSING_FRESH_INFO
+ *     flag on all methods.
  */
 #define CERT_REV_MI_NO_OVERALL_INFO_REQUIREMENT       0L
 #define CERT_REV_MI_REQUIRE_SOME_FRESH_INFO_AVAILABLE 2L


Ошибка при отсутствии файла index теперь 404, а не 500.

--- mod_nginx/ngx_http_mp4frag_module.c
+++ mod_nginx/ngx_http_mp4frag_module.c
@@ -135,8 +135,9 @@

     fd = open(filename, O_RDONLY);
     if ( fd == -1 ) {
+        int e = errno;
         ngx_log_error(NGX_LOG_ERR, r->connection->log, errno, "opening %s", filename);
-        return NGX_HTTP_INTERNAL_SERVER_ERROR;
+        return ( e == ENOENT || e == ENOTDIR ) ? NGX_HTTP_NOT_FOUND : NGX_HTTP_INTERNAL_SERVER_ERROR;
     }
     if ( fstat(fd, &st) == -1 ) {
         close(fd);
@@ -194,13 +195,10 @@
         return rc;
     }

-#if 0
-    /* set the 'Content-type' header */
-    r->headers_out.content_type.len = sizeof("text/html") - 1;
-    r->headers_out.content_type.data = (u_char *) "text/html";
-#endif
-
     last = ngx_http_map_uri_to_path(r, &path, &root, 0);
+
+    ngx_log_error(NGX_LOG_DEBUG, r->connection->log, 0, "path=%s", path.data);
+
     lastslash = strrchr((char*)path.data, '/');
     if ( lastslash ) {
         path.len = lastslash - (char*)path.data;
@@ -221,6 +219,7 @@
     medianum = atoi(lastslash + 1);

     memcpy(lastslash + 1, "index", 6);
+    ngx_log_error(NGX_LOG_DEBUG, r->connection->log, 0, "index_path=%s", path.data);

     if ( (rc = make_mapping((const char *)path.data, &index_map, r)) != NGX_OK ) {
         return rc;


ITS#7992 assume Windows paths are UTF-8

ITS#7992 assume Windows paths are UTF-8

--- libraries/liblmdb/mdb.c
+++ libraries/liblmdb/mdb.c
@@ -1441,6 +1441,8 @@
 static SECURITY_DESCRIPTOR mdb_null_sd;
 static SECURITY_ATTRIBUTES mdb_all_sa;
 static int mdb_sec_inited;
+
+static int utf8_to_utf16(const char *src, int srcsize, wchar_t **dst, int *dstsize);
 #endif

 /** Return the library version info. */
@@ -4518,9 +4520,12 @@
 	off_t size, rsize;

 #ifdef _WIN32
-	env->me_lfd = CreateFileA(lpath, GENERIC_READ|GENERIC_WRITE,
+	wchar_t *wlpath;
+	utf8_to_utf16(lpath, -1, &wlpath, NULL);
+	env->me_lfd = CreateFileW(wlpath, GENERIC_READ|GENERIC_WRITE,
 		FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS,
 		FILE_ATTRIBUTE_NORMAL, NULL);
+	free(wlpath);
 #else
 	env->me_lfd = open(lpath, O_RDWR|O_CREAT|MDB_CLOEXEC, mode);
 #endif
@@ -4771,6 +4776,9 @@
 {
 	int		oflags, rc, len, excl = -1;
 	char *lpath, *dpath;
+#ifdef _WIN32
+	wchar_t *wpath;
+#endif

 	if (env->me_fd!=INVALID_HANDLE_VALUE || (flags & ~(CHANGEABLE|CHANGELESS)))
 		return EINVAL;
@@ -4834,8 +4842,10 @@
 		len = OPEN_ALWAYS;
 	}
 	mode = FILE_ATTRIBUTE_NORMAL;
-	env->me_fd = CreateFileA(dpath, oflags, FILE_SHARE_READ|FILE_SHARE_WRITE,
+	utf8_to_utf16(dpath, -1, &wpath, NULL);
+	env->me_fd = CreateFileW(wpath, oflags, FILE_SHARE_READ|FILE_SHARE_WRITE,
 		NULL, len, mode, NULL);
+	free(wpath);
 #else
 	if (F_ISSET(flags, MDB_RDONLY))
 		oflags = O_RDONLY;
@@ -4864,9 +4874,11 @@
 			 */
 #ifdef _WIN32
 			len = OPEN_EXISTING;
-			env->me_mfd = CreateFileA(dpath, oflags,
+			utf8_to_utf16(dpath, -1, &wpath, NULL);
+			env->me_mfd = CreateFileW(wpath, oflags,
 				FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, len,
 				mode | FILE_FLAG_WRITE_THROUGH, NULL);
+			free(wpath);
 #else
 			oflags &= ~O_CREAT;
 			env->me_mfd = open(dpath, oflags | MDB_DSYNC, mode);
@@ -9265,6 +9277,9 @@
 	int rc, len;
 	char *lpath;
 	HANDLE newfd = INVALID_HANDLE_VALUE;
+#ifdef _WIN32
+	wchar_t *wpath;
+#endif

 	if (env->me_flags & MDB_NOSUBDIR) {
 		lpath = (char *)path;
@@ -9282,8 +9297,10 @@
 	 * already in the OS cache.
 	 */
 #ifdef _WIN32
-	newfd = CreateFileA(lpath, GENERIC_WRITE, 0, NULL, CREATE_NEW,
+	utf8_to_utf16(lpath, -1, &wpath, NULL);
+	newfd = CreateFileW(wpath, GENERIC_WRITE, 0, NULL, CREATE_NEW,
 				FILE_FLAG_NO_BUFFERING|FILE_FLAG_WRITE_THROUGH, NULL);
+	free(wpath);
 #else
 	newfd = open(lpath, O_WRONLY|O_CREAT|O_EXCL, 0666);
 #endif
@@ -9988,3 +10005,22 @@
 }
 #endif	/* MDB_ROBUST_SUPPORTED */
 /** @} */
+
+#if defined(_WIN32)
+static int utf8_to_utf16(const char *src, int srcsize, wchar_t **dst, int *dstsize)
+{
+	int need;
+	wchar_t *result;
+	need = MultiByteToWideChar(CP_UTF8, 0, src, srcsize, NULL, 0);
+	if (need == 0xFFFD)
+		return EILSEQ;
+	if (need == 0)
+		return EINVAL;
+	result = malloc(sizeof(wchar_t) * need);
+	MultiByteToWideChar(CP_UTF8, 0, src, srcsize, result, need);
+	if (dstsize)
+		*dstsize = need;
+	*dst = result;
+	return 0;
+}
+#endif /* defined(_WIN32) */


Add extern to the function declarations in rangelist.h. (dm)

git-svn-id: 30a5f035a20f1bc647618dbad7eea2a951b61b7c@2013 91a5dbb7-01b9-0310-9b5f-b28072856b6e

--- Programs/rangelist.h
+++ Programs/rangelist.h
@@ -35,41 +35,41 @@
 /* Creates an item of a range list */
 /* Specify the range, a pointer to previous and next item */
 /* Returns the adress of the newly created range, NULL if not enough memory */
-rangeList *createRange(rangeList *p, uint32_t x, uint32_t y, rangeList *n);
+extern rangeList *createRange(rangeList *p, uint32_t x, uint32_t y, rangeList *n);

 /* Function : freeRange */
 /* Destroys an item of a range list */
 /* If provided, the previous item will be linked to the next item */
-void freeRange(rangeList *p, rangeList *c);
+extern void freeRange(rangeList *p, rangeList *c);

 /* Function : fHreeRangeList */
 /* Frees a whole list */
 /* If you wan to destroy a whole list, call this function, rather than */
 /* calling freeRange on each element, since th latter cares about links */
 /* and hence is slower */
-void freeRangeList(rangeList **l);
+extern void freeRangeList(rangeList **l);

 /* Function : contains */
 /* Determines if the range list l contains x */
 /* If yes, returns the adress of the cell [a..b] such that a<=x<=b */
 /* If no, returns NULL */
-rangeList *contains(rangeList *l, uint32_t n);
+extern rangeList *contains(rangeList *l, uint32_t n);

 /* Function : displayRangeList */
 /* Prints a range list on stdout */
 /* This is for debugging only */
-void displayRangeList(rangeList *l);
+extern void displayRangeList(rangeList *l);

 /* Function : addRange */
 /* Adds a range to a range list */
 /* We have to keep a sorted list of [disjoints] ranges */
 /* Return 0 if success, -1 if an error occurs */
-int addRange(uint32_t x0, uint32_t y0, rangeList **l);
+extern int addRange(uint32_t x0, uint32_t y0, rangeList **l);

 /* Function : removeRange */
 /* Removes a range from a range list */
 /* Returns 0 if success, -1 if failure */
-int removeRange(uint32_t x0, uint32_t y0, rangeList **l);
+extern int removeRange(uint32_t x0, uint32_t y0, rangeList **l);

 #ifdef __cplusplus
 }


boot_serial: cleanup max output size calculation

Calculation of BOOT_SERIAL_OUT_MAX was based on MCUBOOT_IMAGE_NUMBER
while in other places BOOT_IMAGE_NUMBER is taken into account as
number of images. Let's align the calculation to use same literal value
as others.

Signed-off-by: Andrzej Puzdrowski <0222c24e1773dd88269ed0e559909ec9bea3604a@nordicsemi.no>

--- boot/boot_serial/src/boot_serial.c
+++ boot/boot_serial/src/boot_serial.c
@@ -63,12 +63,8 @@

 BOOT_LOG_MODULE_DECLARE(mcuboot);

-#ifndef BOOT_IMAGE_NUMBER
-#define BOOT_IMAGE_NUMBER MCUBOOT_IMAGE_NUMBER
-#endif
-
 #define BOOT_SERIAL_INPUT_MAX   512
-#define BOOT_SERIAL_OUT_MAX     (128 * MCUBOOT_IMAGE_NUMBER)
+#define BOOT_SERIAL_OUT_MAX     (128 * BOOT_IMAGE_NUMBER)

 #ifdef __ZEPHYR__
 /* base64 lib encodes data to null-terminated string */