drm: Parse color format information in CEA blocks

The CEA extension block has a field which describes which YCbCr modes are
supported by the device, use it to fill the drm_display_info color_formats
fields. Also the existence of a CEA extension block is used as indication
that the device supports RGB.

Signed-off-by: Lars-Peter Clausen <3318dc5ce3e4fb7c28a0b841b6801c884e1d0896@metafoo.de>
Reviewed-by: Jesse Barnes <bc7add126c2dbb8382bf1c28ac262b9363a32706@virtuousgeek.org>
Signed-off-by: Dave Airlie <f2295d84e358395675bc8031be58672073ae065e@redhat.com>

--- drivers/gpu/drm/drm_edid.c
+++ drivers/gpu/drm/drm_edid.c
@@ -1312,6 +1312,8 @@
 #define VENDOR_BLOCK    0x03
 #define SPEAKER_BLOCK	0x04
 #define EDID_BASIC_AUDIO	(1 << 6)
+#define EDID_CEA_YCRCB444	(1 << 5)
+#define EDID_CEA_YCRCB422	(1 << 4)

 /**
  * Search EDID for CEA extension block.
@@ -1666,11 +1668,27 @@
 	info->bpc = 0;
 	info->color_formats = 0;

+	if (edid->revision < 3)
+		return;
+
+	if (!(edid->input & DRM_EDID_INPUT_DIGITAL))
+		return;
+
+	/* Get data from CEA blocks if present */
+	edid_ext = drm_find_cea_extension(edid);
+	if (edid_ext) {
+		info->cea_rev = edid_ext[1];
+
+		/* The existence of a CEA block should imply RGB support */
+		info->color_formats = DRM_COLOR_FORMAT_RGB444;
+		if (edid_ext[3] & EDID_CEA_YCRCB444)
+			info->color_formats |= DRM_COLOR_FORMAT_YCRCB444;
+		if (edid_ext[3] & EDID_CEA_YCRCB422)
+			info->color_formats |= DRM_COLOR_FORMAT_YCRCB422;
+	}
+
 	/* Only defined for 1.4 with digital displays */
 	if (edid->revision < 4)
-		return;
-
-	if (!(edid->input & DRM_EDID_INPUT_DIGITAL))
 		return;

 	switch (edid->input & DRM_EDID_DIGITAL_DEPTH_MASK) {
@@ -1698,18 +1716,11 @@
 		break;
 	}

-	info->color_formats = DRM_COLOR_FORMAT_RGB444;
+	info->color_formats |= DRM_COLOR_FORMAT_RGB444;
 	if (edid->features & DRM_EDID_FEATURE_RGB_YCRCB444)
 		info->color_formats |= DRM_COLOR_FORMAT_YCRCB444;
 	if (edid->features & DRM_EDID_FEATURE_RGB_YCRCB422)
 		info->color_formats |= DRM_COLOR_FORMAT_YCRCB422;
-
-	/* Get data from CEA blocks if present */
-	edid_ext = drm_find_cea_extension(edid);
-	if (!edid_ext)
-		return;
-
-	info->cea_rev = edid_ext[1];
 }

 /**


Added color prompt

Added color prompt

--- Include/KAI/ConsoleColor.h
+++ Include/KAI/ConsoleColor.h
@@ -13,6 +13,9 @@
 		Warning,
 		StackEntry,
 		StackIndex,
+		LanguageName,
+		NumObjects,
+		Pathname,
 		Last
 	};


hwmon/smsc47b397: Don't report missing fans as spinning at 82 RPM

Also protects ourselves against a possible division by zero.

Signed-off-by: Jean Delvare <49ad6a9f5aa17024c23048df346d55bda6837e01@linux-fr.org>
Signed-off-by: Mark M. Hoffman <5aed555d2bd1319e6397948a784e5d0b93442eeb@lightlink.com>

--- drivers/hwmon/smsc47b397.c
+++ drivers/hwmon/smsc47b397.c
@@ -174,6 +174,8 @@
    REG: count of 90kHz pulses / revolution */
 static int fan_from_reg(u16 reg)
 {
+	if (reg == 0 || reg == 0xffff)
+		return 0;
 	return 90000 * 60 / reg;
 }


i2c/eeprom: Hide Sony Vaio serial numbers

The sysfs interface to DMI data takes care to not make the system
serial number and UUID world-readable, presumably due to privacy
concerns. For consistency, we should not let the eeprom driver
export these same strings to the world on Sony Vaio laptops.
Instead, only make them readable by root, as we already do for BIOS
passwords.

Signed-off-by: Jean Delvare <49ad6a9f5aa17024c23048df346d55bda6837e01@linux-fr.org>

--- drivers/i2c/chips/eeprom.c
+++ drivers/i2c/chips/eeprom.c
@@ -128,13 +128,20 @@
 	for (slice = off >> 5; slice <= (off + count - 1) >> 5; slice++)
 		eeprom_update_client(client, slice);

-	/* Hide Vaio security settings to regular users (16 first bytes) */
-	if (data->nature == VAIO && off < 16 && !capable(CAP_SYS_ADMIN)) {
-		size_t in_row1 = 16 - off;
-		in_row1 = min(in_row1, count);
-		memset(buf, 0, in_row1);
-		if (count - in_row1 > 0)
-			memcpy(buf + in_row1, &data->data[16], count - in_row1);
+	/* Hide Vaio private settings to regular users:
+	   - BIOS passwords: bytes 0x00 to 0x0f
+	   - UUID: bytes 0x10 to 0x1f
+	   - Serial number: 0xc0 to 0xdf */
+	if (data->nature == VAIO && !capable(CAP_SYS_ADMIN)) {
+		int i;
+
+		for (i = 0; i < count; i++) {
+			if ((off + i <= 0x1f) ||
+			    (off + i >= 0xc0 && off + i <= 0xdf))
+				buf[i] = 0;
+			else
+				buf[i] = data->data[off + i];
+		}
 	} else {
 		memcpy(buf, &data->data[off], count);
 	}
@@ -204,7 +211,7 @@
 		 && i2c_smbus_read_byte(new_client) == 'G'
 		 && i2c_smbus_read_byte(new_client) == '-') {
 			dev_info(&new_client->dev, "Vaio EEPROM detected, "
-				"enabling password protection\n");
+				 "enabling privacy protection\n");
 			data->nature = VAIO;
 		}
 	}


iommu/omap: Allocate archdata on the fly for DT-based devices

The OMAP IOMMU driver locates the IOMMU associated to a device using the
IOMMU name stored in the device archdata iommu field. That field is
expected to be populated by platform code and is left unset for DT-based
devices. This results in a crash when the IOMMU driver attaches a domain
to a device.

Fix this by allocating the archdata iommu structure when devices are
added and freeing when they are removed. Devices without an OF node, and
devices without an iommus property in their OF node are ignored. The
iommu name is initialized from the IOMMU device node name.

This should be simplified when removing non-DT support completely from
the IOMMU users as the IOMMU name won't be needed anymore, and the
IOMMU device pointer could then be stored in the archdata iommu field
directly.

Signed-off-by: Laurent Pinchart <3ded2f39a78f0d7044839546f95841842b4d7c96@ideasonboard.com>
[68636d6b0a4dfe1213ee9d7712e75a8cc339119f@ti.com: updated to use device name instead of OF name]
Signed-off-by: Suman Anna <68636d6b0a4dfe1213ee9d7712e75a8cc339119f@ti.com>
Signed-off-by: Joerg Roedel <4688a6871ff025801033b3c4b039d55a29f8f937@8bytes.org>

--- drivers/iommu/omap-iommu.c
+++ drivers/iommu/omap-iommu.c
@@ -1253,6 +1253,49 @@
 	return 0;
 }

+static int omap_iommu_add_device(struct device *dev)
+{
+	struct omap_iommu_arch_data *arch_data;
+	struct device_node *np;
+
+	/*
+	 * Allocate the archdata iommu structure for DT-based devices.
+	 *
+	 * TODO: Simplify this when removing non-DT support completely from the
+	 * IOMMU users.
+	 */
+	if (!dev->of_node)
+		return 0;
+
+	np = of_parse_phandle(dev->of_node, "iommus", 0);
+	if (!np)
+		return 0;
+
+	arch_data = kzalloc(sizeof(*arch_data), GFP_KERNEL);
+	if (!arch_data) {
+		of_node_put(np);
+		return -ENOMEM;
+	}
+
+	arch_data->name = kstrdup(dev_name(dev), GFP_KERNEL);
+	dev->archdata.iommu = arch_data;
+
+	of_node_put(np);
+
+	return 0;
+}
+
+static void omap_iommu_remove_device(struct device *dev)
+{
+	struct omap_iommu_arch_data *arch_data = dev->archdata.iommu;
+
+	if (!dev->of_node || !arch_data)
+		return;
+
+	kfree(arch_data->name);
+	kfree(arch_data);
+}
+
 static struct iommu_ops omap_iommu_ops = {
 	.domain_init	= omap_iommu_domain_init,
 	.domain_destroy	= omap_iommu_domain_destroy,
@@ -1262,6 +1305,8 @@
 	.unmap		= omap_iommu_unmap,
 	.iova_to_phys	= omap_iommu_iova_to_phys,
 	.domain_has_cap	= omap_iommu_domain_has_cap,
+	.add_device	= omap_iommu_add_device,
+	.remove_device	= omap_iommu_remove_device,
 	.pgsize_bitmap	= OMAP_IOMMU_PGSIZES,
 };


[PATCH] -Wundef fixes (hisax)

[PATCH] -Wundef fixes (hisax)

CARD_... in hisax are all used with #if; CARD_FN_ENTERNOW_PCI lacks define
to 0 if corresponding config option is not set.

Signed-off-by: Al Viro <de609eb4d5d70b1d38ec6642adbfc33a2781f63c@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@osdl.org>

--- drivers/isdn/hisax/hisax.h
+++ drivers/isdn/hisax/hisax.h
@@ -1241,6 +1241,8 @@

 #ifdef CONFIG_HISAX_ENTERNOW_PCI
 #define CARD_FN_ENTERNOW_PCI 1
+#else
+#define CARD_FN_ENTERNOW_PCI 0
 #endif

 #define TEI_PER_CARD 1


Input: rc-keymap - return KEY_RESERVED for unknown mappings

Do not respond with -EINVAL to EVIOCGKEYCODE for not-yet-mapped
scancodes, but rather return KEY_RESERVED.

This fixes breakage with Ubuntu's input-kbd utility that stopped
returning full keymaps for remote controls.

Tested-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>
Tested-by: Mark Lord <c65a0fb7e74ffd2c9fc3a0f9aacb0f6a24b0a68b@teksavvy.com>
Signed-off-by: Dmitry Torokhov <10a8c465cefc9bdd6c925e26964d23c90f1141cc@mail.ru>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- drivers/media/rc/rc-main.c
+++ drivers/media/rc/rc-main.c
@@ -458,20 +458,26 @@
 		index = ir_lookup_by_scancode(rc_map, scancode);
 	}

-	if (index >= rc_map->len) {
-		if (!(ke->flags & INPUT_KEYMAP_BY_INDEX))
-			IR_dprintk(1, "unknown key for scancode 0x%04x\n",
-				   scancode);
+	if (index < rc_map->len) {
+		entry = &rc_map->scan[index];
+
+		ke->index = index;
+		ke->keycode = entry->keycode;
+		ke->len = sizeof(entry->scancode);
+		memcpy(ke->scancode, &entry->scancode, sizeof(entry->scancode));
+
+	} else if (!(ke->flags & INPUT_KEYMAP_BY_INDEX)) {
+		/*
+		 * We do not really know the valid range of scancodes
+		 * so let's respond with KEY_RESERVED to anything we
+		 * do not have mapping for [yet].
+		 */
+		ke->index = index;
+		ke->keycode = KEY_RESERVED;
+	} else {
 		retval = -EINVAL;
 		goto out;
 	}
-
-	entry = &rc_map->scan[index];
-
-	ke->index = index;
-	ke->keycode = entry->keycode;
-	ke->len = sizeof(entry->scancode);
-	memcpy(ke->scancode, &entry->scancode, sizeof(entry->scancode));

 	retval = 0;


V4L/DVB (10858): vino: convert to video_ioctl2.

Signed-off-by: Hans Verkuil <f625be9dbdcbbd12a043857af148e8fb895d9a1d@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <ad86ba2154032c9f55743a190faa2459a9d61d42@redhat.com>

--- drivers/media/video/vino.c
+++ drivers/media/video/vino.c
@@ -2884,35 +2884,7 @@
 	return VINO_DATA_FMT_NONE;
 }

-static int vino_enum_data_norm(struct vino_channel_settings *vcs, __u32 index)
-{
-	int data_norm = VINO_DATA_NORM_NONE;
-	unsigned long flags;
-
-	spin_lock_irqsave(&vino_drvdata->input_lock, flags);
-	switch(vcs->input) {
-	case VINO_INPUT_COMPOSITE:
-	case VINO_INPUT_SVIDEO:
-		if (index == 0) {
-			data_norm = VINO_DATA_NORM_PAL;
-		} else if (index == 1) {
-			data_norm = VINO_DATA_NORM_NTSC;
-		} else if (index == 2) {
-			data_norm = VINO_DATA_NORM_SECAM;
-		}
-		break;
-	case VINO_INPUT_D1:
-		if (index == 0) {
-			data_norm = VINO_DATA_NORM_D1;
-		}
-		break;
-	}
-	spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
-
-	return data_norm;
-}
-
-static int vino_enum_input(struct vino_channel_settings *vcs, __u32 index)
+static int vino_int_enum_input(struct vino_channel_settings *vcs, __u32 index)
 {
 	int input = VINO_INPUT_NONE;
 	unsigned long flags;
@@ -2991,7 +2963,8 @@

 /* V4L2 ioctls */

-static void vino_v4l2_querycap(struct v4l2_capability *cap)
+static int vino_querycap(struct file *file, void *__fh,
+		struct v4l2_capability *cap)
 {
 	memset(cap, 0, sizeof(struct v4l2_capability));

@@ -3003,16 +2976,18 @@
 		V4L2_CAP_VIDEO_CAPTURE |
 		V4L2_CAP_STREAMING;
 	// V4L2_CAP_OVERLAY, V4L2_CAP_READWRITE
-}
-
-static int vino_v4l2_enuminput(struct vino_channel_settings *vcs,
+	return 0;
+}
+
+static int vino_enum_input(struct file *file, void *__fh,
 			       struct v4l2_input *i)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	__u32 index = i->index;
 	int input;
 	dprintk("requested index = %d\n", index);

-	input = vino_enum_input(vcs, index);
+	input = vino_int_enum_input(vcs, index);
 	if (input == VINO_INPUT_NONE)
 		return -EINVAL;

@@ -3034,9 +3009,10 @@
 	return 0;
 }

-static int vino_v4l2_g_input(struct vino_channel_settings *vcs,
+static int vino_g_input(struct file *file, void *__fh,
 			     unsigned int *i)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	__u32 index;
 	int input;
 	unsigned long flags;
@@ -3057,52 +3033,24 @@
 	return 0;
 }

