gpio: mxs: Add IRQ_TYPE_EDGE_BOTH support

This patch adds support for IRQ_TYPE_EDGE_BOTH needed for some driver
(gpio-keys).

Inspired from gpio-mxc.c

Acked-by: Shawn Guo <912cf7eb7d8018e2943586ae6657d21fd4e38239@linaro.org>
Signed-off-by: Gwenhael Goavec-Merou <795f300ad10bb99fa929ce5b21a5b6eba1d65a5b@armadeus.com>
Signed-off-by: Linus Walleij <9cd9d802d23c0ed5e224beabf4ae4a5c478746ef@linaro.org>

--- drivers/gpio/gpio-mxs.c
+++ drivers/gpio/gpio-mxs.c
@@ -65,6 +65,7 @@
 	struct irq_domain *domain;
 	struct bgpio_chip bgc;
 	enum mxs_gpio_id devid;
+	u32 both_edges;
 };

 static inline int is_imx23_gpio(struct mxs_gpio_port *port)
@@ -81,13 +82,23 @@

 static int mxs_gpio_set_irq_type(struct irq_data *d, unsigned int type)
 {
+	u32 val;
 	u32 pin_mask = 1 << d->hwirq;
 	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
 	struct mxs_gpio_port *port = gc->private;
 	void __iomem *pin_addr;
 	int edge;

+	port->both_edges &= ~pin_mask;
 	switch (type) {
+	case IRQ_TYPE_EDGE_BOTH:
+		val = gpio_get_value(port->bgc.gc.base + d->hwirq);
+		if (val)
+			edge = GPIO_INT_FALL_EDGE;
+		else
+			edge = GPIO_INT_RISE_EDGE;
+		port->both_edges |= pin_mask;
+		break;
 	case IRQ_TYPE_EDGE_RISING:
 		edge = GPIO_INT_RISE_EDGE;
 		break;
@@ -124,6 +135,23 @@
 	return 0;
 }

+static void mxs_flip_edge(struct mxs_gpio_port *port, u32 gpio)
+{
+	u32 bit, val, edge;
+	void __iomem *pin_addr;
+
+	bit = 1 << gpio;
+
+	pin_addr = port->base + PINCTRL_IRQPOL(port);
+	val = readl(pin_addr);
+	edge = val & bit;
+
+	if (edge)
+		writel(bit, pin_addr + MXS_CLR);
+	else
+		writel(bit, pin_addr + MXS_SET);
+}
+
 /* MXS has one interrupt *per* gpio port */
 static void mxs_gpio_irq_handler(u32 irq, struct irq_desc *desc)
 {
@@ -137,6 +165,9 @@

 	while (irq_stat != 0) {
 		int irqoffset = fls(irq_stat) - 1;
+		if (port->both_edges & (1 << irqoffset))
+			mxs_flip_edge(port, irqoffset);
+
 		generic_handle_irq(irq_find_mapping(port->domain, irqoffset));
 		irq_stat &= ~(1 << irqoffset);
 	}


gpio: fix inclusion of local header

gpio: fix inclusion of local header

since we are in the same directory, include the file directly.

Change-Id: I21c959538e4a3d9e3fba99eaa9b09697fffe25b0
Signed-off-by: Anas Nashif <0d9952ec84ac43c159f6b7e7ed99a9080c00dd6e@intel.com>

--- drivers/gpio/gpio_sch.c
+++ drivers/gpio/gpio_sch.c
@@ -22,7 +22,7 @@
 #include <sys_io.h>
 #include <misc/util.h>

-#include <gpio_sch.h>
+#include "gpio_sch.h"

 #ifndef CONFIG_GPIO_DEBUG
 #define DBG(...)


hwmon: (adm1029) fix checkpatch issues

hwmon: (adm1029) fix checkpatch issues

fixed:
ERROR: space prohibited after that open parenthesis '('
+#define DIV_FROM_REG(val)	( 1 << (((val) >> 6) - 1))

WARNING: simple_strtol is obsolete, use kstrtol instead
+	long val = simple_strtol(buf, NULL, 10);

ERROR: do not use assignment in if condition
+	if ((err = sysfs_create_group(&client->dev.kobj, &adm1029_group)))

Signed-off-by: Frans Meulenbroeks <6def945a6cdf470073fde46d27fb7849dda40aca@gmail.com>
Signed-off-by: Guenter Roeck <32ce62c5480002985aec58d7044038218061ef55@ericsson.com>

--- drivers/hwmon/adm1029.c
+++ drivers/hwmon/adm1029.c
@@ -78,7 +78,7 @@

 #define TEMP_FROM_REG(val)	((val) * 1000)

-#define DIV_FROM_REG(val)	( 1 << (((val) >> 6) - 1))
+#define DIV_FROM_REG(val)	(1 << (((val) >> 6) - 1))

 /* Registers to be checked by adm1029_update_device() */
 static const u8 ADM1029_REG_TEMP[] = {
@@ -200,8 +200,11 @@
 	struct i2c_client *client = to_i2c_client(dev);
 	struct adm1029_data *data = i2c_get_clientdata(client);
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
-	long val = simple_strtol(buf, NULL, 10);
 	u8 reg;
+	long val;
+	int ret = kstrtol(buf, 10, &val);
+	if (ret < 0)
+		return ret;

 	mutex_lock(&data->update_lock);

@@ -355,7 +358,8 @@
 	}

 	/* Register sysfs hooks */
-	if ((err = sysfs_create_group(&client->dev.kobj, &adm1029_group)))
+	err = sysfs_create_group(&client->dev.kobj, &adm1029_group);
+	if (err)
 		goto exit_free;

 	data->hwmon_dev = hwmon_device_register(&client->dev);


hwmon: (adm9240) Convert to devm_hwmon_device_register_with_groups

Use ATTRIBUTE_GROUPS macro and devm_hwmon_device_register_with_groups() to
simplify the code a bit.

Signed-off-by: Axel Lin <b6ffd6973e972cb999e8e535ab74da7fee0c035f@ingics.com>
Signed-off-by: Guenter Roeck <ba324ca7b1c77fc20bb970d5aff6eea9377918a5@roeck-us.net>

--- drivers/hwmon/adm9240.c
+++ drivers/hwmon/adm9240.c
@@ -132,7 +132,7 @@

 /* per client data */
 struct adm9240_data {
-	struct device *hwmon_dev;
+	struct i2c_client *client;
 	struct mutex update_lock;
 	char valid;
 	unsigned long last_updated_measure;
@@ -170,8 +170,8 @@

 static struct adm9240_data *adm9240_update_device(struct device *dev)
 {
-	struct i2c_client *client = to_i2c_client(dev);
-	struct adm9240_data *data = i2c_get_clientdata(client);
+	struct adm9240_data *data = dev_get_drvdata(dev);
+	struct i2c_client *client = data->client;
 	int i;

 	mutex_lock(&data->update_lock);
@@ -278,8 +278,8 @@
 		const char *buf, size_t count)
 {
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
-	struct i2c_client *client = to_i2c_client(dev);
-	struct adm9240_data *data = i2c_get_clientdata(client);
+	struct adm9240_data *data = dev_get_drvdata(dev);
+	struct i2c_client *client = data->client;
 	long val;
 	int err;

@@ -334,8 +334,8 @@
 		const char *buf, size_t count)
 {
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
-	struct i2c_client *client = to_i2c_client(dev);
-	struct adm9240_data *data = i2c_get_clientdata(client);
+	struct adm9240_data *data = dev_get_drvdata(dev);
+	struct i2c_client *client = data->client;
 	unsigned long val;
 	int err;

@@ -356,8 +356,8 @@
 		const char *buf, size_t count)
 {
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
-	struct i2c_client *client = to_i2c_client(dev);
-	struct adm9240_data *data = i2c_get_clientdata(client);
+	struct adm9240_data *data = dev_get_drvdata(dev);
+	struct i2c_client *client = data->client;
 	unsigned long val;
 	int err;

@@ -431,8 +431,8 @@
 		const char *buf, size_t count)
 {
 	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
-	struct i2c_client *client = to_i2c_client(dev);
-	struct adm9240_data *data = i2c_get_clientdata(client);
+	struct adm9240_data *data = dev_get_drvdata(dev);
+	struct i2c_client *client = data->client;
 	int nr = attr->index;
 	u8 new_div;
 	unsigned long val;
@@ -544,8 +544,8 @@
 		struct device_attribute *attr,
 		const char *buf, size_t count)
 {
-	struct i2c_client *client = to_i2c_client(dev);
-	struct adm9240_data *data = i2c_get_clientdata(client);
+	struct adm9240_data *data = dev_get_drvdata(dev);
+	struct i2c_client *client = data->client;
 	long val;
 	int err;

@@ -565,8 +565,8 @@
 		struct device_attribute *attr,
 		const char *buf, size_t count)
 {
-	struct i2c_client *client = to_i2c_client(dev);
-	struct adm9240_data *data = i2c_get_clientdata(client);
+	struct adm9240_data *data = dev_get_drvdata(dev);
+	struct i2c_client *client = data->client;
 	unsigned long val;

 	if (kstrtoul(buf, 10, &val) || val != 0)
@@ -583,7 +583,7 @@
 static SENSOR_DEVICE_ATTR(intrusion0_alarm, S_IRUGO | S_IWUSR, show_alarm,
 		chassis_clear, 12);

-static struct attribute *adm9240_attributes[] = {
+static struct attribute *adm9240_attrs[] = {
 	&sensor_dev_attr_in0_input.dev_attr.attr,
 	&sensor_dev_attr_in0_min.dev_attr.attr,
 	&sensor_dev_attr_in0_max.dev_attr.attr,
@@ -627,9 +627,7 @@
 	NULL
 };

-static const struct attribute_group adm9240_group = {
-	.attrs = adm9240_attributes,
-};
+ATTRIBUTE_GROUPS(adm9240);

 /*** sensor chip detect and driver install ***/
@@ -724,44 +722,25 @@
 static int adm9240_probe(struct i2c_client *new_client,
 			 const struct i2c_device_id *id)
 {
+	struct device *dev = &new_client->dev;
+	struct device *hwmon_dev;
 	struct adm9240_data *data;
-	int err;
-
-	data = devm_kzalloc(&new_client->dev, sizeof(*data), GFP_KERNEL);
+
+	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;

 	i2c_set_clientdata(new_client, data);
+	data->client = new_client;
 	mutex_init(&data->update_lock);

 	adm9240_init_client(new_client);

-	/* populate sysfs filesystem */
-	err = sysfs_create_group(&new_client->dev.kobj, &adm9240_group);
-	if (err)
-		return err;
-
-	data->hwmon_dev = hwmon_device_register(&new_client->dev);
-	if (IS_ERR(data->hwmon_dev)) {
-		err = PTR_ERR(data->hwmon_dev);
-		goto exit_remove;
-	}
-
-	return 0;
-
-exit_remove:
-	sysfs_remove_group(&new_client->dev.kobj, &adm9240_group);
-	return err;
-}
-
-static int adm9240_remove(struct i2c_client *client)
-{
-	struct adm9240_data *data = i2c_get_clientdata(client);
-
-	hwmon_device_unregister(data->hwmon_dev);
-	sysfs_remove_group(&client->dev.kobj, &adm9240_group);
-
-	return 0;
+	hwmon_dev = devm_hwmon_device_register_with_groups(dev,
+							   new_client->name,
+							   data,
+							   adm9240_groups);
+	return PTR_ERR_OR_ZERO(hwmon_dev);
 }

 static const struct i2c_device_id adm9240_id[] = {
@@ -778,7 +757,6 @@
 		.name	= "adm9240",
 	},
 	.probe		= adm9240_probe,
-	.remove		= adm9240_remove,
 	.id_table	= adm9240_id,
 	.detect		= adm9240_detect,
 	.address_list	= normal_i2c,


hwmon: (emc1403) Add support for alarm and diode fault status on EMC14x2

Alarm and fault status register on EMC1402, EMC1412, and EMC1422 is reported
in a different register than with other chips. Add support for it.

Signed-off-by: Guenter Roeck <ba324ca7b1c77fc20bb970d5aff6eea9377918a5@roeck-us.net>

--- drivers/hwmon/emc1403.c
+++ drivers/hwmon/emc1403.c
@@ -299,6 +299,39 @@
 	.attrs = emc1404_attrs,
 };

+/*
+ * EMC14x2 uses a different register and different bits to report alarm and
+ * fault status. For simplicity, provide a separate attribute group for this
+ * chip series.
+ * Since we can not re-use the same attribute names, create a separate attribute
+ * array.
+ */
+static struct sensor_device_attribute_2 emc1402_alarms[] = {
+	SENSOR_ATTR_2(temp1_min_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x20),
+	SENSOR_ATTR_2(temp1_max_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x40),
+	SENSOR_ATTR_2(temp1_crit_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x01),
+
+	SENSOR_ATTR_2(temp2_fault, S_IRUGO, show_bit, NULL, 0x02, 0x04),
+	SENSOR_ATTR_2(temp2_min_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x08),
+	SENSOR_ATTR_2(temp2_max_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x10),
+	SENSOR_ATTR_2(temp2_crit_alarm, S_IRUGO, show_bit, NULL, 0x02, 0x02),
+};
+
+static struct attribute *emc1402_alarm_attrs[] = {
+	&emc1402_alarms[0].dev_attr.attr,
+	&emc1402_alarms[1].dev_attr.attr,
+	&emc1402_alarms[2].dev_attr.attr,
+	&emc1402_alarms[3].dev_attr.attr,
+	&emc1402_alarms[4].dev_attr.attr,
+	&emc1402_alarms[5].dev_attr.attr,
+	&emc1402_alarms[6].dev_attr.attr,
+	NULL,
+};
+
+static const struct attribute_group emc1402_alarm_group = {
+	.attrs = emc1402_alarm_attrs,
+};
+
 static int emc1403_detect(struct i2c_client *client,
 			struct i2c_board_info *info)
 {
@@ -395,6 +428,9 @@
 		data->groups[0] = &emc1402_group;
 	}

+	if (id->driver_data == emc1402)
+		data->groups[1] = &emc1402_alarm_group;
+
 	hwmon_dev = devm_hwmon_device_register_with_groups(&client->dev,
 							   client->name, data,
 							   data->groups);


Fix non-TSC guest clocksource lockup

Fix non-TSC guest clocksource lockup

lguest uses a host-supplied wallclock-based clocksource when the TSC
is not reliable.  As this is already in nanoseconds, I naively used a
multiplier of 1 and a shift of 0.

But update_wall_time() in its infinite wisdom decides to adjust the
clock a little (where does it think it's getting a more accurate time
from?)

It will happily tweak the multiplier... to 0, then -1.

So the "fix" is to use a shift of 22 like everyone else, and a
multiplier of 1 << 22.

Signed-off-by: Rusty Russell <df9728c9e5104131c08c7adb03af425394842596@rustcorp.com.au>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- drivers/lguest/lguest.c
+++ drivers/lguest/lguest.c
@@ -687,7 +687,8 @@
 	.rating		= 400,
 	.read		= lguest_clock_read,
 	.mask		= CLOCKSOURCE_MASK(64),
-	.mult		= 1,
+	.mult		= 1 << 22,
+	.shift		= 22,
 };

 /* The "scheduler clock" is just our real clock, adjusted to start at zero */
@@ -770,7 +771,6 @@
 	 * way, the "rating" is initialized so high that it's always chosen
 	 * over any other clocksource. */
 	if (lguest_data.tsc_khz) {
-		lguest_clock.shift = 22;
 		lguest_clock.mult = clocksource_khz2mult(lguest_data.tsc_khz,
 							 lguest_clock.shift);
 		lguest_clock.flags = CLOCK_SOURCE_IS_CONTINUOUS;


mmal/codec: Flush the decoder when running out of buffers

Normally the decoder should not run out of input buffers as it is fed with
packetized data and for each input block a picture shall be generated. In rare
situations the decoder seems to fail internally and does stop generating
pictures. In this case the input buffers are not released either. If this
happens the whole pipeline stalls and vlc buffers input data until system runs
out of memory. To avoid this error case force the decoder to flush its port
if it runs out of input buffers. This causes a short image distortion but the
decoder won't block anymore.

Signed-off-by: Julian Scheel <354106e416911844661e1603d99ecf7d1c318dda@jusst.de>
Signed-off-by: Rémi Denis-Courmont <f0699137713be92736351a0674e79536595e4a60@remlab.net>

--- modules/hw/mmal/codec.c
+++ modules/hw/mmal/codec.c
@@ -481,6 +481,39 @@
             break;
 }

+static int flush_decoder(decoder_t *dec)
+{
+    decoder_sys_t *sys = dec->p_sys;
+    MMAL_STATUS_T status;
+    int ret = 0;
+
+    msg_Dbg(dec, "Flushing decoder ports...");
+    mmal_port_disable(sys->output);
+    mmal_port_disable(sys->input);
+    mmal_port_flush(sys->output);
+    mmal_port_flush(sys->input);
+    msg_Dbg(dec, "Ports flushed, returning to normal operation");
+    status = mmal_port_enable(sys->input, input_port_cb);
+    if (status != MMAL_SUCCESS) {
+        msg_Err(dec, "Failed to enable input port %s (status=%"PRIx32" %s)",
+                sys->input->name, status, mmal_status_to_string(status));
+        ret = VLC_EGENERIC;
+        goto out;
+    }
+    msg_Dbg(dec, "Input enabled");
+    status = mmal_port_enable(sys->output, output_port_cb);
+    if (status != MMAL_SUCCESS) {
+        msg_Err(dec, "Failed to enable output port %s (status=%"PRIx32" %s)",
+                sys->output->name, status, mmal_status_to_string(status));
+        ret = VLC_EGENERIC;
+        goto out;
+    }
+    msg_Dbg(dec, "Output enabled");
+
+out:
+    return ret;
+}
+
 static picture_t *decode(decoder_t *dec, block_t **pblock)
 {
     decoder_sys_t *sys = dec->p_sys;
@@ -546,6 +579,14 @@
         buffer = mmal_queue_timedwait(sys->input_pool->queue, 2);
         if (!buffer) {
             msg_Err(dec, "Failed to retrieve buffer header for input data");
+
+            /* Flush the decoder output port to make sure we don't get stuck
+             * forever. This shall normally not happen but may happen if the
+             * decoder goes mad. */
+            if (flush_decoder(dec)) {
+                msg_Err(dec, "Failed to flush decoder, something seems really broken...");
+                dec->b_error = true;
+            }
             break;
         }
         mmal_buffer_header_reset(buffer);


V4L/DVB: media/IR/imon: potential double unlock on error

If there is an error here we should unlock in the caller (which is
imon_init_intf1()).  We can remove this stray unlock.

Signed-off-by: Dan Carpenter <72501f147b2753e6660fdce744d9ac3084854f5e@gmail.com>
Acked-by: Jarod Wilson <14059c7158912dcae849c377925c87d46da48cdf@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>

--- drivers/media/IR/imon.c
+++ drivers/media/IR/imon.c
@@ -1776,7 +1776,6 @@

 touch_register_failed:
 	input_free_device(ictx->touch);
-	mutex_unlock(&ictx->lock);

 touch_alloc_failed:
 	return NULL;


ARM: 5697/1: MMCI Break out clock divider setup

This breaks out the clock divider set-up code from the
mmci_set_ios() code and surrounds the two register
writes with a host lock so we don't get collisions if
(in future code) two code paths want to change the
clock divider at the same time as can be the case if
we get something like pre/post- clock frequency change
notifications soonish.

Signed-off-by: Linus Walleij <9cd9d802d23c0ed5e224beabf4ae4a5c478746ef@stericsson.com>
Signed-off-by: Russell King <f6aa0246ff943bfa8602cdf60d40c481b38ed232@arm.linux.org.uk>

--- drivers/mmc/host/mmci.c
+++ drivers/mmc/host/mmci.c
@@ -38,6 +38,33 @@

 static unsigned int fmax = 515633;

+/*
+ * This must be called with host->lock held
+ */
+static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired)
+{
+	u32 clk = 0;
+
+	if (desired) {
+		if (desired >= host->mclk) {
+			clk = MCI_CLK_BYPASS;
+			host->cclk = host->mclk;
+		} else {
+			clk = host->mclk / (2 * desired) - 1;
+			if (clk >= 256)
+				clk = 255;
+			host->cclk = host->mclk / (2 * (clk + 1));
+		}
+		if (host->hw_designer == 0x80)
+			clk |= MCI_FCEN; /* Bug fix in ST IP block */
+		clk |= MCI_CLK_ENABLE;
+		/* This hasn't proven to be worthwhile */
+		/* clk |= MCI_CLK_PWRSAVE; */
+	}
+
+	writel(clk, host->base + MMCICLOCK);
+}
+
 static void
 mmci_request_end(struct mmci_host *host, struct mmc_request *mrq)
 {
@@ -419,22 +446,8 @@
 static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 {
 	struct mmci_host *host = mmc_priv(mmc);
-	u32 clk = 0, pwr = 0;
-
-	if (ios->clock) {
-		if (ios->clock >= host->mclk) {
-			clk = MCI_CLK_BYPASS;
-			host->cclk = host->mclk;
-		} else {
-			clk = host->mclk / (2 * ios->clock) - 1;
-			if (clk >= 256)
-				clk = 255;
-			host->cclk = host->mclk / (2 * (clk + 1));
-		}
-		if (host->hw_designer == AMBA_VENDOR_ST)
-			clk |= MCI_FCEN; /* Bug fix in ST IP block */
-		clk |= MCI_CLK_ENABLE;
-	}
+	u32 pwr = 0;
+	unsigned long flags;

 	if (host->plat->translate_vdd)
 		pwr |= host->plat->translate_vdd(mmc_dev(mmc), ios->vdd);
@@ -465,12 +478,16 @@
 		}
 	}

-	writel(clk, host->base + MMCICLOCK);
+	spin_lock_irqsave(&host->lock, flags);
+
+	mmci_set_clkreg(host, ios->clock);

 	if (host->pwr != pwr) {
 		host->pwr = pwr;
 		writel(pwr, host->base + MMCIPOWER);
 	}
+
+	spin_unlock_irqrestore(&host->lock, flags);
 }

 static int mmci_get_ro(struct mmc_host *mmc)


MMC: OMAP: Using setup_timer instead of init_timer

Using setup_timer() instead of init_timer() on omap.c file.

Signed-off-by: Carlos Eduardo Aguiar <2790fb4f610d9f7a6f36128e95aa4e8da56e9cf0@indt.org.br>
Signed-off-by: Tony Lindgren <1001e8702733cced254345e193c88aaa47a4f5de@atomide.com>
Signed-off-by: Pierre Ossman <8b64f2aeec7ea42cd6838e5b2901f7aa61dfa5d4@drzeus.cx>

--- drivers/mmc/host/omap.c
+++ drivers/mmc/host/omap.c
@@ -1235,9 +1235,8 @@
 			goto err_remove_slot_name;

 		INIT_WORK(&slot->switch_work, mmc_omap_cover_handler);
-		init_timer(&slot->switch_timer);
-		slot->switch_timer.function = mmc_omap_switch_timer;
-		slot->switch_timer.data = (unsigned long) slot;
+		setup_timer(&slot->switch_timer, mmc_omap_switch_timer,
+			    (unsigned long) slot);
 		schedule_work(&slot->switch_work);
 	}

@@ -1302,17 +1301,12 @@
 	}

 	INIT_WORK(&host->cmd_abort, mmc_omap_abort_command);
