platform/kernel/linux-3.10.git
9 years agoRevert "WORKAROUND: Temporary workaround for Suspend-To-Ram."
Jonghwa Lee [Mon, 3 Feb 2014 08:29:25 +0000 (17:29 +0900)]
Revert "WORKAROUND: Temporary workaround for Suspend-To-Ram."

This reverts commit 682061cb597d5174de6fee211a2ad565c33680f7.

Change-Id: I4ac3f3b86ecd6a8b15ea2d266ab84b16aeb69dda
Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
9 years agospec: add missing build dependences and output packages cleanup.
Jacek Pielaszkiewicz [Mon, 27 Jan 2014 14:19:59 +0000 (15:19 +0100)]
spec: add missing build dependences and output packages cleanup.

The following changes have been implemeneted:
1. Add BuildRequires on module-init-tools
2. Cleanup  Documentation directory from *.txt files
3. Update file permisions for executable files (*.sh, *pl)

Change-Id: I06a9348f6220ce2383b6f788635acbd0fe5ef78e
Signed-off-by: Jacek Pielaszkiewicz <j.pielaszkie@samsung.com>
9 years agousb: gadget: eliminate memory leak in slp gadget
Andrzej Pietrasiewicz [Thu, 23 Jan 2014 10:18:36 +0000 (11:18 +0100)]
usb: gadget: eliminate memory leak in slp gadget

Free the allocated acm_function_config struct in case of error.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Change-Id: Ie935cf67beccc2071d1ecd74437cffbe6a6827b8

9 years agousb: gadget: adapt slp to new interface of rndis
Andrzej Pietrasiewicz [Thu, 23 Jan 2014 10:08:57 +0000 (11:08 +0100)]
usb: gadget: adapt slp to new interface of rndis

f_rndis has a new interface. Use it.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Change-Id: I4cd8baf2180cc69fb372c6cce018ecf3a5729a38

9 years agousb: gadget: temporarily turn off rndis from slp gadget
Andrzej Pietrasiewicz [Wed, 22 Jan 2014 13:58:04 +0000 (14:58 +0100)]
usb: gadget: temporarily turn off rndis from slp gadget

This fixes build break caused by recently merged removal
of compatibility layer in rndis.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Change-Id: I11c2d02e2d491f30f8c9936916f627389787a1e5

9 years agotizen: packaging: support perf build
Chanho Park [Tue, 21 Jan 2014 01:11:34 +0000 (10:11 +0900)]
tizen: packaging: support perf build

Change-Id: Idc375608e3bde344347de6ad37c434b5f16aefbc
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
9 years agoAdd dependency on kernel package in kernel-devel package.
Jacek Pielaszkiewicz [Mon, 20 Jan 2014 09:20:35 +0000 (10:20 +0100)]
Add dependency on kernel package in kernel-devel package.

Change-Id: Iba7d12ecac46b3e5985f412f4cc3f623162cf728
Signed-off-by: Jacek Pielaszkiewicz <j.pielaszkie@samsung.com>
9 years agousb: gadget: fix NULL pointer dereference
Andrzej Pietrasiewicz [Mon, 20 Jan 2014 07:32:43 +0000 (08:32 +0100)]
usb: gadget: fix NULL pointer dereference

Fix possible NULL pointer dereference introduced in

219580e64f035bb9018dbb08d340f90b0ac50f8c
usb: f_fs: check quirk to pad epout buf size when not aligned to
maxpacketsize

In cases we do wait with:

wait_event_interruptible(epfile->wait, (ep = epfile->ep));

for endpoint to be enabled, functionfs_bind() has not been called yet
and epfile->ffs->gadget is still NULL and the automatic variable 'gadget'
has been initialized with NULL at the point of its definition.
Later on it is used as a parameter to:

usb_ep_align_maybe(gadget, ep->ep, len)

which in turn dereferences it.

This patch fixes it by moving the actual assignment to the local 'gadget'
variable after the potential waiting has completed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
9 years agousb: gadget: FunctionFS: use consistent naming with regard to ffs_lock
Andrzej Pietrasiewicz [Mon, 13 Jan 2014 12:48:05 +0000 (13:48 +0100)]
usb: gadget: FunctionFS: use consistent naming with regard to ffs_lock

Consistently prefix function name with underscore if the function has to
be called with ffs_lock taken.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
9 years agousb: gadget: FunctionFS: staticize functions used only in f_fs.c
Andrzej Pietrasiewicz [Mon, 13 Jan 2014 12:20:25 +0000 (13:20 +0100)]
usb: gadget: FunctionFS: staticize functions used only in f_fs.c

ffs_alloc_dev and ffs_free_dev are used only in f_fs.c,
so make them static.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
9 years agousb: gadget: code cleanup
Andrzej Pietrasiewicz [Mon, 13 Jan 2014 15:42:02 +0000 (16:42 +0100)]
usb: gadget: code cleanup

Remove trailing whitespace

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
9 years agousb: gadget: FunctionFS: dereference ffs_dev conditionally
Andrzej Pietrasiewicz [Mon, 13 Jan 2014 15:41:22 +0000 (16:41 +0100)]
usb: gadget: FunctionFS: dereference ffs_dev conditionally

ffs_dev->ffs_release_dev_callback should be accessed only if ffs_dev
is not NULL.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
9 years agousb: gadget: fix up some comments about CONFIG_USB_DEBUG
Greg Kroah-Hartman [Thu, 19 Dec 2013 23:43:10 +0000 (15:43 -0800)]
usb: gadget: fix up some comments about CONFIG_USB_DEBUG

