block: genhd: Add disk/partition specific uevent callbacks for partition info

For disk devices, a new uevent parameter 'NPARTS' specifies the number
of partitions detected by the kernel. Partition devices get 'PARTN' which
specifies the partitions index in the table, and 'PARTNAME', which
specifies PARTNAME specifices the partition name of a partition device

Signed-off-by: Max Liao <liaops@embedinfo.com>
usb: gadget: Add Android Composite Gadget driver

The Android Gadget driver is a composite driver that allows
userspace to change at runtime the list of functions enabled in
its configuration and to configure these functions. It supports
multiple functions: acm, adb, rndis, mtp/ptp, mass storage and
accessory.

It is usually controlled by a daemon that changes the configuration
based on user settings. For example, rndis is enabled when the user
enables sharing the phone data connection and adb (Android Debug
Bridge) is only enabled when the user wants to debug applications
for security reasons.

As an example on how to use it, the following shell commands will
make the gadget disconnect from the host and make it be re-enumerated
as a composite with 1 rndis and 2 acm interfaces, and a different
product id:

echo 0       > /sys/class/android_usb/android0/enable
echo rndis,acm > /sys/class/android_usb/android0/functions
echo 2       > /sys/class/android_usb/android0/f_acm/instances
echo 2d01    > /sys/class/android_usb/android0/idProduct
echo 1       > /sys/class/android_usb/android0/enable

The driver requires a gadget controller that supports software
control of the D+ pullup and the controller driver must support
disabling the pullup during composite_bind.

Signed-off-by: Mike Lockwood <lockwood@android.com>
Signed-off-by: Benoit Goby <benoit@android.com>
usb: gadget: mtp: Add MTP/PTP function

USB gadget function driver used by the Android framework to
implement the MTP and PTP protocols. It creates a character device
that provides an interface for fast transfer of files and
supports transferring files greater than 4GB.

Signed-off-by: Mike Lockwood <lockwood@android.com>
usb: gadget: adb: Add ADB function

Android Debug Bridge (adb) is a command line tool that lets
users communicate with a Android-powered device. It is used
mainly to debug applications and tranfer files. f_adb implements
the transport layer between the ADB Server (on the host) and the
ADBD daemon (on the device).

Signed-off-by: Mike Lockwood <lockwood@android.com>
usb: gadget: accessory: Add Android Accessory function

USB accessory mode allows users to connect USB host hardware
specifically designed for Android-powered devices. The accessories
must adhere to the Android accessory protocol outlined in the
http://accessories.android.com documentation. This allows
Android devices that cannot act as a USB host to still interact with
USB hardware. When an Android device is in USB accessory mode, the
attached Android USB accessory acts as the host, provides power
to the USB bus, and enumerates connected devices.

Signed-off-by: Mike Lockwood <lockwood@android.com>
usb: gadget: adb: allow freezing in adb_read

wait_event_interruptible in adb_read might return -ERESTARTSYS if
userspace is frozen during adb_read or another signal is delivered
to adb.  If so, don't set dev->error to avoid resetting the adb
connection.

Change-Id: I5a7baa013a9a3a3b5305de7e6a0d18546a560018
Signed-off-by: Colin Cross <ccross@android.com>
usb: gadget: adb: do not set error flag when dequeuing req

When an ep_out req is dequeued because of userspace freezing,
don't set the error flag.

Change-Id: I680f1a1059b8ac2244aaa069e7d42dc44abf98e9
Signed-off-by: Colin Cross <ccross@android.com>
usb: gadget: adb: Only enable the gadget when adbd is ready

When adb is enabled, only connect the gadget when adbd is ready. If adbd
dies or is restarted (e.g. "adb root"), the gadget is disconnected when
the adb device is close, and it is re-connected once adb re-open the
device.

- Add callbacks to adb, similar to FunctionFs callbacks, to notify the
  gadget when the daemon is ready or closed.
- Refcount calls to android_enable/android_disable to enable the gadget
  only once all the function daemons are ready.
- Add enable/disble to android_usb_function to notify the function when
  it is added/removed from the list of enabled functions.

Change-Id: Id54ff85aec9cf8715c94b4f9bd6137a79ad58bfc
Signed-off-by: Benoit Goby <benoit@android.com>
usb: gadget: android: Fix product name

Product names may contain spaces and scanf %s only matches the 1st word.
Use strlcpy instead.

Change-Id: Ie8703fea9775f7fc17fe615a42597ca3816d36b0
Signed-off-by: Benoit Goby <benoit@android.com>
usb: gadget: android: Add FunctionFS

Add support for FunctionFS (ffs) to implement usb functions in userspace.

The aliases property stores the list of functions that are implemented
using functionfs.

For example:
echo "adb,mtp" > /sys/class/android_usb/android0/f_ffs/aliases

Then when the function are enabled:
echo "adb,acm" > /sys/class/android_usb/android0/functions
Internally, ffs and acm will be used.

Change-Id: I44117b183d48a5a99ddbee3ef2cf8998be74598e
Signed-off-by: Benoit Goby <benoit@android.com>
usb: gadget: accessory: Fix section mismatch

create_bulk_endpoints should not be __init since it is called when
accessory is enabled

Change-Id: If827a4531f0f6c15af938345163923186368e2a5
Signed-off-by: Benoit Goby <benoit@android.com>
usb: gadget: Fix usb string id allocation

Don't reset next_string_id every time the gadget is enabled, this makes
the next strings allocated overwrite strings allocated at probe time.
Instead, fix rndis not to allocate new string ids on every config bind.

Change-Id: Ied28ee416bb6f00c434c34176fe5b7f0dcb2b2d4
Signed-off-by: Benoit Goby <benoit@android.com>
USB: gadget: Add ACCESSORY_SET_AUDIO_MODE control request and ioctl

The control request will be used by the host to enable/disable USB audio
and the ioctl will be used by userspace to read the audio mode

Change-Id: I81c38611b588451e80eacdccc417ca6e11c60cab
Signed-off-by: Mike Lockwood <lockwood@google.com>
USB: gadget: f_accessory: Add support for HID input devices

Change-Id: I4f1452db32508382df52acdc47c0eb395ae328c7
Signed-off-by: Mike Lockwood <lockwood@google.com>
USB: gadget: f_audio_source: New gadget driver for audio output

This driver presents a standard USB audio class interface to the host
and an ALSA PCM device to userspace

Change-Id: If16b14a5ff27045f9cb2daaf1ae9195c5eeab7d0
Signed-off-by: Mike Lockwood <lockwood@google.com>
USB: gadget: fix compile warnings and errors

The mainline patches are for Linux-3.4, did a port to linux-3.6,
this patches fix the source compile warnings and errors.

Signed-off-by: Max Liao <liaops@embedinfo.com>
usb: gadget: adb: add rx queue to support promote data receiving perfromance

tested OK by adb push 40M+ files

Signed-off-by: Max Liao <liaops@embedinfo.com>
usb: adb: report usb cable status to android

Board could be recognised by PC when usb cable plugin before system startup.

Signed-off-by: Max Liao <liaops@embedinfo.com>
USB: gadget: u_serial: fix typo cause warning

fix typo error introduced by commit ea0e6276 (usb: gadget: add
multiple definition guards) which causes the following build warning:

  warning: "pr_vdebug" redefined

Signed-off-by: Bo Shen <voice.shen@atmel.com>
usb: gadget: stay awake while usb connected

stay awake while usb connected

Signed-off-by: Max Liao <liaops@embedinfo.com>