-	init_timer(&host->cmd_timer);
-	host->cmd_timer.function = mmc_omap_cmd_timer;
-	host->cmd_timer.data = (unsigned long) host;
+	setup_timer(&host->cmd_timer, mmc_omap_cmd_timer, (unsigned long) host);

 	spin_lock_init(&host->dma_lock);
-	init_timer(&host->dma_timer);
+	setup_timer(&host->dma_timer, mmc_omap_dma_timer, (unsigned long) host);
 	spin_lock_init(&host->slot_lock);
 	init_waitqueue_head(&host->slot_wq);
-
-	host->dma_timer.function = mmc_omap_dma_timer;
-	host->dma_timer.data = (unsigned long) host;

 	host->pdata = pdata;
 	host->dev = &pdev->dev;


[MTD] Fix do_div() type warning in mtdconcat

It expects a uint64_t; give it one.

Signed-off-by: David Woodhouse <97b3379caa91f4ee97e44013ae4dc6350540fa9d@infradead.org>

--- drivers/mtd/mtdconcat.c
+++ drivers/mtd/mtdconcat.c
@@ -178,7 +178,7 @@

 	/* Check alignment */
 	if (mtd->writesize > 1) {
-		loff_t __to = to;
+		uint64_t __to = to;
 		if (do_div(__to, mtd->writesize) || (total_len % mtd->writesize))
 			return -EINVAL;
 	}


[MTD] NAND: Add register debugging spew option to CAFÉ driver

Signed-off-by: David Woodhouse <97b3379caa91f4ee97e44013ae4dc6350540fa9d@infradead.org>

--- drivers/mtd/nand/cafe.c
+++ drivers/mtd/nand/cafe.c
@@ -72,6 +72,9 @@
 static int debug = 0;
 module_param(debug, int, 0644);

+static int regdebug = 0;
+module_param(regdebug, int, 0644);
+
 static int checkecc = 1;
 module_param(checkecc, int, 0644);

@@ -228,12 +231,6 @@
 		cafe_writel(cafe, cafe->ctl2 | 0x100 | NAND_CMD_READSTART, NAND_CTRL2);

  do_command:
-#if 0
-	/* http://dev.laptop.org/ticket/200
-	   ECC on read only works if we read precisely 0x80e bytes */
-	if (cafe->datalen == 2112)
-		cafe->datalen = 2062;
-#endif
 	cafe_dev_dbg(&cafe->pdev->dev, "dlen %x, ctl1 %x, ctl2 %x\n",
 		cafe->datalen, ctl1, cafe_readl(cafe, NAND_CTRL2));

@@ -254,13 +251,13 @@
 	}
 	cafe->datalen = 0;

-#if 0
-	{ int i;
-	printk("About to write command %08x\n", ctl1);
-	for (i=0; i< 0x5c; i+=4)
-		printk("Register %x: %08x\n", i, readl(cafe->mmio + i));
-	}
-#endif
+	if (unlikely(regdebug)) {
+		int i;
+		printk("About to write command %08x to register 0\n", ctl1);
+		for (i=4; i< 0x5c; i+=4)
+			printk("Register %x: %08x\n", i, readl(cafe->mmio + i));
+	}
+
 	cafe_writel(cafe, ctl1, NAND_CTRL1);
 	/* Apply this short delay always to ensure that we do wait tWB in
 	 * any case on any machine. */