These two gadget drivers said that their #endif was for
CONFIG_USB_DEBUG, but they really were not, so fix them up to be
correct.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: should use u16 type variable to store MaxPower
Du, ChangbinX [Tue, 17 Dec 2013 11:47:42 +0000 (11:47 +0000)]
usb: gadget: should use u16 type variable to store MaxPower

From 7e827a0d300e084f74c65122baa5e3193f9a7f18 Mon Sep 17 00:00:00 2001
From: "Du, Changbin" <changbinx.du@intel.com>
Date: Mon, 16 Dec 2013 20:32:13 +0800
Subject: [PATCH] usb/gadget: should use u16 type variable to store MaxPower

The MaxPower field is of u16 type. So using u8 type variable can break
data (high byte lost).

Signed-off-by: Du, Changbin <changbinx.du@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: configfs: include appropriate header file in configfs.c
Rashika Kheria [Thu, 19 Dec 2013 10:07:37 +0000 (15:37 +0530)]
usb: gadget: configfs: include appropriate header file in configfs.c

Include appropriate header file drivers/usb/gadget/configfs.h in
gadget/configfs.c because function unregister_gadget_item() has its
prototype declaration in gadget/configfs.h.

This eliminates the following warning in gadget/configfs.c:
drivers/usb/gadget/configfs.c:994:6: warning: no previous prototype for ‘unregister_gadget_item’ [-Wmissing-prototypes]

Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: call try_to_freeze only when its safe
George Cherian [Fri, 8 Nov 2013 05:20:52 +0000 (10:50 +0530)]
usb: gadget: f_mass_storage: call try_to_freeze only when its safe

Call try_to_freeze() in sleep_thread() only when it's safe to sleep.
do_read() and do_write() calls sleep_thread with lock held.
Make sure these won't call try_to_freeze() by passing can_freeze flag
to sleep_thread.

Calling try_to_freeze() with a lock hold was done since day one in
f_mass_storage but since commit 0f9548ca1 ("lockdep: check that no
locks held at freeze time") lockdep complains about it.

Signed-off-by: George Cherian <george.cherian@ti.com>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: zero: module parameters can be static
Fengguang Wu [Mon, 25 Nov 2013 17:10:59 +0000 (11:10 -0600)]
usb: gadget: zero: module parameters can be static

g_zero's module parameters can, and should, be
static. This fixes sparse warnings.

Cc: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: mass storage: fix return of delayed status
Pratyush Anand [Mon, 4 Nov 2013 16:43:54 +0000 (22:13 +0530)]
usb: gadget: mass storage: fix return of delayed status

Mass storage gadget returns DELAYED_STATUS in stead of
USB_GADGET_DELAYED_STATUS while handling bulk reset request. Since
peripheral driver uses USB_GADGET_DELAYED_STATUS for delayed status
handling, therefore replace DELAYED_STATUS by USB_GADGET_DELAYED_STATUS
in mass storage driver.

Since, DELAYED_STATUS and hence EP0_BUFSIZE will no longer be used now,
so remove them.

Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Cc: Paul Zimmerman <Paul.Zimmerman@synopsys.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: fix mass storage dependency
Andrzej Pietrasiewicz [Mon, 4 Nov 2013 12:46:17 +0000 (13:46 +0100)]
usb: gadget: f_mass_storage: fix mass storage dependency

Legacy gadgets supporting mass storage (g_mass_storage, g_acm_ms, g_multi)
all depend on BLOCK.

Make the standalone compilation of f_mass_storage (without any legacy
gadget) dependent no BLOCK, too.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_sourcesink: Fix sparse warning
Jingoo Han [Mon, 16 Dec 2013 09:44:43 +0000 (18:44 +0900)]
usb: gadget: f_sourcesink: Fix sparse warning

Make local symbols static in order to fix the following sparse
warnings.

drivers/usb/gadget/f_sourcesink.c:205:34: warning: symbol 'ss_source_comp_desc' was not declared. Should it be static?
drivers/usb/gadget/f_sourcesink.c:222:34: warning: symbol 'ss_sink_comp_desc' was not declared. Should it be static?
drivers/usb/gadget/f_sourcesink.c:240:34: warning: symbol 'ss_iso_source_comp_desc' was not declared. Should it be static?
drivers/usb/gadget/f_sourcesink.c:258:34: warning: symbol 'ss_iso_sink_comp_desc' was not declared. Should it be static?

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_serial: Fix sparse warning
Jingoo Han [Mon, 16 Dec 2013 09:44:25 +0000 (18:44 +0900)]
usb: gadget: f_serial: Fix sparse warning

Make local symbol static in order to fix the following sparse
warning.

drivers/usb/gadget/f_serial.c:357:21: warning: symbol 'gser_alloc' was not declared. Should it be static?

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_phonet: Fix sparse warning
Jingoo Han [Mon, 16 Dec 2013 09:44:07 +0000 (18:44 +0900)]
usb: gadget: f_phonet: Fix sparse warning

Make local symbol static in order to fix the following sparse
warning.

drivers/usb/gadget/f_phonet.c:692:21: warning: symbol 'phonet_alloc' was not declared. Should it be static?

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_obex: Fix sparse warning
Jingoo Han [Mon, 16 Dec 2013 09:43:50 +0000 (18:43 +0900)]
usb: gadget: f_obex: Fix sparse warning

Make local symbol static in order to fix the following sparse
warning.

drivers/usb/gadget/f_obex.c:502:21: warning: symbol 'obex_alloc' was not declared. Should it be static?

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_ncm: Fix sparse warning
Jingoo Han [Mon, 16 Dec 2013 09:43:32 +0000 (18:43 +0900)]
usb: gadget: f_ncm: Fix sparse warning

Make local symbol static in order to fix the following sparse
warning.

drivers/usb/gadget/f_ncm.c:1389:21: warning: symbol 'ncm_alloc' was not declared. Should it be static?

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: Fix sparse warning
Jingoo Han [Mon, 16 Dec 2013 09:42:48 +0000 (18:42 +0900)]
usb: gadget: f_mass_storage: Fix sparse warning

Use NULL instead of 0 when returning pointer, to fix the following
sparse warnings.

drivers/usb/gadget/f_mass_storage.c:3114:60: warning: Using plain integer as NULL pointer
drivers/usb/gadget/f_mass_storage.c:3114:63: warning: Using plain integer as NULL pointer

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_loopback: Fix sparse warning
Jingoo Han [Mon, 16 Dec 2013 09:40:49 +0000 (18:40 +0900)]
usb: gadget: f_loopback: Fix sparse warning

Make local symbols static in order to fix the following sparse
warnings.

drivers/usb/gadget/f_loopback.c:123:34: warning: symbol 'ss_loop_source_comp_desc' was not declared. Should it be static?
drivers/usb/gadget/f_loopback.c:139:34: warning: symbol 'ss_loop_sink_comp_desc' was not declared. Should it be static?

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: nokia: fix error recovery path for optional functions
Andrzej Pietrasiewicz [Fri, 13 Dec 2013 13:46:40 +0000 (14:46 +0100)]
usb: gadget: nokia: fix error recovery path for optional functions

In the nokia gadget some USB functions (obex 1 and 2, phonet) are optional.

If at the start of nokia_bind_config e.g. fi_phonet is an error pointer,
which can happen because we don't fail the bind process if
usb_get_function_instance() fails for fi_phonet, then f_phonet is NULL, and

phonet_stat = usb_add_function(c, f_phonet);

is never called and phonet_stat remains 0.

If, in these circumstances, we hit the err_conf label then !phonet_stat
evaluates to true and we try usb_remove_function() with its second
parameter being f_phonet which is NULL and it causes NULL pointer
dereference.

This patch changes the initial values of (obex1|obex2|phonet)_stat to a
nonzero value so that if the err_conf label is hit while the respective
functions have not been acquired the usb_remove_function() is not called
for those functions.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_fs: fix sparse warning
Felipe Balbi [Thu, 12 Dec 2013 18:15:43 +0000 (12:15 -0600)]
usb: gadget: f_fs: fix sparse warning

use NULL when returning NULL pointers, not 0.

Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: FunctionFS: add configfs support
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:36 +0000 (15:15 +0100)]
usb: gadget: FunctionFS: add configfs support

