#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <fcntl.h> #include <string.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <linux/types.h> #include <linux/spi/spidev.h> static int verbose; static void do_read(int fd, int len) { unsigned char buf[32], *bp; int status; /* read at least 2 bytes, no more than 32 */ if (len < 2) len = 2; else if (len > sizeof(buf)) len = sizeof(buf); memset(buf, 0, sizeof buf); status = read(fd, buf, len); if (status < 0) { perror("read"); return; } if (status != len) { fprintf(stderr, "short read\n"); return; } printf("read(%2d, %2d): %02x %02x,", len, status, buf[0], buf[1]); status -= 2; bp = buf + 2; while (status-- > 0) printf(" %02x", *bp++); printf("\n"); } static void do_msg(int fd, int len) { struct spi_ioc_transfer xfer[2]; unsigned char buf[32], *bp; int status; memset(xfer, 0, sizeof xfer); memset(buf, 0, sizeof buf); if (len > sizeof buf) len = sizeof buf; buf[0] = 0xaa; xfer[0].tx_buf = (unsigned long)buf; xfer[0].len = 1; xfer[1].rx_buf = (unsigned long) buf; xfer[1].len = len; status = ioctl(fd, SPI_IOC_MESSAGE(2), xfer); if (status < 0) { perror("SPI_IOC_MESSAGE"); return; } printf("response(%2d, %2d): ", len, status); for (bp = buf; len; len--) printf(" %02x", *bp++); printf("\n"); } static void dumpstat(const char *name, int fd) { __u8 lsb, bits; __u32 mode, speed; if (ioctl(fd, SPI_IOC_RD_MODE32, &mode) < 0) { perror("SPI rd_mode"); return; } if (ioctl(fd, SPI_IOC_RD_LSB_FIRST, &lsb) < 0) { perror("SPI rd_lsb_fist"); return; } if (ioctl(fd, SPI_IOC_RD_BITS_PER_WORD, &bits) < 0) { perror("SPI bits_per_word"); return; } if (ioctl(fd, SPI_IOC_RD_MAX_SPEED_HZ, &speed) < 0) { perror("SPI max_speed_hz"); return; } printf("%s: spi mode 0x%x, %d bits %sper word, %d Hz max\n", name, mode, bits, lsb ? "(lsb first) " : "", speed); } int main(int argc, char **argv) { int c; int readcount = 0; int msglen = 0; int fd; const char *name; while ((c = getopt(argc, argv, "hm:r:v")) != EOF) { switch (c) { case 'm': msglen = atoi(optarg); if (msglen < 0) goto usage; continue; case 'r': readcount = atoi(optarg); if (readcount < 0) goto usage; continue; case 'v': verbose++; continue; case 'h': case '?': usage: fprintf(stderr, "usage: %s [-h] [-m N] [-r N] /dev/spidevB.D\n", argv[0]); return 1; } } if ((optind + 1) != argc) goto usage; name = argv[optind]; fd = open(name, O_RDWR); if (fd < 0) { perror("open"); return 1; } dumpstat(name, fd); if (msglen) do_msg(fd, msglen); if (readcount) do_read(fd, readcount); close(fd); return 0; } alue='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/commit/?h=nds-private-remove&id=edb6fa1a6452edf736c04d02e3f6de59043df69e'>root</a>/<a href='/cgit.cgi/linux/net-next.git/commit/include?h=nds-private-remove&id=edb6fa1a6452edf736c04d02e3f6de59043df69e'>include</a>/<a href='/cgit.cgi/linux/net-next.git/commit/include/clocksource?h=nds-private-remove&id=edb6fa1a6452edf736c04d02e3f6de59043df69e'>clocksource</a>/<a href='/cgit.cgi/linux/net-next.git/commit/include/clocksource/pxa.h?h=nds-private-remove&id=edb6fa1a6452edf736c04d02e3f6de59043df69e'>pxa.h</a></div><div class='content'><div class='cgit-panel'><b>diff options</b><form method='get'><input type='hidden' name='h' value='nds-private-remove'/><input type='hidden' name='id' value='edb6fa1a6452edf736c04d02e3f6de59043df69e'/><table><tr><td colspan='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><table summary='commit info' class='commit-info'> <tr><th>author</th><td>Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz></td><td class='right'>2016-12-08 11:43:34 +1300</td></tr> <tr><th>committer</th><td>Ralf Baechle <ralf@linux-mips.org></td><td class='right'>2016-12-11 11:19:04 +0100</td></tr> <tr><th>commit</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/include/clocksource/pxa.h?h=nds-private-remove&id=edb6fa1a6452edf736c04d02e3f6de59043df69e'>edb6fa1a6452edf736c04d02e3f6de59043df69e</a> (<a href='/cgit.cgi/linux/net-next.git/patch/include/clocksource/pxa.h?id=edb6fa1a6452edf736c04d02e3f6de59043df69e'>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&id=edb6fa1a6452edf736c04d02e3f6de59043df69e'>f854dd896b1e5033a26f305ec9a50a87b1b13939</a> /<a href='/cgit.cgi/linux/net-next.git/tree/include/clocksource/pxa.h?h=nds-private-remove&id=edb6fa1a6452edf736c04d02e3f6de59043df69e'>include/clocksource/pxa.h</a></td></tr> <tr><th>parent</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/include/clocksource/pxa.h?h=nds-private-remove&id=3e5de27e940d00d8d504dfb96625fb654f641509'>3e5de27e940d00d8d504dfb96625fb654f641509</a> (<a href='/cgit.cgi/linux/net-next.git/diff/include/clocksource/pxa.h?h=nds-private-remove&id=edb6fa1a6452edf736c04d02e3f6de59043df69e&id2=3e5de27e940d00d8d504dfb96625fb654f641509'>diff</a>)</td></tr></table> <div class='commit-subject'>MIPS: Return -ENODEV from weak implementation of rtc_mips_set_time</div><div class='commit-msg'>The sync_cmos_clock function in kernel/time/ntp.c first tries to update the internal clock of the cpu by calling the "update_persistent_clock64" architecture specific function. If this returns -ENODEV, it then tries to update an external RTC using "rtc_set_ntp_time". On the mips architecture, the weak implementation of the underlying function would return 0 if it wasn't overridden. This meant that the sync_cmos_clock function would never try to update an external RTC (if both CONFIG_GENERIC_CMOS_UPDATE and CONFIG_RTC_SYSTOHC are configured) Returning -ENODEV instead, means that an external RTC will be tried. Signed-off-by: Luuk Paulussen <luuk.paulussen@alliedtelesis.co.nz> Reviewed-by: Richard Laing <richard.laing@alliedtelesis.co.nz> Reviewed-by: Scott Parlane <scott.parlane@alliedtelesis.co.nz> Reviewed-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/14649/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org> </div><div class='diffstat-header'><a href='/cgit.cgi/linux/net-next.git/diff/?h=nds-private-remove&id=edb6fa1a6452edf736c04d02e3f6de59043df69e'>Diffstat</a> (limited to 'include/clocksource/pxa.h')</div><table summary='diffstat' class='diffstat'>