-static int vino_v4l2_s_input(struct vino_channel_settings *vcs,
-			     unsigned int *i)
-{
+static int vino_s_input(struct file *file, void *__fh,
+			     unsigned int i)
+{
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	int input;
-	dprintk("requested input = %d\n", *i);
-
-	input = vino_enum_input(vcs, *i);
+	dprintk("requested input = %d\n", i);
+
+	input = vino_int_enum_input(vcs, i);
 	if (input == VINO_INPUT_NONE)
 		return -EINVAL;

 	return vino_set_input(vcs, input);
 }

-static int vino_v4l2_enumstd(struct vino_channel_settings *vcs,
-			     struct v4l2_standard *s)
-{
-	int index = s->index;
-	int data_norm;
-
-	data_norm = vino_enum_data_norm(vcs, index);
-	dprintk("standard index = %d\n", index);
-
-	if (data_norm == VINO_DATA_NORM_NONE)
-		return -EINVAL;
-
-	dprintk("standard name = %s\n",
-	       vino_data_norms[data_norm].description);
-
-	memset(s, 0, sizeof(struct v4l2_standard));
-	s->index = index;
-
-	s->id = vino_data_norms[data_norm].std;
-	s->frameperiod.numerator = 1;
-	s->frameperiod.denominator =
-		vino_data_norms[data_norm].fps_max;
-	s->framelines =
-		vino_data_norms[data_norm].framelines;
-	strcpy(s->name,
-	       vino_data_norms[data_norm].description);
-
-	return 0;
-}
-
-static int vino_v4l2_querystd(struct vino_channel_settings *vcs,
+static int vino_querystd(struct file *file, void *__fh,
 			      v4l2_std_id *std)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	unsigned long flags;
 	int err = 0;

@@ -3138,9 +3086,10 @@
 	return err;
 }

-static int vino_v4l2_g_std(struct vino_channel_settings *vcs,
+static int vino_g_std(struct file *file, void *__fh,
 			   v4l2_std_id *std)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	unsigned long flags;

 	spin_lock_irqsave(&vino_drvdata->input_lock, flags);
@@ -3153,9 +3102,10 @@
 	return 0;
 }

-static int vino_v4l2_s_std(struct vino_channel_settings *vcs,
+static int vino_s_std(struct file *file, void *__fh,
 			   v4l2_std_id *std)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	unsigned long flags;
 	int ret = 0;

@@ -3207,185 +3157,152 @@
 	return ret;
 }

-static int vino_v4l2_enum_fmt(struct vino_channel_settings *vcs,
+static int vino_enum_fmt_vid_cap(struct file *file, void *__fh,
 			      struct v4l2_fmtdesc *fd)
 {
 	enum v4l2_buf_type type = fd->type;
 	int index = fd->index;
+
 	dprintk("format index = %d\n", index);

-	switch (fd->type) {
-	case V4L2_BUF_TYPE_VIDEO_CAPTURE:
-		if ((fd->index < 0) ||
-		    (fd->index >= VINO_DATA_FMT_COUNT))
-			return -EINVAL;
-		dprintk("format name = %s\n",
-		       vino_data_formats[index].description);
-
-		memset(fd, 0, sizeof(struct v4l2_fmtdesc));
-		fd->index = index;
-		fd->type = type;
-		fd->pixelformat = vino_data_formats[index].pixelformat;
-		strcpy(fd->description, vino_data_formats[index].description);
-		break;
-	case V4L2_BUF_TYPE_VIDEO_OVERLAY:
-	default:
+	if ((fd->index < 0) ||
+			(fd->index >= VINO_DATA_FMT_COUNT))
 		return -EINVAL;
-	}
-
+	dprintk("format name = %s\n",
+			vino_data_formats[index].description);
+
+	memset(fd, 0, sizeof(struct v4l2_fmtdesc));
+	fd->index = index;
+	fd->type = type;
+	fd->pixelformat = vino_data_formats[index].pixelformat;
+	strcpy(fd->description, vino_data_formats[index].description);
 	return 0;
 }

-static int vino_v4l2_try_fmt(struct vino_channel_settings *vcs,
+static int vino_try_fmt_vid_cap(struct file *file, void *__fh,
 			     struct v4l2_format *f)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	struct vino_channel_settings tempvcs;
 	unsigned long flags;
-
-	switch (f->type) {
-	case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
-		struct v4l2_pix_format *pf = &f->fmt.pix;
-
-		dprintk("requested: w = %d, h = %d\n",
-		       pf->width, pf->height);
-
-		spin_lock_irqsave(&vino_drvdata->input_lock, flags);
-		memcpy(&tempvcs, vcs, sizeof(struct vino_channel_settings));
-		spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
-
-		tempvcs.data_format = vino_find_data_format(pf->pixelformat);
-		if (tempvcs.data_format == VINO_DATA_FMT_NONE) {
-			tempvcs.data_format = VINO_DATA_FMT_GREY;
-			pf->pixelformat =
-				vino_data_formats[tempvcs.data_format].
-				pixelformat;
-		}
-
-		/* data format must be set before clipping/scaling */
-		vino_set_scaling(&tempvcs, pf->width, pf->height);
-
-		dprintk("data format = %s\n",
-		       vino_data_formats[tempvcs.data_format].description);
-
-		pf->width = (tempvcs.clipping.right - tempvcs.clipping.left) /
-			tempvcs.decimation;
-		pf->height = (tempvcs.clipping.bottom - tempvcs.clipping.top) /
-			tempvcs.decimation;
-
-		pf->field = V4L2_FIELD_INTERLACED;
-		pf->bytesperline = tempvcs.line_size;
-		pf->sizeimage = tempvcs.line_size *
-			(tempvcs.clipping.bottom - tempvcs.clipping.top) /
-			tempvcs.decimation;
-		pf->colorspace =
-			vino_data_formats[tempvcs.data_format].colorspace;
-
-		pf->priv = 0;
-		break;
-	}
-	case V4L2_BUF_TYPE_VIDEO_OVERLAY:
-	default:
-		return -EINVAL;
-	}
-
+	struct v4l2_pix_format *pf = &f->fmt.pix;
+
+	dprintk("requested: w = %d, h = %d\n",
+			pf->width, pf->height);
+
+	spin_lock_irqsave(&vino_drvdata->input_lock, flags);
+	memcpy(&tempvcs, vcs, sizeof(struct vino_channel_settings));
+	spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
+
+	tempvcs.data_format = vino_find_data_format(pf->pixelformat);
+	if (tempvcs.data_format == VINO_DATA_FMT_NONE) {
+		tempvcs.data_format = VINO_DATA_FMT_GREY;
+		pf->pixelformat =
+			vino_data_formats[tempvcs.data_format].
+			pixelformat;
+	}
+
+	/* data format must be set before clipping/scaling */
+	vino_set_scaling(&tempvcs, pf->width, pf->height);
+
+	dprintk("data format = %s\n",
+			vino_data_formats[tempvcs.data_format].description);
+
+	pf->width = (tempvcs.clipping.right - tempvcs.clipping.left) /
+		tempvcs.decimation;
+	pf->height = (tempvcs.clipping.bottom - tempvcs.clipping.top) /
+		tempvcs.decimation;
+
+	pf->field = V4L2_FIELD_INTERLACED;
+	pf->bytesperline = tempvcs.line_size;
+	pf->sizeimage = tempvcs.line_size *
+		(tempvcs.clipping.bottom - tempvcs.clipping.top) /
+		tempvcs.decimation;
+	pf->colorspace =
+		vino_data_formats[tempvcs.data_format].colorspace;
+
+	pf->priv = 0;
 	return 0;
 }

-static int vino_v4l2_g_fmt(struct vino_channel_settings *vcs,
+static int vino_g_fmt_vid_cap(struct file *file, void *__fh,
 			   struct v4l2_format *f)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	unsigned long flags;
-
-	switch (f->type) {
-	case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
-		struct v4l2_pix_format *pf = &f->fmt.pix;
-
-		spin_lock_irqsave(&vino_drvdata->input_lock, flags);
-
-		pf->width = (vcs->clipping.right - vcs->clipping.left) /
-			vcs->decimation;
-		pf->height = (vcs->clipping.bottom - vcs->clipping.top) /
-			vcs->decimation;
-		pf->pixelformat =
-			vino_data_formats[vcs->data_format].pixelformat;
-
-		pf->field = V4L2_FIELD_INTERLACED;
-		pf->bytesperline = vcs->line_size;
-		pf->sizeimage = vcs->line_size *
-			(vcs->clipping.bottom - vcs->clipping.top) /
-			vcs->decimation;
-		pf->colorspace =
-			vino_data_formats[vcs->data_format].colorspace;
-
-		pf->priv = 0;
-
-		spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
-		break;
-	}
-	case V4L2_BUF_TYPE_VIDEO_OVERLAY:
-	default:
-		return -EINVAL;
-	}
-
+	struct v4l2_pix_format *pf = &f->fmt.pix;
+
+	spin_lock_irqsave(&vino_drvdata->input_lock, flags);
+
+	pf->width = (vcs->clipping.right - vcs->clipping.left) /
+		vcs->decimation;
+	pf->height = (vcs->clipping.bottom - vcs->clipping.top) /
+		vcs->decimation;
+	pf->pixelformat =
+		vino_data_formats[vcs->data_format].pixelformat;
+
+	pf->field = V4L2_FIELD_INTERLACED;
+	pf->bytesperline = vcs->line_size;
+	pf->sizeimage = vcs->line_size *
+		(vcs->clipping.bottom - vcs->clipping.top) /
+		vcs->decimation;
+	pf->colorspace =
+		vino_data_formats[vcs->data_format].colorspace;
+
+	pf->priv = 0;
+
+	spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
 	return 0;
 }

-static int vino_v4l2_s_fmt(struct vino_channel_settings *vcs,
+static int vino_s_fmt_vid_cap(struct file *file, void *__fh,
 			   struct v4l2_format *f)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	int data_format;
 	unsigned long flags;
-
-	switch (f->type) {
-	case V4L2_BUF_TYPE_VIDEO_CAPTURE: {
-		struct v4l2_pix_format *pf = &f->fmt.pix;
-
-		spin_lock_irqsave(&vino_drvdata->input_lock, flags);
-
-		data_format = vino_find_data_format(pf->pixelformat);
-
-		if (data_format == VINO_DATA_FMT_NONE) {
-			vcs->data_format = VINO_DATA_FMT_GREY;
-			pf->pixelformat =
-				vino_data_formats[vcs->data_format].
-				pixelformat;
-		} else {
-			vcs->data_format = data_format;
-		}
-
-		/* data format must be set before clipping/scaling */
-		vino_set_scaling(vcs, pf->width, pf->height);
-
-		dprintk("data format = %s\n",
-		       vino_data_formats[vcs->data_format].description);
-
-		pf->width = vcs->clipping.right - vcs->clipping.left;
-		pf->height = vcs->clipping.bottom - vcs->clipping.top;
-
-		pf->field = V4L2_FIELD_INTERLACED;
-		pf->bytesperline = vcs->line_size;
-		pf->sizeimage = vcs->line_size *
-			(vcs->clipping.bottom - vcs->clipping.top) /
-			vcs->decimation;
-		pf->colorspace =
-			vino_data_formats[vcs->data_format].colorspace;
-
-		pf->priv = 0;
-
-		spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
-		break;
-	}
-	case V4L2_BUF_TYPE_VIDEO_OVERLAY:
-	default:
-		return -EINVAL;
-	}
-
+	struct v4l2_pix_format *pf = &f->fmt.pix;
+
+	spin_lock_irqsave(&vino_drvdata->input_lock, flags);
+
+	data_format = vino_find_data_format(pf->pixelformat);
+
+	if (data_format == VINO_DATA_FMT_NONE) {
+		vcs->data_format = VINO_DATA_FMT_GREY;
+		pf->pixelformat =
+			vino_data_formats[vcs->data_format].
+			pixelformat;
+	} else {
+		vcs->data_format = data_format;
+	}
+
+	/* data format must be set before clipping/scaling */
+	vino_set_scaling(vcs, pf->width, pf->height);
+
+	dprintk("data format = %s\n",
+	       vino_data_formats[vcs->data_format].description);
+
+	pf->width = vcs->clipping.right - vcs->clipping.left;
+	pf->height = vcs->clipping.bottom - vcs->clipping.top;
+
+	pf->field = V4L2_FIELD_INTERLACED;
+	pf->bytesperline = vcs->line_size;
+	pf->sizeimage = vcs->line_size *
+		(vcs->clipping.bottom - vcs->clipping.top) /
+		vcs->decimation;
+	pf->colorspace =
+		vino_data_formats[vcs->data_format].colorspace;
+
+	pf->priv = 0;
+
+	spin_unlock_irqrestore(&vino_drvdata->input_lock, flags);
 	return 0;
 }

-static int vino_v4l2_cropcap(struct vino_channel_settings *vcs,
+static int vino_cropcap(struct file *file, void *__fh,
 			     struct v4l2_cropcap *ccap)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	const struct vino_data_norm *norm;
 	unsigned long flags;

@@ -3415,9 +3332,10 @@
 	return 0;
 }

