/* * Thunderbolt Cactus Ridge driver - capabilities lookup * * Copyright (c) 2014 Andreas Noever */ #include #include #include "tb.h" struct tb_cap_any { union { struct tb_cap_basic basic; struct tb_cap_extended_short extended_short; struct tb_cap_extended_long extended_long; }; } __packed; static bool tb_cap_is_basic(struct tb_cap_any *cap) { /* basic.cap is u8. This checks only the lower 8 bit of cap. */ return cap->basic.cap != 5; } static bool tb_cap_is_long(struct tb_cap_any *cap) { return !tb_cap_is_basic(cap) && cap->extended_short.next == 0 && cap->extended_short.length == 0; } static enum tb_cap tb_cap(struct tb_cap_any *cap) { if (tb_cap_is_basic(cap)) return cap->basic.cap; else /* extended_short/long have cap at the same offset. */ return cap->extended_short.cap; } static u32 tb_cap_next(struct tb_cap_any *cap, u32 offset) { int next; if (offset == 1) { /* * The first pointer is part of the switch header and always * a simple pointer. */ next = cap->basic.next; } else { /* * Somehow Intel decided to use 3 different types of capability * headers. It is not like anyone could have predicted that * single byte offsets are not enough... */ if (tb_cap_is_basic(cap)) next = cap->basic.next; else if (!tb_cap_is_long(cap)) next = cap->extended_short.next; else next = cap->extended_long.next; } /* * "Hey, we could terminate some capability lists with a null offset * and others with a pointer to the last element." - "Great idea!" */ if (next == offset) return 0; return next; } /** * tb_find_cap() - find a capability * * Return: Returns a positive offset if the capability was found and 0 if not. * Returns an error code on failure. */ int tb_find_cap(struct tb_port *port, enum tb_cfg_space space, enum tb_cap cap) { u32 offset = 1; struct tb_cap_any header; int res; int retries = 10; while (retries--) { res = tb_port_read(port, &header, space, offset, 1); if (res) { /* Intel needs some help with linked lists. */ if (space == TB_CFG_PORT && offset == 0xa && port->config.type == TB_TYPE_DP_HDMI_OUT) { offset = 0x39; continue; } return res; } if (offset != 1) { if (tb_cap(&header) == cap) return offset; if (tb_cap_is_long(&header)) { /* tb_cap_extended_long is 2 dwords */ res = tb_port_read(port, &header, space, offset, 2); if (res) return res; } } offset = tb_cap_next(&header, offset); if (!offset) return 0; } tb_port_WARN(port, "run out of retries while looking for cap %#x in config space %d, last offset: %#x\n", cap, space, offset); return -EIO; } 9274379'>root/net/8021q/vlanproc.c
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2017-01-11 15:36:20 +0000
committerMark Brown <broonie@kernel.org>2017-01-18 16:32:44 +0000
commitb98acbff9a05b371c5f0ca6e44a3af8ce9274379 (patch)
treed6835885f859a456e62ce93621041138d6a54f9b /net/8021q/vlanproc.c
parentd00b74613fb18dfd0a5aa99270ee2e72d5c808d7 (diff)
regulator: twl6030: fix range comparison, allowing vsel = 59
The range min_uV > 1350000 && min_uV <= 150000 is never reachable because of a typo in the previous range check and hence vsel = 59 is never reached. Fix the previous range check to enable the vsel = 59 setting. Fixes CoverityScan CID#728454 ("Logially dead code") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'net/8021q/vlanproc.c')
09c&id2=7a308bb3016f57e5be11a677d15b821536419d36'>diff)
x86/microcode/intel: Drop stashed AP patch pointer optimization
This was meant to save us the scanning of the microcode containter in the initrd since the first AP had already done that but it can also hurt us: Imagine a single hyperthreaded CPU (Intel(R) Atom(TM) CPU N270, for example) which updates the microcode on the BSP but since the microcode engine is shared between the two threads, the update on CPU1 doesn't happen because it has already happened on CPU0 and we don't find a newer microcode revision on CPU1. Which doesn't set the intel_ucode_patch pointer and at initrd jettisoning time we don't save the microcode patch for later application. Now, when we suspend to RAM, the loaded microcode gets cleared so we need to reload but there's no patch saved in the cache. Removing the optimization fixes this issue and all is fine and dandy. Fixes: 06b8534cb728 ("x86/microcode: Rework microcode loading") Signed-off-by: Borislav Petkov <bp@suse.de> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/20170120202955.4091-2-bp@alien8.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'tools/build/feature/test-lzma.c')