eCryptfs: Avoid unnecessary disk read and data decryption during writing

ecryptfs_write_begin grabs a page from page cache for writing.
If the page contains invalid data, or data older than the
counterpart on the disk, eCryptfs will read out the
corresponing data from the disk into the page, decrypt them,
then perform writing. However, for this page, if the length
of the data to be written into is equal to page size,
that means the whole page of data will be overwritten,
in which case, it does not matter whatever the data were before,
it is beneficial to perform writing directly rather than bothering
to read and decrypt first.

With this optimization, according to our test on a machine with
Intel Core 2 Duo processor, iozone 'write' operation on an existing
file with write size being multiple of page size will enjoy a steady
3x speedup.

Signed-off-by: Li Wang <wangli@kylinos.com.cn>
Signed-off-by: Yunchuan Wen <wenyunchuan@kylinos.com.cn>
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
ASoC: cs4271: fix sparse warning

Make the flag in the pdata of type bool to fix a sparse warning.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
ASoC: cs4271: fix property check

The driver had the property check for 'cirrus,amutec_eq_bmutec' the
wrong way around. That happens if you misspell the property in the
bindings during tests.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
usb: dwc3: debugfs: fix regdump offset

As with dwc_readl/writel, the global registers are specified as
offsets starting from the beginning of the xHCI address space,
but the memory region pointed to by dwc->regs already maps to
the start of the global addresses. Fix by offsetting each of the
regs relative to DWC3_GLOBALS_REGS_START.

Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: renesas_usbhs: gadget: remove usbhsg_uep_init()

Current driver always initialized uep->pipe to NULL on usbhsg_try_start().
But it breaks relationship with
usb_ep_ops :: enable/disable functions when suspend/resume.
This patch solved this issue by initializing uep->pipe on probe()

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
USB: fix fsl_otg config dependency

USB_GADGET_FSL_USB2 has been changed to USB_FSL_USB2 by commit
193ab2a6070039e7ee2b9b9bebea754a7c52fd1b (usb: gadget: allow
multiple gadgets to be built). But old USB_GADGET_FSL_USB2 is
still listed as dependency for fsl_otg driver, so the driver
cannot be selected in the configuration currently. Fix it.

Signed-off-by: Anatolij Gustschin <agust@denx.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: gadget: mv_udc: fix the clk APIs

the clock common driver changes, and arch-mmp will make use of
the common clock driver instead of its own.
So for enable clock.
first prepare the clock
then enable the clock.

for disable clock
first disable the clock
then unprepare the clock

Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: host: ehci-mv: fix clk APIs

the clock common driver changes, and arch-mmp will make use of
the common clock driver instead of its own.
So for enable clock.
first prepare the clock
then enable the clock.

for disable clock
first disable the clock
then unprepare the clock

Signed-off-by: Chao Xie <chao.xie@marvell.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: gadget: s3c-hsotg: Fix invalid free of devm_ allocated data

Since hsotg object is allocated using devm_kzalloc() API, there is no
need to free this explicitly. But we need to keep the release API to
prevent warnings.

Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: renesas_usbhs: gadget: usbhsg_ep_disable() care pipe settings

Current usbhsg_ep_disable() didn't care
uep->pipe and pipe->mod_private variable which is used on usbhsg_ep_enable().
It breaks renesas_usbhs gadget when resume.
This patch fixes it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: renesas_usbhs: mod_host: fixup usbhsh_ureq_free() timing

usbhsh_ureq_free() free ureq which includes ubshs_pkt.
But current driver used usbhs_pkt after freed ureq.
This patch fixup this bug.
Special thanks to Chen

Reported-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: otg: mv_otg: fix the clk APIs

the clock common driver changes, and arch-mmp will make use of
the common clock driver instead of its own.
So for enable clock.
first prepare the clock
then enable the clock.

for disable clock
first disable the clock
then unprepare the clock

Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: gadget: dummy: fix enumeration with g_multi

If we do have endpoints named like "ep-a" then bEndpointAddress is
counted internally by the gadget framework.

If we do have endpoints named like "ep-1" then bEndpointAddress is
assigned from the digit after "ep-".

If we do have both, then it is likely that after we used up the
"generic" endpoints we will use the digits and thus assign one
bEndpointAddress to multiple endpoints.

This theory can be proofed by using the completely enabled g_multi.
Without this patch, the mass storage won't enumerate and times out
because it shares endpoints with RNDIS.

This patch also adds fills up the endpoints list so we have in total
endpoints 1 to 15 in + out available while some of them are restricted
to certain types like BULK or ISO. Without this change the nokia gadget
won't load because the system does not provide enough (BULK) endpoints
but it did before ep-a - ep-f were removed.

Cc: stable@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: musb: dsps: header movement build error fix

"54db6ee ARM: OMAP2+: Introduce local usb.h" moved control module bit
definitions from plat/usb.h (which dsps glue was using) to a local
header in mach-omap2. And in parallel,
"c68bb4c usb: musb: dsps: control module handling (quirk)" added
control module handling capability to dsps glue driver that used
those control module bit definitions.

Integration of above two changes would cause build error in musb dsps
glue driver (they go through different trees upstream) as is seen now
in linux-next. Fix it by adding necessary definitions in dsps glue
driver.

Signed-off-by: Afzal Mohammed <afzal@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: gadget: amd5536udc: avoid NULL pointer dereference in udc_pci_probe()

