/*
 * POWER Data Stream Control Register (DSCR) sysfs interface test
 *
 * This test updates to system wide DSCR default through the sysfs interface
 * and then verifies that all the CPU specific DSCR defaults are updated as
 * well verified from their sysfs interfaces.
 *
 * Copyright 2015, Anshuman Khandual, IBM Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation.
 */
#include "dscr.h"

static int check_cpu_dscr_default(char *file, unsigned long val)
{
	char buf[10];
	int fd, rc;

	fd = open(file, O_RDWR);
	if (fd == -1) {
		perror("open() failed");
		return 1;
	}

	rc = read(fd, buf, sizeof(buf));
	if (rc == -1) {
		perror("read() failed");
		return 1;
	}
	close(fd);

	buf[rc] = '\0';
	if (strtol(buf, NULL, 16) != val) {
		printf("DSCR match failed: %ld (system) %ld (cpu)\n",
					val, strtol(buf, NULL, 16));
		return 1;
	}
	return 0;
}

static int check_all_cpu_dscr_defaults(unsigned long val)
{
	DIR *sysfs;
	struct dirent *dp;
	char file[LEN_MAX];

	sysfs = opendir(CPU_PATH);
	if (!sysfs) {
		perror("opendir() failed");
		return 1;
	}

	while ((dp = readdir(sysfs))) {
		if (!(dp->d_type & DT_DIR))
			continue;
		if (!strcmp(dp->d_name, "cpuidle"))
			continue;
		if (!strstr(dp->d_name, "cpu"))
			continue;

		sprintf(file, "%s%s/dscr", CPU_PATH, dp->d_name);
		if (access(file, F_OK))
			continue;

		if (check_cpu_dscr_default(file, val))
			return 1;
	}
	closedir(sysfs);
	return 0;
}

int dscr_sysfs(void)
{
	unsigned long orig_dscr_default;
	int i, j;

	orig_dscr_default = get_default_dscr();
	for (i = 0; i < COUNT; i++) {
		for (j = 0; j < DSCR_MAX; j++) {
			set_default_dscr(j);
			if (check_all_cpu_dscr_defaults(j))
				goto fail;
		}
	}
	set_default_dscr(orig_dscr_default);
	return 0;
fail:
	set_default_dscr(orig_dscr_default);
	return 1;
}

