1. 20 6月, 2013 1 次提交
  2. 10 4月, 2013 1 次提交
    • A
      procfs: new helper - PDE_DATA(inode) · d9dda78b
      Al Viro 提交于
      The only part of proc_dir_entry the code outside of fs/proc
      really cares about is PDE(inode)->data.  Provide a helper
      for that; static inline for now, eventually will be moved
      to fs/proc, along with the knowledge of struct proc_dir_entry
      layout.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      d9dda78b
  3. 25 3月, 2013 1 次提交
  4. 26 1月, 2013 1 次提交
  5. 17 11月, 2012 1 次提交
    • K
      ACPI / battery: Correct battery capacity values on Thinkpads · 4000e626
      Kamil Iskra 提交于
      Add a quirk to correctly report battery capacity on 2010 and 2011
      Lenovo Thinkpad models.
      
      The affected models that I tested (x201, t410, t410s, and x220)
      exhibit a problem where, when battery capacity reporting unit is mAh,
      the values being reported are wrong.  Pre-2010 and 2012 models appear
      to always report in mWh and are thus unaffected.  Also, in mid-2012
      Lenovo issued a BIOS update for the 2011 models that fixes the issue
      (tested on x220 with a post-1.29 BIOS).  No such update is available
      for the 2010 models, so those still need this patch.
      
      Problem description: for some reason, the affected Thinkpads switch
      the reporting unit between mAh and mWh; generally, mAh is used when a
      laptop is plugged in and mWh when it's unplugged, although a
      suspend/resume or rmmod/modprobe is needed for the switch to take
      effect.  The values reported in mAh are *always* wrong.  This does
      not appear to be a kernel regression; I believe that the values were
      never reported correctly.  I tested back to kernel 2.6.34, with
      multiple machines and BIOS versions.
      
      Simply plugging a laptop into mains before turning it on is enough to
      reproduce the problem.  Here's a sample /proc/acpi/battery/BAT0/info
      from Thinkpad x220 (before a BIOS update) with a 4-cell battery:
      
      present:                 yes
      design capacity:         2886 mAh
      last full capacity:      2909 mAh
      battery technology:      rechargeable
      design voltage:          14800 mV
      design capacity warning: 145 mAh
      design capacity low:     13 mAh
      cycle count:              0
      capacity granularity 1:  1 mAh
      capacity granularity 2:  1 mAh
      model number:            42T4899
      serial number:           21064
      battery type:            LION
      OEM info:                SANYO
      
      Once the laptop switches the unit to mWh (unplug from mains, suspend,
      resume), the output changes to:
      
      present:                 yes
      design capacity:         28860 mWh
      last full capacity:      29090 mWh
      battery technology:      rechargeable
      design voltage:          14800 mV
      design capacity warning: 1454 mWh
      design capacity low:     200 mWh
      cycle count:              0
      capacity granularity 1:  1 mWh
      capacity granularity 2:  1 mWh
      model number:            42T4899
      serial number:           21064
      battery type:            LION
      OEM info:                SANYO
      
      Can you see how the values for "design capacity", etc., differ by a
      factor of 10 instead of 14.8 (the design voltage of this battery)?
      On the battery itself it says: 14.8V, 1.95Ah, 29Wh, so clearly the
      values reported in mWh are correct and the ones in mAh are not.
      
      My guess is that this problem has been around ever since those
      machines were released, but because the most common Thinkpad
      batteries are rated at 10.8V, the error (8%) is small enough that it
      simply hasn't been noticed or at least nobody could be bothered to
      look into it.
      
      My patch works around the problem by adjusting the incorrectly
      reported mAh values by "10000 / design_voltage".  The patch also has
      code to figure out if it should be activated or not.  It only
      activates on Lenovo Thinkpads, only when the unit is mAh, and, as an
      extra precaution, only when the battery capacity reported through
      ACPI does not match what is reported through DMI (I've never
      encountered a machine where the first two conditions would be true
      but the last would not, but better safe than sorry).
      
      I've been using this patch for close to a year on several systems
      without any problems.
      
      References: https://bugzilla.kernel.org/show_bug.cgi?id=41062Acked-by: NHenrique de Moraes Holschuh <hmh@hmh.eng.br>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      4000e626
  6. 10 8月, 2012 1 次提交
  7. 01 7月, 2012 1 次提交
  8. 02 6月, 2012 1 次提交
  9. 08 5月, 2012 1 次提交
  10. 04 1月, 2012 1 次提交
  11. 06 8月, 2011 1 次提交
    • S
      Battery: sysfs_remove_battery(): possible circular locking · 69d94ec6
      Sergey Senozhatsky 提交于
      Commit 9c921c22
      Author: Lan Tianyu <tianyu.lan@intel.com>
      
          ACPI / Battery: Resolve the race condition in the sysfs_remove_battery()
      
      fixed BUG https://bugzilla.kernel.org/show_bug.cgi?id=35642 , but as a side
      effect made lockdep unhappy with sysfs_remove_battery():
      
      [14818.477168]
      [14818.477170] =======================================================
      [14818.477200] [ INFO: possible circular locking dependency detected ]
      [14818.477221] 3.1.0-dbg-07865-g1280ea8-dirty #668
      [14818.477236] -------------------------------------------------------
      [14818.477257] s2ram/1599 is trying to acquire lock:
      [14818.477276]  (s_active#8){++++.+}, at: [<ffffffff81169147>] sysfs_addrm_finish+0x31/0x5a
      [14818.477323]
      [14818.477325] but task is already holding lock:
      [14818.477350]  (&battery->lock){+.+.+.}, at: [<ffffffffa0047278>] sysfs_remove_battery+0x10/0x4b [battery]
      [14818.477395]
      [14818.477397] which lock already depends on the new lock.
      [14818.477399]
      [..]
      [14818.479121] stack backtrace:
      [14818.479148] Pid: 1599, comm: s2ram Not tainted 3.1.0-dbg-07865-g1280ea8-dirty #668
      [14818.479175] Call Trace:
      [14818.479198]  [<ffffffff814828c3>] print_circular_bug+0x293/0x2a4
      [14818.479228]  [<ffffffff81070cb5>] __lock_acquire+0xfe4/0x164b
      [14818.479260]  [<ffffffff81169147>] ? sysfs_addrm_finish+0x31/0x5a
      [14818.479288]  [<ffffffff810718d2>] lock_acquire+0x138/0x1ac
      [14818.479316]  [<ffffffff81169147>] ? sysfs_addrm_finish+0x31/0x5a
      [14818.479345]  [<ffffffff81168a79>] sysfs_deactivate+0x9b/0xec
      [14818.479373]  [<ffffffff81169147>] ? sysfs_addrm_finish+0x31/0x5a
      [14818.479405]  [<ffffffff81169147>] sysfs_addrm_finish+0x31/0x5a
      [14818.479433]  [<ffffffff81167bc5>] sysfs_hash_and_remove+0x54/0x77
      [14818.479461]  [<ffffffff811681b9>] sysfs_remove_file+0x12/0x14
      [14818.479488]  [<ffffffff81385bf8>] device_remove_file+0x12/0x14
      [14818.479516]  [<ffffffff81386504>] device_del+0x119/0x17c
      [14818.479542]  [<ffffffff81386575>] device_unregister+0xe/0x1a
      [14818.479570]  [<ffffffff813c6ef9>] power_supply_unregister+0x23/0x27
      [14818.479601]  [<ffffffffa004729c>] sysfs_remove_battery+0x34/0x4b [battery]
      [14818.479632]  [<ffffffffa004778f>] battery_notify+0x2c/0x3a [battery]
      [14818.479662]  [<ffffffff8148fe82>] notifier_call_chain+0x74/0xa1
      [14818.479692]  [<ffffffff810624b4>] __blocking_notifier_call_chain+0x6c/0x89
      [14818.479722]  [<ffffffff810624e0>] blocking_notifier_call_chain+0xf/0x11
      [14818.479751]  [<ffffffff8107e40e>] pm_notifier_call_chain+0x15/0x27
      [14818.479770]  [<ffffffff8107ee1a>] enter_state+0xa7/0xd5
      [14818.479782]  [<ffffffff8107e341>] state_store+0xaa/0xc0
      [14818.479795]  [<ffffffff8107e297>] ? pm_async_store+0x45/0x45
      [14818.479807]  [<ffffffff81248837>] kobj_attr_store+0x17/0x19
      [14818.479820]  [<ffffffff81167e27>] sysfs_write_file+0x103/0x13f
      [14818.479834]  [<ffffffff81109037>] vfs_write+0xad/0x13d
      [14818.479847]  [<ffffffff811092b2>] sys_write+0x45/0x6c
      [14818.479860]  [<ffffffff81492f92>] system_call_fastpath+0x16/0x1b
      
      This patch introduces separate lock to struct acpi_battery to
      grab in sysfs_remove_battery() instead of battery->lock.
      So fix by Lan Tianyu is still there, we just grab independent lock.
      Signed-off-by: NSergey Senozhatsky <sergey.senozhatsky@gmail.com>
      Tested-by: NLan Tianyu <tianyu.lan@intel.com>
      Signed-off-by: NLen Brown <len.brown@intel.com>
      69d94ec6
  12. 21 7月, 2011 1 次提交
    • P
      treewide: fix potentially dangerous trailing ';' in #defined values/expressions · 497888cf
      Phil Carmody 提交于
      All these are instances of
        #define NAME value;
      or
        #define NAME(params_opt) value;
      
      These of course fail to build when used in contexts like
        if(foo $OP NAME)
        while(bar $OP NAME)
      and may silently generate the wrong code in contexts such as
        foo = NAME + 1;    /* foo = value; + 1; */
        bar = NAME - 1;    /* bar = value; - 1; */
        baz = NAME & quux; /* baz = value; & quux; */
      
      Reported on comp.lang.c,
      Message-ID: <ab0d55fe-25e5-482b-811e-c475aa6065c3@c29g2000yqd.googlegroups.com>
      Initial analysis of the dangers provided by Keith Thompson in that thread.
      
      There are many more instances of more complicated macros having unnecessary
      trailing semicolons, but this pile seems to be all of the cases of simple
      values suffering from the problem. (Thus things that are likely to be found
      in one of the contexts above, more complicated ones aren't.)
      Signed-off-by: NPhil Carmody <ext-phil.2.carmody@nokia.com>
      Signed-off-by: NJiri Kosina <jkosina@suse.cz>
      497888cf
  13. 17 7月, 2011 3 次提交
  14. 14 7月, 2011 6 次提交
  15. 23 3月, 2011 1 次提交
  16. 21 1月, 2011 1 次提交
  17. 12 1月, 2011 2 次提交
  18. 25 12月, 2010 1 次提交
  19. 10 12月, 2010 1 次提交
  20. 24 10月, 2010 1 次提交
    • R
      ACPI / Battery: Return -ENODEV for unknown values in get_property() · a1b4bd69
      Rafael J. Wysocki 提交于
      The function acpi_battery_get_property() is called by the
      power supply framework's function power_supply_show_property()
      implementing the sysfs interface for power supply devices as the
      ACPI battery driver's ->get_property() callback.  Thus it is supposed
      to return error code if the value of the given property is unknown.
      Unfortunately, however, it returns 0 in those cases and puts a
      wrong (negative) value into the intval field of the
      union power_supply_propval object provided by
      power_supply_show_property().  In consequence, wrong negative
      values are read by user space from the battery's sysfs files.
      
      Fix this by making acpi_battery_get_property() return -ENODEV
      for properties with unknown values (-ENODEV is returned, because
      power_supply_uevent() returns with error for any other error code
      returned by power_supply_show_property()).
      Reported-and-tested-by: NSitsofe Wheeler <sitsofe@yahoo.com>
      Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
      Signed-off-by: NLen Brown <len.brown@intel.com>
      a1b4bd69
  21. 22 10月, 2010 1 次提交
  22. 16 10月, 2010 1 次提交
  23. 31 8月, 2010 1 次提交
  24. 07 7月, 2010 1 次提交
  25. 05 4月, 2010 2 次提交
  26. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  27. 28 1月, 2010 1 次提交
  28. 16 1月, 2010 2 次提交
  29. 16 12月, 2009 1 次提交
  30. 30 8月, 2009 1 次提交
    • H
      ACPI battery: work around negative s16 battery current on Acer · bc76f90b
      Hector Martin 提交于
      Acer Aspire 8930G laptops (and possibly others) report the battery current
      as a 16-bit signed negative when it is charging.  It also reports it as
      0x10000 when the current is 0.  This patch adds a quirk for this which
      takes the absolute value of the reported current cast to an s16.  This is
      a DSDT bug present in the latest BIOS revision (the EC register is 16 bits
      signed and the DSDT attempts to take the 16-bit two's complement of this,
      which works for discharge but not charge.  It also breaks zero values
      because a 32-bit register is used and the high bits aren't thrown away).
      
      I've enabled this for all Acer systems which report in mA units.  This
      should be safe since it won't break compliant systems unless they report a
      current above 32A, which is insane.  The patch also detects the valid
      32-bit value -1, which indicates unknown status, and does not attempt the
      fix in that case (note that this does not conflict with 16-bit -1, which
      is 65535 as read normally and gets translated to 1mA).
      Signed-off-by: NHector Martin <hector@marcansoft.com>
      Acked-by: NAlexey Starikovskiy <astarikovskiy@suse.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLen Brown <len.brown@intel.com>
      bc76f90b