-static int vino_v4l2_g_crop(struct vino_channel_settings *vcs,
+static int vino_g_crop(struct file *file, void *__fh,
 			    struct v4l2_crop *c)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	unsigned long flags;

 	switch (c->type) {
@@ -3439,9 +3357,10 @@
 	return 0;
 }

-static int vino_v4l2_s_crop(struct vino_channel_settings *vcs,
+static int vino_s_crop(struct file *file, void *__fh,
 			    struct v4l2_crop *c)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	unsigned long flags;

 	switch (c->type) {
@@ -3461,9 +3380,10 @@
 	return 0;
 }

-static int vino_v4l2_g_parm(struct vino_channel_settings *vcs,
+static int vino_g_parm(struct file *file, void *__fh,
 			    struct v4l2_streamparm *sp)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	unsigned long flags;

 	switch (sp->type) {
@@ -3491,9 +3411,10 @@
 	return 0;
 }

-static int vino_v4l2_s_parm(struct vino_channel_settings *vcs,
+static int vino_s_parm(struct file *file, void *__fh,
 			    struct v4l2_streamparm *sp)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	unsigned long flags;

 	switch (sp->type) {
@@ -3524,9 +3445,10 @@
 	return 0;
 }

-static int vino_v4l2_reqbufs(struct vino_channel_settings *vcs,
+static int vino_reqbufs(struct file *file, void *__fh,
 			     struct v4l2_requestbuffers *rb)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	if (vcs->reading)
 		return -EBUSY;

@@ -3606,9 +3528,10 @@
 		fb->id, fb->size, fb->data_size, fb->offset);
 }

-static int vino_v4l2_querybuf(struct vino_channel_settings *vcs,
+static int vino_querybuf(struct file *file, void *__fh,
 			      struct v4l2_buffer *b)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	if (vcs->reading)
 		return -EBUSY;

@@ -3641,9 +3564,10 @@
 	return 0;
 }

-static int vino_v4l2_qbuf(struct vino_channel_settings *vcs,
+static int vino_qbuf(struct file *file, void *__fh,
 			  struct v4l2_buffer *b)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	if (vcs->reading)
 		return -EBUSY;

@@ -3679,10 +3603,11 @@
 	return 0;
 }

-static int vino_v4l2_dqbuf(struct vino_channel_settings *vcs,
-			   struct v4l2_buffer *b,
-			   unsigned int nonblocking)
-{
+static int vino_dqbuf(struct file *file, void *__fh,
+			   struct v4l2_buffer *b)
+{
+	struct vino_channel_settings *vcs = video_drvdata(file);
+	unsigned int nonblocking = file->f_flags & O_NONBLOCK;
 	if (vcs->reading)
 		return -EBUSY;

@@ -3754,8 +3679,10 @@
 	return 0;
 }

-static int vino_v4l2_streamon(struct vino_channel_settings *vcs)
-{
+static int vino_streamon(struct file *file, void *__fh,
+		enum v4l2_buf_type i)
+{
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	unsigned int incoming;
 	int ret;
 	if (vcs->reading)
@@ -3792,8 +3719,10 @@
 	return 0;
 }

-static int vino_v4l2_streamoff(struct vino_channel_settings *vcs)
-{
+static int vino_streamoff(struct file *file, void *__fh,
+		enum v4l2_buf_type i)
+{
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	if (vcs->reading)
 		return -EBUSY;

@@ -3806,9 +3735,10 @@
 	return 0;
 }

-static int vino_v4l2_queryctrl(struct vino_channel_settings *vcs,
+static int vino_queryctrl(struct file *file, void *__fh,
 			       struct v4l2_queryctrl *queryctrl)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	unsigned long flags;
 	int i;
 	int err = 0;
@@ -3855,9 +3785,10 @@
 	return err;
 }

-static int vino_v4l2_g_ctrl(struct vino_channel_settings *vcs,
+static int vino_g_ctrl(struct file *file, void *__fh,
 			    struct v4l2_control *control)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	unsigned long flags;
 	int i;
 	int err = 0;
@@ -3928,9 +3859,10 @@
 	return err;
 }

-static int vino_v4l2_s_ctrl(struct vino_channel_settings *vcs,
+static int vino_s_ctrl(struct file *file, void *__fh,
 			    struct v4l2_control *control)
 {
+	struct vino_channel_settings *vcs = video_drvdata(file);
 	unsigned long flags;
 	int i;
 	int err = 0;
@@ -4237,112 +4169,6 @@
 	return ret;
 }

-static long vino_do_ioctl(struct file *file, unsigned int cmd, void *arg)
-{
-	struct vino_channel_settings *vcs = video_drvdata(file);
-
-#ifdef VINO_DEBUG
-	switch (_IOC_TYPE(cmd)) {
-	case 'v':
-		dprintk("ioctl(): V4L1 unsupported (0x%08x)\n", cmd);
-		break;
-	case 'V':
-		dprintk("ioctl(): V4L2 %s (0x%08x)\n",
-			v4l2_ioctl_names[_IOC_NR(cmd)], cmd);
-		break;
-	default:
-		dprintk("ioctl(): unsupported command 0x%08x\n", cmd);
-	}
-#endif
-
-	switch (cmd) {
-	/* V4L2 interface */
-	case VIDIOC_QUERYCAP: {
-		vino_v4l2_querycap(arg);
-		break;
-	}
-	case VIDIOC_ENUMINPUT: {
-		return vino_v4l2_enuminput(vcs, arg);
-	}
-	case VIDIOC_G_INPUT: {
-		return vino_v4l2_g_input(vcs, arg);
-	}
-	case VIDIOC_S_INPUT: {
-		return vino_v4l2_s_input(vcs, arg);
-	}
-	case VIDIOC_ENUMSTD: {
-		return vino_v4l2_enumstd(vcs, arg);
-	}
-	case VIDIOC_QUERYSTD: {
-		return vino_v4l2_querystd(vcs, arg);
-	}
-	case VIDIOC_G_STD: {
-		return vino_v4l2_g_std(vcs, arg);
-	}
-	case VIDIOC_S_STD: {
-		return vino_v4l2_s_std(vcs, arg);
-	}
-	case VIDIOC_ENUM_FMT: {
-		return vino_v4l2_enum_fmt(vcs, arg);
-	}
-	case VIDIOC_TRY_FMT: {
-		return vino_v4l2_try_fmt(vcs, arg);
-	}
-	case VIDIOC_G_FMT: {
-		return vino_v4l2_g_fmt(vcs, arg);
-	}
-	case VIDIOC_S_FMT: {
-		return vino_v4l2_s_fmt(vcs, arg);
-	}
-	case VIDIOC_CROPCAP: {
-		return vino_v4l2_cropcap(vcs, arg);
-	}
-	case VIDIOC_G_CROP: {
-		return vino_v4l2_g_crop(vcs, arg);
-	}
-	case VIDIOC_S_CROP: {
-		return vino_v4l2_s_crop(vcs, arg);
-	}
-	case VIDIOC_G_PARM: {
-		return vino_v4l2_g_parm(vcs, arg);
-	}
-	case VIDIOC_S_PARM: {
-		return vino_v4l2_s_parm(vcs, arg);
-	}
-	case VIDIOC_REQBUFS: {
-		return vino_v4l2_reqbufs(vcs, arg);
-	}
-	case VIDIOC_QUERYBUF: {
-		return vino_v4l2_querybuf(vcs, arg);
-	}
-	case VIDIOC_QBUF: {
-		return vino_v4l2_qbuf(vcs, arg);
-	}
-	case VIDIOC_DQBUF: {
-		return vino_v4l2_dqbuf(vcs, arg, file->f_flags & O_NONBLOCK);
-	}
-	case VIDIOC_STREAMON: {
-		return vino_v4l2_streamon(vcs);
-	}
-	case VIDIOC_STREAMOFF: {
-		return vino_v4l2_streamoff(vcs);
-	}
-	case VIDIOC_QUERYCTRL: {
-		return vino_v4l2_queryctrl(vcs, arg);
-	}
-	case VIDIOC_G_CTRL: {
-		return vino_v4l2_g_ctrl(vcs, arg);
-	}
-	case VIDIOC_S_CTRL: {
-		return vino_v4l2_s_ctrl(vcs, arg);
-	}
-	default:
-		return -ENOIOCTLCMD;
-	}
-
-	return 0;
-}
-
 static long vino_ioctl(struct file *file,
 		      unsigned int cmd, unsigned long arg)
 {
@@ -4352,7 +4178,7 @@
 	if (mutex_lock_interruptible(&vcs->mutex))
 		return -EINTR;

-	ret = video_usercopy(file, cmd, arg, vino_do_ioctl);
+	ret = video_ioctl2(file, cmd, arg);

 	mutex_unlock(&vcs->mutex);

@@ -4363,6 +4189,34 @@

 /* __initdata */
 static int vino_init_stage;
+
+const struct v4l2_ioctl_ops vino_ioctl_ops = {
+	.vidioc_enum_fmt_vid_cap     = vino_enum_fmt_vid_cap,
+	.vidioc_g_fmt_vid_cap 	     = vino_g_fmt_vid_cap,
+	.vidioc_s_fmt_vid_cap  	     = vino_s_fmt_vid_cap,
+	.vidioc_try_fmt_vid_cap	     = vino_try_fmt_vid_cap,
+	.vidioc_querycap    	     = vino_querycap,
+	.vidioc_enum_input   	     = vino_enum_input,
+	.vidioc_g_input      	     = vino_g_input,
+	.vidioc_s_input      	     = vino_s_input,
+	.vidioc_g_std 		     = vino_g_std,
+	.vidioc_s_std 		     = vino_s_std,
+	.vidioc_querystd             = vino_querystd,
+	.vidioc_cropcap      	     = vino_cropcap,
+	.vidioc_s_crop       	     = vino_s_crop,
+	.vidioc_g_crop       	     = vino_g_crop,
+	.vidioc_s_parm 		     = vino_s_parm,
+	.vidioc_g_parm 		     = vino_g_parm,
+	.vidioc_reqbufs              = vino_reqbufs,
+	.vidioc_querybuf             = vino_querybuf,
+	.vidioc_qbuf                 = vino_qbuf,
+	.vidioc_dqbuf                = vino_dqbuf,
+	.vidioc_streamon             = vino_streamon,
+	.vidioc_streamoff            = vino_streamoff,
+	.vidioc_queryctrl            = vino_queryctrl,
+	.vidioc_g_ctrl               = vino_g_ctrl,
+	.vidioc_s_ctrl               = vino_s_ctrl,
+};

 static const struct v4l2_file_operations vino_fops = {
 	.owner		= THIS_MODULE,
@@ -4376,6 +4230,8 @@
 static struct video_device v4l_device_template = {
 	.name		= "NOT SET",
 	.fops		= &vino_fops,
+	.ioctl_ops 	= &vino_ioctl_ops,
+	.tvnorms 	= V4L2_STD_NTSC | V4L2_STD_PAL | V4L2_STD_SECAM,
 	.minor		= -1,
 };


Update SkyBoxMaterial.h

Update SkyBoxMaterial.h

--- SOCEngine/SOCEngine/Rendering/Sky/SkyBoxMaterial.h
+++ SOCEngine/SOCEngine/Rendering/Sky/SkyBoxMaterial.h
@@ -10,22 +10,19 @@
 	class SkyBoxMaterial : public Material
 	{
 	public:
-		SkyBoxMaterial(const std::string& key);
+		using Material::Material;

-	public:
 		void Initialize(Device::DirectX& dx, Manager::ShaderManager& shaderMgr);
 		void UpdateConstBuffer(Device::DirectX& dx, const Math::Matrix& transposedWVPMat);
 		void UpdateCubeMap(TextureBindIndex bind, const Texture::Texture2D& tex);

-		GET_CONST_ACCESSOR(Shaders, const Shader::ShaderGroup&, _shader);
 		GET_CONST_ACCESSOR(ConstBuffer, const Buffer::ExplicitConstBuffer<Math::Matrix>&, _wvpCB);
-
-	protected:
-		SET_ACCESSOR(Shaders, const Shader::ShaderGroup&, _shader);
-		SET_ACCESSOR(ConstBuffer, const Buffer::ExplicitConstBuffer<Math::Matrix>&, _wvpCB);
+		GET_CONST_ACCESSOR(VertexShader, const Shader::VertexShader&, _vs);
+		GET_CONST_ACCESSOR(PixelShader, const Shader::PixelShader&, _ps);

 	private:
-		Shader::ShaderGroup							_shader;
+		Shader::VertexShader				_vs;
+		Shader::PixelShader				_ps;
 		Buffer::ExplicitConstBuffer<Math::Matrix>	_wvpCB;
 	};
-}+}


mfd: arizona: Use num_core_supplies in arizona_dev_exit

Currently we call regulator_bulk_disable with
ARRAY_SIZE(arizona->core_supplies), however this array may be larger
than the number of supplies actually used by the chip we are dealing
with. Use the provided num_core_supplies member instead, so that we only
disable supplies which actually exist.

Signed-off-by: Charles Keepax <8e4aa0015eb43ed5ca66aaca3fb498609e1e427c@opensource.wolfsonmicro.com>
Signed-off-by: Lee Jones <630e34333487a351a857f6b705e04d30b37c1629@linaro.org>

--- drivers/mfd/arizona-core.c
+++ drivers/mfd/arizona-core.c
@@ -1038,7 +1038,7 @@
 	if (arizona->pdata.reset)
 		gpio_set_value_cansleep(arizona->pdata.reset, 0);

-	regulator_bulk_disable(ARRAY_SIZE(arizona->core_supplies),
+	regulator_bulk_disable(arizona->num_core_supplies,
 			       arizona->core_supplies);
 	return 0;
 }


drivers/misc/ti-st: check chip_awake NULL check

Before calling on any of the platform hooks, shared transport driver checks
for the validity of the platform hooks as to whether it is provided or not.
A wrong function was being checked for, before the chip_awake hook was called
by the HCI-LL sleep logic handler. This patch corrects the check.

Signed-off-by: Pavan Savoy <ff7908d51496428af54c99c54a6c8cd69c24548d@ti.com>
Signed-off-by: Matthias Kaehlcke <e388d34fd3c0456122779e95f262c0d70198a168@kaehlcke.net>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@linuxfoundation.org>

--- drivers/misc/ti-st/st_ll.c
+++ drivers/misc/ti-st/st_ll.c
@@ -87,7 +87,7 @@
 	/* communicate to platform about chip wakeup */
 	kim_data = st_data->kim_data;
 	pdata = kim_data->kim_pdev->dev.platform_data;
-	if (pdata->chip_asleep)
+	if (pdata->chip_awake)
 		pdata->chip_awake(NULL);
 }


TI DaVinci EMAC: Clear statistics register properly.

The mechanism to clear the statistics register is dependent
on the status of GMIIEN bit in MAC control register. If the
GMIIEN bit is set, the stats registers are write to decrement.
If the GMIIEN bit is cleared, the stats registers are plain
read/write registers. The stats register clearing operation
must take into account the current state of GMIIEN as it
can be cleared when the interface is brought down.

With existing implementation logic, querying for interface stats
when the interface is down, can corrupt the statistics counters.
This patch examines the GMIIEN bit status in MAC_CONTROL
register before choosing an appropriate mask for clearing stats
registers.

Signed-off-by: Sriramakrishnan <59e8b83587ff69352fc901bcb4b505e679cea1a9@ti.com>
Acked-by: Chaithrika U S <11b8a6491bc984cfa671197e7fd35937415978d5@ti.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/davinci_emac.c
+++ drivers/net/davinci_emac.c
@@ -332,6 +332,9 @@
 /* EMAC EOI codes for C0 */
 #define EMAC_DM646X_MAC_EOI_C0_RXEN	(0x01)
 #define EMAC_DM646X_MAC_EOI_C0_TXEN	(0x02)
+
+/* EMAC Stats Clear Mask */
+#define EMAC_STATS_CLR_MASK    (0xFFFFFFFF)

 /** net_buf_obj: EMAC network bufferdata structure
  *
@@ -2548,40 +2551,49 @@
 static struct net_device_stats *emac_dev_getnetstats(struct net_device *ndev)
 {
 	struct emac_priv *priv = netdev_priv(ndev);
+	u32 mac_control;
+	u32 stats_clear_mask;

 	/* update emac hardware stats and reset the registers*/

+	mac_control = emac_read(EMAC_MACCONTROL);
+
+	if (mac_control & EMAC_MACCONTROL_GMIIEN)
+		stats_clear_mask = EMAC_STATS_CLR_MASK;
+	else
+		stats_clear_mask = 0;
+
 	priv->net_dev_stats.multicast += emac_read(EMAC_RXMCASTFRAMES);
-	emac_write(EMAC_RXMCASTFRAMES, EMAC_ALL_MULTI_REG_VALUE);
+	emac_write(EMAC_RXMCASTFRAMES, stats_clear_mask);

 	priv->net_dev_stats.collisions += (emac_read(EMAC_TXCOLLISION) +
 					   emac_read(EMAC_TXSINGLECOLL) +
 					   emac_read(EMAC_TXMULTICOLL));
-	emac_write(EMAC_TXCOLLISION, EMAC_ALL_MULTI_REG_VALUE);
-	emac_write(EMAC_TXSINGLECOLL, EMAC_ALL_MULTI_REG_VALUE);
-	emac_write(EMAC_TXMULTICOLL, EMAC_ALL_MULTI_REG_VALUE);
+	emac_write(EMAC_TXCOLLISION, stats_clear_mask);
+	emac_write(EMAC_TXSINGLECOLL, stats_clear_mask);
+	emac_write(EMAC_TXMULTICOLL, stats_clear_mask);

 	priv->net_dev_stats.rx_length_errors += (emac_read(EMAC_RXOVERSIZED) +
 						emac_read(EMAC_RXJABBER) +
 						emac_read(EMAC_RXUNDERSIZED));
-	emac_write(EMAC_RXOVERSIZED, EMAC_ALL_MULTI_REG_VALUE);
-	emac_write(EMAC_RXJABBER, EMAC_ALL_MULTI_REG_VALUE);
-	emac_write(EMAC_RXUNDERSIZED, EMAC_ALL_MULTI_REG_VALUE);
+	emac_write(EMAC_RXOVERSIZED, stats_clear_mask);
+	emac_write(EMAC_RXJABBER, stats_clear_mask);
+	emac_write(EMAC_RXUNDERSIZED, stats_clear_mask);

 	priv->net_dev_stats.rx_over_errors += (emac_read(EMAC_RXSOFOVERRUNS) +
 					       emac_read(EMAC_RXMOFOVERRUNS));
-	emac_write(EMAC_RXSOFOVERRUNS, EMAC_ALL_MULTI_REG_VALUE);
-	emac_write(EMAC_RXMOFOVERRUNS, EMAC_ALL_MULTI_REG_VALUE);
+	emac_write(EMAC_RXSOFOVERRUNS, stats_clear_mask);
+	emac_write(EMAC_RXMOFOVERRUNS, stats_clear_mask);

 	priv->net_dev_stats.rx_fifo_errors += emac_read(EMAC_RXDMAOVERRUNS);
-	emac_write(EMAC_RXDMAOVERRUNS, EMAC_ALL_MULTI_REG_VALUE);
+	emac_write(EMAC_RXDMAOVERRUNS, stats_clear_mask);

 	priv->net_dev_stats.tx_carrier_errors +=
 		emac_read(EMAC_TXCARRIERSENSE);
-	emac_write(EMAC_TXCARRIERSENSE, EMAC_ALL_MULTI_REG_VALUE);
+	emac_write(EMAC_TXCARRIERSENSE, stats_clear_mask);

 	priv->net_dev_stats.tx_fifo_errors = emac_read(EMAC_TXUNDERRUN);
-	emac_write(EMAC_TXUNDERRUN, EMAC_ALL_MULTI_REG_VALUE);
+	emac_write(EMAC_TXUNDERRUN, stats_clear_mask);

 	return &priv->net_dev_stats;
 }


igbvf: Remove some dead code in igbvf

igbvf: Remove some dead code in igbvf

Removed unused variable in igbvf.

Signed-off-by: Julian Stecklina <3a0b7f7e7482ac3ab28d6381fc9892b07df2c74c@os.inf.tu-dresden.de>
Acked-by: Greg Rose <6e297de79f9a9aeb97534f5d0c67075a1e50217c@intel.com>
Tested-by: Emil Tantilov <7bb77ce8696ed668ba78a49cc3445dd5ee9fe4b8@intel.com>
Signed-off-by: Jeff Kirsher <87e35f5be20bb3e67f4ba6b86f5f6be3085b1b3a@intel.com>

--- drivers/net/igbvf/netdev.c
+++ drivers/net/igbvf/netdev.c
@@ -1852,8 +1852,6 @@

 	if (link) {
 		if (!netif_carrier_ok(netdev)) {
-			bool txb2b = 1;
-
 			mac->ops.get_link_up_info(&adapter->hw,
 			                          &adapter->link_speed,
 			                          &adapter->link_duplex);
@@ -1863,11 +1861,9 @@
 			adapter->tx_timeout_factor = 1;
 			switch (adapter->link_speed) {
 			case SPEED_10:
-				txb2b = 0;
 				adapter->tx_timeout_factor = 16;
 				break;
 			case SPEED_100:
-				txb2b = 0;
 				/* maybe add some timeout factor ? */
 				break;
 			}


Remove unused zero-copy code from velocity NIC driver.

This code hasn't been enabled in forever.

Signed-off-by: Dave Jones <d5ec0d24602845f6f4b6a35ef729998d1fba5507@redhat.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/via-velocity.c
+++ drivers/net/via-velocity.c
@@ -976,9 +976,6 @@
 	dev->netdev_ops = &velocity_netdev_ops;
 	dev->ethtool_ops = &velocity_ethtool_ops;

-#ifdef  VELOCITY_ZERO_COPY_SUPPORT
-	dev->features |= NETIF_F_SG;
-#endif
 	dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_FILTER |
 		NETIF_F_HW_VLAN_RX;

@@ -1849,11 +1846,7 @@

 		pktlen = max_t(unsigned int, skb->len, ETH_ZLEN);
 		for (i = 0; i < tdinfo->nskb_dma; i++) {
-#ifdef VELOCITY_ZERO_COPY_SUPPORT
-			pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i], le16_to_cpu(td->tdesc1.len), PCI_DMA_TODEVICE);
-#else
 			pci_unmap_single(vptr->pdev, tdinfo->skb_dma[i], pktlen, PCI_DMA_TODEVICE);
-#endif
 			tdinfo->skb_dma[i] = 0;
 		}
 	}
@@ -2095,13 +2088,6 @@

 	len = cpu_to_le16(pktlen);

-#ifdef VELOCITY_ZERO_COPY_SUPPORT
-	if (skb_shinfo(skb)->nr_frags > 6 && __skb_linearize(skb)) {
-		kfree_skb(skb);
-		return NETDEV_TX_OK;
-	}
-#endif
-
 	spin_lock_irqsave(&vptr->lock, flags);

 	index = vptr->tx.curr[qnum];
@@ -2111,59 +2097,18 @@
 	td_ptr->tdesc1.TCR = TCR0_TIC;
 	td_ptr->td_buf[0].size &= ~TD_QUEUE;

-#ifdef VELOCITY_ZERO_COPY_SUPPORT
-	if (skb_shinfo(skb)->nr_frags > 0) {
-		int nfrags = skb_shinfo(skb)->nr_frags;
-		tdinfo->skb = skb;
-		if (nfrags > 6) {
-			skb_copy_from_linear_data(skb, tdinfo->buf, skb->len);
-			tdinfo->skb_dma[0] = tdinfo->buf_dma;
-			td_ptr->tdesc0.len = len;
-			td_ptr->tx.buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
-			td_ptr->tx.buf[0].pa_high = 0;
-			td_ptr->tx.buf[0].size = len;	/* queue is 0 anyway */
-			tdinfo->nskb_dma = 1;
-		} else {
-			int i = 0;
-			tdinfo->nskb_dma = 0;
-			tdinfo->skb_dma[i] = pci_map_single(vptr->pdev, skb->data,
-						skb_headlen(skb), PCI_DMA_TODEVICE);
-
-			td_ptr->tdesc0.len = len;
-
-			/* FIXME: support 48bit DMA later */
-			td_ptr->tx.buf[i].pa_low = cpu_to_le32(tdinfo->skb_dma);
-			td_ptr->tx.buf[i].pa_high = 0;
-			td_ptr->tx.buf[i].size = cpu_to_le16(skb_headlen(skb));
-
-			for (i = 0; i < nfrags; i++) {
-				skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
-				void *addr = (void *)page_address(frag->page) + frag->page_offset;
-
-				tdinfo->skb_dma[i + 1] = pci_map_single(vptr->pdev, addr, frag->size, PCI_DMA_TODEVICE);
-
-				td_ptr->tx.buf[i + 1].pa_low = cpu_to_le32(tdinfo->skb_dma[i + 1]);
-				td_ptr->tx.buf[i + 1].pa_high = 0;
-				td_ptr->tx.buf[i + 1].size = cpu_to_le16(frag->size);
-			}
-			tdinfo->nskb_dma = i - 1;
-		}
-
-	} else
-#endif
-	{
-		/*
-		 *	Map the linear network buffer into PCI space and
-		 *	add it to the transmit ring.
-		 */
-		tdinfo->skb = skb;
-		tdinfo->skb_dma[0] = pci_map_single(vptr->pdev, skb->data, pktlen, PCI_DMA_TODEVICE);
-		td_ptr->tdesc0.len = len;
-		td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
-		td_ptr->td_buf[0].pa_high = 0;
-		td_ptr->td_buf[0].size = len;
-		tdinfo->nskb_dma = 1;
-	}
+	/*
+	 *	Map the linear network buffer into PCI space and
+	 *	add it to the transmit ring.
+	 */
+	tdinfo->skb = skb;
+	tdinfo->skb_dma[0] = pci_map_single(vptr->pdev, skb->data, pktlen, PCI_DMA_TODEVICE);
+	td_ptr->tdesc0.len = len;
+	td_ptr->td_buf[0].pa_low = cpu_to_le32(tdinfo->skb_dma[0]);
+	td_ptr->td_buf[0].pa_high = 0;
+	td_ptr->td_buf[0].size = len;
+	tdinfo->nskb_dma = 1;
+
 	td_ptr->tdesc1.cmd = TCPLS_NORMAL + (tdinfo->nskb_dma + 1) * 16;

 	if (vptr->vlgrp && vlan_tx_tag_present(skb)) {


xen-netfront: Use setup_timer

xen-netfront: Use setup_timer

Use the timer API function setup_timer instead of structure field
assignments to initialize a timer.

A simplified version of the Coccinelle semantic patch that performs
this transformation is as follows:

@change@
expression e, func, da;
@@

-init_timer (&e);
+setup_timer (&e, func, da);
-e.data = da;
-e.function = func;

Signed-off-by: Vaishali Thakkar <d326f246a6487957dd2597537de070b545202a3d@gmail.com>
Signed-off-by: David S. Miller <fe08d3c717adf2ae63592e4c9aec6e3e404d8e3e@davemloft.net>

--- drivers/net/xen-netfront.c
+++ drivers/net/xen-netfront.c
@@ -1560,9 +1560,8 @@
 	spin_lock_init(&queue->tx_lock);
 	spin_lock_init(&queue->rx_lock);

-	init_timer(&queue->rx_refill_timer);
-	queue->rx_refill_timer.data = (unsigned long)queue;
-	queue->rx_refill_timer.function = rx_refill_timeout;
+	setup_timer(&queue->rx_refill_timer, rx_refill_timeout,
+		    (unsigned long)queue);

 	snprintf(queue->name, sizeof(queue->name), "%s-q%u",
 		 queue->info->netdev->name, queue->id);


wmi: parse_wdg() should return kernel error codes

The current code returns a mix of acpi_status and kernel error codes.
It should just return kernel error codes.  There are already error paths
in this function which return -ENOMEM and that's what the caller
expects.

Signed-off-by: Dan Carpenter <ff341aa343d564f9e53e9dcb6996be8c04859a66@oracle.com>
Signed-off-by: Matthew Garrett <d1dada306f6f6bc535ec5238317ee8d221588a1a@nebula.com>


power: pm8921-bms: Fix CC conversion precision

In a previous patch, the precision of the coulomb counter conversion
was reduced. Fix this by converting the CC value to picovolt-hours
before dividing by r_sense uohm to convert back to microvolt-hours.

Change-Id: I2cb4f99ea3636159dfefd2747b24e6ac3bbb7a04
Signed-off-by: Xiaozhe Shi <4c58d9c21c42c2a4cf34b559441bd01b9c143cf4@codeaurora.org>

--- drivers/power/pm8921-bms.c
+++ drivers/power/pm8921-bms.c
@@ -643,15 +643,15 @@
 #define SLEEP_CLK_HZ		32764
 #define SECONDS_PER_HOUR	3600
 /**
- * ccmicrovolt_to_uvh -
+ * ccmicrovolt_to_pvh -
  * @cc_uv:  coulumb counter converted to uV
  *
- * RETURNS:	coulumb counter based charge in uVh
- *		(micro Volt Hour)
+ * RETURNS:	coulumb counter based charge in pVh
+ *		(pico Volt Hour)
  */
-static s64 ccmicrovolt_to_uvh(s64 cc_uv)
-{
-	return div_s64(cc_uv * CC_READING_TICKS,
+static s64 ccmicrovolt_to_pvh(s64 cc_uv)
+{
+	return div_s64(cc_uv * CC_READING_TICKS * 1000000L,
 			SLEEP_CLK_HZ * SECONDS_PER_HOUR);
 }

@@ -1174,7 +1174,7 @@
  */
 static void calculate_cc_uah(struct pm8921_bms_chip *chip, int cc, int *val)
 {
-	int64_t cc_voltage_uv, cc_uvh, cc_uah;
+	int64_t cc_voltage_uv, cc_pvh, cc_uah;

 	cc_voltage_uv = cc;
 	cc_voltage_uv -= chip->cc_reading_at_100;
@@ -1184,9 +1184,9 @@
 	cc_voltage_uv = cc_to_microvolt(chip, cc_voltage_uv);
 	cc_voltage_uv = pm8xxx_cc_adjust_for_gain(cc_voltage_uv);
 	pr_debug("cc_voltage_uv = %lld microvolts\n", cc_voltage_uv);
-	cc_uvh = ccmicrovolt_to_uvh(cc_voltage_uv);
-	pr_debug("cc_uvh = %lld micro_volt_hour\n", cc_uvh);
-	cc_uah = div_s64(cc_uvh * 1000000LL, chip->r_sense_uohm);
+	cc_pvh = ccmicrovolt_to_pvh(cc_voltage_uv);
+	pr_debug("cc_pvh = %lld pico_volt_hour\n", cc_pvh);
+	cc_uah = div_s64(cc_pvh, chip->r_sense_uohm);
 	*val = cc_uah;
 }


power: pm8921-bms: adjust rbatt and ocv both for shutdown soc

When ocv (open circuit voltage of the battery) is adjusted to match a
specific soc, rbatt (the battery resistance) changes too. This is because
rbatt is dependent on the remaining charge which changes as the ocv
changes.

The issue we observed with this changing rbatt was the unusable charge
changes which causes the soc to move away from the soc the algorithm
attempts to match.

To get around this issue adjust both the rbatt and ocv when we want to
match a soc for a specific soc.

Change-Id: Ifa8efe1e37b9982d6d67730f911e47e369e9b4ff
Signed-off-by: Abhijeet Dharmapurikar <98996d53ce579fa37f08d0061abc5355e223c79e@codeaurora.org>

--- drivers/power/pm8921-bms.c
+++ drivers/power/pm8921-bms.c
@@ -1526,16 +1526,22 @@
 }
 EXPORT_SYMBOL(pm8921_bms_invalidate_shutdown_soc);

-static int adjust_remaining_charge_for_shutdown_soc(
+static void adjust_rc_and_uuc_for_shutdown_soc(
 						struct pm8921_bms_chip *chip,
 						int batt_temp,
 						int chargecycles,
 						int fcc_uah,
 						int uuc_uah,
 						int cc_uah,
-						int remaining_charge_uah)
-{
-	s64 rc;
+						int remaining_charge_uah,
+						int rbatt,
+						int *ret_rc,
+						int *ret_uuc,
+						int *ret_rbatt)
+{
+	s64 new_rc;
+	int new_uuc;
+	int new_rbatt;
 	int pc;
 	int ocv, ocv_uv;
 	int batt_temp_degc = batt_temp / 10;
@@ -1548,18 +1554,13 @@
 	 * value of zero means the shutdown soc should not be used, the battery
 	 * was removed for extended period, the coincell capacitor could have
 	 * drained
-	 */
-	if (shutdown_soc == 0) {
-		rc = remaining_charge_uah;
-		goto out;
-	}
-
-	/*
 	 * shutdown_soc_invalid means the shutdown soc should not be used,
 	 * the battery was removed for a small period
 	 */
-	if (shutdown_soc_invalid) {
-		rc = remaining_charge_uah;
+	if (shutdown_soc == 0 || shutdown_soc_invalid) {
+		new_rc = remaining_charge_uah;
+		new_uuc = uuc_uah;
+		new_rbatt = rbatt;
 		goto out;
 	}

@@ -1569,15 +1570,47 @@

 	pr_debug("shutdown_soc = %d forcing it now\n", shutdown_soc);

-	rc = (s64)shutdown_soc * (fcc_uah - uuc_uah);
-	rc = div_s64(rc, 100) + cc_uah + uuc_uah;
-	pc = DIV_ROUND_CLOSEST((int)rc * 100, fcc_uah);
+	/* step 1 get to a reasonable rbatt */
+	if (chip->last_ocv_uv < chip->v_cutoff * 1000) {
+		int new_pc_for_rbatt;
+		int iavg_ua;
+		int iavg_ma;
+		int soc_for_rbatt;
+
+		new_pc_for_rbatt = calculate_pc(chip, chip->v_cutoff * 1000,
+						batt_temp, chargecycles);
+
+		soc_for_rbatt
+			= (new_pc_for_rbatt * fcc_uah - cc_uah * 100) / fcc_uah;
+		new_rbatt = get_rbatt(chip, soc_for_rbatt, batt_temp);
+
+		pm8921_bms_get_battery_current(&iavg_ua);
+		iavg_ma = iavg_ua / 1000;
+		if (iavg_ma < 0)
+			iavg_ma = CHARGING_IAVG_MA;
+
+		new_uuc = calculate_uuc_uah_at_given_current(chip,
+					batt_temp, chargecycles,
+					new_rbatt, fcc_uah, iavg_ma);
+
+		pr_debug("new pc = %d, soc_rbatt = %d, new_rbatt = %d,\n",
+				new_pc_for_rbatt, soc_for_rbatt, new_rbatt);
+		pr_debug("iavg_ma = %d, new_uuc = %d\n", iavg_ma, new_uuc);
+	} else {
+		new_rbatt = rbatt;
+		new_uuc = uuc_uah;
+	}
+
+	/* step 2 adjust rc using the new uuc */
+	new_rc = (s64)shutdown_soc * (fcc_uah - new_uuc);
+	new_rc = div_s64(new_rc, 100) + cc_uah + new_uuc;
+	pc = DIV_ROUND_CLOSEST((int)new_rc * 100, fcc_uah);
 	pc = clamp(pc, 0, 100);

 	ocv = interpolate_ocv(chip, batt_temp_degc, pc);

-	pr_debug("To force shutdown_soc = %d, rc = %d, pc = %d, ocv mv = %d\n",
-				shutdown_soc, (int)rc, pc, ocv);
+	pr_debug("To force shutdown_soc = %d, new_rc = %d, pc = %d, ocv mv = %d\n",
+				shutdown_soc, (int)new_rc, pc, ocv);
 	new_pc = interpolate_pc(chip, batt_temp_degc, ocv);
 	pr_debug("test revlookup pc = %d for ocv = %d\n", new_pc, ocv);

@@ -1597,8 +1630,10 @@
 	chip->pon_ocv_uv = chip->last_ocv_uv;
 	chip->last_ocv_uv = ocv_uv;
 out:
+	*ret_rbatt = new_rbatt;
+	*ret_rc = (int)new_rc;
+	*ret_uuc = new_uuc;
 	mutex_unlock(&soc_invalidation_mutex);
-	return (int)rc;
 }

 #define SOC_CATCHUP_SEC_MAX		600
@@ -1676,6 +1711,9 @@
 	int rbatt;
 	int iavg_ua;
 	int delta_time_us;
+	int new_rc_uah;
+	int new_ucc_uah;
+	int new_rbatt;

 	calculate_soc_params(chip, raw, batt_temp, chargecycles,
 						&fcc_uah,
@@ -1686,16 +1724,24 @@
 						&iavg_ua,
 						&delta_time_us);

-	if (delta_time_us == 0)
+	if (delta_time_us == 0) {
 		/*
 		 * soc for the first time - use shutdown soc
 		 * to adjust pon ocv
 		 */
-		remaining_charge_uah = adjust_remaining_charge_for_shutdown_soc(
+		adjust_rc_and_uuc_for_shutdown_soc(
 						chip,
 						batt_temp, chargecycles,
 						fcc_uah, unusable_charge_uah,
-						cc_uah, remaining_charge_uah);
+						cc_uah, remaining_charge_uah,
+						rbatt,
+						&new_rc_uah, &new_ucc_uah,
+						&new_rbatt);
+
+		remaining_charge_uah = new_rc_uah;
+		unusable_charge_uah = new_ucc_uah;
+		rbatt = new_rbatt;
+	}

 	/* calculate remaining usable charge */
 	remaining_usable_charge_uah = remaining_charge_uah


rapidio: add device object linking into discovery

Add setting links between rio_dev objects into the discovery process.
This needed to report device connections on agent (non-host) processors
that perform RIO discovery.  Originally, these links have been introduced
for enumerating host only to support error management.

Signed-off-by: Alexandre Bounine <4ee99b187650e6ea4b9259bc798eb76cfca96ee4@idt.com>
Cc: Kumar Gala <383ef5577c6e1178b93f59ec8d0936f76d2a98c4@kernel.crashing.org>
Cc: Matt Porter <c1d287ff3802a4aab0e3770389ea24a33314618b@kernel.crashing.org>
Cc: Li Yang <ecc108c9e46a7124cf4a03d161d413e34ffc15a7@freescale.com>
Cc: Thomas Moll <98b46f2b4869277d5f2f051aba086f22d7d27ca5@sysgo.com>
Cc: Micha Nelissen <5f726662e7ca541c0aec63efdec81c7c2711727a@neli.hopto.org>
Signed-off-by: Andrew Morton <5c1e68b099950c134891f0b6e179498a8ebe9cf9@linux-foundation.org>
Signed-off-by: Linus Torvalds <69652caca27c8b940640ad396ab71f93cacec34f@linux-foundation.org>

--- drivers/rapidio/rio-scan.c
+++ drivers/rapidio/rio-scan.c
@@ -947,7 +947,7 @@
  */
 static int __devinit
 rio_disc_peer(struct rio_net *net, struct rio_mport *port, u16 destid,
-	      u8 hopcount)
+	      u8 hopcount, struct rio_dev *prev, int prev_port)
 {
 	u8 port_num, route_port;
 	struct rio_dev *rdev;
@@ -957,6 +957,9 @@
 	if ((rdev = rio_setup_device(net, port, destid, hopcount, 0))) {
 		/* Add device to the global and bus/net specific list. */
 		list_add_tail(&rdev->net_list, &net->devices);
+		rdev->prev = prev;
+		if (prev && rio_is_switch(prev))
+			prev->rswitch->nextdev[prev_port] = rdev;
 	} else
 		return -1;

@@ -998,8 +1001,8 @@
 				if (ndestid == RIO_ANY_DESTID(port->sys_size))
 					continue;
 				rio_unlock_device(port, destid, hopcount);
-				if (rio_disc_peer
-				    (net, port, ndestid, hopcount + 1) < 0)
+				if (rio_disc_peer(net, port, ndestid,
+					hopcount + 1, rdev, port_num) < 0)
 					return -1;
 			}
 		}
@@ -1291,7 +1294,7 @@
 						   mport->host_deviceid);

 		if (rio_disc_peer(net, mport, RIO_ANY_DESTID(mport->sys_size),
-					0) < 0) {
+					0, NULL, 0) < 0) {
 			printk(KERN_INFO
 			       "RIO: master port %d device has failed discovery\n",
 			       mport->id);


regulator: lp8755: Fix mask for pchip->mphase

According to the datasheet, it has 9 multi-phase mode from 0 to 8 and it takes
4 bits in the register.
The mask for pchip->mphase should be 0x0F.

Signed-off-by: Axel Lin <b6ffd6973e972cb999e8e535ab74da7fee0c035f@ingics.com>
Signed-off-by: Mark Brown <b51b9a92386687a9ac927cebfa0f978adeb8cea5@opensource.wolfsonmicro.com>

--- drivers/regulator/lp8755.c
+++ drivers/regulator/lp8755.c
@@ -301,7 +301,7 @@
 	ret = lp8755_read(pchip, 0x3D, &regval);
 	if (ret < 0)
 		goto out_i2c_error;
-	pchip->mphase = regval & 0x07;
+	pchip->mphase = regval & 0x0F;

 	/* set default data based on multi-phase config */
 	for (icnt = 0; icnt < mphase_buck[pchip->mphase].nreg; icnt++) {


rtc: at91sam9: use clk API instead of relying on AT91_SLOW_CLOCK

The RTT block is using the slow clock which is accessible through the clk
API.
Use the clk API to retrieve, enable and get the slow clk rate instead of
the AT91_SLOW_CLOCK macro (which hardcodes the slow clk rate).
Doing this allows us to reference the clk thus preventing the CCF from
disabling it during the "disable unused" phase.

Signed-off-by: Boris BREZILLON <4e91513d4f418754031d3d36b3fc73980c40a38c@free-electrons.com>
Acked-by: Alexandre Belloni <a7228e626ecf0022ac91fc1cd8db88e71d0e5e0e@free-electrons.com>
Acked-by: Johan Hovold <759412786bc533369b22377bf83fb9056c5b25b2@kernel.org>
Acked-by: Arnd Bergmann <f2c659f01951776204a6c5b902787d9019fbeebd@arndb.de>
Signed-off-by: Nicolas Ferre <45b517be0e5ec6dc3a39715767c1d18e090d39b4@atmel.com>

--- drivers/rtc/rtc-at91sam9.c
+++ drivers/rtc/rtc-at91sam9.c
@@ -23,6 +23,7 @@
 #include <linux/io.h>
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
+#include <linux/clk.h>

 /*
  * This driver uses two configurable hardware resources that live in the
@@ -60,8 +61,6 @@
 #define AT91_RTT_SR		0x0c			/* Real-time Status Register */
 #define AT91_RTT_ALMS		(1 << 0)		/* Real-time Alarm Status */
 #define AT91_RTT_RTTINC		(1 << 1)		/* Real-time Timer Increment */
-
-#define AT91_SLOW_CLOCK		32768

 /*
  * We store ALARM_DISABLED in ALMV to record that no alarm is set.
@@ -77,6 +76,7 @@
 	struct regmap		*gpbr;
 	unsigned int		gpbr_offset;
 	int 			irq;
+	struct clk		*sclk;
 };

 #define rtt_readl(rtc, field) \
@@ -328,6 +328,7 @@
 	struct sam9_rtc	*rtc;
 	int		ret, irq;
 	u32		mr;
+	unsigned int	sclk_rate;

 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0) {
@@ -385,11 +386,27 @@
 		return -ENOMEM;
 	}

+	rtc->sclk = devm_clk_get(&pdev->dev, NULL);
+	if (IS_ERR(rtc->sclk))
+		return PTR_ERR(rtc->sclk);
+
+	sclk_rate = clk_get_rate(rtc->sclk);
+	if (!sclk_rate || sclk_rate > AT91_RTT_RTPRES) {
+		dev_err(&pdev->dev, "Invalid slow clock rate\n");
+		return -EINVAL;
+	}
+
+	ret = clk_prepare_enable(rtc->sclk);
+	if (ret) {
+		dev_err(&pdev->dev, "Could not enable slow clock\n");
+		return ret;
+	}
+
 	mr = rtt_readl(rtc, MR);

 	/* unless RTT is counting at 1 Hz, re-initialize it */
-	if ((mr & AT91_RTT_RTPRES) != AT91_SLOW_CLOCK) {
-		mr = AT91_RTT_RTTRST | (AT91_SLOW_CLOCK & AT91_RTT_RTPRES);
+	if ((mr & AT91_RTT_RTPRES) != sclk_rate) {
+		mr = AT91_RTT_RTTRST | (sclk_rate & AT91_RTT_RTPRES);
 		gpbr_writel(rtc, 0);
 	}

@@ -433,6 +450,9 @@

 	/* disable all interrupts */
 	rtt_writel(rtc, MR, mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN));
+
+	if (!IS_ERR(rtc->sclk))
+		clk_disable_unprepare(rtc->sclk);

 	return 0;
 }


rtc: at91sam9: get sclk rate after enabling it

See help for clk_get_rate(): "obtain the current clock rate (in Hz) for a
clock source. This is only valid once the clock source has been enabled."

It currently returns the correct value but that may not stay that way.

Signed-off-by: Alexandre Belloni <a7228e626ecf0022ac91fc1cd8db88e71d0e5e0e@free-electrons.com>
Acked-by: Boris Brezillon <4e91513d4f418754031d3d36b3fc73980c40a38c@free-electrons.com>
Acked-by: Nicolas Ferre <45b517be0e5ec6dc3a39715767c1d18e090d39b4@atmel.com>


[SCSI] bfa: Fixes for 0-terminated strncpy and possible null pointer dereference

This patch fixes two cppcheck errors in drivers/scsi/bfa/bfad_im.c

[jejb: correct strlcpy fix]
Signed-off-by: Jakob Normark <8feb8724ae19a5abf68528930645467d982c6bf3@gmail.com>
Acked-by: Vijay Mohan Guvva <707c98e562d6bf4db7c2f2c516d8e15d7da9bc8a@brocade.com>
Signed-off-by: James Bottomley <1acebbdca565c7b6b638bdc23b58b5610d1a56b8@Parallels.com>

--- drivers/scsi/bfa/bfad_im.c
+++ drivers/scsi/bfa/bfad_im.c
@@ -944,12 +944,14 @@
 bfad_im_slave_alloc(struct scsi_device *sdev)
 {
 	struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
-	struct bfad_itnim_data_s *itnim_data =
-				(struct bfad_itnim_data_s *) rport->dd_data;
-	struct bfa_s *bfa = itnim_data->itnim->bfa_itnim->bfa;
+	struct bfad_itnim_data_s *itnim_data;
+	struct bfa_s *bfa;

 	if (!rport || fc_remote_port_chkready(rport))
 		return -ENXIO;
+
+	itnim_data = (struct bfad_itnim_data_s *) rport->dd_data;
+	bfa = itnim_data->itnim->bfa_itnim->bfa;

 	if (bfa_get_lun_mask_status(bfa) == BFA_LUNMASK_ENABLED) {
 		/*
@@ -1035,7 +1037,7 @@
 	/* For fibre channel services type 0x20 */
 	fc_host_supported_fc4s(host)[7] = 1;

-	strncpy(symname, bfad->bfa_fcs.fabric.bport.port_cfg.sym_name.symname,
+	strlcpy(symname, bfad->bfa_fcs.fabric.bport.port_cfg.sym_name.symname,
 		BFA_SYMNAME_MAXLEN);
 	sprintf(fc_host_symbolic_name(host), "%s", symname);


[PATCH] libata: implement ata_poll_qc_complete and use it in polling functions

[PATCH libata-dev-2.6:upstream] implement ata_poll_qc_complete and use it in polling functions

 Previously, libata polling functions turned irq back on and completed
qc commands without holding host lock.  This creates a race condition
between the polling task and interrupts from other ports on the same
host set or spurious interrupt from itself.

 This patch implements ata_poll_qc_complete which enables irq and
completes qc atomically and convert all polling functions.

 Note: atapi_packet_task() didn't use to turn irq back on or clear
ATA_FLAG_NOINTR on error exits.  This patch makes it use
ata_poll_qc_complete which does both.

 Note: With this change, ALL invocations of ata_qc_complete() are now
done under host_set lock.

Signed-off-by: Tejun Heo <ccfba69985e72fbcd9ba8bbb6db43d42971ad06d@gmail.com>
Signed-off-by: Jeff Garzik <15f615bf7d20c2937c7eb5aa759110fd6768848c@pobox.com>

--- drivers/scsi/libata-core.c
+++ drivers/scsi/libata-core.c
@@ -2402,6 +2402,26 @@
 }

 /**
+ *	ata_poll_qc_complete - turn irq back on and finish qc
+ *	@qc: Command to complete
+ *	@drv_stat: ATA status register content
+ *
+ *	LOCKING:
+ *	None.  (grabs host lock)
+ */
+
+void ata_poll_qc_complete(struct ata_queued_cmd *qc, u8 drv_stat)
+{
+	struct ata_port *ap = qc->ap;
+
+	spin_lock_irq(&ap->host_set->lock);
+	ap->flags &= ~ATA_FLAG_NOINTR;
+	ata_irq_on(ap);
+	ata_qc_complete(qc, drv_stat);
+	spin_unlock_irq(&ap->host_set->lock);
+}
+
+/**
  *	ata_pio_poll -
  *	@ap:
  *
@@ -2492,9 +2512,7 @@

 	ap->pio_task_state = PIO_ST_IDLE;

-	ata_irq_on(ap);
-
-	ata_qc_complete(qc, drv_stat);
+	ata_poll_qc_complete(qc, drv_stat);
 }

@@ -2844,9 +2862,7 @@
 		if ((status & ATA_DRQ) == 0) {
 			ap->pio_task_state = PIO_ST_IDLE;

-			ata_irq_on(ap);
-
-			ata_qc_complete(qc, status);
+			ata_poll_qc_complete(qc, status);
 			return;
 		}

@@ -2876,9 +2892,7 @@

 	ap->pio_task_state = PIO_ST_IDLE;

-	ata_irq_on(ap);
-
-	ata_qc_complete(qc, drv_stat | ATA_ERR);
+	ata_poll_qc_complete(qc, drv_stat | ATA_ERR);
 }

 static void ata_pio_task(void *_data)
@@ -3791,7 +3805,7 @@
 	return;

 err_out:
-	ata_qc_complete(qc, ATA_ERR);
+	ata_poll_qc_complete(qc, ATA_ERR);
 }


[PATCH] libata: separate out sata_phy_resume() from sata_std_hardreset()

This patch separates out sata_phy_resume() from sata_std_hardreset().
The function will later be used by probeinit callback.

Signed-off-by: Tejun Heo <ccfba69985e72fbcd9ba8bbb6db43d42971ad06d@gmail.com>
Signed-off-by: Jeff Garzik <15f615bf7d20c2937c7eb5aa759110fd6768848c@pobox.com>

--- drivers/scsi/libata-core.c
+++ drivers/scsi/libata-core.c
@@ -2277,6 +2277,24 @@
 	DPRINTK("EXIT\n");
 }

+static int sata_phy_resume(struct ata_port *ap)
+{
+	unsigned long timeout = jiffies + (HZ * 5);
+	u32 sstatus;
+
+	scr_write_flush(ap, SCR_CONTROL, 0x300);
+
+	/* Wait for phy to become ready, if necessary. */
+	do {
+		msleep(200);
+		sstatus = scr_read(ap, SCR_STATUS);
+		if ((sstatus & 0xf) != 1)
+			return 0;
+	} while (time_before(jiffies, timeout));
+
+	return -1;
+}
+
 /**
  *	ata_std_softreset - reset host port via ATA SRST
  *	@ap: port to reset
@@ -2357,8 +2375,7 @@
  */
 int sata_std_hardreset(struct ata_port *ap, int verbose, unsigned int *class)
 {
-	u32 sstatus, serror;
-	unsigned long timeout = jiffies + (HZ * 5);
+	u32 serror;

 	DPRINTK("ENTER\n");

@@ -2371,15 +2388,8 @@
 	 */
 	msleep(1);

-	scr_write_flush(ap, SCR_CONTROL, 0x300);
-
-	/* Wait for phy to become ready, if necessary. */
-	do {
-		msleep(200);
-		sstatus = scr_read(ap, SCR_STATUS);
-		if ((sstatus & 0xf) != 1)
-			break;
-	} while (time_before(jiffies, timeout));
+	/* Bring phy back */
+	sata_phy_resume(ap);

 	/* Clear SError */
 	serror = scr_read(ap, SCR_ERROR);


serial/uart_nrf5: Make config_info pointers const.

Preparation for const driver configuration data.

Change-Id: Id02596f2e35faa2e3ba2c0e0ffd7bbe8e5e92896
Signed-off-by: Marcus Shawcroft <cf6354583ee83038f2010cbcbe1b1f2adb85107d@gmail.com>

--- drivers/serial/uart_nrf5.c
+++ drivers/serial/uart_nrf5.c
@@ -82,7 +82,7 @@

 /* convenience defines */
 #define DEV_CFG(dev) \
-	((struct uart_device_config * const)(dev)->config->config_info)
+	((const struct uart_device_config * const)(dev)->config->config_info)
 #define DEV_DATA(dev) \
 	((struct uart_nrf5_dev_data_t * const)(dev)->driver_data)
 #define UART_STRUCT(dev) \


uart qmsi: Fix definition of device_pm_ops

The macro defining the device_pm_ops structs is located inside an
ifdef for CONFIG_UART_QMSI_0, so when the UART_0 is disabled at build
time, but UART_1 is still used, it references a struct not defined.

Fix it by placing the DEFINE_DEVICE_PM_OPS line outside the ifdef block.

Change-Id: I7dafda162741201ee47b5b480c07ec8c1f373d64
Signed-off-by: Iván Briano <e5bb0ea9e2726000eec3a04030e22edb132ff9c8@intel.com>

--- drivers/serial/uart_qmsi.c
+++ drivers/serial/uart_qmsi.c
@@ -91,6 +91,8 @@
 }
 #endif

+DEFINE_DEVICE_PM_OPS(uart, device_pm_nop, uart_resume_device);
+
 #ifdef CONFIG_UART_QMSI_0
 #ifdef CONFIG_UART_INTERRUPT_DRIVEN
 static void irq_config_func_0(struct device *dev);
@@ -113,8 +115,6 @@
 };

 static struct uart_qmsi_drv_data drv_data_0;
-
-DEFINE_DEVICE_PM_OPS(uart, device_pm_nop, uart_resume_device);

 DEVICE_INIT_PM(uart_0, CONFIG_UART_QMSI_0_NAME, &uart_qmsi_init,
 	       DEVICE_PM_OPS_GET(uart), &drv_data_0, &config_info_0, PRIMARY,


Staging: hv: rename the vmbus to "hyperv"

This changes the name of the bus in sysfs from "vmbus" to "hyperv" which
is the name it should show (vmbus is way to generic).

Cc: Haiyang Zhang <6c26c5044f1d67d9ed5db6596adb36d25510e216@microsoft.com>
Cc: Hank Janssen <e6f1dacc1d794bd13c3a15bd13b25100c5d4d1f8@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>

--- drivers/staging/hv/vmbus.c
+++ drivers/staging/hv/vmbus.c
@@ -27,7 +27,7 @@
 #include "version_info.h"
 #include "vmbus_private.h"

-static const char *gDriverName = "vmbus";
+static const char *gDriverName = "hyperv";

 /*
  * Windows vmbus does not defined this.


USB: usbtmc: Use usb_clear_halt() instead of custom code.

Make the USB Test & Measurement driver use usb_clear_halt() instead of
usb_control_msg() to clear a stalled endpoint.  This will allow devices to
be tested under an xHCI host controller.  The endpoint stall will not be
cleared in the internal xHCI hardware state unless usb_clear_halt() is
used.

Signed-off-by: Sarah Sharp <d4c4fc5069677be84f589aa6e14eedffef9ba12f@linux.intel.com>
Cc: Steve Holland <23b529bba871edbcd85f2c23d57535c937df77fa@iastate.edu>
Cc: Oliver Neukum <c539153ba1f947bd4b6f910263b967c4a0a62357@neukum.org>
Cc: Jouni Ryno <4a4aca96578a40b384fded176040324948d68fb4@fmi.fi>
Cc: Gergely Imreh <74449e3aedfaa0d6a6bf65a913316ac698c6961f@gmail.com>
Signed-off-by: Greg Kroah-Hartman <4645f7897fd33786a2ee1264d590b3c400559d85@suse.de>

--- drivers/usb/class/usbtmc.c
+++ drivers/usb/class/usbtmc.c
@@ -347,13 +347,8 @@
 	goto exit;

 usbtmc_abort_bulk_out_clear_halt:
-	rv = usb_control_msg(data->usb_dev,
-			     usb_sndctrlpipe(data->usb_dev, 0),
-			     USB_REQ_CLEAR_FEATURE,
-			     USB_DIR_OUT | USB_TYPE_STANDARD |
-			     USB_RECIP_ENDPOINT,
-			     USB_ENDPOINT_HALT, data->bulk_out, buffer,
-			     0, USBTMC_TIMEOUT);
+	rv = usb_clear_halt(data->usb_dev,
+			    usb_sndbulkpipe(data->usb_dev, data->bulk_out));

 	if (rv < 0) {
 		dev_err(dev, "usb_control_msg returned %d\n", rv);
@@ -708,14 +703,8 @@

 usbtmc_clear_bulk_out_halt:

-	rv = usb_control_msg(data->usb_dev,
-			     usb_sndctrlpipe(data->usb_dev, 0),
-			     USB_REQ_CLEAR_FEATURE,
-			     USB_DIR_OUT | USB_TYPE_STANDARD |
-			     USB_RECIP_ENDPOINT,
-			     USB_ENDPOINT_HALT,
-			     data->bulk_out, buffer, 0,
-			     USBTMC_TIMEOUT);
+	rv = usb_clear_halt(data->usb_dev,
+			    usb_sndbulkpipe(data->usb_dev, data->bulk_out));
 	if (rv < 0) {
 		dev_err(dev, "usb_control_msg returned %d\n", rv);
 		goto exit;
@@ -736,13 +725,8 @@
 	if (!buffer)
 		return -ENOMEM;

-	rv = usb_control_msg(data->usb_dev,
-			     usb_sndctrlpipe(data->usb_dev, 0),
-			     USB_REQ_CLEAR_FEATURE,
-			     USB_DIR_OUT | USB_TYPE_STANDARD |
-			     USB_RECIP_ENDPOINT,
-			     USB_ENDPOINT_HALT, data->bulk_out,
-			     buffer, 0, USBTMC_TIMEOUT);
+	rv = usb_clear_halt(data->usb_dev,
+			    usb_sndbulkpipe(data->usb_dev, data->bulk_out));

 	if (rv < 0) {
 		dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n",
@@ -765,12 +749,8 @@
 	if (!buffer)
 		return -ENOMEM;

-	rv = usb_control_msg(data->usb_dev, usb_sndctrlpipe(data->usb_dev, 0),
-			     USB_REQ_CLEAR_FEATURE,
-			     USB_DIR_OUT | USB_TYPE_STANDARD |
-			     USB_RECIP_ENDPOINT,
-			     USB_ENDPOINT_HALT, data->bulk_in, buffer, 0,
-			     USBTMC_TIMEOUT);
+	rv = usb_clear_halt(data->usb_dev,
+			    usb_rcvbulkpipe(data->usb_dev, data->bulk_in));

 	if (rv < 0) {
 		dev_err(&data->usb_dev->dev, "usb_control_msg returned %d\n",


formatting changes

formatting changes

git-svn-id: e88a1e38e13faf406e05cc89eca8dd613216f6c4@880 434f946d-2f3d-0410-ba4c-cb9f52fb0dbf

--- trunk/libmesh/include/base/variant_filter_iterator.h
+++ trunk/libmesh/include/base/variant_filter_iterator.h
@@ -1,4 +1,4 @@
-// $Id: variant_filter_iterator.h,v 1.3 2004-11-09 21:46:16 benkirk Exp $
+// $Id: variant_filter_iterator.h,v 1.4 2004-11-09 22:24:32 benkirk Exp $

 // The libMesh Finite Element Library.
 // Copyright (C) 2002-2004  Benjamin S. Kirk, John W. Peterson
@@ -24,6 +24,8 @@

 #include <iterator>
 #include <iostream>
+#include <algorithm> // for std::swap
+#include <stdlib.h>  // for abort()

 /**
  * Original Authors: Corwin Joy          * Michael Gradman
@@ -45,9 +47,11 @@
 class variant_filter_iterator : public std::iterator<std::forward_iterator_tag,  Type>
 #endif
 {
-public:
-
-  // Abstract base class for the iterator type.
+private:
+
+  /**
+   * Abstract base class for the iterator type.
+   */
   struct IterBase
   {
     virtual ~IterBase() {}
@@ -58,7 +62,10 @@
   };

-  // Abstract base class for the predicate.
+
+  /**
+   * Abstract base class for the predicate.
+   */
   struct PredBase
   {
     virtual ~PredBase() {}
@@ -68,21 +75,27 @@

-  // The actual iterator object is held as a template parameter here.
+  /**
+   * The actual iterator object is held as a template parameter here.
+   */
   template<typename IterType>
   struct Iter : IterBase
   {
-    // Constructor
-    Iter ( IterType v ) : iter_data ( v )
-    {}
-
-
-    // Destructor
+    /**
+     * Constructor
+     */
+    Iter (const IterType& v) :
+      iter_data (v) {}
+
+    /**
+     * Destructor
+     */
     virtual ~Iter () {}
-

-    // Returns a copy of this object as a pointer to
-    // the base (non-templated) class.
+    /**
+     * @returns a copy of this object as a pointer to
+     * the base (non-templated) class.
+     */
     virtual IterBase* clone() const
     {
       variant_filter_iterator::Iter<IterType> *copy =
@@ -90,60 +103,73 @@
       return copy;
     }

-
+    /**
+     * Custom interface method.
+     */
     virtual Type& operator*() const   // <-- CUSTOM INTERFACE METHOD
     {
       return *iter_data;
     }

-
-
+    /**
+     * Custom interface method.
+     */
     virtual void operator++()         // <-- CUSTOM INTERFACE METHOD
     {
-      //std::cout << "called Iter::op++()" << std::endl;
       ++iter_data;
     }

-    // Use dynamic_cast to convert the base pointer
-    // passed in to the derived type.  If the cast
-    // fails it means you compared two different derived
-    // classes.
+    /**
+     * Use dynamic_cast to convert the base pointer
+     * passed in to the derived type.  If the cast
+     * fails it means you compared two different derived
+     * classes.
+     */
     virtual bool equal(const IterBase *other) const
     {
       const variant_filter_iterator::Iter<IterType>* p =
 	dynamic_cast<const variant_filter_iterator::Iter<IterType>*>(other);
-
+
       // Check for failed cast
-      if ( p == NULL )
+      if (p == NULL)
 	{
 	  std::cerr << "Dynamic cast failed in Iter::equal(...)" << std::endl;
 	  abort();
 	}

-      //std::cout << "called Iter::equal" << std::endl;
-      return iter_data == p->iter_data;
-    }
-
+      return (iter_data == p->iter_data);
+    }
+
+    /**
+     * This is the iterator passed by the user.
+     */
     IterType iter_data;
   };

-
-
-
-  // The actual predicate is held as a template parameter here.
-  // There are two template arguments here, one for the actual type
-  // of the predicate and one for the iterator type.
+
+  /**
+   * The actual predicate is held as a template parameter here.
+   * There are two template arguments here, one for the actual type
+   * of the predicate and one for the iterator type.
+   */
   template <typename IterType, typename PredType>
   struct Pred : PredBase
   {
-    // Constructor
-    Pred ( PredType const& v ) : pred_data ( v ) {}
-
-    // Destructor
+    /**
+     * Constructor
+     */
+    Pred (const PredType& v) :
+      pred_data (v) {}
+
+    /**
+     * Destructor
+     */
     virtual ~Pred () {}

-    // Returns a copy of this object as a pointer to the base class.
+    /**
+     * Returns a copy of this object as a pointer to the base class.
+     */
     virtual PredBase* clone() const
     {
       variant_filter_iterator::Pred<IterType,PredType> *copy =
@@ -151,10 +177,11 @@
       return copy;
     }

-    // Re-implementation of op()
+    /**
+     * Re-implementation of op()
+     */
     virtual bool operator() (const IterBase* in) const
     {
-      //std::cout << "called Pred::op()" << std::endl;
       assert (in != NULL);

       // Attempt downcast
@@ -173,87 +200,105 @@
       return pred_data(p->iter_data);
     }

-    // This is the predicate passed in by the user.
+    /**
+     * This is the predicate passed in by the user.
+     */
     PredType pred_data;
   };

- private:
-  // Polymorphic pointer to the object.  Don't confuse
-  // with the data pointer located in the Iter!
+
+  /**
+   * Polymorphic pointer to the object.  Don't confuse
+   * with the data pointer located in the \p Iter!
+   */
   IterBase* data;

-  // Also have a polymorphic pointer to the end object,
-  // this prevents iterating past the end.
+  /**
+   * Also have a polymorphic pointer to the end object,
+   * this prevents iterating past the end.
+   */
   IterBase* end;

-  // The predicate object.  Must have op() capable of
-  // operating on IterBase* pointers.  Therefore it has
-  // to follow the same paradigm as IterBase.
+  /**
+   * The predicate object.  Must have op() capable of
+   * operating on IterBase* pointers.  Therefore it has
+   * to follow the same paradigm as \p IterBase.
+   */
   PredBase* pred;

-
-

 public:
+
+  /**
+   * The iterator this class provides.
+   */
   typedef variant_filter_iterator<Type, Predicate> Iterator;

-  // Templated Constructor.  Allows you to construct the iterator
-  // and predicate from any types.  Also advances the data pointer
-  // to the first entry which satisfies the predicate.
+  /**
+   * Templated Constructor.  Allows you to construct the iterator
+   * and predicate from any types.  Also advances the data pointer
+   * to the first entry which satisfies the predicate.
+   */
   template<typename IterType, class PredType>
-  variant_filter_iterator ( IterType const& v, IterType const& e, PredType const& p )
-    : data ( new Iter<IterType>(v) ),
-      end  ( new Iter<IterType>(e) ),
-      pred ( new Pred<IterType,PredType>(p) )
+  variant_filter_iterator (const IterType& d,
+			   const IterType& e,
+			   const PredType& p ):
+    data ( new Iter<IterType>(d) ),
+    end  ( new Iter<IterType>(e) ),
+    pred ( new Pred<IterType,PredType>(p) )
   {
     this->satisfy_predicate();
   }
-
-
-
-  // Default Constructor.
-  variant_filter_iterator () : data(NULL), end(NULL), pred(NULL) {}
-
-
-
-  // Copy Constructor.
-  // * Copy the internal data instead of sharing it.
-  variant_filter_iterator( const Iterator& rhs ) :
-    data ( rhs.data != NULL ? rhs.data->clone() : NULL),
-    end  ( rhs.end  != NULL ? rhs.end->clone()  : NULL),
-    pred ( rhs.pred != NULL ? rhs.pred->clone() : NULL)
-  {}
-
-
-
-  // Destructor
+
+  /**
+   * Default Constructor.
+   */
+  variant_filter_iterator () :
+    data(NULL),
+    end(NULL),
+    pred(NULL) {}
+
+  /**
+   * Copy Constructor.
+   * Copy the internal data instead of sharing it.
+   */
+  variant_filter_iterator (const Iterator& rhs) :
+    data (rhs.data != NULL ? rhs.data->clone() : NULL),
+    end  (rhs.end  != NULL ? rhs.end->clone()  : NULL),
+    pred (rhs.pred != NULL ? rhs.pred->clone() : NULL) {}
+
+  /**
+   * Destructor
+   */
   ~variant_filter_iterator()
   {
-    delete data;
-    delete end;
-    delete pred;
-  }
-
-
-
-  // unary op*() forwards on to Iter::op*()
+    delete data; data = NULL;
+    delete end;  end  = NULL;
+    delete pred; pred = NULL;
+  }
+
+  /**
+   * unary op*() forwards on to \p Iter::op*()
+   */
   Type& operator*() const
   {
     return **data;
   }

-  // op->()
+  /**
+   * op->()
+   */
   Type* operator->() const
   {
     return (&**this);
   }
-
-
-
-  // op++() forwards on to Iter::op++()
+
+  /**
+   * op++() forwards on to \p Iter::op++()
+   */
   Iterator& operator++()
   {
     ++*data;
@@ -261,7 +306,9 @@
     return (*this);
   }

-  // postfix op++() creates a temporary!
+  /**
+   * postfix op++(), creates a temporary!
+   */
   const Iterator operator++(int) // const here to prevent iterator++++ type operations
   {
     Iterator oldValue(*this); // standard is to return old value
@@ -270,44 +317,35 @@
     return oldValue;
   }

-
-  // forwards on the the equal function defined for the
-  // IterBase pointer.  Possibly also compare the end pointers,
-  // but this is usually not important and would require an
-  // additional dynamic_cast.
+  /**
+   * forwards on the the equal function defined for the
+   * IterBase pointer.  Possibly also compare the end pointers,
+   * but this is usually not important and would require an
+   * additional dynamic_cast.
+   */
   bool equal(const variant_filter_iterator& other) const
   {
     return data->equal(other.data);
   }

-
-
-
-
-  // swap, used to implement op=
+  /**
+   * swap, used to implement op=
+   */
   void swap(Iterator& lhs, Iterator& rhs)
   {
-    IterBase *temp;
-
     // Swap the data pointers
-    temp = lhs.data;
-    lhs.data = rhs.data;
-    rhs.data = temp;
+    std::swap (lhs.data, rhs.data);

     // Swap the end pointers
-    temp = lhs.end;
-    lhs.end = rhs.end;
-    rhs.end = temp;
+    std::swap (lhs.end, rhs.end);

     // Also swap the predicate objects.
-    PredBase *tempp;
-    tempp    = lhs.pred;
-    lhs.pred = rhs.pred;
-    rhs.pred = tempp;
-  }
-
-
-  // op=
+    std::swap (lhs.pred, rhs.pred);
+  }
+
+  /**
+   * Assignment operator.
+   */
   Iterator& operator=(const Iterator& rhs)
   {
     Iterator temp(rhs);
@@ -318,14 +356,16 @@

 private:
-  // Advances the data pointer until it reaches
-  // the end or the predicate is satisfied.
+
+  /**
+   * Advances the data pointer until it reaches
+   * the end or the predicate is satisfied.
+   */
   void satisfy_predicate()
   {
-    while ( !(data->equal(end)) && ( !(*pred)(data) ) )
+    while ( !data->equal(end) && !(*pred)(data) )
       ++(*data);
-  }
-
+  }
 };

@@ -333,13 +373,13 @@

+//---------------------------------------------------------------------------
 // op==
 template<class Type, class Predicate>
 inline
 bool operator==(const variant_filter_iterator<Type, Predicate>& x,
 		const variant_filter_iterator<Type, Predicate>& y)
 {
-  //std::cout << "Called op==() for variant_filter_iterators." << std::endl;
   return x.equal(y);
 }

@@ -351,8 +391,7 @@
 bool operator!=(const variant_filter_iterator<Type, Predicate>& x,
 		const variant_filter_iterator<Type, Predicate>& y)
 {
-  //std::cout << "Called op!=() for variant_filter_iterators." << std::endl;
-  return (!(x == y));
+  return !(x == y);
 }


COMP: Eliminate compiler warnings about the vtktiff code on the 64-bit Windows dashboards.

--- Utilities/vtktiff/tif_dirwrite.c
+++ Utilities/vtktiff/tif_dirwrite.c
@@ -1004,6 +1004,12 @@
         return (status);
 }

+#if defined ( _MSC_VER )
+#if defined ( _WIN64 )
+#pragma warning ( disable : 4334 )
+#endif
+#endif
+
 static int
 TIFFWriteTransferFunction(TIFF* tif, TIFFDirEntry* dir)
 {


More asserts, sp->vbc this time.

More asserts, sp->vbc this time.

git-svn-id: 2c9807fa3ff65b17195bd55dc8a6c4261e10127b@606 d4fa192b-c00b-0410-8231-f00ffab90ce4

--- bin/varnishd/cache_center.c
+++ bin/varnishd/cache_center.c
@@ -84,6 +84,7 @@
 {

 	assert(sp->obj == NULL);
+	assert(sp->vbc == NULL);
 	if (sp->fd >= 0 && sp->doclose != NULL)
 		vca_close_session(sp, sp->doclose);
 	VCL_Rel(sp->vcl);
@@ -163,6 +164,7 @@
 cnt_fetch(struct sess *sp)
 {

+	assert(sp->vbc != NULL);
 	RFC2616_cache_policy(sp, sp->vbc->http);

 	VCL_fetch_method(sp);
@@ -188,7 +190,9 @@
 	}
 	if (sp->handling == VCL_RET_INSERT) {
 		sp->obj->cacheable = 1;
+		assert(sp->vbc != NULL);
 		FetchBody(sp);
+		assert(sp->vbc == NULL);
 		HSH_Ref(sp->obj); /* get another, STP_DELIVER will deref */
 		HSH_Unbusy(sp->obj);
 		sp->wrk->acct.fetch++;
@@ -400,8 +404,10 @@
 	if (sp->handling == VCL_RET_LOOKUP)
 		INCOMPL();
 	if (sp->handling == VCL_RET_FETCH) {
+		assert(sp->vbc == NULL);
 		FetchHeaders(sp);
 		sp->step = STP_FETCH;
+		assert(sp->vbc != NULL);
 		return (0);
 	}
 	INCOMPL();
@@ -426,7 +432,9 @@
 cnt_pass(struct sess *sp)
 {

+	assert(sp->vbc == NULL);
 	PassSession(sp);
+	assert(sp->vbc != NULL);
 	sp->step = STP_PASSBODY;
 	return (0);
 }
@@ -451,7 +459,9 @@
 {

 	sp->wrk->acct.pass++;
+	assert(sp->vbc != NULL);
 	PassBody(sp);
+	assert(sp->vbc == NULL);
 	sp->step = STP_DONE;
 	return (0);
 }
@@ -518,6 +528,7 @@
 	sp->vcl = VCL_Get();

 	assert(sp->obj == NULL);
+	assert(sp->vbc == NULL);

 	sp->wrk->acct.req++;
 	done = http_DissectRequest(sp->http, sp->fd);


No need for initialization

No need for initialization

--- bin/varnishtest/vtc_http2.c
+++ bin/varnishtest/vtc_http2.c
@@ -342,7 +342,7 @@
 static void
 exclusive_stream_dependency(const struct stream *s)
 {
-	struct stream *target = NULL;
+	struct stream *target;
 	struct http *hp = s->hp;

 	if (s->id == 0)


bin/xbps-rindex/index-add.c: use-after-free (CID 62764)

--- bin/xbps-rindex/index-add.c
+++ bin/xbps-rindex/index-add.c
@@ -46,7 +46,7 @@
 	struct xbps_repo *repo = NULL;
 	struct stat st;
 	const char *arch;
-	char *sha256, *pkgver, *opkgver, *oarch, *pkgname;
+	char *sha256, *pkgver, *pkgname;
 	char *tmprepodir = NULL, *repodir = NULL;
 	int rv = 0, ret = 0;
 	bool flush = false, found = false;
@@ -114,6 +114,8 @@
 				goto out;
 			}
 		} else if (!force) {
+			char *opkgver = NULL, *oarch = NULL;
+
 			/* Only check version if !force */
 			xbps_dictionary_get_cstring(curpkgd, "pkgver", &opkgver);
 			xbps_dictionary_get_cstring(curpkgd, "architecture", &oarch);
@@ -123,14 +125,13 @@
 			 * If the considered package reverts the package in the index,
 			 * consider the current package as the newer one.
 			 */
-			if(ret < 0 && xbps_pkg_reverts(binpkgd, opkgver)) {
+			if (ret < 0 && xbps_pkg_reverts(binpkgd, opkgver)) {
 				ret = 1;
-			}
 			/*
 			 * If package in the index reverts considered package, consider the
 			 * package in the index as the newer one.
 			 */
-			else if (ret > 0 && xbps_pkg_reverts(curpkgd, pkgver)) {
+			} else if (ret > 0 && xbps_pkg_reverts(curpkgd, pkgver)) {
 				ret = -1;
 			}

@@ -148,9 +149,9 @@
 			 * Current package version is greater than
 			 * index version.
 			 */
+			printf("index: removed obsolete entry `%s' (%s).\n", opkgver, oarch);
 			xbps_dictionary_remove(idx, pkgname);
 			xbps_dictionary_remove(idxfiles, opkgver);
-			printf("index: removed obsolete entry `%s' (%s).\n", opkgver, oarch);
 			free(opkgver);
 			free(oarch);
 		}


Add some debug logging

Add some debug logging

git-svn-id: a4d7c1866f8397a4106e0b57fc4fbf792bbdaaaf@10343 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

--- libavformat/matroskaenc.c
+++ libavformat/matroskaenc.c
@@ -601,6 +601,8 @@
     MatroskaMuxContext *mkv = s->priv_data;
     ByteIOContext *pb = &s->pb;

+    av_log(s, AV_LOG_DEBUG, "Writing block at offset %llu, size %d, pts %lld, dts %lld, duration %d, flags %d\n",
+           url_ftell(pb), pkt->size, pkt->pts, pkt->dts, pkt->duration, flags);
     put_ebml_id(pb, blockid);
     put_ebml_size(pb, pkt->size + 4, 0);
     put_byte(pb, 0x80 | (pkt->stream_index + 1));     // this assumes stream_index is less than 126
@@ -618,6 +620,7 @@

     // start a new cluster every 5 MB or 5 sec
     if (url_ftell(pb) > mkv->cluster + 5*1024*1024 || pkt->pts > mkv->cluster_pts + 5000) {
+        av_log(s, AV_LOG_DEBUG, "Starting new cluster at offset %llu bytes, pts %llu\n", url_ftell(pb), pkt->pts);
         end_ebml_master(pb, mkv->cluster);

         if (mkv_add_seekhead_entry(mkv->cluster_seekhead, MATROSKA_ID_CLUSTER, url_ftell(pb)) < 0)
@@ -663,6 +666,7 @@
     mkv_write_seekhead(pb, mkv->main_seekhead);

     // update the duration
+    av_log(s, AV_LOG_DEBUG, "end duration = %llu\n", mkv->duration);
     currentpos = url_ftell(pb);
     url_fseek(pb, mkv->duration_offset, SEEK_SET);
     put_ebml_float(pb, MATROSKA_ID_DURATION, mkv->duration);


syslog.c: fix indentation and style. No code changes.

--- libc/misc/syslog/syslog.c
+++ libc/misc/syslog/syslog.c
@@ -148,46 +148,46 @@
  * OPENLOG -- open system log
  */
 void
-openlog( const char *ident, int logstat, int logfac )
-{
-    int logType = SOCK_DGRAM;
-
-    __UCLIBC_MUTEX_LOCK(mylock);
-
-    if (ident != NULL)
-	LogTag = ident;
-    LogStat = logstat;
-    if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0)
-	LogFacility = logfac;
-    if (LogFile == -1) {
+openlog(const char *ident, int logstat, int logfac)
+{
+	int logType = SOCK_DGRAM;
+
+	__UCLIBC_MUTEX_LOCK(mylock);
+
+	if (ident != NULL)
+		LogTag = ident;
+	LogStat = logstat;
+	if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0)
+		LogFacility = logfac;
+	if (LogFile == -1) {
 retry:
-	if (LogStat & LOG_NDELAY) {
-	    if ((LogFile = socket(AF_UNIX, logType, 0)) == -1) {
-		goto DONE;
-	    }
-	    fcntl(LogFile, F_SETFD, 1); /* 1 == FD_CLOEXEC */
-	    /* We don't want to block if e.g. syslogd is SIGSTOPed */
-	    fcntl(LogFile, F_SETFL, O_NONBLOCK | fcntl(LogFile, F_GETFL));
-	}
-    }
-
-    if (LogFile != -1 && !connected) {
-	if (connect(LogFile, &SyslogAddr, sizeof(SyslogAddr)) != -1) {
-	    connected = 1;
-	} else {
-	    if (LogFile != -1) {
-		close(LogFile);
-		LogFile = -1;
-	    }
-	    if (logType == SOCK_DGRAM) {
-		logType = SOCK_STREAM;
-		goto retry;
-	    }
-	}
-    }
+		if (LogStat & LOG_NDELAY) {
+			if ((LogFile = socket(AF_UNIX, logType, 0)) == -1) {
+				goto DONE;
+			}
+			fcntl(LogFile, F_SETFD, 1); /* 1 == FD_CLOEXEC */
+			/* We don't want to block if e.g. syslogd is SIGSTOPed */
+			fcntl(LogFile, F_SETFL, O_NONBLOCK | fcntl(LogFile, F_GETFL));
+		}
+	}
+
+	if (LogFile != -1 && !connected) {
+		if (connect(LogFile, &SyslogAddr, sizeof(SyslogAddr)) != -1) {
+			connected = 1;
+		} else {
+			if (LogFile != -1) {
+				close(LogFile);
+				LogFile = -1;
+			}
+			if (logType == SOCK_DGRAM) {
+				logType = SOCK_STREAM;
+				goto retry;
+			}
+		}
+	}

 DONE:
-    __UCLIBC_MUTEX_UNLOCK(mylock);
+	__UCLIBC_MUTEX_UNLOCK(mylock);
 }
 libc_hidden_def(openlog)

@@ -196,7 +196,7 @@
  *     print message on log file; output is intended for syslogd(8).
  */
 void
-vsyslog( int pri, const char *fmt, va_list ap )
+vsyslog(int pri, const char *fmt, va_list ap)
 {
 	register char *p;
 	char *last_chr, *head_end, *end, *stdp;
@@ -207,10 +207,10 @@
 	struct sigaction action, oldaction;
 	int sigpipe;

-	memset (&action, 0, sizeof (action));
+	memset(&action, 0, sizeof(action));
 	action.sa_handler = closelog_intern;
-	sigemptyset (&action.sa_mask);
-	sigpipe = sigaction (SIGPIPE, &action, &oldaction);
+	sigemptyset(&action.sa_mask); /* TODO: memset already zeroed it out! */
+	sigpipe = sigaction(SIGPIPE, &action, &oldaction);

 	saved_errno = errno;

@@ -317,7 +317,7 @@
 getout:
 	__UCLIBC_MUTEX_UNLOCK(mylock);
 	if (sigpipe == 0)
-		sigaction (SIGPIPE, &oldaction, (struct sigaction *) NULL);
+		sigaction(SIGPIPE, &oldaction, (struct sigaction *) NULL);
 }
 libc_hidden_def(vsyslog)

@@ -336,7 +336,7 @@
  * CLOSELOG -- close the system log
  */
 void
-closelog( void )
+closelog(void)
 {
 	closelog_intern(0); /* 0: do not reset LogXXX globals to default */
 }
@@ -345,13 +345,12 @@
 /* setlogmask -- set the log mask level */
 int setlogmask(int pmask)
 {
-    int omask;
-
-    omask = LogMask;
-    __UCLIBC_MUTEX_LOCK(mylock);
-    if (pmask != 0)
-	LogMask = pmask;
-    __UCLIBC_MUTEX_UNLOCK(mylock);
-    return (omask);
-}
-
+	int omask;
+
+	omask = LogMask;
+	__UCLIBC_MUTEX_LOCK(mylock);
+	if (pmask != 0)
+		LogMask = pmask;
+	__UCLIBC_MUTEX_UNLOCK(mylock);
+	return omask;
+}


Improves coverage

Improves coverage

--- libchula/test/util_test.c
+++ libchula/test/util_test.c
@@ -317,13 +317,11 @@
     chula_tmp_dir_copy (&path);
     chula_buffer_add_va (&path, "/mkdir_pid%d/mkdir/1/22/333/4444", getpid());

-    printf ("path1 %s\n", path.buf);
-
     /* Path does not exists */
     ck_assert (chula_stat (path.buf, &st) == -1);

     /* Create dir */
-    ret = chula_mkdir_p (&path, 0777);
+    ret = chula_mkdir_p_perm (&path, 0777, R_OK);
     ck_assert (ret == ret_ok);

     /* Path does exists */


Solve the hang issue at the end of video capture using goocamera.

Set the correct  changes of states for de-initialization of tunneled components.

--- libgoo-ti/goo-ti-camera.c
+++ libgoo-ti/goo-ti-camera.c
@@ -526,7 +526,7 @@
 	OMX_PARAM_PORTDEFINITIONTYPE* param;
 	param = GOO_PORT_GET_DEFINITION (port);

-	if (vstab_mode == TRUE)
+	if (vstab_mode == TRUE /*&&   param->format.video.eColorFormat == OMX_COLOR_FormatYCbYCr*/)

 	{
 		GOO_OBJECT_DEBUG (self, "activating vstab");
@@ -540,6 +540,7 @@
 		goo_component_set_config_by_index (GOO_COMPONENT (self),
 						   OMX_IndexConfigCommonFrameStabilisation,
 						   param);
+
 		g_free (param);
 	}

@@ -999,8 +1000,6 @@
 		return;
 	}

-	GOO_OBJECT_INFO (postproc, "Sending idle state command");
-
 	/* Sending postprocessor to idle state */
 #if 1
 	goo_component_set_state_idle (postproc);
@@ -1015,7 +1014,6 @@
 		);
 	GOO_OBJECT_UNLOCK (postproc);
 #endif
-
 	goo_component_wait_for_next_state (postproc);
 	g_object_unref (postproc);

@@ -1061,14 +1059,16 @@
 	{
 		goo_component_allocate_all_ports (videoenc);
 	}
-
+
+	goo_component_wait_for_next_state (videoenc);
 	if (tmpstate == OMX_StateExecuting)
 	{
 		/* unblock all the async_queues */
 		goo_component_flush_all_ports (videoenc);
 	}
-#endif
-	goo_component_wait_for_next_state (videoenc);
+
+#endif
+	goo_component_wait_for_next_state (videoenc);
 	g_object_unref (videoenc);
 	return;
 }
@@ -1137,17 +1137,16 @@
 		g_assert (FALSE);
 	}

