aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mpi/mpi-bit.c
diff options
context:
space:
mode:
authorLee, Chun-Yi <joeyli.kernel@gmail.com>2012-12-14 03:14:28 -0500
committerMatthew Garrett <matthew.garrett@nebula.com>2013-02-24 17:49:56 -0500
commit5f3511d2a61e7874730d3ccc1a32d418259133be (patch)
treeb4920ded8516948c52da29f79d526c737a8e9a07 /lib/mpi/mpi-bit.c
parente6c33f1fe797355f1aed53b01230bd13ef52deff (diff)
acer-wmi: support Lenovo ideapad S205 1038DPG wifi switch
Found another Lenovo ideapad S205 the product name is 1038DPG, it has a 0x78 EC register exposes the state of wifi hardware switch on the machine. So, add this patch to support Lenovo ideapad S205-1038DPG wifi hardware switch in acer-wmi driver. Evidently the Ideapad S205 is just a model name on the market, but they have totally different product name in DMI table. Reference: bko#43007 https://bugzilla.kernel.org/show_bug.cgi?id=43007 Tested-by: Colin <colin.newell@gmail.com> Cc: Carlos Corbacho <carlos@strangeworlds.co.uk> Cc: Matthew Garrett <mjg@redhat.com> Cc: Dmitry Torokhov <dtor@mail.ru> Cc: Corentin Chary <corentincj@iksaif.net> Cc: Thomas Renninger <trenn@suse.de> Signed-off-by: Lee, Chun-Yi <jlee@suse.com> Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
Diffstat (limited to 'lib/mpi/mpi-bit.c')
0 files changed, 0 insertions, 0 deletions
ass="hl opt">.get_type() def offset_of(typeobj, field): element = gdb.Value(0).cast(typeobj) return int(str(element[field].address).split()[0], 16) def container_of(ptr, typeobj, member): return (ptr.cast(get_long_type()) - offset_of(typeobj, member)).cast(typeobj) class ContainerOf(gdb.Function): """Return pointer to containing data structure. $container_of(PTR, "TYPE", "ELEMENT"): Given PTR, return a pointer to the data structure of the type TYPE in which PTR is the address of ELEMENT. Note that TYPE and ELEMENT have to be quoted as strings.""" def __init__(self): super(ContainerOf, self).__init__("container_of") def invoke(self, ptr, typename, elementname): return container_of(ptr, gdb.lookup_type(typename.string()).pointer(), elementname.string()) ContainerOf() BIG_ENDIAN = 0 LITTLE_ENDIAN = 1 target_endianness = None def get_target_endianness(): global target_endianness if target_endianness is None: endian = gdb.execute("show endian", to_string=True) if "little endian" in endian: target_endianness = LITTLE_ENDIAN elif "big endian" in endian: target_endianness = BIG_ENDIAN else: raise gdb.GdbError("unknown endianness '{0}'".format(str(endian))) return target_endianness def read_u16(buffer): if get_target_endianness() == LITTLE_ENDIAN: return ord(buffer[0]) + (ord(buffer[1]) << 8) else: return ord(buffer[1]) + (ord(buffer[0]) << 8) def read_u32(buffer): if get_target_endianness() == LITTLE_ENDIAN: return read_u16(buffer[0:2]) + (read_u16(buffer[2:4]) << 16) else: return read_u16(buffer[2:4]) + (read_u16(buffer[0:2]) << 16) def read_u64(buffer): if get_target_endianness() == LITTLE_ENDIAN: return read_u32(buffer[0:4]) + (read_u32(buffer[4:8]) << 32) else: return read_u32(buffer[4:8]) + (read_u32(buffer[0:4]) << 32) target_arch = None def is_target_arch(arch): if hasattr(gdb.Frame, 'architecture'): return arch in gdb.newest_frame().architecture().name() else: global target_arch if target_arch is None: target_arch = gdb.execute("show architecture", to_string=True) return arch in target_arch GDBSERVER_QEMU = 0 GDBSERVER_KGDB = 1 gdbserver_type = None def get_gdbserver_type(): def exit_handler(event): global gdbserver_type gdbserver_type = None gdb.events.exited.disconnect(exit_handler) def probe_qemu(): try: return gdb.execute("monitor info version", to_string=True) != "" except: return False def probe_kgdb(): try: thread_info = gdb.execute("info thread 2", to_string=True) return "shadowCPU0" in thread_info except: return False global gdbserver_type if gdbserver_type is None: if probe_qemu(): gdbserver_type = GDBSERVER_QEMU elif probe_kgdb(): gdbserver_type = GDBSERVER_KGDB if gdbserver_type is not None and hasattr(gdb, 'events'): gdb.events.exited.connect(exit_handler) return gdbserver_type