@@ -388,7 +385,10 @@
 		}

 		if ((i = cafe_correct_ecc(buf, syn)) < 0) {
-			dev_dbg(&cafe->pdev->dev, "Failed to correct ECC\n");
+			dev_dbg(&cafe->pdev->dev, "Failed to correct ECC at %08x\n",
+				cafe_readl(cafe, NAND_ADDR2) * 2048);
+			for (i=0; i< 0x5c; i+=4)
+				printk("Register %x: %08x\n", i, readl(cafe->mmio + i));
 			mtd->ecc_stats.failed++;
 		} else {
 			dev_dbg(&cafe->pdev->dev, "Corrected %d symbol errors\n", i);


UBI: print PID in debug messages

UBI: print PID in debug messages

Signed-off-by: Artem Bityutskiy <2f96f8cd3e2780a209d0ab27d1b44624d0019d3f@linux.intel.com>

--- drivers/mtd/ubi/debug.h
+++ drivers/mtd/ubi/debug.h
@@ -39,7 +39,8 @@
 		print_hex_dump(l, ps, pt, r, g, b, len, a)

 #define ubi_dbg_msg(type, fmt, ...) \
-	pr_debug("UBI DBG " type ": " fmt "\n", ##__VA_ARGS__)
+	pr_debug("UBI DBG " type " (pid %d): " fmt "\n", current->pid,       \
+		 ##__VA_ARGS__)

 /* Just a debugging messages not related to any specific UBI subsystem */
 #define dbg_msg(fmt, ...)                                    \


[NET] myri_sbus: Convert to new SBUS device layer.

Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/myri_sbus.c
+++ drivers/net/myri_sbus.c
@@ -1,10 +1,10 @@
-/* myri_sbus.h: MyriCOM MyriNET SBUS card driver.
+/* myri_sbus.c: MyriCOM MyriNET SBUS card driver.
  *
- * Copyright (C) 1996, 1999 David S. Miller (davem@redhat.com)
+ * Copyright (C) 1996, 1999, 2006 David S. Miller (davem@davemloft.net)
  */

 static char version[] =
-        "myri_sbus.c:v1.9 12/Sep/99 David S. Miller (davem@redhat.com)\n";
+        "myri_sbus.c:v2.0 June 23, 2006 David S. Miller (davem@davemloft.net)\n";

 #include <linux/module.h>
 #include <linux/config.h>
@@ -79,10 +79,6 @@
 #define DHDR(x) printk x
 #else
 #define DHDR(x)
-#endif
-
-#ifdef MODULE
-static struct myri_eth *root_myri_dev;
 #endif

 static void myri_reset_off(void __iomem *lp, void __iomem *cregs)
@@ -896,8 +892,9 @@
 }
 #endif

-static int __init myri_ether_init(struct sbus_dev *sdev, int num)
-{
+static int __init myri_ether_init(struct sbus_dev *sdev)
+{
+	static int num;
 	static unsigned version_printed;
 	struct net_device *dev;
 	struct myri_eth *mp;
@@ -912,6 +909,9 @@

 	if (version_printed++ == 0)
 		printk(version);
+
+	SET_MODULE_OWNER(dev);
+	SET_NETDEV_DEV(dev, &sdev->ofdev.dev);

 	mp = (struct myri_eth *) dev->priv;
 	spin_lock_init(&mp->irq_lock);
@@ -1092,10 +1092,9 @@
 		goto err_free_irq;
 	}

-#ifdef MODULE
-	mp->next_module = root_myri_dev;
-	root_myri_dev = mp;
-#endif
+	dev_set_drvdata(&sdev->ofdev.dev, mp);
+
+	num++;

 	printk("%s: MyriCOM MyriNET Ethernet ", dev->name);

@@ -1114,61 +1113,68 @@
 	return -ENODEV;
 }

-static int __init myri_sbus_match(struct sbus_dev *sdev)
-{
-	char *name = sdev->prom_name;
-
-	if (!strcmp(name, "MYRICOM,mlanai") ||
-	    !strcmp(name, "myri"))
-		return 1;
+
+static int __devinit myri_sbus_probe(struct of_device *dev, const struct of_device_id *match)
+{
+	struct sbus_dev *sdev = to_sbus_device(&dev->dev);
+
+	return myri_ether_init(sdev);
+}
+
+static int __devexit myri_sbus_remove(struct of_device *dev)
+{
+	struct myri_eth *mp = dev_get_drvdata(&dev->dev);
+	struct net_device *net_dev = mp->dev;
+
+	unregister_netdevice(net_dev);
+
+	free_irq(net_dev->irq, net_dev);
+
+	if (mp->eeprom.cpuvers < CPUVERS_4_0) {
+		sbus_iounmap(mp->regs, mp->reg_size);
+	} else {
+		sbus_iounmap(mp->cregs, PAGE_SIZE);
+		sbus_iounmap(mp->lregs, (256 * 1024));
+		sbus_iounmap(mp->lanai, (512 * 1024));
+	}
+
+	free_netdev(net_dev);
+
+	dev_set_drvdata(&dev->dev, NULL);

 	return 0;
 }

-static int __init myri_sbus_probe(void)
-{
-	struct sbus_bus *bus;
-	struct sbus_dev *sdev = NULL;
-	static int called;
-	int cards = 0, v;
-
-#ifdef MODULE
-	root_myri_dev = NULL;
-#endif
-
-	if (called)
-		return -ENODEV;
-	called++;
-
-	for_each_sbus(bus) {
-		for_each_sbusdev(sdev, bus) {
-			if (myri_sbus_match(sdev)) {
-				cards++;
-				DET(("Found myricom myrinet as %s\n", sdev->prom_name));
-				if ((v = myri_ether_init(sdev, (cards - 1))))
-					return v;
-			}
-		}
-	}
-	if (!cards)
-		return -ENODEV;
-	return 0;
-}
-
-static void __exit myri_sbus_cleanup(void)
-{
-#ifdef MODULE
-	while (root_myri_dev) {
-		struct myri_eth *next = root_myri_dev->next_module;
-
-		unregister_netdev(root_myri_dev->dev);
-		/* this will also free the co-allocated 'root_myri_dev' */
-		free_netdev(root_myri_dev->dev);
-		root_myri_dev = next;
-	}
-#endif /* MODULE */
-}
-
-module_init(myri_sbus_probe);
-module_exit(myri_sbus_cleanup);
+static struct of_device_id myri_sbus_match[] = {
+	{
+		.name = "MYRICOM,mlanai",
+	},
+	{
+		.name = "myri",
+	},
+	{},
+};
+
+MODULE_DEVICE_TABLE(of, myri_sbus_match);
+
+static struct of_platform_driver myri_sbus_driver = {
+	.name		= "myri",
+	.match_table	= myri_sbus_match,
+	.probe		= myri_sbus_probe,
+	.remove		= __devexit_p(myri_sbus_remove),
+};
+
+static int __init myri_sbus_init(void)
+{
+	return of_register_driver(&myri_sbus_driver, &sbus_bus_type);
+}
+
+static void __exit myri_sbus_exit(void)
+{
+	of_unregister_driver(&myri_sbus_driver);
+}
+
+module_init(myri_sbus_init);
+module_exit(myri_sbus_exit);
+
 MODULE_LICENSE("GPL");


phy/fixed: use an unique MDIO bus name.

phy/fixed: use an unique MDIO bus name.

Signed-off-by: Florian Fainelli <73262ad0334ab37227b2f7a0205f51db1e606681@openwrt.org>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/phy/fixed.c
+++ drivers/net/phy/fixed.c
@@ -220,7 +220,7 @@
 		goto err_mdiobus_reg;
 	}

-	snprintf(fmb->mii_bus->id, MII_BUS_ID_SIZE, "0");
+	snprintf(fmb->mii_bus->id, MII_BUS_ID_SIZE, "fixed-0");
 	fmb->mii_bus->name = "Fixed MDIO Bus";
 	fmb->mii_bus->priv = fmb;
 	fmb->mii_bus->parent = &pdev->dev;


r8152: nway reset after setting eee

r8152: nway reset after setting eee

Restart autonegotiation is necessary after setting EEE.

Signed-off-by: Hayes Wang <2e4abddca5cd1005ec71becebc17a5257b0bced7@realtek.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/usb/r8152.c
+++ drivers/net/usb/r8152.c
@@ -3471,6 +3471,8 @@
 		goto out;

 	ret = tp->rtl_ops.eee_set(tp, edata);
+	if (!ret)
+		ret = mii_nway_restart(&tp->mii);

 	usb_autopm_put_interface(tp->intf);


Use a better check for overflow from a<<b.

--- Objects/intobject.c
+++ Objects/intobject.c
@@ -675,13 +675,15 @@
 			return NULL;
 		return PyInt_FromLong(0L);
 	}
-	c = (long)((unsigned long)a << b);
-	if ((c >> b) != a || (c < 0 && a > 0)) {
+	c = a < 0 ? ~a : a;
+	c >>= LONG_BIT - 1 - b;
+	if (c) {
 		if (PyErr_Warn(PyExc_DeprecationWarning,
 			       "x<<y losing bits or changing sign "
 			       "will return a long in Python 2.4 and up") < 0)
 			return NULL;
 	}
+	c = (long)((unsigned long)a << b);
 	return PyInt_FromLong(c);
 }


PCI ASPM: remove has_switch field

PCI ASPM: remove has_switch field

We don't need the 'has_switch' field in the struct pcie_link_state.

Acked-by: Shaohua Li <cb3904095a5bc20edc93ba3dfa3e7d27d981b654@intel.com>
Signed-off-by: Kenji Kaneshige <06fb390d28d4d3a1c65b19c7f623121e2bb09dfc@jp.fujitsu.com>
Signed-off-by: Jesse Barnes <bc7add126c2dbb8382bf1c28ac262b9363a32706@virtuousgeek.org>

--- drivers/pci/pcie/aspm.c
+++ drivers/pci/pcie/aspm.c
@@ -47,8 +47,6 @@
 	u32 clkpm_capable:1;		/* Clock PM capable? */
 	u32 clkpm_enabled:1;		/* Current Clock PM state */
 	u32 clkpm_default:1;		/* Default Clock PM state by BIOS */
-
-	u32 has_switch:1;		/* Downstream has switches? */

 	/* Latencies */
 	struct aspm_latency latency;	/* Exit latency */
@@ -595,7 +593,6 @@
 	INIT_LIST_HEAD(&link->children);
 	INIT_LIST_HEAD(&link->link);
 	link->pdev = pdev;
-	link->has_switch = pcie_aspm_downstream_has_switch(link);
 	if (pdev->pcie_type == PCI_EXP_TYPE_DOWNSTREAM) {
 		struct pcie_link_state *parent;
 		parent = pdev->bus->parent->self->link_state;
@@ -655,7 +652,7 @@
 	 * initialization will config the whole hierarchy. But we must
 	 * make sure BIOS doesn't set unsupported link state.
 	 */
-	if (link->has_switch) {
+	if (pcie_aspm_downstream_has_switch(link)) {
 		state = pcie_aspm_check_state(link, link->aspm_default);
 		__pcie_aspm_config_link(link, state);
 	} else {


fixed memory issues in pvsbuffer that suddenly appeared post-5.12

--- Opcodes/pvsbuffer.c
+++ Opcodes/pvsbuffer.c
@@ -58,7 +58,6 @@
     p->handle->header.wintype = p->fin->wintype;
     p->handle->header.format  = p->fin->format;
     p->handle->header.framecount = p->fin->framecount;
-    csound->Message(csound,"N: %d\n", p->handle->header.N);
     p->nframes = p->handle->frames = (*p->len) * csound->esr/hop;
     if (p->buffer.auxp == NULL ||
         p->buffer.size < sizeof(float) * (N + 2) * p->nframes)
@@ -131,7 +130,7 @@
       p->fout->format  = PVS_AMP_FREQ;
       p->fout->framecount = 1;
     }
-    csound->Message(csound,"handle-read: %d\n", handle->header.N);
+

     if (p->fout->frame.auxp == NULL ||
          p->fout->frame.size < sizeof(float) * (N + 2))


PCI: Change pbus_size_mem() return values to be more conventional

pbus_size_mem() previously returned 0 for failure and 1 for success.
Change it to return -ENOSPC for failure and 0 for success.

No functional change.

Signed-off-by: Bjorn Helgaas <f10ec01be0c6b54271af5c550cd257810bdf3268@google.com>

--- drivers/pci/setup-bus.c
+++ drivers/pci/setup-bus.c
@@ -915,6 +915,10 @@
  *
  * Calculate the size of the bus and minimal alignment which
  * guarantees that all child resources fit in this size.
+ *
+ * Returns -ENOSPC if there's no available bus resource of the desired type.
+ * Otherwise, sets the bus resource start/end to indicate the required
+ * size, adds things to realloc_head (if supplied), and returns 0.
  */
 static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
 			 unsigned long type, unsigned long type2,
@@ -931,7 +935,7 @@
 	resource_size_t children_add_size = 0;

 	if (!b_res)
-		return 0;
+		return -ENOSPC;

 	memset(aligns, 0, sizeof(aligns));
 	max_order = 0;
@@ -1003,7 +1007,7 @@
 				 "%pR to %pR (unused)\n", b_res,
 				 &bus->busn_res);
 		b_res->flags = 0;
-		return 1;
+		return 0;
 	}
 	b_res->start = min_align;
 	b_res->end = size0 + min_align - 1;
@@ -1014,7 +1018,7 @@
 				 "%pR to %pR add_size %llx\n", b_res,
 				 &bus->busn_res, (unsigned long long)size1-size0);
 	}
-	return 1;
+	return 0;
 }

 unsigned long pci_cardbus_resource_alignment(struct resource *res)
@@ -1126,6 +1130,7 @@
 	unsigned long mask, prefmask, type2 = 0, type3 = 0;
 	resource_size_t additional_mem_size = 0, additional_io_size = 0;
 	struct resource *b_res;