Add support for using FunctionFS in configfs-based USB gadgets.

[ balbi@ti.com : removed redefinition of VERBOSE_DEBUG and few
trailing whitespaces ]

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: FunctionFS: Remove compatibility layer
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:35 +0000 (15:15 +0100)]
usb: gadget: FunctionFS: Remove compatibility layer

There are no old function interface users left, so the old interface can
be removed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: g_ffs: convert to new interface of f_fs
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:34 +0000 (15:15 +0100)]
usb: gadget: g_ffs: convert to new interface of f_fs

Prepare for configfs integration. Use the new interface so that f_fs can be
made a module.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: FunctionFS: convert to new function interface with backward compatibility
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:33 +0000 (15:15 +0100)]
usb: gadget: FunctionFS: convert to new function interface with backward compatibility

This is required in order to integrate configfs support.
f_fs needs to be a separately compiled module and so it needs to use the new
interface.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: FunctionFS: add devices management code
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:32 +0000 (15:15 +0100)]
usb: gadget: FunctionFS: add devices management code

This will be required in order to use the new function interface
(usb_get_function_instance/usb_put_function_instance)

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyunmgin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: FunctionFS: create utility file
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:31 +0000 (15:15 +0100)]
usb: gadget: FunctionFS: create utility file

A header file to be used by f_fs.c and g_ffs.c will be required when
f_fs.c is converted into a module.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: FunctionFS: Remove VLAIS usage from gadget code
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:30 +0000 (15:15 +0100)]
usb: gadget: FunctionFS: Remove VLAIS usage from gadget code

The use of variable length arrays in structs (VLAIS) in the Linux Kernel code
precludes the use of compilers which don't implement VLAIS (for instance the
Clang compiler). This alternate patch calculates offsets into the kmalloc-ed
memory buffer using macros. The previous patch required multiple kmalloc and
kfree calls. This version uses "group" vs "struct" since it really is not a
struct and is essentially a group of VLA in a common allocated block. This
version also fixes the issues pointed out by Andrzej Pietrasiewicz and
Michal Nazarewicz.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
Signed-off-by: Behan Webster <behanw@converseincode.com>
[elimination of miexed declaration and code, checkpatch cleanup]
[fixes after Michal's review]
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: rndis: merge u_rndis.ko with usb_f_rndis.ko
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:29 +0000 (15:15 +0100)]
usb: gadget: rndis: merge u_rndis.ko with usb_f_rndis.ko

The rndis function's users use only the new interface, so the two modules
can be merged.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_rndis: remove compatibility layer
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:28 +0000 (15:15 +0100)]
usb: gadget: f_rndis: remove compatibility layer