int main(int argc, char *argv[])
{
	return test_harness(dscr_sysfs, "dscr_sysfs_test");
}
ivate-remove&amp;id=5226b7919641f285bf0f8db84deeb3920b160ec7'>commit</a><a href='/cgit.cgi/linux/net-next.git/diff/sound/usb/6fire/control.c?h=nds-private-remove&amp;id=5226b7919641f285bf0f8db84deeb3920b160ec7'>diff</a></td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/sound/usb/6fire/control.c'>
<input type='hidden' name='h' value='nds-private-remove'/><input type='hidden' name='id' value='5226b7919641f285bf0f8db84deeb3920b160ec7'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/log/?h=nds-private-remove&amp;id=5226b7919641f285bf0f8db84deeb3920b160ec7'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/sound?h=nds-private-remove&amp;id=5226b7919641f285bf0f8db84deeb3920b160ec7'>sound</a>/<a href='/cgit.cgi/linux/net-next.git/log/sound/usb?h=nds-private-remove&amp;id=5226b7919641f285bf0f8db84deeb3920b160ec7'>usb</a>/<a href='/cgit.cgi/linux/net-next.git/log/sound/usb/6fire?h=nds-private-remove&amp;id=5226b7919641f285bf0f8db84deeb3920b160ec7'>6fire</a>/<a href='/cgit.cgi/linux/net-next.git/log/sound/usb/6fire/control.c?h=nds-private-remove&amp;id=5226b7919641f285bf0f8db84deeb3920b160ec7'>control.c</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/sound/usb/6fire/control.c?h=nds-private-remove&amp;id=5226b7919641f285bf0f8db84deeb3920b160ec7&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>
'2'/></tr><tr><td class='label'>context:</td><td class='ctrl'><select name='context' onchange='this.form.submit();'><option value='1'>1</option><option value='2'>2</option><option value='3' selected='selected'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option></select></td></tr><tr><td class='label'>space:</td><td class='ctrl'><select name='ignorews' onchange='this.form.submit();'><option value='0' selected='selected'>include</option><option value='1'>ignore</option></select></td></tr><tr><td class='label'>mode:</td><td class='ctrl'><select name='dt' onchange='this.form.submit();'><option value='0' selected='selected'>unified</option><option value='1'>ssdiff</option><option value='2'>stat only</option></select></td></tr><tr><td/><td class='ctrl'><noscript><input type='submit' value='reload'/></noscript></td></tr></table></form></div><div class='diffstat-header'><a href='/cgit.cgi/linux/net-next.git/diff/?id=dd86e373e09fb16b83e8adf5c48c421a4ca76468&amp;id2=0b3589be9b98994ce3d5aeca52445d1f5627c4ba'>Diffstat</a> (limited to 'sound/soc/bcm/Kconfig')</div><table summary='diffstat' class='diffstat'>decf9137069646b593d3439171a8a8e2'>1bae6c99decf9137069646b593d3439171a8a8e2</a> (<a href='/cgit.cgi/linux/net-next.git/patch/net/ipv6/exthdrs_offload.c?id=1bae6c99decf9137069646b593d3439171a8a8e2'>patch</a>)</td></tr>
<tr><th>tree</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/tree/?h=nds-private-remove&amp;id=1bae6c99decf9137069646b593d3439171a8a8e2'>431604a568cd2303973470de326bd9731370a025</a> /<a href='/cgit.cgi/linux/net-next.git/tree/net/ipv6/exthdrs_offload.c?h=nds-private-remove&amp;id=1bae6c99decf9137069646b593d3439171a8a8e2'>net/ipv6/exthdrs_offload.c</a></td></tr>
<tr><th>parent</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/net/ipv6/exthdrs_offload.c?h=nds-private-remove&amp;id=63c190429020a9701b42887ac22c28f287f1762f'>63c190429020a9701b42887ac22c28f287f1762f</a> (<a href='/cgit.cgi/linux/net-next.git/diff/net/ipv6/exthdrs_offload.c?h=nds-private-remove&amp;id=1bae6c99decf9137069646b593d3439171a8a8e2&amp;id2=63c190429020a9701b42887ac22c28f287f1762f'>diff</a>)</td></tr><tr><th>parent</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/net/ipv6/exthdrs_offload.c?h=nds-private-remove&amp;id=2b2d3eb41c920b47df2fcedd1489cf748bd09466'>2b2d3eb41c920b47df2fcedd1489cf748bd09466</a> (<a href='/cgit.cgi/linux/net-next.git/diff/net/ipv6/exthdrs_offload.c?h=nds-private-remove&amp;id=1bae6c99decf9137069646b593d3439171a8a8e2&amp;id2=2b2d3eb41c920b47df2fcedd1489cf748bd09466'>diff</a>)</td></tr></table>
<div class='commit-subject'>Merge branch 'sh_eth-E-DMAC-interrupt-mask-cleanups'</div><div class='commit-msg'>Sergei Shtylyov says:

====================
sh_eth: E-DMAC interrupt mask cleanups

   Here's a set of 3 patches against DaveM's 'net-next.git' repo. The main goal
of this set is to stop using the bare numbers for the E-DMAC interrupt masks.

[1/3] sh_eth: rename EESIPR bits
[2/3] sh_eth: add missing EESIPR bits
[3/3] sh_eth: stop using bare numbers for EESIPR values
====================

Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</div><div class='diffstat-header'><a href='/cgit.cgi/linux/net-next.git/diff/?h=nds-private-remove&amp;id=1bae6c99decf9137069646b593d3439171a8a8e2'>Diffstat</a> (limited to 'net/ipv6/exthdrs_offload.c')</div><table summary='diffstat' class='diffstat'>