+	int ret;

 	list_for_each_entry(dev, &bus->devices, bus_list) {
 		struct pci_bus *b = dev->subordinate;
@@ -1175,25 +1180,27 @@
 		prefmask = IORESOURCE_MEM | IORESOURCE_PREFETCH;
 		if (b_res[2].flags & IORESOURCE_MEM_64) {
 			prefmask |= IORESOURCE_MEM_64;
-			if (pbus_size_mem(bus, prefmask, prefmask,
+			ret = pbus_size_mem(bus, prefmask, prefmask,
 				  prefmask, prefmask,
 				  realloc_head ? 0 : additional_mem_size,
-				  additional_mem_size, realloc_head)) {
-					/*
-					 * Success, with pref mmio64,
-					 * next will size non-pref or
-					 * non-mmio64 */
-					mask = prefmask;
-					type2 = prefmask & ~IORESOURCE_MEM_64;
-					type3 = prefmask & ~IORESOURCE_PREFETCH;
+				  additional_mem_size, realloc_head);
+			if (ret == 0) {
+				/*
+				 * Success, with pref mmio64,
+				 * next will size non-pref or
+				 * non-mmio64 */
+				mask = prefmask;
+				type2 = prefmask & ~IORESOURCE_MEM_64;
+				type3 = prefmask & ~IORESOURCE_PREFETCH;
 			}
 		}
 		if (!type2) {
 			prefmask &= ~IORESOURCE_MEM_64;
-			if (pbus_size_mem(bus, prefmask, prefmask,
+			ret = pbus_size_mem(bus, prefmask, prefmask,
 					 prefmask, prefmask,
 					 realloc_head ? 0 : additional_mem_size,
-					 additional_mem_size, realloc_head)) {
+					 additional_mem_size, realloc_head);
+			if (ret == 0) {
 				/* Success, next will size non-prefetch. */
 				mask = prefmask;
 			} else


Don't allow setting an invalid auxiliary send

--- OpenAL32/alSource.c
+++ OpenAL32/alSource.c
@@ -671,6 +671,7 @@
     if(alIsSource(source))
     {
         ALsource *pSource = (ALsource*)ALTHUNK_LOOKUPENTRY(source);
+        ALCdevice *Device = pContext->Device;

         switch (eParam)
         {
@@ -681,8 +682,8 @@
                 break;

             case AL_AUXILIARY_SEND_FILTER:
-                if(lValue2 >= 0 && lValue2 < MAX_SENDS &&
-                   (alIsAuxiliaryEffectSlot(lValue1) || lValue1 == 0) &&
+                if((ALuint)lValue2 < Device->NumAuxSends &&
+                   (lValue1 == 0 || alIsAuxiliaryEffectSlot(lValue1)) &&
                    alIsFilter(lValue3))
                 {
                     ALeffectslot *ALEffectSlot = (ALeffectslot*)ALTHUNK_LOOKUPENTRY(lValue1);


lib: Add L2CAP Create/Move Channel definitions

--- lib/l2cap.h
+++ lib/l2cap.h
@@ -5,6 +5,7 @@
  *  Copyright (C) 2000-2001  Qualcomm Incorporated
  *  Copyright (C) 2002-2003  Maxim Krasnyansky <maxk@qualcomm.com>
  *  Copyright (C) 2002-2010  Marcel Holtmann <marcel@holtmann.org>
+ *  Copyright (c) 2012       Code Aurora Forum. All rights reserved.
  *
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -82,6 +83,12 @@
 #define L2CAP_ECHO_RSP		0x09
 #define L2CAP_INFO_REQ		0x0a
 #define L2CAP_INFO_RSP		0x0b
+#define L2CAP_CREATE_REQ	0x0c
+#define L2CAP_CREATE_RSP	0x0d
+#define L2CAP_MOVE_REQ		0x0e
+#define L2CAP_MOVE_RSP		0x0f
+#define L2CAP_MOVE_CFM		0x10
+#define L2CAP_MOVE_CFM_RSP	0x11

 /* L2CAP extended feature mask */
 #define L2CAP_FEAT_FLOWCTL	0x00000001
@@ -226,6 +233,44 @@
 #define L2CAP_IR_SUCCESS	0x0000
 #define L2CAP_IR_NOTSUPP	0x0001

+typedef struct {
+	uint16_t	psm;
+	uint16_t	scid;
+	uint8_t		id;
+} __attribute__ ((packed)) l2cap_create_req;
+#define L2CAP_CREATE_REQ_SIZE 5
+
+typedef struct {
+	uint16_t	dcid;
+	uint16_t	scid;
+	uint16_t	result;
+	uint16_t	status;
+} __attribute__ ((packed)) l2cap_create_rsp;
+#define L2CAP_CREATE_RSP_SIZE 8
+
+typedef struct {
+	uint16_t	icid;
+	uint8_t		id;
+} __attribute__ ((packed)) l2cap_move_req;
+#define L2CAP_MOVE_REQ_SIZE 3
+
+typedef struct {
+	uint16_t	icid;
+	uint16_t	result;
+} __attribute__ ((packed)) l2cap_move_rsp;
+#define L2CAP_MOVE_RSP_SIZE 4
+
+typedef struct {
+	uint16_t	icid;
+	uint16_t	result;
+} __attribute__ ((packed)) l2cap_move_cfm;
+#define L2CAP_MOVE_CFM_SIZE 4
+
+typedef struct {
+	uint16_t	icid;
+} __attribute__ ((packed)) l2cap_move_cfm_rsp;
+#define L2CAP_MOVE_CFM_RSP_SIZE 2
+
 #ifdef __cplusplus
 }
 #endif


drivers: pwm: pwm_stm32.c: enable ARR preload

Enable ARR preload so that period or pulse updates are taken
into account synchronously with update event
(at the end of a ongoing period)
And thus avoid undetermined intermediate pulse.

Signed-off-by: Alexandre Bourdiol <c23cc711c078d3e6bb50b3dc45a1b8842691e59a@st.com>

--- drivers/pwm/pwm_stm32.c
+++ drivers/pwm/pwm_stm32.c
@@ -228,13 +228,17 @@
 			return -EIO;
 		}

+		LL_TIM_EnableARRPreload(cfg->timer);
 		LL_TIM_OC_EnablePreload(cfg->timer, channel);
+		LL_TIM_SetAutoReload(cfg->timer, period_cycles - 1u);
+		LL_TIM_GenerateEvent_UPDATE(cfg->timer);
 	} else {
 		LL_TIM_OC_SetPolarity(cfg->timer, channel, get_polarity(flags));
 		set_timer_compare[pwm - 1u](cfg->timer, pulse_cycles);
-	}
-
-	LL_TIM_SetAutoReload(cfg->timer, period_cycles - 1u);
+		LL_TIM_SetAutoReload(cfg->timer, period_cycles - 1u);
+	}
+
+

 	return 0;
 }


drivers/rtc/rtc-r9701.c: reset registers if invalid values are detected

hwclock refuses to set date/time if RTC registers contain invalid
values.  Check the date/time register values at probe time and
initialize them to make hwclock happy.

Signed-off-by: Andreas Dumberger <f0ace40453a44741db231e68d234ecbb2886f5a0@tqs.de>
Signed-off-by: Anatolij Gustschin <f79f5d5f0b8928b7f49f0262a90d53ad98a87c22@denx.de>
Cc: Alessandro Zummo <f0b9bd96bf07bfecc189c62159960134588fafe5@towertech.it>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- drivers/rtc/rtc-r9701.c
+++ drivers/rtc/rtc-r9701.c
@@ -122,6 +122,7 @@
 static int __devinit r9701_probe(struct spi_device *spi)
 {
 	struct rtc_device *rtc;
+	struct rtc_time dt;
 	unsigned char tmp;
 	int res;

@@ -130,6 +131,27 @@
 	if (res || tmp != 0x20) {
 		dev_err(&spi->dev, "cannot read RTC register\n");
 		return -ENODEV;
+	}
+
+	/*
+	 * The device seems to be present. Now check if the registers
+	 * contain invalid values. If so, try to write a default date:
+	 * 2000/1/1 00:00:00
+	 */
+	r9701_get_datetime(&spi->dev, &dt);
+	if (rtc_valid_tm(&dt)) {
+		dev_info(&spi->dev, "trying to repair invalid date/time\n");
+		dt.tm_sec  = 0;
+		dt.tm_min  = 0;
+		dt.tm_hour = 0;
+		dt.tm_mday = 1;
+		dt.tm_mon  = 0;
+		dt.tm_year = 100;
+
+		if (r9701_set_datetime(&spi->dev, &dt)) {
+			dev_err(&spi->dev, "cannot repair RTC register\n");
+			return -ENODEV;
+		}
 	}

 	rtc = rtc_device_register("r9701",


[SCSI] libiscsi: remove unneeded queue work when max_cmdsn is increased

iscsi_queuecommand will only take in commands that can fit in the
current window. So, if a command is on the cmdqueue then it can
fit in the current window. If a command is on the mgmtqueue, then
we are setting the immediate bit so they will also fit in the
window. As a result, we never need to to do a iscsi_conn_queue_work
when the maxCmdSn is increased.

What should happen is that a command will complete the window will
be increased, then the scsi layer will send us more commands by
running the scsi_device queues.

Signed-off-by: Mike Christie <6fe105eefab41990d7ec714c6c25ade3095cdb48@cs.wisc.edu>
Signed-off-by: James Bottomley <1acebbdca565c7b6b638bdc23b58b5610d1a56b8@Parallels.com>

--- drivers/scsi/libiscsi.c
+++ drivers/scsi/libiscsi.c
@@ -110,16 +110,8 @@
 		session->exp_cmdsn = exp_cmdsn;

 	if (max_cmdsn != session->max_cmdsn &&
-	    !iscsi_sna_lt(max_cmdsn, session->max_cmdsn)) {
+	    !iscsi_sna_lt(max_cmdsn, session->max_cmdsn))
 		session->max_cmdsn = max_cmdsn;
-		/*
-		 * if the window closed with IO queued, then kick the
-		 * xmit thread
-		 */
-		if (!list_empty(&session->leadconn->cmdqueue) ||
-		    !list_empty(&session->leadconn->mgmtqueue))
-			iscsi_conn_queue_work(session->leadconn);
-	}
 }

 void iscsi_update_cmdsn(struct iscsi_session *session, struct iscsi_nopin *hdr)


llama: Enable CONFIG_FORCE_CONSOLE_RESUME option in llama board

The response time of console is too slow during LOW_POWER_IDLE
mode is enabled. Just enable FORCE_CONSOLE_RESUME to let console
work fine.

Change-Id: I43bf1d48af6d0ac8179bc67e5a813ec1d5e880a2
Signed-off-by: Ben Lok <310171a828df105188e0b545d65d6370e8133283@mediatek.com>

--- board/llama/board.h
+++ board/llama/board.h
@@ -18,6 +18,7 @@
 #define CONFIG_CHARGER_DISCHARGE_ON_AC
 #define CONFIG_CHARGER_V2
 #define CONFIG_EXTPOWER_GPIO
+#define CONFIG_FORCE_CONSOLE_RESUME
 #define CONFIG_HOST_COMMAND_STATUS
 #define CONFIG_I2C
 #define CONFIG_KEYBOARD_COL2_INVERTED


[SCSI] scsi_lib.c: fix warning in scsi_kmap_atomic_sg

drivers/scsi/scsi_lib.c: In function `scsi_kmap_atomic_sg':
drivers/scsi/scsi_lib.c:2394: warning: unsigned int format, different type arg (arg 3)
drivers/scsi/scsi_lib.c:2394: warning: unsigned int format, different type arg (arg 4)

Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@osdl.org>
Signed-off-by: James Bottomley <407b36959ca09543ccda8f8e06721c791bc53435@SteelEye.com>

--- drivers/scsi/scsi_lib.c
+++ drivers/scsi/scsi_lib.c
@@ -2375,7 +2375,8 @@
 	}

 	if (unlikely(i == sg_count)) {
-		printk(KERN_ERR "%s: Bytes in sg: %u, requested offset %u, elements %d\n",
+		printk(KERN_ERR "%s: Bytes in sg: %zu, requested offset %zu, "
+			"elements %d\n",
 		       __FUNCTION__, sg_len, *offset, sg_count);
 		WARN_ON(1);
 		return NULL;


serial: sh-sci: Fix up the cpufreq notifier to use the proper port clock.

Signed-off-by: Paul Mundt <38b52dbb5f0b63d149982b6c5de788ec93a89032@linux-sh.org>

--- drivers/serial/sh-sci.c
+++ drivers/serial/sh-sci.c
@@ -748,7 +748,7 @@
 	return ret;
 }

-#if defined(CONFIG_CPU_FREQ) && defined(CONFIG_HAVE_CLK)
+#ifdef CONFIG_HAVE_CLK
 /*
  * Here we define a transistion notifier so that we can update all of our
  * ports' baud rate when the peripheral clock changes.
@@ -756,41 +756,20 @@
 static int sci_notifier(struct notifier_block *self,
 			unsigned long phase, void *p)
 {
-	struct cpufreq_freqs *freqs = p;
 	int i;

 	if ((phase == CPUFREQ_POSTCHANGE) ||
-	    (phase == CPUFREQ_RESUMECHANGE)) {
+	    (phase == CPUFREQ_RESUMECHANGE))
 		for (i = 0; i < SCI_NPORTS; i++) {
-			struct uart_port *port = &sci_ports[i].port;
-			struct clk *clk;
-
-			/*
-			 * Update the uartclk per-port if frequency has
-			 * changed, since it will no longer necessarily be
-			 * consistent with the old frequency.
-			 *
-			 * Really we want to be able to do something like
-			 * uart_change_speed() or something along those lines
-			 * here to implicitly reset the per-port baud rate..
-			 *
-			 * Clean this up later..
-			 */
-			clk = clk_get(NULL, "module_clk");
-			port->uartclk = clk_get_rate(clk);
-			clk_put(clk);
-		}
-
-		printk(KERN_INFO "%s: got a postchange notification "
-		       "for cpu %d (old %d, new %d)\n",
-		       __func__, freqs->cpu, freqs->old, freqs->new);
-	}
+			struct sci_port *s = &sci_ports[i];
+			s->port.uartclk = clk_get_rate(s->clk);
+		}

 	return NOTIFY_OK;
 }

 static struct notifier_block sci_nb = { &sci_notifier, NULL, 0 };
-#endif /* CONFIG_CPU_FREQ && CONFIG_HAVE_CLK */
+#endif

 static int sci_request_irq(struct sci_port *port)
 {
@@ -1326,9 +1305,8 @@
 		uart_add_one_port(&sci_uart_driver, &sciport->port);
 	}

-#if defined(CONFIG_CPU_FREQ) && defined(CONFIG_HAVE_CLK)
+#ifdef CONFIG_HAVE_CLK
 	cpufreq_register_notifier(&sci_nb, CPUFREQ_TRANSITION_NOTIFIER);
-	dev_info(&dev->dev, "CPU frequency notifier registered\n");
 #endif

 #ifdef CONFIG_SH_STANDARD_BIOS
@@ -1347,6 +1325,10 @@
 static int __devexit sci_remove(struct platform_device *dev)
 {
 	int i;
+
+#ifdef CONFIG_HAVE_CLK
+	cpufreq_unregister_notifier(&sci_nb, CPUFREQ_TRANSITION_NOTIFIER);
+#endif

 	for (i = 0; i < SCI_NPORTS; i++)
 		uart_remove_one_port(&sci_uart_driver, &sci_ports[i].port);


lib-auth: Treat cert_username="" and initial_resp_base64="" the same as NULLs.

--- src/lib-auth/auth-client-request.c
+++ src/lib-auth/auth-client-request.c
@@ -82,9 +82,9 @@
 	request->request_info.mech = p_strdup(pool, request_info->mech);
 	request->request_info.service = p_strdup(pool, request_info->service);
 	request->request_info.cert_username =
-		p_strdup(pool, request_info->cert_username);
+		p_strdup_empty(pool, request_info->cert_username);
 	request->request_info.initial_resp_base64 =
-		p_strdup(pool, request_info->initial_resp_base64);
+		p_strdup_empty(pool, request_info->initial_resp_base64);

 	request->callback = callback;
 	request->context = context;


serial: sh-sci: remove duplicated #include

Remove duplicated #include('s) in
  drivers/serial/sh-sci.c

Signed-off-by: Huang Weiyi <3747a8217f9c255c8b609f0f2e71d2a8804c1b96@gmail.com>
Signed-off-by: Paul Mundt <38b52dbb5f0b63d149982b6c5de788ec93a89032@linux-sh.org>

--- drivers/serial/sh-sci.c
+++ drivers/serial/sh-sci.c
@@ -50,7 +50,6 @@
 #include <linux/list.h>
 #include <linux/dmaengine.h>
 #include <linux/scatterlist.h>
-#include <linux/timer.h>

 #ifdef CONFIG_SUPERH
 #include <asm/sh_bios.h>


spi/atmel: Fix format specifier warnings

This patch fixes the following sparse warnings.
dma_addr_t can be either u32 or u64 so we should cast to the
largest type and use the format specifier %llx.

drivers/spi/spi-atmel.c: In function ‘atmel_spi_next_xfer_dma_submit’:
drivers/spi/spi-atmel.c:631:2: warning:
	format ‘%x’ expects argument of type ‘unsigned int’,
	but argument 7 has type ‘dma_addr_t’ [-Wformat]
drivers/spi/spi-atmel.c:631:2: warning:
	format ‘%x’ expects argument of type ‘unsigned int’,
	but argument 9 has type ‘dma_addr_t’ [-Wformat]
drivers/spi/spi-atmel.c: In function ‘atmel_spi_pdc_next_xfer’:
drivers/spi/spi-atmel.c:734:3: warning:
	format ‘%x’ expects argument of type ‘unsigned int’,
	but argument 7 has type ‘dma_addr_t’ [-Wformat]
drivers/spi/spi-atmel.c:734:3: warning:
	format ‘%x’ expects argument of type ‘unsigned int’,
	but argument 9 has type ‘dma_addr_t’ [-Wformat]
drivers/spi/spi-atmel.c:773:3: warning:
	format ‘%x’ expects argument of type ‘unsigned int’,
	but argument 7 has type ‘dma_addr_t’ [-Wformat]
drivers/spi/spi-atmel.c:773:3: warning:
	format ‘%x’ expects argument of type ‘unsigned int’,
	but argument 9 has type ‘dma_addr_t’ [-Wformat]

Signed-off-by: Emil Goode <8f82f727ceef69ddbc9c99a3e77927715fed00fe@gmail.com>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@linaro.org>

--- drivers/spi/spi-atmel.c
+++ drivers/spi/spi-atmel.c
@@ -629,9 +629,9 @@
 		goto err_dma;

 	dev_dbg(master->dev.parent,
-		"  start dma xfer %p: len %u tx %p/%08x rx %p/%08x\n",
-		xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
-		xfer->rx_buf, xfer->rx_dma);
+		"  start dma xfer %p: len %u tx %p/%08llx rx %p/%08llx\n",
+		xfer, xfer->len, xfer->tx_buf, (unsigned long long)xfer->tx_dma,
+		xfer->rx_buf, (unsigned long long)xfer->rx_dma);

 	/* Enable relevant interrupts */
 	spi_writel(as, IER, SPI_BIT(OVRES));
@@ -732,9 +732,10 @@
 		spi_writel(as, TCR, len);

 		dev_dbg(&msg->spi->dev,
-			"  start xfer %p: len %u tx %p/%08x rx %p/%08x\n",
-			xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
-			xfer->rx_buf, xfer->rx_dma);
+			"  start xfer %p: len %u tx %p/%08llx rx %p/%08llx\n",
+			xfer, xfer->len, xfer->tx_buf,
+			(unsigned long long)xfer->tx_dma, xfer->rx_buf,
+			(unsigned long long)xfer->rx_dma);
 	} else {
 		xfer = as->next_transfer;
 		remaining = as->next_remaining_bytes;
@@ -771,9 +772,10 @@
 		spi_writel(as, TNCR, len);

 		dev_dbg(&msg->spi->dev,
-			"  next xfer %p: len %u tx %p/%08x rx %p/%08x\n",
-			xfer, xfer->len, xfer->tx_buf, xfer->tx_dma,
-			xfer->rx_buf, xfer->rx_dma);
+			"  next xfer %p: len %u tx %p/%08llx rx %p/%08llx\n",
+			xfer, xfer->len, xfer->tx_buf,
+			(unsigned long long)xfer->tx_dma, xfer->rx_buf,
+			(unsigned long long)xfer->rx_dma);
 		ieval = SPI_BIT(ENDRX) | SPI_BIT(OVRES);
 	} else {
 		spi_writel(as, RNCR, 0);


Error message fix for currently unused mailbox list index code.

--HG--
branch : HEAD

--- src/lib-index/mailbox-list-index.c
+++ src/lib-index/mailbox-list-index.c
@@ -52,7 +52,7 @@
 int mailbox_list_index_set_syscall_error(struct mailbox_list_index *index,
 					 const char *function)
 {
-	i_error("%s failed with file %s: %m", index->filepath, function);
+	i_error("%s failed with file %s: %m", function, index->filepath);
 	return -1;
 }


USB: file.c: remove dbg() usage

USB: file.c: remove dbg() usage

dbg() was a very old USB-specific macro that should no longer
be used. This patch removes it from being used in the driver
and uses dev_dbg() instead.

CC: Al Viro <de609eb4d5d70b1d38ec6642adbfc33a2781f63c@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/usb/core/file.c
+++ drivers/usb/core/file.c
@@ -183,7 +183,7 @@
 	if (retval)
 		return retval;

-	dev_dbg(&intf->dev, "looking for a minor, starting at %d", minor_base);
+	dev_dbg(&intf->dev, "looking for a minor, starting at %d\n", minor_base);

 	down_write(&minor_rwsem);
 	for (minor = minor_base; minor < MAX_USB_MINORS; ++minor) {
@@ -239,7 +239,7 @@
 	if (intf->minor == -1)
 		return;

-	dbg ("removing %d minor", intf->minor);
+	dev_dbg(&intf->dev, "removing %d minor\n", intf->minor);

 	down_write(&minor_rwsem);
 	usb_minors[intf->minor] = NULL;


lib-master: Added extra debug info for a "user not found" error message.

--- src/lib-master/master-login-auth.c
+++ src/lib-master/master-login-auth.c
@@ -246,7 +246,7 @@

 	request = master_login_auth_lookup_request(auth, id);
 	if (request != NULL) {
-		i_error("Authenticated user not found from userdb");
+		i_error("Authenticated user not found from userdb (id=%u)", id);
 		request->callback(NULL, MASTER_AUTH_ERRMSG_INTERNAL_FAILURE,
 				  request->context);
 		i_free(request);


usb: dwc3: core: enable phy suspend quirk on non-FPGA

as it turns out, at least AM437x silicon (non-FPGA)
needs to enable PHY suspend quirk. So let's allow
for PHY suspend quirk to be used with non-FPGA
builds too.

Signed-off-by: Felipe Balbi <94dddeeef08b001e003cce128ddc162a4e2c6cd2@ti.com>

--- drivers/usb/dwc3/core.c
+++ drivers/usb/dwc3/core.c
@@ -404,7 +404,7 @@
 	if (dwc->tx_de_emphasis_quirk)
 		reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis);

-	if (dwc->dis_u3_susphy_quirk && dwc->is_fpga)
+	if (dwc->dis_u3_susphy_quirk)
 		reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;

 	dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
@@ -422,7 +422,7 @@
 	if (dwc->revision > DWC3_REVISION_194A)
 		reg |= DWC3_GUSB2PHYCFG_SUSPHY;

-	if (dwc->dis_u2_susphy_quirk && dwc->is_fpga)
+	if (dwc->dis_u2_susphy_quirk)
 		reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;

 	dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);


Fetching message parts or virtual size from cache didn't work correctly and could have crashed.

--- src/lib-storage/index/index-mail.c
+++ src/lib-storage/index/index-mail.c
@@ -777,7 +777,7 @@
 	   header/body */
 	if ((mail->wanted_fields & MAIL_FETCH_MESSAGE_PARTS) != 0) {
 		unsigned int cache_field =
-			cache_fields[MAIL_FETCH_MESSAGE_PARTS].idx;
+			cache_fields[MAIL_CACHE_MESSAGEPART].idx;

 		if (mail_cache_field_exists(cache_view, seq, cache_field) <= 0)
 			data->access_part |= PARSE_HDR | PARSE_BODY;
@@ -785,7 +785,7 @@

 	if ((mail->wanted_fields & MAIL_FETCH_VIRTUAL_SIZE) != 0) {
 		unsigned int cache_field =
-			cache_fields[MAIL_FETCH_VIRTUAL_SIZE].idx;
+			cache_fields[MAIL_CACHE_VIRTUAL_FULL_SIZE].idx;

 		if (mail_cache_field_exists(cache_view, seq, cache_field) <= 0)
 			data->access_part |= READ_HDR | READ_BODY;


usb: ehci should use u16 for isochronous intervals

While most isochronous endpoints have short polling intervals, the
EHCI driver won't necessarily handle larger ones correctly.

This patch switches to use a "u16" to represent those periods, not
a u8, since it can always work:  the largest expressible period
is 2^15 units ... not the previous too-short limit of 128 frames
(full or low speeds) or microframes (high speed, 32 frames).

This bug is essentially theoretical, since the few ISO endpoints
I've seen which don't use one transfer per frame are high speed
ones using more than that (including high bandwidth, 24 KB/msec).

Signed-off-by: David Brownell <a0d09457d62acbdeb1fae1223575100ccbfffdf9@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>

--- drivers/usb/host/ehci.h
+++ drivers/usb/host/ehci.h
@@ -550,8 +550,8 @@
 	 * trusting urb->interval == f(epdesc->bInterval) and
 	 * including the extra info for hw_bufp[0..2]
 	 */
-	u8			interval;
 	u8			usecs, c_usecs;
+	u16			interval;
 	u16			tt_usecs;
 	u16			maxp;
 	u16			raw_mask;


minor cleanup

minor cleanup

--- src/lib-storage/index/index-save.c
+++ src/lib-storage/index/index-save.c
@@ -55,14 +55,11 @@
 		}

 		data = io_buffer_get_data(buf, &size);
-		if (size == 0)
-			continue;
-
 		if (size > data_size)
 			size = data_size;
 		data_size -= size;

-		if (write_with_crlf(fd, data, size, &last_cr)) {
+		if (write_with_crlf(fd, data, size, &last_cr) != 0) {
 			mail_storage_set_critical(storage, "write() failed "
 						  "for file %s: %m", path);
 			return FALSE;


virtio: don't crash when device is buggy

Because of a sanity check in virtio_dev_remove, a buggy device can crash
kernel.  And in case of rproc it's userspace so it's not a good idea.
We are unloading a driver so how bad can it be?
Be less aggressive in handling this error: if it's a driver bug,
warning once should be enough.

Signed-off-by: Michael S. Tsirkin <255103e50249e3d658441816e0597170ebfc16ef@redhat.com>
Signed-off-by: Rusty Russell <df9728c9e5104131c08c7adb03af425394842596@rustcorp.com.au>

--- drivers/virtio/virtio.c
+++ drivers/virtio/virtio.c
@@ -159,7 +159,7 @@
 	drv->remove(dev);

 	/* Driver should have reset device. */
-	BUG_ON(dev->config->get_status(dev));
+	WARN_ON_ONCE(dev->config->get_status(dev));

 	/* Acknowledge the device's existence again. */
 	add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE);


r200: invalidate texture paths in some more places

--- src/mesa/drivers/dri/r200/r200_tex.c
+++ src/mesa/drivers/dri/r200/r200_tex.c
@@ -43,8 +43,6 @@
 #include "main/teximage.h"
 #include "main/texobj.h"

-#include "texmem.h"
-
 #include "radeon_mipmap_tree.h"
 #include "r200_context.h"
 #include "r200_state.h"
@@ -210,6 +208,9 @@
 static void r200SetTexFilter( radeonTexObjPtr t, GLenum minf, GLenum magf )
 {
    GLuint anisotropy = (t->pp_txfilter & R200_MAX_ANISO_MASK);
+
+   /* Force revalidation to account for switches from/to mipmapping. */
+   t->validated = GL_FALSE;

    t->pp_txfilter &= ~(R200_MIN_FILTER_MASK | R200_MAG_FILTER_MASK);
    t->pp_txformat_x &= ~R200_VOLUME_FILTER_MASK;
@@ -389,7 +390,11 @@
        * we just have to rely on loading the right subset of mipmap levels
        * to simulate a clamped LOD.
        */
-      driSwapOutTextureObject( (driTextureObject *) t );
+      if (t->mt) {
+         radeon_miptree_unreference(t->mt);
+	 t->mt = 0;
+	 t->validated = GL_FALSE;
+      }
       break;

    default:


remove code that forceds fb 0 . let disp name do it

git-svn-id: 02aad79badda6dfe9dc72877135550b4bc575585@44149 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

--- src/lib/ecore_evas/ecore_evas_fb.c
+++ src/lib/ecore_evas/ecore_evas_fb.c
@@ -657,7 +657,6 @@
      {
 	einfo->info.virtual_terminal = 0;
 	einfo->info.device_number = strtol(disp_name, NULL, 10);
-	einfo->info.device_number = 0;
 	einfo->info.refresh = 0;
 	einfo->info.rotation = ee->rotation;
 	evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);


starting to find existing iemladspa-mergeplugins


965: dump curbe contents to stderr

965: dump curbe contents to stderr

--- src/mesa/pipe/i965simple/brw_curbe.c
+++ src/mesa/pipe/i965simple/brw_curbe.c
@@ -254,12 +254,13 @@
       /* map the vertex constant buffer and copy to curbe: */
       ws->buffer_map(ws, cbuffer->buffer, 0);
       ws->buffer_get_subdata(ws, cbuffer->buffer,
-                             0, cbuffer->size,
+                             0,
+			     cbuffer->size,
                              &buf[offset]);
       ws->buffer_unmap(ws, cbuffer->buffer);
    }

-   if (0) {
+   if (1) {
       for (i = 0; i < sz*16; i+=4)
 	 _mesa_printf("curbe %d.%d: %f %f %f %f\n", i/8, i&4,
 		      buf[i+0], buf[i+1], buf[i+2], buf[i+3]);


gallium: Use directory name in include.

gallium: Use directory name in include.

--- src/mesa/pipe/pipebuffer/pb_buffer.h
+++ src/mesa/pipe/pipebuffer/pb_buffer.h
@@ -46,7 +46,8 @@

 #include <assert.h>
 #include <stdlib.h>
-#include "p_compiler.h"
+
+#include "pipe/p_compiler.h"

 #include "pipe/p_state.h"


st/mesa: Remove unnecessary headers from st_cb_clear.c.

--- src/mesa/state_tracker/st_cb_clear.c
+++ src/mesa/state_tracker/st_cb_clear.c
@@ -42,17 +42,14 @@
 #include "st_cb_accum.h"
 #include "st_cb_clear.h"
 #include "st_cb_fbo.h"
-#include "st_draw.h"
 #include "st_program.h"
 #include "st_public.h"
-#include "st_mesa_to_tgsi.h"
 #include "st_inlines.h"

 #include "pipe/p_context.h"
 #include "pipe/p_inlines.h"
 #include "pipe/p_state.h"
 #include "pipe/p_defines.h"
-#include "util/u_pack_color.h"
 #include "util/u_simple_shaders.h"
 #include "util/u_draw_quad.h"


More changes for the roaFromFile problem.

--- roa-utils/roa_test.c
+++ roa-utils/roa_test.c
@@ -90,8 +90,8 @@

 int main(int argc, char** argv)
 {
-  struct ROA    *roa = NULL;
-  struct ROA    *roa2 = NULL;
+  struct ROA    roa;
+  struct ROA    roa2;
   unsigned char *blob = NULL;
   FILE   *fp = NULL;
   scmcon *conp;
@@ -105,6 +105,8 @@
   char   *fn = NULL;
   int     sta = 0;

+  ROA(&roa, (ushort)0);
+  ROA(&roa2, (ushort)0);
   if ( argc < 2 )
     filename_cnf = "roa.cnf";
   else
@@ -118,8 +120,8 @@
 		    filename_cnf, err2string(sta), sta);
       return sta;
     }
-  sta = roaToFile(roa, filename_pem, FMT_PEM);
-  roaFree(roa);
+  sta = roaToFile(&roa, filename_pem, FMT_PEM);
+  delete_casn(&roa.self);
   if ( sta < 0 )
     {
       (void)fprintf(stderr, "roaToFile(%s) failed with error %s (%d)\n",
@@ -133,7 +135,7 @@
 		    filename_pem, err2string(sta), sta);
       return sta;
     }
-  ski = (char *)roaSKI(roa2);
+  ski = (char *)roaSKI(&roa2);
   if ( ski == NULL || ski[0] == 0 )
     {
       (void)fprintf(stderr, "ROA has NULL SKI\n");
@@ -142,7 +144,7 @@
   scmp = initscm();
   if ( scmp == NULL )
     {
-      roaFree(roa2);
+      delete_casn(&roa2.self);
       free(ski);
       (void)fprintf(stderr,
 		    "Internal error: cannot initialize database schema\n");
@@ -154,7 +156,7 @@
     {
       (void)fprintf(stderr, "Cannot connect to DSN %s: %s\n",
 		    scmp->dsn, errmsg);
-      roaFree(roa2);
+      delete_casn(&roa2.self);
       free(ski);
       freescm(scmp);
       return -4;
@@ -167,7 +169,7 @@
     {
       (void)fprintf(stderr, "ROA certificate has no parent in DB: error %s (%d)\n",
 		    err2string(sta), sta);
-      roaFree(roa2);
+      delete_casn(&roa2.self);
       return sta;
     }
   blob = myreadfile(fn, &sta);
@@ -177,28 +179,28 @@
 		    fn, err2string(sta), sta);

       X509_free(cert);
-      roaFree(roa2);
+      delete_casn(&roa2.self);
       return(sta);
     }
-  sta = roaValidate2(roa2);
+  sta = roaValidate2(&roa2);
   free((void *)blob);
   X509_free(cert);
   if ( sta < 0 )
     {
       (void)fprintf(stderr, "ROA failed semantic validation: error %s (%d)\n",
 		    err2string(sta), sta);
-      roaFree(roa2);
+      delete_casn(&roa2.self);
       return sta;
     }
   fp = fopen("roa.txt", "a");
   if ( fp == NULL )
     {
       (void)fprintf(stderr, "Cannot open roa.txt\n");
-      roaFree(roa2);
+      delete_casn(&roa2.self);
       return -5;
     }
-  sta = roaGenerateFilter(roa2, NULL, fp, NULL, 0);
-  roaFree(roa2);
+  sta = roaGenerateFilter(&roa2, NULL, fp, NULL, 0);
+  delete_casn(&roa2.self);
   (void)fclose(fp);
   if ( sta < 0 )
     {


Revert "calamari: fix polling to actually take place."

My bad, the logic was right. The timer is only re-issued after a
successful transfer.

This reverts commit 8d3c7d8939e136149f080a9b03fa8ec533e77364.

--- src/modules/flow/calamari/calamari.c
+++ src/modules/flow/calamari/calamari.c
@@ -443,7 +443,7 @@
     }

     mdata->timer = NULL;
-    return true;
+    return false;
 }

 static int


Add the geometry transformation on the bounds calculation

--- enesim/lib/renderer/enesim_renderer_ellipse.c
+++ enesim/lib/renderer/enesim_renderer_ellipse.c
@@ -1085,12 +1085,25 @@
 		Enesim_Rectangle *rect)
 {
 	Enesim_Renderer_Ellipse *thiz;
+	const Enesim_Renderer_State *cs = states[ENESIM_STATE_CURRENT];
+	const Enesim_Renderer_Shape_State *css = sstates[ENESIM_STATE_CURRENT];

 	thiz = _ellipse_get(r);
 	rect->x = thiz->current.x - thiz->current.rx;
 	rect->y = thiz->current.y - thiz->current.ry;
 	rect->w = thiz->current.rx * 2;
 	rect->h = thiz->current.ry * 2;
+	/* translate by the origin */
+	rect->x += cs->ox;
+	rect->y += cs->oy;
+	/* apply the geometry transformation */
+	if (cs->geometry_transformation_type != ENESIM_MATRIX_IDENTITY)
+	{
+		Enesim_Quad q;
+
+		enesim_matrix_rectangle_transform(&cs->geometry_transformation, rect, &q);
+		enesim_quad_rectangle_to(&q, rect);
+	}
 }

 static void _ellipse_destination_boundings(Enesim_Renderer *r,
@@ -1194,7 +1207,7 @@
 	/* .boundings =  		*/ _ellipse_boundings,
 	/* .destination_boundings = 	*/ _ellipse_destination_boundings,
 	/* .flags = 			*/ _ellipse_flags,
-	/* .hints_get = 			*/ _ellipse_hints,
+	/* .hints_get = 		*/ _ellipse_hints,
 	/* .is_inside = 		*/ NULL,
 	/* .damage = 			*/ NULL,
 	/* .has_changed = 		*/ _ellipse_has_changed,


Cleanup mutex release in error case

Cleanup mutex release in error case

git-svn-id: ab66a9de07fa9d47c5829c82992f5279466c775f@3287 63c20433-aa62-49bd-875c-5a186b69a8fb

--- modules/mpd_in/mpd_in.c
+++ modules/mpd_in/mpd_in.c
@@ -608,6 +608,7 @@
             if (count < 1) {
                 GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[MPD_IN] 0 representations, aborting\n"));
                 gf_free(base_init_url);
+		        gf_mx_v(mpdin->dl_mutex);
                 return GF_BAD_PARAM;
             }
             GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[MPD_IN] Resizing to %u max_cached elements instead of %u.\n", count, mpdin->max_cached));
@@ -616,7 +617,7 @@
         }
         e = gf_dm_sess_process(mpdin->seg_dnload);
         /* Mime-Type check */
-	strncpy(mime, gf_dm_sess_mime_type(mpdin->seg_dnload), sizeof(mime));
+		strncpy(mime, gf_dm_sess_mime_type(mpdin->seg_dnload), sizeof(mime));
         strlwr(mime);
         if (mime && mpdin->seg_ifce == NULL) {
             GF_Err e;
@@ -626,8 +627,10 @@
             gf_free( rep->mime);
             rep->mime = gf_strdup( mime );
             e = MPD_LoadMediaService(mpdin, mime);
-            if (e != GF_OK)
+			if (e != GF_OK) {
+		        gf_mx_v(mpdin->dl_mutex);
                 return e;
+			}
         }
         if (!mime || (stricmp(mime, rep->mime))) {
             GF_LOG(GF_LOG_ERROR, GF_LOG_MODULE, ("[MPD_IN] Mime '%s' is not correct for '%s', it should be '%s'\n", mime, base_init_url, rep->mime));
@@ -778,7 +781,6 @@
 			/*byte-range request from file are ignored*/
 	        if (seg->use_byterange) {
 				mpdin->is_dl_segments = 0;
-				gf_mx_v(mpdin->dl_mutex);
 				break;
 			}
 			resource_name = local_file_name = (char *) new_base_seg_url;
@@ -795,12 +797,10 @@
 		}

 		if (e == GF_OK || mpdin->segment_must_be_streamed) {
-            //gf_mx_p(mpdin->dl_mutex);
             mpdin->cached[mpdin->nb_cached].cache = gf_strdup(local_file_name);
             mpdin->cached[mpdin->nb_cached].url = gf_strdup( resource_name );
             GF_LOG(GF_LOG_INFO, GF_LOG_MODULE, ("[MPD_IN] Added file to cache\n\tURL: %s\n\tCache: %s\n\tElements in cache: %u/%u\n", mpdin->cached[mpdin->nb_cached].url, mpdin->cached[mpdin->nb_cached].cache, mpdin->nb_cached+1, mpdin->max_cached));
             mpdin->nb_cached++;
-            //gf_mx_v(mpdin->dl_mutex);
             mpdin->download_segment_index++;
             if (mpdin->auto_switch_count) {
                 mpdin->nb_segs_done++;


fix in unused part of fp.h

fix in unused part of fp.h

svn: r8211


reset mothership after getting config options

--- spu/replicate/replicatespu_config.c
+++ spu/replicate/replicatespu_config.c
@@ -87,5 +87,9 @@

 	replicate_spu.buffer_size = crMothershipGetMTU( conn );

+	/* reset so next OpenGL app can use the mothership config */
+	crDebug("Replicate SPU: resetting mothership config");
+	crMothershipReset(conn);
+
 	crMothershipDisconnect( conn );
 }


nodedev: Don't fail device enumeration if MDEVCTL is missing

After all devices were enumerated, the enumeration thread call
nodeDeviceUpdateMediatedDevices() to refresh the state of
mediated devices. This means that 'mdevctl' will be executed. But
it may be missing on some systems (e.g. mine) in which case we
should just skip the update of mdevs instead of failing whole
device enumeration.

Signed-off-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>
Reviewed-by: Erik Skultety <2c14d38fa47c8799f1b9c16280abe27f8edfec6e@redhat.com>

--- src/node_device/node_device_driver.c
+++ src/node_device/node_device_driver.c
@@ -42,8 +42,11 @@
 #include "virnetdev.h"
 #include "virutil.h"
 #include "vircommand.h"
+#include "virlog.h"

 #define VIR_FROM_THIS VIR_FROM_NODEDEV
+
+VIR_LOG_INIT("node_device.node_device_driver");

 virNodeDeviceDriverState *driver;

@@ -1604,8 +1607,14 @@
 {
     g_autofree virNodeDeviceDef **defs = NULL;
     g_autofree char *errmsg = NULL;
+    g_autofree char *mdevctl = NULL;
     virMdevctlForEachData data = { 0, };
     size_t i;
+
+    if (!(mdevctl = virFindFileInPath(MDEVCTL))) {
+        VIR_DEBUG(MDEVCTL " not found. Skipping update of mediated devices.");
+        return 0;
+    }

     if ((data.ndefs = virMdevctlListDefined(&defs, &errmsg)) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,


xbps_array_foreach_cb_multi: handle the case of sysconf returning 0.

--- lib/plist.c
+++ lib/plist.c
@@ -101,7 +101,7 @@
 		return 0;

 	maxthreads = (int)sysconf(_SC_NPROCESSORS_ONLN);
-	if (maxthreads < 0 || maxthreads == 1) /* use single threaded routine */
+	if (maxthreads <= 0 || maxthreads == 1) /* use single threaded routine */
 		return xbps_array_foreach_cb(xhp, array, dict, fn, arg);

 	thd = calloc(maxthreads, sizeof(*thd));


Make private function static

Make private function static

--- pango/ext/pango/rbpangoglyphinfo.c
+++ pango/ext/pango/rbpangoglyphinfo.c
@@ -15,13 +15,16 @@

 /**********************************/
-PangoGlyphInfo*
-pango_glyph_info_copy (const PangoGlyphInfo* info)
+static PangoGlyphInfo *
+pango_glyph_info_copy(const PangoGlyphInfo *info)
 {
-  PangoGlyphInfo* data;
-  g_return_val_if_fail (info != NULL, NULL);
+  PangoGlyphInfo *data;
+
+  g_return_val_if_fail(info != NULL, NULL);
+
   data = g_new(PangoGlyphInfo, 1);
   *data = *info;
+
   return data;
 }


fix warning

fix warning

--- roofit/roofitcore/inc/RooComplex.h
+++ roofit/roofitcore/inc/RooComplex.h
@@ -16,7 +16,7 @@
 #ifndef ROO_COMPLEX
 #define ROO_COMPLEX

-#if !defined(ROO_MATH) && !defined(ROO_COMPLEX_CXX) && !defined(__CINT__) && \
+#if !defined(ROO_MATH) && !defined(ROO_COMPLEX_CXX) && !defined(__CLING__) && \
     !defined(R__DICTIONARY_FILENAME)
 #warning "RooComplex is deprecated, use std::complex instead!"
 #endif


eeprom

eeprom

majid delet

--- at91sam7x-ek/basic-twi-eeprom-project/main.c
+++ at91sam7x-ek/basic-twi-eeprom-project/main.c
@@ -34,6 +34,9 @@
 /// Slave address of AT24C chips.
 #define AT24C_ADDRESS   0x50

+
+/// Page size of an AT24C512 chip (in bytes)
+//#define PAGE_SIZE       64
 /// Page size of an AT24C02 chip (in bytes)
 #define PAGE_SIZE       8

@@ -69,7 +72,7 @@
    	//Section 1
     PIO_Configure(pins, PIO_LISTSIZE(pins));
     TRACE_CONFIGURE(DBGU_STANDARD, 115200, BOARD_MCK);
-    printf("Basic TWI EEPROM Project\n\rNaminicGroup,MajidKhalili\n\r");
+    printf("Basic TWI EEPROM Project\n\rNaminicGroup\n\r");

 	//Section 2
     // Configure TWI


BMP085: bmp085.init() should return 0

BMP085: bmp085.init() should return 0


changes to qCompilerAndStdLib_Supports_override and qCompilerAndStdLib_Supports_errno_t for clang++

--- Library/Sources/Stroika/Foundation/Configuration/Private/Defaults_CompilerAndStdLib_.h
+++ Library/Sources/Stroika/Foundation/Configuration/Private/Defaults_CompilerAndStdLib_.h
@@ -451,16 +451,17 @@

-/*
-@CONFIGVAR:     qCompilerAndStdLib_Supports_errno_t
-@DESCRIPTION:
Controls whether or not the compiler provides an implementation
-                of errno_t (gcc for example just assumes its int)

-*/
+/**
+ *  qCompilerAndStdLib_Supports_errno_t controls whether or not the compiler provides an implementation
+ *  of errno_t (gcc for example just assumes its int).
+ *
+ *  NB: POSIX and C99 just say to assume its an int and doesn't define errno_t.
+ */
 #if     !defined (qCompilerAndStdLib_Supports_errno_t)
 #if     defined (__clang__)
-#define qCompilerAndStdLib_Supports_errno_t ((__clang_major__ > 3) || ((__clang_major__ == 3) && (__clang_minor__ >= 3)))
+#define qCompilerAndStdLib_Supports_errno_t 0
 #elif   defined (__GNUC__)
-#define qCompilerAndStdLib_Supports_errno_t (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 8)))
+#define qCompilerAndStdLib_Supports_errno_t 0
 #elif   defined (_MSC_VER)
 #define qCompilerAndStdLib_Supports_errno_t 1
 #else
@@ -562,8 +563,8 @@
 @DESCRIPTION:
Controls whether or not the compiler the override function annotion (added in C++11).

 */
 #if     !defined (qCompilerAndStdLib_Supports_override)
-#if     defined (__GNUC__) && !defined (__clang__) && (__GNUC__ < 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ < 7)))
-#define qCompilerAndStdLib_Supports_override    0
+#if     defined (__GNUC__) && !defined (__clang__)
+#define qCompilerAndStdLib_Supports_override     (__GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 7)))
 #elif   defined (_MSC_VER)
 #define qCompilerAndStdLib_Supports_override    (_MSC_VER > _MS_VS_2k10_VER_)
 #else


fix the 'BL' printing problem. add underscore before function_label

--- PS5/src/generator.c
+++ PS5/src/generator.c
@@ -666,7 +666,7 @@

 		case BL:
 			fprintf(stream, "\tbl\t");
-			fprintf(stream, "%s\n", this->operands[0]);
+			fprintf(stream, "_%s\n", this->operands[0]);
 			break;
 		case LABEL:
 			fprintf(stream, "_%s:\n", this->operands[0]);


Fixed alphabetical key events for OSX

Fixed alphabetical key events for OSX

git-svn-id: 33bf1455041ebe448dbaea643fd5b4b7ce02239d@2966 63c20433-aa62-49bd-875c-5a186b69a8fb

--- modules/sdl_out/video.c
+++ modules/sdl_out/video.c
@@ -341,46 +341,54 @@
 	case SDLK_HELP: evt->key_code = GF_KEY_HELP; break;
 	case SDLK_PRINT: evt->key_code = GF_KEY_PRINTSCREEN; break;

+#if (SDL_MAJOR_VERSION>=1) && (SDL_MINOR_VERSION>=3)
 /*
 	SDLK_CARET		= 94,
-	SDLK_a			= 97,
-	SDLK_b			= 98,
-	SDLK_c			= 99,
-	SDLK_d			= 100,
-	SDLK_e			= 101,
-	SDLK_f			= 102,
-	SDLK_g			= 103,
-	SDLK_h			= 104,
-	SDLK_i			= 105,
-	SDLK_j			= 106,
-	SDLK_k			= 107,
-	SDLK_l			= 108,
-	SDLK_m			= 109,
-	SDLK_n			= 110,
-	SDLK_o			= 111,
-	SDLK_p			= 112,
-	SDLK_q			= 113,
-	SDLK_r			= 114,
-	SDLK_s			= 115,
-	SDLK_t			= 116,
-	SDLK_u			= 117,
-	SDLK_v			= 118,
-	SDLK_w			= 119,
-	SDLK_x			= 120,
-	SDLK_y			= 121,
-	SDLK_z			= 122,
-	SDLK_DELETE		= 127,
+ */
+	case SDLK_a:
+	case SDLK_b:
+	case SDLK_c:
+	case SDLK_d:
+	case SDLK_e:
+	case SDLK_f:
+	case SDLK_g:
+	case SDLK_h:
+	case SDLK_i:
+	case SDLK_j:
+	case SDLK_k:
+	case SDLK_l:
+	case SDLK_m:
+	case SDLK_n:
+	case SDLK_o:
+	case SDLK_p:
+	case SDLK_q:
+	case SDLK_r:
+	case SDLK_s:
+	case SDLK_t:
+	case SDLK_u:
+	case SDLK_v:
+	case SDLK_w:
+	case SDLK_x:
+	case SDLK_y:
+	case SDLK_z:
+		evt->key_code = GF_KEY_A + SDLkey - SDLK_a;
+		break;
+			/*
+ SDLK_DELETE		= 127,

 	SDLK_SYSREQ		= 317,
 	SDLK_POWER		= 320,

 */
-
+#endif
+
 	default:
 		if ((SDLkey>=0x30) && (SDLkey<=0x39))  evt->key_code = GF_KEY_0 + SDLkey-0x30;
 		else if ((SDLkey>=0x41) && (SDLkey<=0x5A))  evt->key_code = GF_KEY_A + SDLkey-0x51;
 		else
+		{
 			evt->key_code = GF_KEY_UNIDENTIFIED;
+		}
 		break;
 	}
 }


Remove useless return()

Remove useless return()

--- libsodium.c
+++ libsodium.c
@@ -449,7 +449,6 @@
     ZVAL_DEREF(val_zv);
     if (IS_IMMUTABLE(val_zv)) {
         zend_error(E_ERROR, "increment(): value is immutable");
-        return;
     }
     if (Z_TYPE_P(val_zv) != IS_STRING) {
         zend_error(E_ERROR, "increment(): a PHP string is required");
@@ -481,7 +480,6 @@
     ZVAL_DEREF(val_zv);
     if (IS_IMMUTABLE(val_zv)) {
         zend_error(E_ERROR, "add(): value is immutable");
-        return;
     }
     if (Z_TYPE_P(val_zv) != IS_STRING) {
         zend_error(E_ERROR, "add(): PHP strings are required");


[project @ 2005-04-20 13:58:00 by simonmar]
Remove bogus code: the mutable list does not need to be rebuilt during
compaction.  It just needs to be updated, which is already happening.

(fixes crashes in compacting collection; I think a different fix is
required for STABLE, though)

--- ghc/rts/GCCompact.c
+++ ghc/rts/GCCompact.c
@@ -841,11 +841,6 @@
 		move(free,p,size);
 	    }

-	    // Rebuild the mutable list for the old generation.
-	    if (ip_MUTABLE(info)) {
-		recordMutable((StgClosure *)free);
-	    }
-
 	    // relocate TSOs
 	    if (info->type == TSO) {
 		move_TSO((StgTSO *)p, (StgTSO *)free);


fourth part of CS50X pset1 homework

fourth part of CS50X pset1 homework

error: pathspec 'week01/pset1/greedy.c' did not match any file(s) known to git

--- week01/pset1/greedy.c
+++ week01/pset1/greedy.c
@@ -0,0 +1,52 @@
+#include <cs50.h>
+#include <stdio.h>
+
+int main(void)
+{
+	// first deal with input
+	printf("O hai! ");
+	float raw_input;
+	do
+	{
+		printf("How much change is owed?\n");
+		raw_input = GetFloat();
+	}
+	while(raw_input < 0.0);
+
+    /*
+    ** now it gets UGLY
+    ** this is to deal with 4.2 * 100 = 419.999
+    ** SERISLY, WAT DA FUK, C?!
+    */
+    int thousands = (int)(raw_input * 1000);
+    int cents = thousands / 10;
+    int remainder = thousands % 10;
+    if (remainder == 9) cents++;
+
+	// now the algo itself
+	// while there is change
+	int result = 0;
+	while(cents)
+	{
+		if (cents >= 25)
+		{
+			cents -= 25;
+			result++;
+		} else if (cents >= 10)
+		{
+			cents -= 10;
+			result++;
+		} else if (cents >= 5)
+		{
+			cents -= 5;
+			result++;
+		} else if (cents >= 1)
+		{
+			cents -= 1;
+			result++;
+		}
+	}
+
+	// produce result to the user on screen
+	printf("%d\n", result);
+}


Fixed a bug that broke my config test app

--- DataAccess/giodevice.h
+++ DataAccess/giodevice.h
@@ -53,7 +53,7 @@
         signals:

             // This signal happens when there's new data available
-            void ReadyRead(const QUuid &identity_of_emitter);
+            void ReadyRead(const QUuid &identity_of_emitter = QUuid());

         public:


Non-saved file for previous commit

Non-saved file for previous commit

--- DataLogger/eFJenergy.c
+++ DataLogger/eFJenergy.c
@@ -353,28 +353,9 @@
 {
 	#ifndef	NOEMONCMS

-	if ( mysql_conn == NULL || mysql_real_connect (mysql_conn, mysql_server, mysql_username, mysql_password, mysql_database, 0, NULL, 0) == NULL )
-	{
-		printf_outputerror("MySQL query not saved: %s\n",mysql_statement);
-		mysql_close( mysql_conn );
-		mysql_write_affected_rows = -3;
-		return 0;
-	}
-
-	int retval = mysql_query( mysql_conn, mysql_statement);
-	if ( retval == 0 )
-		mysql_write_affected_rows = mysql_affected_rows (mysql_conn);
-	else
-		mysql_write_affected_rows = -1;
-	mysql_close( mysql_conn );
-	pthread_mutex_unlock(&mysql_lock);
-	printf_debug("mysql_write: unlocked\n");
-	return retval;
 	#else
 	printf_outputerror("JSON: %s\n",json_string);
 	fflush(stdout);
-	mysql_write_affected_rows = -2;
-
 	return 0;
 	#endif


Fixed DataSourceFromSocket - added missing CancellationToken

--- DataSourceFromSocket.h
+++ DataSourceFromSocket.h
@@ -42,7 +42,7 @@
 			}

 			ConstByteData data(&_packetBuffer[_dataOffset], _dataSize);
-			size_t processed_size = consumer.Process(data);
+			size_t processed_size = consumer.Process(data, token);
 			_dataOffset += processed_size;
 			_dataSize -= processed_size;
 		}
@@ -90,7 +90,7 @@
 			size_t processed_size = 0;
 			{
 				MutexUnlock ul(l);
-				processed_size = consumer.Process(r.GetData());
+				processed_size = consumer.Process(r.GetData(), token);
 			}

 			r.Pop(processed_size);


Работает(а раньше, а раньше, оказывается, нет)

--- rscs/_source/servo.c
+++ rscs/_source/servo.c
@@ -57,7 +57,7 @@
 	OCR1A = 20 * TEAK_IN_MS / PRESCALER;
 	OCR1B = current->ocr;

-	TCCR1A |= (0<<WGM10) | (0<<WGM11); // CTC, OCR1A
+	TCCR1A |= (0<<WGM10) | (0<<WGM11); 			// CTC, OCR1A
 	TCCR1B |= (1<<WGM12) | (0<<WGM13)
 			| (0<<CS10) | (1<<CS11) | (0<<CS12); //prescaler - 8
 #ifdef __AVR_ATmega328P__
@@ -73,7 +73,7 @@
 	servo->max = TEAK_IN_MS * 2.2 / PRESCALER;
 	servo->id = id;
 	servo->mask = (1 << id);
-	servo->ocr = (servo->min+servo->max)/2;
+	servo->ocr = (servo->max + servo->min) / 2;
 	servo->new_ocr = -1;
 }

@@ -162,7 +162,7 @@
 		t = t->next;
 	}
 	if(t == NULL) { return;}
-	t->new_ocr = (mcs * TEAK_IN_MS) / 1000.0 ;
+	t->new_ocr = (mcs * TEAK_IN_MS) / (1000.0 * PRESCALER) ;
 }

 int _set_angle(rscs_servo *servo)
@@ -184,11 +184,17 @@

 ISR(TIMER1_COMPB_vect)
 {
-	do
+	while (1)
 	{
 		RSCS_SERVO_PORT &= ~current->mask;
-		current = current->next;
-	} while (current->next != NULL && current->next->ocr == current->ocr);
+		if (current->next != NULL && current->next->ocr == current->ocr){
+			current = current->next;
+		}
+		else{
+			current = current->next;
+			break;
+		}
+	}

 	if(current == NULL)
 	{
@@ -203,9 +209,8 @@
 		}
 		current = head;
 	}
-
-
 	OCR1B = current->ocr;
+
 }

 ISR(TIMER1_COMPA_vect)


Add missing #include <string> in a new file that uses std::string.
Review URL: http://codereview.chromium.org/200113

git-svn-id: dd90618784b6a4b323ea0c23a071cb1c9e6f2ac7@26067 4ff67af0-8c30-449e-8e8b-ad334ec8d88c

--- app/sql/connection.h
+++ app/sql/connection.h
@@ -7,6 +7,7 @@

 #include <map>
 #include <set>
+#include <string>

 #include "base/basictypes.h"
 #include "base/ref_counted.h"


Problem: zebra has no examples Solution: add a hello world example

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

--- examples/hello/hello.c
+++ examples/hello/hello.c
@@ -0,0 +1,48 @@
+#include <zebra.h>
+
+int main()
+{
+    //  Create and start web server
+    zactor_t *zeb_microhttpd = zactor_new (zeb_microhttpd_actor, NULL);
+
+    zstr_send (zeb_microhttpd, "START");
+    zsock_wait (zeb_microhttpd);             //  Wait until actor started
+
+    zstr_sendx (zeb_microhttpd, "ENDPOINT", "inproc://http_broker", NULL);
+    zsock_wait (zeb_microhttpd);             //  Wait until endpoint configured
+
+    //  Create and start broker
+    zactor_t *broker = zactor_new (zeb_broker, "broker");
+    zstr_sendx (broker, "BIND", "inproc://http_broker", NULL);
+
+    //  Create and connect handler
+    zeb_client_t *handler = zeb_client_new ();
+    zeb_client_connect (handler, "inproc://http_broker",  1000, "handler");
+    zeb_client_set_handler (handler, "GET", "/hello");
+
+    printf("Enter http://localhost:8888/hello into your browser!\n");
+    //  Receive Request
+    zmsg_t *request = zeb_client_recv (handler);
+    xrap_msg_t *xrap_msg = xrap_msg_decode (&request);
+    xrap_msg_destroy (&xrap_msg);
+
+    //  Send Response
+    xrap_msg = xrap_msg_new (XRAP_MSG_GET_OK);
+    xrap_msg_set_status_code (xrap_msg, 200);
+    xrap_msg_set_content_type (xrap_msg, "text/plain");
+    xrap_msg_set_content_body (xrap_msg, "Hello World!");
+    zmsg_t *response = xrap_msg_encode (&xrap_msg);
+    zeb_client_deliver (handler, zeb_client_sender (handler), &response);
+    zuuid_t *sender = zeb_client_sender (handler);
+    zuuid_destroy (&sender);
+
+    //  Cleanup
+    zeb_client_destroy (&handler);
+    zactor_destroy (&broker);
+    zstr_send (zeb_microhttpd, "STOP");
+    zsock_wait (zeb_microhttpd);             //  Wait until actor stopped
+    zactor_destroy (&zeb_microhttpd);
+
+    printf("Done!\n");
+    return 0;
+}


Include stdio.h for snprintf().

Include stdio.h for snprintf().

--- whisperlib/base/log.h
+++ whisperlib/base/log.h
@@ -16,6 +16,8 @@
 #ifndef _WHISPERLIB_BASE_LOG_H
 #define _WHISPERLIB_BASE_LOG_H

+#include <stdio.h>
+
 #ifdef ANDROID
 #include <android/log.h>
 #include <sstream>


emplace

emplace

--- src/main/include/ConcurrentQueue.h
+++ src/main/include/ConcurrentQueue.h
@@ -14,14 +14,14 @@
         void push(const T& t)
         {
             std::lock_guard<std::mutex> lock(mutex_);
-            queue_.push_front(t);
+            queue_.emplace_back(t);
         }

         T pop()
         {
             std::lock_guard<std::mutex> lock(mutex_);
-            T v = queue_.back();
-            queue_.pop_back();
+            T v = queue_.front();
+            queue_.pop_front();
             return v;
         }


I don't know exactly how licence issues work here, but let's make clear that the (only) licence in this file is just the PHP licence of the original piece of code

--- clients/src/php/Cimpl/php_monetdb.c
+++ clients/src/php/Cimpl/php_monetdb.c
@@ -1,3 +1,5 @@
+/* this file is based on the PostgreSQL PHP module, which carried the
+ * following licence: */
 /*
    +----------------------------------------------------------------------+
    | PHP Version 5                                                        |
@@ -15,12 +17,12 @@
    | Authors: Zeev Suraski <zeev@zend.com>                                |
    |          Jouni Ahto <jouni.ahto@exdec.fi>                            |
    |          Yasuo Ohgaki <yohgaki@php.net>                              |
-   |          Youichi Iwakiri <yiwakiri@st.rim.or.jp> (m_copy_*)         |
+   |          Youichi Iwakiri <yiwakiri@st.rim.or.jp> (m_copy_*)          |
    |          Chris Kings-Lynne <chriskl@php.net> (v3 protocol)           |
-   |          Fabian Groffen <fabian@cwi.nl> (MonetDB version)            |
    +----------------------------------------------------------------------+
  */
-
+/* afterwards the file was changed for MonetDB by MonetDB developers */
+
 /* $Id$ */
 #include <clients_config.h>


Delete ui_editaddressdialog.h

Delete ui_editaddressdialog.h

--- build/ui_editaddressdialog.h
+++ build/ui_editaddressdialog.h
@@ -1,110 +0,0 @@
-/********************************************************************************
-** Form generated from reading UI file 'editaddressdialog.ui'
-**
-** Created by: Qt User Interface Compiler version 4.8.5
-**
-** WARNING! All changes made in this file will be lost when recompiling UI file!
-********************************************************************************/
-
-#ifndef UI_EDITADDRESSDIALOG_H
-#define UI_EDITADDRESSDIALOG_H
-
-#include <QtCore/QVariant>
-#include <QtGui/QAction>
-#include <QtGui/QApplication>
-#include <QtGui/QButtonGroup>
-#include <QtGui/QDialog>
-#include <QtGui/QDialogButtonBox>
-#include <QtGui/QFormLayout>
-#include <QtGui/QHeaderView>
-#include <QtGui/QLabel>
-#include <QtGui/QLineEdit>
-#include <QtGui/QVBoxLayout>
-
-QT_BEGIN_NAMESPACE
-
-class Ui_EditAddressDialog
-{
-public:
-    QVBoxLayout *verticalLayout;
-    QFormLayout *formLayout;
-    QLabel *label;
-    QLineEdit *labelEdit;
-    QLabel *label_2;
-    QLineEdit *addressEdit;
-    QDialogButtonBox *buttonBox;
-
-    void setupUi(QDialog *EditAddressDialog)
-    {
-        if (EditAddressDialog->objectName().isEmpty())
-            EditAddressDialog->setObjectName(QString::fromUtf8("EditAddressDialog"));
-        EditAddressDialog->resize(457, 126);
-        verticalLayout = new QVBoxLayout(EditAddressDialog);
-        verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
-        formLayout = new QFormLayout();
-        formLayout->setObjectName(QString::fromUtf8("formLayout"));
-        formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
-        label = new QLabel(EditAddressDialog);
-        label->setObjectName(QString::fromUtf8("label"));
-
-        formLayout->setWidget(0, QFormLayout::LabelRole, label);
-
-        labelEdit = new QLineEdit(EditAddressDialog);
-        labelEdit->setObjectName(QString::fromUtf8("labelEdit"));
-
-        formLayout->setWidget(0, QFormLayout::FieldRole, labelEdit);
-
-        label_2 = new QLabel(EditAddressDialog);
-        label_2->setObjectName(QString::fromUtf8("label_2"));
-
-        formLayout->setWidget(1, QFormLayout::LabelRole, label_2);
-
-        addressEdit = new QLineEdit(EditAddressDialog);
-        addressEdit->setObjectName(QString::fromUtf8("addressEdit"));
-
-        formLayout->setWidget(1, QFormLayout::FieldRole, addressEdit);
-
-
-        verticalLayout->addLayout(formLayout);
-
-        buttonBox = new QDialogButtonBox(EditAddressDialog);
-        buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
-        buttonBox->setOrientation(Qt::Horizontal);
-        buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
-
-        verticalLayout->addWidget(buttonBox);
-
-#ifndef QT_NO_SHORTCUT
-        label->setBuddy(labelEdit);
-        label_2->setBuddy(addressEdit);
-#endif // QT_NO_SHORTCUT
-
-        retranslateUi(EditAddressDialog);
-        QObject::connect(buttonBox, SIGNAL(accepted()), EditAddressDialog, SLOT(accept()));
-        QObject::connect(buttonBox, SIGNAL(rejected()), EditAddressDialog, SLOT(reject()));
-
-        QMetaObject::connectSlotsByName(EditAddressDialog);
-    } // setupUi
-
-    void retranslateUi(QDialog *EditAddressDialog)
-    {
-        EditAddressDialog->setWindowTitle(QApplication::translate("EditAddressDialog", "Edit Address", 0, QApplication::UnicodeUTF8));
-        label->setText(QApplication::translate("EditAddressDialog", "&Label", 0, QApplication::UnicodeUTF8));
-#ifndef QT_NO_TOOLTIP
-        labelEdit->setToolTip(QApplication::translate("EditAddressDialog", "The label associated with this address book entry", 0, QApplication::UnicodeUTF8));
-#endif // QT_NO_TOOLTIP
-        label_2->setText(QApplication::translate("EditAddressDialog", "&Address", 0, QApplication::UnicodeUTF8));
-#ifndef QT_NO_TOOLTIP
-        addressEdit->setToolTip(QApplication::translate("EditAddressDialog", "The address associated with this address book entry. This can only be modified for sending addresses.", 0, QApplication::UnicodeUTF8));
-#endif // QT_NO_TOOLTIP
-    } // retranslateUi
-
-};
-
-namespace Ui {
-    class EditAddressDialog: public Ui_EditAddressDialog {};
-} // namespace Ui
-
-QT_END_NAMESPACE
-
-#endif // UI_EDITADDRESSDIALOG_H


Added references to USB IAD

Added references to USB IAD

--- inc/usb_std.h
+++ inc/usb_std.h
@@ -108,6 +108,9 @@
 #define USB_CLASS_VENDOR            0xFF    /**<\brief Vendor specific class.*/
 #define USB_SUBCLASS_VENDOR         0xFF    /**<\brief Vendor specific subclass.*/
 #define USB_PROTO_VENDOR            0xFF    /**<\brief Vendor specific protocol.*/
+#define USB_CLASS_IAD               0xEF    /**<\brief Class defined on interface association level.*/
+#define USB_SUBCLASS_IAD            0x02    /**<\brief Subclass defined on interface association level.*/
+#define USB_PROTO_IAD               0x01    /**<\brief Protocol defined on interface association level.*/
 /** @} */

 /**\name USB Standard descriptor types


removed lexan.h

removed lexan.h

git-svn-id: 28d9401aa571d5108e51b194aae6f24ca5964c06@11723 8cc4aa7f-3514-0410-904f-f2cc9021211c

--- include/css.h
+++ include/css.h
@@ -174,7 +174,6 @@
 #include "ivaria/conout.h"
 #include "ivaria/iso.h"
 #include "ivaria/keyval.h"
-#include "ivaria/lexan.h"
 #include "ivaria/mapnode.h"
 #include "ivaria/perfstat.h"
 #include "ivaria/pmeter.h"


remove unnecessary _bytes_inflight check

--- include/h2o.h
+++ include/h2o.h
@@ -2129,6 +2129,7 @@
 static inline h2o_iovec_t h2o_doublebuffer_prepare(h2o_doublebuffer_t *db, h2o_buffer_t **receiving, size_t max_bytes)
 {
     assert(!db->inflight);
+    assert(max_bytes != 0);

     if (db->buf->size == 0) {
         if ((*receiving)->size == 0)
@@ -2140,8 +2141,7 @@
     }
     if ((db->_bytes_inflight = db->buf->size) > max_bytes)
         db->_bytes_inflight = max_bytes;
-    if (db->_bytes_inflight > 0)
-        db->inflight = 1;
+    db->inflight = 1;
     return h2o_iovec_init(db->buf->bytes, db->_bytes_inflight);
 }


Correct comment

Correct comment

--- myfilter.c
+++ myfilter.c
@@ -78,7 +78,7 @@
     exit(EXIT_SUCCESS);
 }

-/* Print error meassage and exit */
+/* Print error message and exit */
 static void perror_exit(const char *msg)
 {
 	perror(msg);


ELF loader: ensure the area is available for MAP_FIXED allocations

--- elf_loader/elf_loader.c
+++ elf_loader/elf_loader.c
@@ -120,12 +120,6 @@
   char *tmpmem;
   size_t phnum;

-  // Reserve the area below MAMBO's image for the application. libelf uses the heap.
-  uintptr_t tmpbase = max(PAGE_SIZE, 0x8000);
-  size_t tmpsz = align_lower((uintptr_t)&__ehdr_start-tmpbase, PAGE_SIZE);
-  tmpmem = mmap((void *)tmpbase, tmpsz, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);
-  assert(tmpmem !=  MAP_FAILED);
-
   fd = open(filename, O_RDONLY);
   if (fd < 0) {
     printf("Couldn't open file %s\n", filename);
@@ -171,27 +165,39 @@
   elf_getphdrnum(elf, &phnum);
   phdr = ELF_GETPHDR(elf);

-  munmap(tmpmem, tmpsz);
-
   /* entry address is the actual execution entry point, either in the interpreter
      (if one is used), or in the executable */
   *entry_addr = ehdr->e_entry;

   /* Allocate the whole memory region, using ASLR if enabled in the kernel */
   void *base_addr = NULL;
-  uintptr_t max_size = 0;
+  uintptr_t min_addr = UINTPTR_MAX;
+  uintptr_t max_addr = 0;
+
+  for (int i = 0; i < phnum; i++) {
+    if (phdr[i].p_type == PT_LOAD) {
+      uintptr_t end = phdr[i].p_vaddr + phdr[i].p_memsz;
+      if (end > max_addr) {
+        max_addr = end;
+      }
+      if (phdr[i].p_vaddr < min_addr) {
+        min_addr = phdr[i].p_vaddr;
+      }
+    }
+  }
+
   if (ehdr->e_type == ET_DYN) {
-    for (int i = 0; i < phnum; i++) {
-      if (phdr[i].p_type == PT_LOAD) {
-        uintptr_t size = phdr[i].p_vaddr + phdr[i].p_memsz;
-        if (size > max_size) {
-          max_size = size;
-        }
-      }
-    }
-    base_addr = mmap(NULL, max_size, PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+    assert(min_addr == 0);
+  } else {
+    assert(min_addr != 0);
+  }
+
+  base_addr = mmap((void *)min_addr, max_addr - min_addr, PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+  if (ehdr->e_type == ET_DYN) {
     assert(base_addr != MAP_FAILED);
     *entry_addr += (uintptr_t)base_addr;
+  } else {
+    assert(base_addr == (void*)min_addr);
   }

   // AT_ENTRY in the AUXV points to the original executable


more tests

more tests

git-svn-id: f2acecaac6fbd5a03f3d4799db58dda434111981@25642 3eda493b-6a19-0410-b2e0-ec8ea4dd8fda

--- pfl/tests/dynarray/dynarray_test.c
+++ pfl/tests/dynarray/dynarray_test.c
@@ -28,6 +28,7 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>

 #include "pfl/cdefs.h"
@@ -177,5 +178,19 @@

 	CHECK(&da, NULL);

+	psc_dynarray_free(&da);
+
+	psc_dynarray_init(&da);
+	psc_dynarray_add(&da, "foobar-a");
+	psc_dynarray_add(&da, "foobar-b");
+	psc_dynarray_add(&da, "foobar-c");
+	psc_assert(strcmp(psc_dynarray_getpos(&da, psc_dynarray_bsearch(
+	    &da, "foobar-b", (void *)strcmp)), "foobar-b") == 0);
+	psc_assert(strcmp(psc_dynarray_getpos(&da, psc_dynarray_bsearch(
+	    &da, "foobar-a", (void *)strcmp)), "foobar-a") == 0);
+	psc_assert(strcmp(psc_dynarray_getpos(&da, psc_dynarray_bsearch(
+	    &da, "foobar-c", (void *)strcmp)), "foobar-c") == 0);
+	psc_dynarray_free(&da);
+
 	exit(0);
 }


Changed function names from "device" to "Port2"

error: pathspec 'experiments/RubyBusInterface/Port2Interface.c' did not match any file(s) known to git

--- experiments/RubyBusInterface/Port2Interface.c
+++ experiments/RubyBusInterface/Port2Interface.c
@@ -0,0 +1,127 @@
+/*
+Ruby Objects to C Datatypes:
+
+int	            NUM2INT(Numeric)	                (Includes type check)
+int	            FIX2INT(Fixnum)	                    (Faster)
+unsigned int	NUM2UINT(Numeric)	                (Includes type check)
+unsigned int	FIX2UINT(Fixnum)	                (Includes type check)
+long	        NUM2LONG(Numeric)	                (Includes type check)
+long	        FIX2LONG(Fixnum)	                (Faster)
+unsigned long	NUM2ULONG(Numeric)	                (Includes type check)
+char	        NUM2CHR(Numeric or String)	        (Includes type check)
+char *	        STR2CSTR(String)
+char *	        rb_str2cstr(String, int *length)	Returns length as well
+double	        NUM2DBL(Numeric)
+
+interest link:
+http://elinux.org/EBC_Exercise_11b_gpio_via_mmap memory map - Rob's
+https://github.com/petermancuso/bbb/commit/1ef2033db0b89adfd8c39e6041287b066428e007
+https://groups.google.com/forum/#!topic/beagleboard/91ikp6Mxi0s  Mike's
+http://rampic.com/beagleboneblack/ PRU - Programming Realtime Unit.
+http://stackoverflow.com/questions/13124271/driving-beaglebone-gpio-through-dev-mem
+https://github.com/majestik666/Beagle_GPIO/blob/master/Beagle_GPIO.cc
+*/
+
+// Include the Ruby headers and goodies
+#include "ruby.h"
+/*
+    Call the ruby code to enable the following pins to :IN mode
+    @bbb_data0 = GPIOPin.new(:P8_45, :IN)
+    @bbb_data1 = GPIOPin.new(:P8_46, :IN)
+    @bbb_data2 = GPIOPin.new(:P8_43, :IN)
+    @bbb_data3 = GPIOPin.new(:P8_44, :IN)
+    @bbb_data4 = GPIOPin.new(:P8_41, :IN)
+    @bbb_data5 = GPIOPin.new(:P8_42, :IN)
+    @bbb_data6 = GPIOPin.new(:P8_39, :IN)
+    @bbb_data7 = GPIOPin.new(:P8_40, :IN)
+*/
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h> // sleep
+
+#define GPIO_DATAOUT 0x13C
+#define GPIO_SETDATAOUT 0x194
+#define GPIO_CLEARDATAOUT 0x190
+#define GPIO_OE 0x134
+#define GPIO_DATAIN 0x138
+
+int dataBusMask = 0xff<<6;
+int AddrShift = 14;
+int DataShift = 6;
+#define GPIO2_START_ADDR 0x481AC000 /*0x44e108a4*/
+#define GPIO2_END_ADDR   0x481AE000  /*0x44e10800 */
+#define GPIO2_SIZE (GPIO2_END_ADDR - GPIO2_START_ADDR)
+
+#define Strobe (1<<23) /*pin 22 for strobe*/
+#define RdnWr (1<<22) // Read on High
+
+volatile void *gpio_addr;
+volatile unsigned int *gpio_AddrData_OE; // gpio_OE
+volatile unsigned int *gpio_AddrData_DataOut;
+volatile unsigned int *gpio_AddrData_DataIn;
+
+
+// Defining a space for information and references about the module to be stored internally
+VALUE Port2Interface = Qnil;
+
+// Prototype for the initialization method - Ruby calls this, not you
+void Init_Port2Interface();
+
+// Prototype for our method 'getFromPort2' - methods are prefixed by 'method_' here
+VALUE method_getFromPort2(VALUE self, VALUE addrRuby);
+void method_sendToPort2(VALUE self, VALUE addrRuby, VALUE addrData);
+void method_initPort2(VALUE self);
+
+// The initialization method for this module
+void Init_Port2Interface() {
+	Port2Interface = rb_define_module("Port2Interface");
+	rb_define_method(Port2Interface, "getFromPort2", method_getFromPort2, 1);
+	rb_define_method(Port2Interface, "sendToPort2", method_sendToPort2, 2);
+	rb_define_method(Port2Interface, "initPort2", method_initPort2, 0);
+}
+
+// Our 'getFromPort2' method.. it simply returns a value of '10' for now.
+/*
+VALUE method_getFromPort2(VALUE self) {
+	int x = 10;
+	return INT2NUM(x);
+}
+*/
+
+VALUE method_getFromPort2(VALUE self, VALUE addrRuby) {
+    int toBeReturned;
+    int dataHold;
+    dataHold = 0; // Flush buffer.
+    dataHold |= FIX2INT(addrRuby)<<AddrShift;
+    dataHold |= RdnWr;  // Extra op with no value...
+    *gpio_AddrData_OE = 0; // All output is on...
+    *gpio_AddrData_OE ^= dataBusMask; // It just needs it.
+    *gpio_AddrData_DataOut = dataHold;
+
+    toBeReturned = 0x000ff&*gpio_AddrData_DataIn>>DataShift;
+    *gpio_AddrData_DataOut ^= RdnWr;
+    // toBeReturned = 0x00ff&&(toBeReturned>>6);
+    // printf("oe=%08x data %08x\n",*gpio_AddrData_OE,toBeReturned);
+	return INT2NUM(toBeReturned);
+}
+
+void method_sendToPort2(VALUE self, VALUE addrRuby, VALUE addrData) {
+    int dataHold;
+    dataHold = 0; // Flush buffer.
+
+    dataHold |= FIX2INT(addrRuby)<<AddrShift;
+    dataHold |= FIX2INT(addrData)<<DataShift;
+
+    *gpio_AddrData_OE = 0; // All output is on...
+    *gpio_AddrData_DataOut = dataHold;
+    *gpio_AddrData_DataOut ^= Strobe; // The "write pulte"
+}
+
+void method_initPort2(VALUE self) {
+    int fd = open("/dev/mem", O_RDWR);
+    gpio_addr = mmap(0, GPIO2_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, GPIO2_START_ADDR);
+    gpio_AddrData_OE = gpio_addr+GPIO_OE; // Sets the strobe register to output.
+    gpio_AddrData_DataOut = gpio_addr+GPIO_DATAOUT;
+    gpio_AddrData_DataIn = gpio_addr+GPIO_DATAIN;
+}