There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: g_ffs: convert to new interface of f_rndis
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:27 +0000 (15:15 +0100)]
usb: gadget: g_ffs: convert to new interface of f_rndis

There is a new interface of f_rndis and g_ffs is the last to use the old one.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_subset: remove compatibility layer
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:26 +0000 (15:15 +0100)]
usb: gadget: f_subset: remove compatibility layer

There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: g_ffs: convert to new interface of f_subset
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:25 +0000 (15:15 +0100)]
usb: gadget: g_ffs: convert to new interface of f_subset

There is a new function interface of f_subset and g_ffs is the last to use
the old one.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_ecm: remove compatibility layer
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:24 +0000 (15:15 +0100)]
usb: gadget: f_ecm: remove compatibility layer

There are no old function interface users left, so the old interface
can be removed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmim Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: g_ffs: convert to new interface of f_ecm
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:23 +0000 (15:15 +0100)]
usb: gadget: g_ffs: convert to new interface of f_ecm

There is a new funtion interface and g_ffs is the last gadget to use the old.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: g_ffs: remove a reduntant gfs_ether_setup variable
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:22 +0000 (15:15 +0100)]
usb: gadget: g_ffs: remove a reduntant gfs_ether_setup variable

Since d6a0143985489e470a118605352f4b18df0ce142
usb: gadget: move the global the_dev variable to their users
"the_dev" variable can be used as a "setup done" flag; non-NULL
meaning "setup done", NULL meaning "setup not done". Moreover,
gether_cleanup() can be safely called with a NULL argument.

Corrected a comment to be consistent with the code.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: configfs: allow setting function instance's name
Andrzej Pietrasiewicz [Tue, 3 Dec 2013 14:15:21 +0000 (15:15 +0100)]
usb: gadget: configfs: allow setting function instance's name

USB function's configfs config group is created in a generic way in
usb/gadget/configfs.c:function_make(), which in turn delegates actual
allocation and setup of the USB function instance to a particular
implementation, e.g. in f_acm.c. The said implementation does its job
in a parameter-less function e.g. acm_alloc_instance(), which results
in creating an unnamed config group, whose name is set later in
function_make(). function_make() creates the name by parsing a string
of the form:

<function name>.<instance name>

which comes from userspace as a parameter to mkdir invocation.

Up to now only <function name> has been used, while <instance name>
has been ignored. This patch adds a set_inst_name() operation to
struct usb_function_instance which allows passing the <instance name>
from function_make() so that it is not ignored. It is entirely up to the
implementor of set_inst_name() what to do with the <instance name>.

In a typical case, the struct usb_function_instance is embedded in a
larger struct which is retrieved in set_inst_name() with container_of(),
and the larger struct contains a field to store the <instance name>.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: f_fs: check quirk to pad epout buf size when not aligned to maxpacketsize
Michal Nazarewicz [Mon, 9 Dec 2013 23:55:37 +0000 (15:55 -0800)]
usb: f_fs: check quirk to pad epout buf size when not aligned to maxpacketsize

Check gadget.quirk_ep_out_aligned_size to decide if buffer size requires
to be aligned to maxpacketsize of an out endpoint.  ffs_epfile_io() needs
to pad epout buffer to match above condition if quirk is found.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: David Cohen <david.a.cohen@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_fs: remove loop from I/O function
Michal Nazarewicz [Mon, 9 Dec 2013 23:55:36 +0000 (15:55 -0800)]
usb: gadget: f_fs: remove loop from I/O function

When endpoint changes (due to it being disabled or alt setting changed),
mimic the action as if the change happened after the request has been
queued, instead of retrying with the new endpoint.

Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Cc: David Cohen <david.a.cohen@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: add quirk_ep_out_aligned_size field to struct usb_gadget
David Cohen [Mon, 9 Dec 2013 23:55:35 +0000 (00:55 +0100)]
usb: gadget: add quirk_ep_out_aligned_size field to struct usb_gadget

Due to USB controllers may have different restrictions, usb gadget layer
needs to provide a generic way to inform gadget functions to complain
with non-standard requirements.

This patch adds 'quirk_ep_out_aligned_size' field to struct usb_gadget
to inform when controller's epout requires buffer size to be aligned to
MaxPacketSize. A helper is also provided to align buffer size when
necessary.

Cc: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: David Cohen <david.a.cohen@linux.intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
[backport from mainline]
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
9 years agousb: gadget: move bitflags to the end of usb_gadget struct
David Cohen [Mon, 9 Dec 2013 23:55:34 +0000 (00:55 +0100)]
usb: gadget: move bitflags to the end of usb_gadget struct

This patch moves all bitflags to the end of usb_gadget struct in order
to improve readability.

Signed-off-by: David Cohen <david.a.cohen@linux.intel.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
[backport from mainline]
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
9 years agousb: gadget: f_sourcesink: add configfs support
Andrzej Pietrasiewicz [Thu, 7 Nov 2013 07:41:28 +0000 (08:41 +0100)]
usb: gadget: f_sourcesink: add configfs support

Add support for using the sourcesink function in gadgets composed with
configfs.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_loopback: add configfs support
Andrzej Pietrasiewicz [Thu, 7 Nov 2013 07:41:27 +0000 (08:41 +0100)]
usb: gadget: f_loopback: add configfs support