dev->pdev is NULL before `dev->pdev = pdev'; use pdev instead.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: gadget: tcm_usb_gadge: fix to return error or 0 in tcm_usbg_drop_nexus()

In the error handling case of tcm_usbg_drop_nexus(), the error code
is assigned to 'ret', but it is ignored. We'd better return 'ret'
instead of always return 0.

dpatch engine is used to auto generate this patch.
(https://github.com/weiyj/dpatch)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: gadget: u_serial: fix switch off blocked

When a device is switched off by software, gserial_cleanup will
be called, and switch off will be blocked in this function
because wake_up_interruptible() in gs_close() can not wake_up
the wait_event() in gserial_cleanup(), it should be changed to
wake_up() to match the wait_event().

Signed-off-by: Haipeng YU <haipeng.yu@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
usb: musb: core: print new line in the driver banner again

Commit 5c8a86e10a7c164f44537fabdc169fd8b4e7a440 (usb: musb: drop unneeded
musb_debug trickery) erroneously removed '\n' from the driver's banner.
Concatenate all the banner substrings while adding it back...

Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Cc: stable@vger.kernel.org # 3.0+
Signed-off-by: Felipe Balbi <balbi@ti.com>
HID: remove x bit from sensor doc

Reported-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
netfilter: ip[6]t_REJECT: fix wrong transport header pointer in TCP reset

The problem occurs when iptables constructs the tcp reset packet.
It doesn't initialize the pointer to the tcp header within the skb.
When the skb is passed to the ixgbe driver for transmit, the ixgbe
driver attempts to access the tcp header and crashes.
Currently, other drivers (such as our 1G e1000e or igb drivers) don't
access the tcp header on transmit unless the TSO option is turned on.

<1>BUG: unable to handle kernel NULL pointer dereference at 0000000d
<1>IP: [<d081621c>] ixgbe_xmit_frame_ring+0x8cc/0x2260 [ixgbe]
<4>*pdpt = 0000000085e5d001 *pde = 0000000000000000
<0>Oops: 0000 [#1] SMP
[...]
<4>Pid: 0, comm: swapper Tainted: P            2.6.35.12 #1 Greencity/Thurley
<4>EIP: 0060:[<d081621c>] EFLAGS: 00010246 CPU: 16
<4>EIP is at ixgbe_xmit_frame_ring+0x8cc/0x2260 [ixgbe]
<4>EAX: c7628820 EBX: 00000007 ECX: 00000000 EDX: 00000000
<4>ESI: 00000008 EDI: c6882180 EBP: dfc6b000 ESP: ced95c48
<4> DS: 007b ES: 007b FS: 00d8 GS: 0000 SS: 0068
<0>Process swapper (pid: 0, ti=ced94000 task=ced73bd0 task.ti=ced94000)
<0>Stack:
<4> cbec7418 c779e0d8 c77cc888 c77cc8a8 0903010a 00000000 c77c0008 00000002
<4><0> cd4997c0 00000010 dfc6b000 00000000 d0d176c9 c77cc8d8 c6882180 cbec7318
<4><0> 00000004 00000004 cbec7230 cbec7110 00000000 cbec70c0 c779e000 00000002
<0>Call Trace:
<4> [<d0d176c9>] ? 0xd0d176c9
<4> [<d0d18a4d>] ? 0xd0d18a4d
<4> [<411e243e>] ? dev_hard_start_xmit+0x218/0x2d7
<4> [<411f03d7>] ? sch_direct_xmit+0x4b/0x114
<4> [<411f056a>] ? __qdisc_run+0xca/0xe0
<4> [<411e28b0>] ? dev_queue_xmit+0x2d1/0x3d0
<4> [<411e8120>] ? neigh_resolve_output+0x1c5/0x20f
<4> [<411e94a1>] ? neigh_update+0x29c/0x330
<4> [<4121cf29>] ? arp_process+0x49c/0x4cd
<4> [<411f80c9>] ? nf_hook_slow+0x3f/0xac
<4> [<4121ca8d>] ? arp_process+0x0/0x4cd
<4> [<4121ca8d>] ? arp_process+0x0/0x4cd
<4> [<4121c6d5>] ? T.901+0x38/0x3b
<4> [<4121c918>] ? arp_rcv+0xa3/0xb4
<4> [<4121ca8d>] ? arp_process+0x0/0x4cd
<4> [<411e1173>] ? __netif_receive_skb+0x32b/0x346
<4> [<411e19e1>] ? netif_receive_skb+0x5a/0x5f
<4> [<411e1ea9>] ? napi_skb_finish+0x1b/0x30
<4> [<d0816eb4>] ? ixgbe_xmit_frame_ring+0x1564/0x2260 [ixgbe]
<4> [<41013468>] ? lapic_next_event+0x13/0x16
<4> [<410429b2>] ? clockevents_program_event+0xd2/0xe4
<4> [<411e1b03>] ? net_rx_action+0x55/0x127
<4> [<4102da1a>] ? __do_softirq+0x77/0xeb
<4> [<4102dab1>] ? do_softirq+0x23/0x27
<4> [<41003a67>] ? do_IRQ+0x7d/0x8e
<4> [<41002a69>] ? common_interrupt+0x29/0x30
<4> [<41007bcf>] ? mwait_idle+0x48/0x4d
<4> [<4100193b>] ? cpu_idle+0x37/0x4c
<0>Code: df 09 d7 0f 94 c2 0f b6 d2 e9 e7 fb ff ff 31 db 31 c0 e9 38
ff ff ff 80 78 06 06 0f 85 3e fb ff ff 8b 7c 24 38 8b 8f b8 00 00 00
<0f> b6 51 0d f6 c2 01 0f 85 27 fb ff ff 80 e2 02 75 0d 8b 6c 24
<0>EIP: [<d081621c>] ixgbe_xmit_frame_ring+0x8cc/0x2260 [ixgbe] SS:ESP

Signed-off-by: Mukund Jampala <jbmukund@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>