-	GOO_OBJECT_INFO (self, "Sending idle state command");
-
-	/* we need the postprocessor in idle before camera*/
-	goo_ti_camera_pp_set_idle (self);
-
+	if (tmpstate == OMX_StateLoaded)
+	{
+		goo_ti_camera_pp_set_idle (self);
+	}
 	if (tmpstate == OMX_StateExecuting)
 	{
 		goo_ti_camera_venc_set_idle (self);
 		goo_ti_camera_jpeg_set_idle (self);
 	}
-
+
 	GOO_OBJECT_LOCK (self);
 	GOO_RUN (
 		OMX_SendCommand (self->handle,
@@ -1168,13 +1167,12 @@
 	{
 	}

+	if (tmpstate == OMX_StateExecuting)
+	{
+		goo_ti_camera_pp_set_idle (self);
+	}
+
 	goo_component_wait_for_next_state (self);
-
-	if (tmpstate == OMX_StateLoaded)
-	{
-		goo_ti_camera_venc_set_idle (self);
-		goo_ti_camera_jpeg_set_idle (self);
-	}

 	if (tmpstate == OMX_StateExecuting)
 	{
@@ -1187,8 +1185,13 @@
 		g_object_unref (port);
 	}

-	GOO_OBJECT_DEBUG (self, "");
-
+
+	if (tmpstate == OMX_StateLoaded)
+	{
+		goo_ti_camera_venc_set_idle (self);
+		goo_ti_camera_jpeg_set_idle (self);
+	}
+
 	return;
 }

@@ -1233,7 +1236,6 @@

 	goo_component_set_state_loaded (videoenc);

-
 	goo_component_wait_for_next_state (videoenc);
 	g_object_unref (videoenc);
 	return;
@@ -1246,7 +1248,6 @@

 	if (jpegenc == NULL)
 	{
-
 		return;
 	}

@@ -1255,10 +1256,7 @@
 		return;
 	}