Add support for using the loopback USB function in gadgets composed with
configfs.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: factor out alloc_ep_req
Andrzej Pietrasiewicz [Thu, 7 Nov 2013 07:41:26 +0000 (08:41 +0100)]
usb: gadget: factor out alloc_ep_req

alloc_ep_req() is a function repeated in several modules.
Make a common implementation and use it.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: composite: redirect setup requests
Andrzej Pietrasiewicz [Thu, 7 Nov 2013 07:41:25 +0000 (08:41 +0100)]
usb: gadget: composite: redirect setup requests

If there are setup requests not directed to an endpont or an interface,
current config's setup() has been attempted so far.
This patch, in case the above fails, adds code which tries the setup() of
configuration's function if there is only one function in the configuration.

This behavior is required to provide equivalent of gadget zero with configfs.

The gadget zero has a "config driver" for sourcesink, but all it does is
delegating the request to the function proper. So when the equivalent gadget
is set up with configfs it needs to handle requests directed to
"config driver", but with configfs it is not possible to specify
"config drivers".

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: update some out of date comments
Dan Carpenter [Thu, 14 Nov 2013 08:42:11 +0000 (11:42 +0300)]
usb: gadget: update some out of date comments

These functions used to return negative errror codes but now they return
ERR_PTRs.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb/gadget: f_mass_storage: use string literal as format in dev_set_name
Andrzej Pietrasiewicz [Fri, 25 Oct 2013 07:09:27 +0000 (09:09 +0200)]
usb/gadget: f_mass_storage: use string literal as format in dev_set_name

Fix commit b27c08c953e994f792a03d9b7cbc5cf3f9844135 where dev_set_name()
is used without a string literal as format.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agousb: gadget: f_mass_storage: style corrections, cleanup & simplification
Andrzej Pietrasiewicz [Wed, 16 Oct 2013 06:34:51 +0000 (08:34 +0200)]
usb: gadget: f_mass_storage: style corrections, cleanup & simplification

Fix spacing, improve error code returned, remove unused #define,
use strtobool() instead of kstrtou8().

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: storage_common: pass filesem to fsg_store_cdrom
Andrzej Pietrasiewicz [Tue, 15 Oct 2013 06:33:13 +0000 (08:33 +0200)]
usb: gadget: storage_common: pass filesem to fsg_store_cdrom

If cdrom flag is set ro flag is implied. Try setting the ro first, and
only if it succeeds set the cdrom flag.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: storage_common: use strtobool instead of kstrtouint
Andrzej Pietrasiewicz [Tue, 15 Oct 2013 06:33:12 +0000 (08:33 +0200)]
usb: gadget: storage_common: use strtobool instead of kstrtouint

strtobool is more flexible for the user and is more appropriate in the
context.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: mass_storage: merge usb_f_mass_storage module with u_ms module
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:08:29 +0000 (10:08 +0200)]
usb: gadget: mass_storage: merge usb_f_mass_storage module with u_ms module

u_ms.ko is needed only together with usb_f_mass_storage.ko. Merge them.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: remove compatibility layer
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:08:28 +0000 (10:08 +0200)]
usb: gadget: f_mass_storage: remove compatibility layer

There are no more old interface users left. Remove it.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: multi: convert to new interface of f_mass_storage
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:08:27 +0000 (10:08 +0200)]
usb: gadget: multi: convert to new interface of f_mass_storage

Convert the legacy multi gadget to the new interface of f_mass_storage,
so that later the compatibility layer in f_mass_storage can be removed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: multi: convert to new interface of f_rndis
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:08:26 +0000 (10:08 +0200)]
usb: gadget: multi: convert to new interface of f_rndis

Convert the legacy multi gadget to the new interface of f_rndis,
so that later the compatibility layer in f_rndis can be removed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: multi: convert to new interface of f_ecm
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:08:25 +0000 (10:08 +0200)]
usb: gadget: multi: convert to new interface of f_ecm

Convert the legacy multi gadget to the new interface of f_ecm,
so that later the compatibility layer in f_ecm can be removed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: acm_ms: convert to new interface of f_mass_storage
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:07:29 +0000 (10:07 +0200)]
usb: gadget: acm_ms: convert to new interface of f_mass_storage

Convert the legacy acm_ms gadget to use the new function interface
of f_mass_storage, so that later the compatibility layer in
f_mass_storage can be removed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: add configfs support
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:06:05 +0000 (10:06 +0200)]
usb: gadget: f_mass_storage: add configfs support

From this commit on f_mass_storage is available through configfs.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: storage_common: add methods to show/store 'cdrom' and 'removable'
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:06:04 +0000 (10:06 +0200)]
usb: gadget: storage_common: add methods to show/store 'cdrom' and 'removable'

This will be required by configfs integration.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: storage_common: make attribute operations more generic
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:06:03 +0000 (10:06 +0200)]
usb: gadget: storage_common: make attribute operations more generic

Show/store methods for sysfs attributes contain code which can be used
also by configfs. Make them abstract the source the lun and rw_semaphore
are taken from.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: mass_storage: convert to new interface of f_mass_storage
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:06:02 +0000 (10:06 +0200)]
usb: gadget: mass_storage: convert to new interface of f_mass_storage

Convert old mass_storage gadget to use the new interface of f_mass_storage
so that later the compatibility layer in f_mass_storage can be removed.

struct fsg_common is not known to mass_storage.c, so a setter method
is added to f_mass_storage.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: convert to new function interface with backward compatib...
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:06:01 +0000 (10:06 +0200)]
usb: gadget: f_mass_storage: convert to new function interface with backward compatibility

