nfsd: nfs4_file_get_access: need to be more careful with O_RDWR

If fi_fds = {non-NULL, NULL, non-NULL} and oflag = O_WRONLY
the WARN_ON_ONCE(!(fp->fi_fds[oflag] || fp->fi_fds[O_RDWR]))
doesn't trigger when it should.

Signed-off-by: Harshula Jayasuriya <harshula@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
nfsd4: fix setlease error return

This actually makes a difference in the 4.1 case, since we use the
status to decide what reason to give the client for the delegation
refusal (see nfsd4_open_deleg_none_ext), and in theory a client might
choose suboptimal behavior if we give the wrong answer.

Reported-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
x86/jump-label: Use best default nops for inital jump label calls

As specified by H. Peter Anvin, the best nops for x86 without knowing
the running computer is:

32bit:
  0x3e, 0x8d, 0x74, 0x26, 0x00 also known as GENERIC_NOP5_ATOMIC

64bit:
  0x0f, 0x1f, 0x44, 0x00, 0x00  also known as P6_NOP5_ATOMIC

Currently the default nop that is used by jump label is:

 0xe9 0x00 0x00 0x00 0x00

Which is really a 5byte jump to the next position.

It's better to use a real nop than a jmp.

Cc: H. Peter Anvin <hpa@linux.intel.com>
Cc: Jason Baron <jbaron@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
x86/jump-label: Do not bother updating nops if they are correct

On boot up, the jump label init function scans all the jump label locations
and converts them to the best nop for the machine. If the nop is already
the ideal nop, do not bother with changing it.

Cc: Jason Baron <jbaron@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
x86/jump-label: Add safety checks to jump label conversions

As with all modifying of kernel text, we need to be very paranoid.

When converting the jump label locations to and from nops to jumps
a check has been added to make sure what we are replacing is what we
expect, otherwise we bug.

Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jason Baron <jbaron@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
x86/jump-label: Show where and what was wrong on errors

When modifying text sections for jump labels, a paranoid check is
performed. If the check fails, the system "bugs". But why it failed
is not shown.

The BUG_ON()s in the jump label update code is replaced with bug_at(ip).
This is a function that will show what pointer failed, and what was
at the location of the failure that made jump label panic.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
MAINTAINERS: drivers/power: add entry for SmartReflex AVS drivers

The SmartReflex AVS driver evolved out of the OMAP kernel and now lives
under drivers/power/avs.

I've historically been maintainer of this but Nishanth Menon is doing most
of the heavy lifting now.  Add us both as co-maintainers.

Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Nishanth Menon <nm@ti.com>
Signed-off-by: Kevin Hilman <khilman@linaro.org>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
power: reset: Add msm restart support

Add support for restart and poweroff functionality present on MSM chipsets
with the MPM2 ps-hold hardware.

Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
Tested-by: Ivan T. Ivanov <iivanov@mm-sol.com>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
power_supply: Make goldfish_battery depend on GOLDFISH || COMPILE_TEST

Nearly all the other goldfish peripherals (mtd, keyboard, etc) have a
dependency on the main platform's GOLDFISH Kconfig item, but this one got
skipped.  Even with consistency as a justification, there was initial
resistance[1] from some people to adding it however, as they wanted the
extra compile coverage.

Now, with CONFIG_COMPILE_TEST, we have the middle ground that will give
people the coverage who want it, and let those who don't want it to skip
ever seeing the option presented.

[1] https://lkml.org/lkml/2013/2/27/333

Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
power supply: collie_battery: Convert to use dev_pm_ops

This commit fixes the following warnings:

 linux/drivers/power/collie_battery.c:372:2: warning: initialization from
 incompatible pointer type [enabled by default]
 linux/drivers/power/collie_battery.c:372:2: warning: (near initialization
 for 'collie_bat_driver.suspend') [enabled by default]

Referencess:

MFD: ucb1x00-core: convert to use dev_pm_ops
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/include/linux/mfd?id=5a09b7120a965a7d7e8494d0ed509135bbce0118

MFD: mcp-core: remove legacy driver suspend/resume methods
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/include/linux/mfd?id=cf4abfcc0df2985ff6061f74e63b8353f2a1d0bc

Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
power_supply: tosa_battery: Get rid of irq_to_gpio usage

This commit fixes the following error:

 linux/drivers/power/tosa_battery.c:153:2: error: implicit declaration of
 function 'irq_to_gpio' [-Werror=implicit-function-declaration]

Since 9d08d5d77a355510c2f5657c86b0a4b25acfe72c, irq_to_gpio() is no longer
available but still in use by collie_battery.c. As it's just for a debug
message, just get rid of this call.

Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
power: Add APM X-Gene system reboot driver

Add APM X-Gene SoC system reboot driver. This driver handles only system
reboot. System shutdown is board specific and can be handled by board
driver or GPIO based shutdown driver.

Signed-off-by: Loc Ho <lho@apm.com>
Signed-off-by: Feng Kan <fkan@apm.com>
Signed-off-by: Kumar Sankaran <ksankaran@apm.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
power_supply: Replace strict_strtol() with kstrtol()

The usage of strict_strtol() is not preferred, because strict_strtol() is
obsolete. Thus, kstrtol() should be used.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
sunrpc: prepare NFS for 2038

1) The kernel sunrpc code needs to handle seconds since epoch
greater than 2147483647. This means functions that parse time
as an int need to handle it as time_t.

2) The kernel changes must be accompanied by userspace changes
in nfs-utils.

Signed-off-by: Harshula Jayasuriya <harshula@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
max8925_power: Fix missing of_node_put

Decrease np device_node refcount after we are done with the node.

Signed-off-by: Libo Chen <libo.chen@huawei.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
ab8500-charger: We print an unintended error message

There is a missing break statement here, so we print an error message that
the USB type is invalid.  The original code still works fine though except
for the error message.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
bq24190_charger: Add support for TI BQ24190 Battery Charger

Add driver support for the Texas Instruments BQ24190 battery charger.
Some of the information provided by the device is about the charger and
other information is about the battery so create two power_supply objects
(one for each) and provide the appropriate information for each one.

The device has many fields that go beyond what is reasonable to report or
modify using the existing 'POWER_SUPPLY_PROP_*' properties so the driver
exports the register fields via sysfs.  They are prefixed by 'f_' (for
'field') to make it easier to distinguish between a register field and a
"normal" sysfs file exported by the power_supply infrastructure.

Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
rx51_battery: Replace hardcoded channels values.

In twl4030_madc header exist defines for fixed channels + add rx51
specific channels and replace all hardcoded channels values.

Signed-off-by: Marek Belisko <marek.belisko@open-nandra.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
twl4030-charger: Fix compiler warning with regulator_enable()

The return value of regulator_enable need to be checked. This patch fixes
the following warning:
drivers/power/twl4030_charger.c: In function ‘twl4030_charger_enable_usb’:
drivers/power/twl4030_charger.c:192:20: warning: ignoring return value of ‘regulator_enable’, declared with attribute warn_unused_result [-Wunused-result]

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
vexpress-poweroff: Should depend on the required infrastructure

ARM Versatile Express reset driver requires platform-specific config
infrastructure to be present in the kernel. When VEXPRESS_CONFIG is not
selected, the build will fail like this:

drivers/built-in.o: In function `vexpress_reset_do.clone.0':
iio-trig-interrupt.c:(.text+0x1aff38): undefined reference to `__vexpress_config_func_get'
iio-trig-interrupt.c:(.text+0x1aff4c): undefined reference to `vexpress_config_write'

Added required dependency to the Kconfig entry.

Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>