-
 	goo_component_set_state_loaded (jpegenc);
-
-

 	goo_component_wait_for_next_state (jpegenc);
 	g_object_unref (jpegenc);
@@ -1270,14 +1268,9 @@
 {
 	self->next_state = OMX_StateLoaded;

-
-
 	goo_ti_camera_pp_set_loaded (self);

-
-
 	GOO_OBJECT_INFO (self, "Sending load state command");
-
 	GOO_OBJECT_LOCK (self);
 	GOO_RUN (
 		OMX_SendCommand (self->handle,
@@ -1288,10 +1281,8 @@
 	GOO_OBJECT_UNLOCK (self);

 	goo_ti_camera_venc_set_loaded (self);
-	goo_ti_camera_jpeg_set_loaded (self);
-
-
-
+	goo_ti_camera_jpeg_set_loaded (self);
+
 	if (self->cur_state == OMX_StateIdle &&
 	    self->next_state == OMX_StateLoaded)
 	{
@@ -1358,7 +1349,31 @@

 		g_object_unref (videoenc);
 	}
-
+/*
+	GooComponent* jpegenc = goo_ti_camera_get_enc (self);
+
+	if (jpegenc != NULL)
+	{
+		GOO_OBJECT_INFO (jpegenc, "Sending executing state command");
+#if 1
+		goo_component_set_state_executing (jpegenc);
+#else
+		GOO_OBJECT_LOCK (jpegenc);
+		jpegenc->next_state = OMX_StateExecuting;
+		GOO_RUN (
+			OMX_SendCommand (jpegenc->handle,
+					 OMX_CommandStateSet,
+					 jpegenc->next_state,
+				 	NULL)
+			);
+		GOO_OBJECT_UNLOCK (jpegenc);
+#endif
+
+		goo_component_wait_for_next_state (jpegenc);
+
+		g_object_unref (jpegenc);
+	}
+*/
 	return;
 }


Refactor: item stats

Refactor: item stats

--- items.c
+++ items.c
@@ -132,13 +132,6 @@

 static EXTENSION_LOGGER_DESCRIPTOR *logger;

-void item_stats_reset(struct default_engine *engine)
-{
-    pthread_mutex_lock(&engine->cache_lock);
-    memset(engine->items.itemstats, 0, sizeof(engine->items.itemstats));
-    pthread_mutex_unlock(&engine->cache_lock);
-}
-
 /* warning: don't use these macros with a function, as it evals its arg twice */
 static inline size_t ITEM_ntotal(struct default_engine *engine, const hash_item *item)
 {
@@ -938,33 +931,33 @@

 static void do_item_stats(struct default_engine *engine, ADD_STAT add_stats, const void *c)
 {
-    int i;
-    for (i = 0; i <= POWER_LARGEST; i++)
+    const char *prefix = "items";
+
+    for (int i = 0; i <= POWER_LARGEST; i++)
     {
-        if (engine->items.tails[i] != NULL || engine->items.sticky_tails[i] != NULL)
-        {
-            const char *prefix = "items";
-            add_statistics(c, add_stats, prefix, i, "number", "%u",
-                           engine->items.sizes[i]+engine->items.sticky_sizes[i]);
+        if (engine->items.tails[i] == NULL && engine->items.sticky_tails[i] == NULL)
+            continue;
+
+        add_statistics(c, add_stats, prefix, i, "number", "%u",
+                       engine->items.sizes[i]+engine->items.sticky_sizes[i]);
 #ifdef ENABLE_STICKY_ITEM
-            add_statistics(c, add_stats, prefix, i, "sticky", "%u",
-                           engine->items.sticky_sizes[i]);
+        add_statistics(c, add_stats, prefix, i, "sticky", "%u",
+                       engine->items.sticky_sizes[i]);
 #endif
-            add_statistics(c, add_stats, prefix, i, "age", "%u",
-                           (engine->items.tails[i] != NULL ? engine->items.tails[i]->time : 0));
-            add_statistics(c, add_stats, prefix, i, "evicted",
-                           "%u", engine->items.itemstats[i].evicted);
-            add_statistics(c, add_stats, prefix, i, "evicted_nonzero",
-                           "%u", engine->items.itemstats[i].evicted_nonzero);
-            add_statistics(c, add_stats, prefix, i, "evicted_time",
-                           "%u", engine->items.itemstats[i].evicted_time);
-            add_statistics(c, add_stats, prefix, i, "outofmemory",
-                           "%u", engine->items.itemstats[i].outofmemory);
-            add_statistics(c, add_stats, prefix, i, "tailrepairs",
-                           "%u", engine->items.itemstats[i].tailrepairs);;
-            add_statistics(c, add_stats, prefix, i, "reclaimed",
-                           "%u", engine->items.itemstats[i].reclaimed);;
-        }
+        add_statistics(c, add_stats, prefix, i, "age", "%u",
+                       (engine->items.tails[i] != NULL ? engine->items.tails[i]->time : 0));
+        add_statistics(c, add_stats, prefix, i, "evicted",
+                       "%u", engine->items.itemstats[i].evicted);
+        add_statistics(c, add_stats, prefix, i, "evicted_nonzero",
+                       "%u", engine->items.itemstats[i].evicted_nonzero);
+        add_statistics(c, add_stats, prefix, i, "evicted_time",
+                       "%u", engine->items.itemstats[i].evicted_time);
+        add_statistics(c, add_stats, prefix, i, "outofmemory",
+                       "%u", engine->items.itemstats[i].outofmemory);
+        add_statistics(c, add_stats, prefix, i, "tailrepairs",
+                       "%u", engine->items.itemstats[i].tailrepairs);;
+        add_statistics(c, add_stats, prefix, i, "reclaimed",
+                       "%u", engine->items.itemstats[i].reclaimed);;
     }
 }

@@ -5243,7 +5236,6 @@
     pthread_mutex_unlock(&engine->cache_lock);
 }

-
 void item_stats_sizes(struct default_engine *engine,
                       ADD_STAT add_stat, const void *cookie)
 {
@@ -5251,6 +5243,14 @@
     do_item_stats_sizes(engine, add_stat, cookie);
     pthread_mutex_unlock(&engine->cache_lock);
 }
+
+void item_stats_reset(struct default_engine *engine)
+{
+    pthread_mutex_lock(&engine->cache_lock);
+    memset(engine->items.itemstats, 0, sizeof(engine->items.itemstats));
+    pthread_mutex_unlock(&engine->cache_lock);
+}
+

 ENGINE_ERROR_CODE item_init(struct default_engine *engine)
 {


whoa, major bug in recent change.

whoa, major bug in recent change.

git-svn-id: 712aefb8596620db6486b8151c1cac37df8d9591@47 b0b603af-a30f-0410-a34e-baf09ae79d0b

--- items.c
+++ items.c
@@ -96,7 +96,7 @@
 }

 void item_free(item *it) {
-    unsigned char ntotal = ITEM_ntotal(it);
+    unsigned int ntotal = ITEM_ntotal(it);
     /* so slab size changer can tell later if item is already free or not */
     it->slabs_clsid = 0;
     slabs_free(it, ntotal);