Converting mass storage to the new function interface requires converting
the USB mass storage's function code and its users.
This patch converts the f_mass_storage.c to the new function interface.
The file is now compiled into a separate usb_f_mass_storage.ko module.
The old function interface is provided by means of a preprocessor conditional
directives. After all users are converted, the old interface can be removed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: create fsg_common_run_thread for use in fsg_common_init
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:06:00 +0000 (10:06 +0200)]
usb: gadget: f_mass_storage: create fsg_common_run_thread for use in fsg_common_init

fsg_common_init is a lengthy function. Factor a portion of it out.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: create fsg_common_set_inquiry_string for use in fsg_comm...
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:05:59 +0000 (10:05 +0200)]
usb: gadget: f_mass_storage: create fsg_common_set_inquiry_string for use in fsg_common_init

fsg_common_init is a lengthy function. Factor a portion of it out.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: create lun creation helpers for use in fsg_common_init
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:05:58 +0000 (10:05 +0200)]
usb: gadget: f_mass_storage: create lun creation helpers for use in fsg_common_init

fsg_common_init is a lengthy function. Factor portions of it out.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: create fsg_common_set_cdev for use in fsg_common_init
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:05:57 +0000 (10:05 +0200)]
usb: gadget: f_mass_storage: create fsg_common_set_cdev for use in fsg_common_init

fsg_common_init is a lengthy function. Factor a portion of it out.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: create lun handling helpers for use in fsg_common_init
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:05:56 +0000 (10:05 +0200)]
usb: gadget: f_mass_storage: create lun handling helpers for use in fsg_common_init

fsg_common_init is a lengthy function. Factor portions of it out.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: create fsg_common_set_num_buffers for use in fsg_common_init
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:05:55 +0000 (10:05 +0200)]
usb: gadget: f_mass_storage: create fsg_common_set_num_buffers for use in fsg_common_init

fsg_common_init is a lengthy function. Factor a portion of it out.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: create fsg_common_setup for use in fsg_common_init
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:05:54 +0000 (10:05 +0200)]
usb: gadget: f_mass_storage: create fsg_common_setup for use in fsg_common_init

fsg_common_init is a lengthy function. Factor a portion of it out.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: make sysfs interface optional
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:05:53 +0000 (10:05 +0200)]
usb: gadget: f_mass_storage: make sysfs interface optional

When configfs is in place, the luns will not be represented in sysfs,
so there will be no struct device associated with a lun.
In order to maintain compatibility and allow configfs adoption
sysfs is made optional in this patch.

As a consequence some debug macros need to be adjusted. Two new
fields are added to struct fsg_lun: name and name_pfx.
The "name" is for storing a string which is presented to the user
instead of the dev_name. The "name_pfx", if non-NULL, is prepended
to the "name" at printing time.

The name_pfx is for a future lun.0, which will be a default group in
mass_storage.<name>. By design at USB function configfs group's creation
time its name is not known (but instead set a bit later in
drivers/usb/gadget/configfs.c:function_make) and it is this name that
serves the purpose of the said name prefix. So instead of copying
a yet-unknown string a pointer to it is stored in struct fsg_lun.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: create _fsg_common_free_buffers
Andrzej Pietrasiewicz [Wed, 9 Oct 2013 08:05:52 +0000 (10:05 +0200)]
usb: gadget: f_mass_storage: create _fsg_common_free_buffers

When configfs is in place, gadgets will have to be able to free
fsg buffers. Add a helper function.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: use usb_gstrings_attach
Andrzej Pietrasiewicz [Thu, 26 Sep 2013 12:38:19 +0000 (14:38 +0200)]
usb: gadget: f_mass_storage: use usb_gstrings_attach

Prepare for handling with configfs.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: add a level of indirection for luns storage
Andrzej Pietrasiewicz [Thu, 26 Sep 2013 12:38:18 +0000 (14:38 +0200)]
usb: gadget: f_mass_storage: add a level of indirection for luns storage

This is needed to prepare for configfs integration.

So far the luns have been allocated during gadget's initialization, based
on the nluns module parameter's value; the exact number is known when the
gadget is initialized and that number of luns is allocated in one go; they
all will be used.

When configfs is in place, the luns will be created one-by-one by the user.
Once the user is satisfied with the number of luns, they activate the
gadget. The number of luns must be <= FSG_MAX_LUN (currently 8), but other
than that it is not known up front and the user need not use contiguous
numbering (apart from the default lun #0). On the other hand, the function
code uses lun numbers to identify them and the number needs to be used
as an index into an array.

Given the above, an array needs to be allocated, but it might happen that
7 out of its 8 elements will not be used. On my machine
sizeof(struct fsg_lun) == 462, so > 3k of memory is allocated but not used
in the worst case.

By adding another level of indirection (allocating an array of pointers
to struct fsg_lun and then allocating individual luns instead of an array
of struct fsg_luns) at most 7 pointers are wasted, which is much less.

This patch also changes some for/while loops to cope with the fact
that in the luns array some entries are potentially empty.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: factor out a header file
Andrzej Pietrasiewicz [Thu, 26 Sep 2013 12:38:17 +0000 (14:38 +0200)]
usb: gadget: f_mass_storage: factor out a header file

In order to prepare for the new function interface the f_mass_storage.c
needs to be compiled as a module, and so a header file will be required.

This patch factors out some code to a new f_mass_storage.h.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: create a utility module for mass_storage
Andrzej Pietrasiewicz [Thu, 26 Sep 2013 12:38:16 +0000 (14:38 +0200)]
usb: gadget: create a utility module for mass_storage

Converting to configfs requires making the f_mass_storage.c a module.

But first we need to get rid of "#include "storage_common.c".

This patch makes storage_common.c a separately compiled file, which is
built as a utility module named u_ms.ko. After all mass storage users are
converted to the new function interface this module can be eliminated
by merging it with the mass storage function's module.

USB descriptors are exported so that they can be accessed from
f_mass_storage.

FSG_VENDOR_ID and FSG_PRODUCT_ID are moved to their only user.

Handling of CONFIG_USB_GADGET_DEBUG_FILES is moved to f_mass_storage.c.
The fsg_num_buffers static is moved to FSG_MODULE_PARAMETER users, so
instead of using a global variable the f_mass_storage introduces
fsg_num_buffers member in fsg_common (and fsg_config).

fsg_strings and fsg_stringtab are moved to f_mass_storage.c.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: Use ERR_CAST inlined function instead of ERR_PTR(PTR_ERR(...))
Duan Jiong [Thu, 26 Sep 2013 07:55:25 +0000 (15:55 +0800)]
usb: gadget: Use ERR_CAST inlined function instead of ERR_PTR(PTR_ERR(...))

trivial patch converting ERR_PTR(PTR_ERR()) into ERR_CAST().
No functional changes.

Signed-off-by: Duan Jiong <duanj.fnst@cn.fujitsu.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: zero: Add flexible auto remote wakeup test method
Peter Chen [Mon, 9 Sep 2013 08:48:29 +0000 (16:48 +0800)]
usb: gadget: zero: Add flexible auto remote wakeup test method

In order to increase test coverage, we can change the interval between
two remote wakeups every time, and the interval can be any user defined
value. This change will no affect current behavior if the user does not
use two introduced module paramters.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_fs: fix error handling
Robert Baldyga [Fri, 27 Sep 2013 10:28:54 +0000 (12:28 +0200)]
usb: gadget: f_fs: fix error handling

This patch add missing error check in ffs_func_bind() function, after
ffs_do_descs() function call for high speed descriptors. Without this
check it's possible that the module will try dereference incorrect
pointer.

[ balbi@ti.com : removed trailing empty line ]

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Robert Baldyga <r.baldyga@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: g_ffs: fix compilation warning
David Cohen [Fri, 4 Oct 2013 22:30:21 +0000 (15:30 -0700)]
usb: g_ffs: fix compilation warning

If USB_FUNCTIONFS is selected without USB_FUNCTIONFS_ETH and
USB_FUNCTIONFS_RNIS, u_ether.h won't be included and then
USB_ETHERNET_MODULE_PARAMAETERS macro won't be available causing the
following warning compilation:

drivers/usb/gadget/g_ffs.c:81:1: warning: data definition has no type or
storage class [enabled by default]
drivers/usb/gadget/g_ffs.c:81:1: warning: type defaults to ‘int’ in
declaration of ‘USB_ETHERNET_MODULE_PARAMETERS’ [-Wimplicit-int]
drivers/usb/gadget/g_ffs.c:81:1: warning: function declaration isn’t a
prototype [-Wstrict-prototypes]

This patch fixes the warning by making USB_ETHERNET_MODULE_PARAMETERS to
be used iff u_ether.h is included, otherwise it is not needed.

Signed-off-by: David Cohen <david.a.cohen@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agousb: gadget: f_mass_storage: reset endpoint driver data when disabled
Peter Oh [Mon, 16 Sep 2013 21:21:14 +0000 (14:21 -0700)]
usb: gadget: f_mass_storage: reset endpoint driver data when disabled

Gadgets endpoint driver data is a criteria to judge that
whether the endpoints are in use or not. When gadget gets
assigned an endpoint from endpoint list, they check its
driver data if the driver data is NULL.

If the driver data is not NULL then they regard it as in use.
Therefore all of gadgets should reset their endpoints driver
data to NULL as they are disabled. Otherwise it causes a leak
of endpoint resource.

Signed-off-by: Peter Oh <poh@broadcom.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_eem: Staticize eem_alloc
Sachin Kamat [Mon, 16 Sep 2013 06:14:46 +0000 (11:44 +0530)]
usb: gadget: f_eem: Staticize eem_alloc

'eem_alloc' is local to this file. Make it static.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_ecm: Staticize ecm_alloc
Sachin Kamat [Mon, 16 Sep 2013 06:14:45 +0000 (11:44 +0530)]
usb: gadget: f_ecm: Staticize ecm_alloc

'ecm_alloc' is local to this file. Make it static.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: add '__ref' for rndis_config_register() and cdc_config_register()
Chen Gang [Mon, 2 Sep 2013 10:14:42 +0000 (18:14 +0800)]
usb: gadget: add '__ref' for rndis_config_register() and cdc_config_register()

They are only called by '__ref' function multi_bind(), and they will
call '__init' functions, so recommend to let them '__ref' too.

The related warnings:

  WARNING: drivers/usb/gadget/g_multi.o(.text+0xded6): Section mismatch in reference from the variable .LM2921 to the variable .init.text:_rndis_do_config
  The function .LM2921() references
  the variable __init _rndis_do_config.
  This is often because .LM2921 lacks a __init
  annotation or the annotation of _rndis_do_config is wrong.

  WARNING: drivers/usb/gadget/g_multi.o(.text+0xdf16): Section mismatch in reference from the variable .LM2953 to the variable .init.text:_cdc_do_config
  The function .LM2953() references
  the variable __init _cdc_do_config.
  This is often because .LM2953 lacks a __init
  annotation or the annotation of _cdc_do_config is wrong.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: gadgetfs: potential use after free in unbind()
Dan Carpenter [Fri, 23 Aug 2013 08:16:15 +0000 (11:16 +0300)]
usb: gadget: gadgetfs: potential use after free in unbind()

ffs_data_put() can sometimes free "ffs" so I have moved the call down
a line below the dereference.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agoUSB: gadget: audit sysfs attribute permissions
Greg Kroah-Hartman [Fri, 23 Aug 2013 23:34:43 +0000 (16:34 -0700)]
USB: gadget: audit sysfs attribute permissions

Convert all USB gadget sysfs attributes to use the _RO or _RW variants,
to make them easier to audit and ensure that the permissions are
correct.

Note, two are left using the DEVICE_ATTR() macro, as there is no
DEVICE_ATTR_WO() in Linus's tree, that will happen after 3.12-rc1 is
out, a follow-on patch will be sent then.

Reviewed-by: Felipe Balbi <balbi@ti.com>
Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
--
 drivers/usb/gadget/composite.c      |    8 +++-----
 drivers/usb/gadget/dummy_hcd.c      |    8 ++++----
 drivers/usb/gadget/f_mass_storage.c |   14 ++++++--------
 drivers/usb/gadget/net2272.c        |    4 ++--
 drivers/usb/gadget/net2280.c        |   18 +++++++++---------
 drivers/usb/gadget/storage_common.c |   25 ++++++++++++-------------
 drivers/usb/gadget/udc-core.c       |   14 +++++++-------
 7 files changed, 43 insertions(+), 48 deletions(-)

9 years agodriver core: device.h: add RW and RO attribute macros
Greg Kroah-Hartman [Sun, 14 Jul 2013 23:05:54 +0000 (16:05 -0700)]
driver core: device.h: add RW and RO attribute macros

Make it easier to create attributes without having to always audit the
mode settings.

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agosysfs.h: add __ATTR_RW() macro
Andrzej Pietrasiewicz [Wed, 15 Jan 2014 09:45:17 +0000 (10:45 +0100)]
sysfs.h: add __ATTR_RW() macro

A number of parts of the kernel created their own version of this, might
as well have the sysfs core provide it instead.

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[mainline backport]
Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
9 years agousb: gadget: rndis: Staticize rndis_init()/rndis_exit()
Jingoo Han [Mon, 5 Aug 2013 03:12:42 +0000 (12:12 +0900)]
usb: gadget: rndis: Staticize rndis_init()/rndis_exit()

rndis_init() and rndis_exit() are used only in this file.
Fix the following sparse warnings:

drivers/usb/gadget/rndis.c:1145:5: warning: symbol 'rndis_init' was not declared. Should it be static?
drivers/usb/gadget/rndis.c:1179:6: warning: symbol 'rndis_exit' was not declared. Should it be static?

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agousb: gadget: f_mass_storage: use NULL instead of 0
Jingoo Han [Mon, 5 Aug 2013 03:11:05 +0000 (12:11 +0900)]
usb: gadget: f_mass_storage: use NULL instead of 0

The local variables such as 'filename', 'vendor_name', and
'product_name' are pointers; thus, use NULL instead of 0 to fix
the following sparse warnings

drivers/usb/gadget/f_mass_storage.c:3046:27: warning: Using plain integer as NULL pointer
drivers/usb/gadget/f_mass_storage.c:3050:28: warning: Using plain integer as NULL pointer
drivers/usb/gadget/f_mass_storage.c:3051:29: warning: Using plain integer as NULL pointer

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
9 years agoUSB: gadget: fix up comment
Greg Kroah-Hartman [Fri, 28 Jun 2013 18:32:57 +0000 (11:32 -0700)]
USB: gadget: fix up comment

This endif is for CONFIG_USB_GADGET_DEBUG_FILES, not CONFIG_USB_DEBUG,
so document it properly.

Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
9 years agoRevert "usb/gadget: create a utility module for mass_storage"
Andrzej Pietrasiewicz [Tue, 14 Jan 2014 13:28:02 +0000 (14:28 +0100)]
Revert "usb/gadget: create a utility module for mass_storage"

This reverts commit 999eab4c72b5afbb59bdb5668a03118ea79e4455.

9 years agoRevert "usb/gadget: f_mass_storage: factor out a header file"
Andrzej Pietrasiewicz [Tue, 14 Jan 2014 13:27:56 +0000 (14:27 +0100)]
Revert "usb/gadget: f_mass_storage: factor out a header file"

This reverts commit aa42314c87dd9ba2b17aa1cb49d76d95d988dffe.

9 years agoRevert "usb/gadget: f_mass_storage: add a level of indirection for luns storage"
Andrzej Pietrasiewicz [Tue, 14 Jan 2014 13:27:26 +0000 (14:27 +0100)]
Revert "usb/gadget: f_mass_storage: add a level of indirection for luns storage"

This reverts commit 51717e532d24736b2813cfc49e4c48374b2fbd12.

9 years agoRevert "usb/gadget: f_mass_storage: use usb_gstrings_attach"
Andrzej Pietrasiewicz [Tue, 14 Jan 2014 13:27:23 +0000 (14:27 +0100)]
Revert "usb/gadget: f_mass_storage: use usb_gstrings_attach"

This reverts commit 2089c2070341b55b6476907100bfe2fd04467edd.