Merge remote-tracking branch 'common/android-4.4' into android-4.4.y

This commit is contained in:
Dmitry Shmidt 2016-11-15 16:36:51 -08:00
commit 93e3336909
8 changed files with 937 additions and 284 deletions

View file

@ -19,6 +19,18 @@ config ANDROID_BINDER_IPC
Android process, using Binder to identify, invoke and pass arguments
between said processes.
config ANDROID_BINDER_DEVICES
string "Android Binder devices"
depends on ANDROID_BINDER_IPC
default "binder"
---help---
Default value for the binder.devices parameter.
The binder.devices parameter is a comma-separated list of strings
that specifies the names of the binder device nodes that will be
created. Each binder device has its own context manager, and is
therefore logically separated from the other devices.
config ANDROID_BINDER_IPC_32BIT
bool
depends on !64BIT && ANDROID_BINDER_IPC

File diff suppressed because it is too large Load diff

View file

@ -425,11 +425,6 @@ static int config_usb_cfg_link(
}
f = usb_get_function(fi);
if (f == NULL) {
/* Are we trying to symlink PTP without MTP function? */
ret = -EINVAL; /* Invalid Configuration */
goto out;
}
if (IS_ERR(f)) {
ret = PTR_ERR(f);
goto out;

View file

@ -377,10 +377,9 @@ static void audio_send(struct audio_dev *audio)
/* compute number of frames to send */
now = ktime_get();
msecs = ktime_to_ns(now) - ktime_to_ns(audio->start_time);
do_div(msecs, 1000000);
frames = msecs * SAMPLE_RATE;
do_div(frames, 1000);
msecs = div_s64((ktime_to_ns(now) - ktime_to_ns(audio->start_time)),
1000000);
frames = div_s64((msecs * SAMPLE_RATE), 1000);
/* Readjust our frames_sent if we fall too far behind.
* If we get too far behind it is better to drop some frames than

View file

@ -1498,7 +1498,7 @@ struct usb_function *function_alloc_mtp_ptp(struct usb_function_instance *fi,
pr_err("\t2: Create MTP function\n");
pr_err("\t3: Create and symlink PTP function"
" with a gadget configuration\n");
return NULL;
return ERR_PTR(-EINVAL); /* Invalid Configuration */
}
dev = fi_mtp->dev;

View file

@ -58,7 +58,7 @@ struct usb_function *usb_get_function(struct usb_function_instance *fi)
struct usb_function *f;
f = fi->fd->alloc_func(fi);
if ((f == NULL) || IS_ERR(f))
if (IS_ERR(f))
return f;
f->fi = fi;
return f;

View file

@ -132,7 +132,7 @@ static int adf_eng_get_data(struct adf_overlay_engine *eng,
eng->ops->n_supported_formats));
mutex_lock(&dev->client_lock);
ret = adf_obj_copy_custom_data_to_user(&eng->base, arg->custom_data,
ret = adf_obj_copy_custom_data_to_user(&eng->base, data.custom_data,
&data.custom_data_size);
mutex_unlock(&dev->client_lock);
@ -144,7 +144,7 @@ static int adf_eng_get_data(struct adf_overlay_engine *eng,
goto done;
}
if (supported_formats && copy_to_user(arg->supported_formats,
if (supported_formats && copy_to_user(data.supported_formats,
supported_formats,
n_supported_formats * sizeof(supported_formats[0])))
ret = -EFAULT;
@ -220,56 +220,45 @@ static int adf_device_post_config(struct adf_device *dev,
int complete_fence_fd;
struct adf_buffer *bufs = NULL;
struct adf_interface **intfs = NULL;
size_t n_intfs, n_bufs, i;
struct adf_post_config data;
size_t i;
void *custom_data = NULL;
size_t custom_data_size;
int ret = 0;
if (copy_from_user(&data, arg, sizeof(data)))
return -EFAULT;
complete_fence_fd = get_unused_fd_flags(O_CLOEXEC);
if (complete_fence_fd < 0)
return complete_fence_fd;
if (get_user(n_intfs, &arg->n_interfaces)) {
ret = -EFAULT;
goto err_get_user;
}
if (n_intfs > ADF_MAX_INTERFACES) {
if (data.n_interfaces > ADF_MAX_INTERFACES) {
ret = -EINVAL;
goto err_get_user;
}
if (get_user(n_bufs, &arg->n_bufs)) {
ret = -EFAULT;
goto err_get_user;
}
if (n_bufs > ADF_MAX_BUFFERS) {
if (data.n_bufs > ADF_MAX_BUFFERS) {
ret = -EINVAL;
goto err_get_user;
}
if (get_user(custom_data_size, &arg->custom_data_size)) {
ret = -EFAULT;
goto err_get_user;
}
if (custom_data_size > ADF_MAX_CUSTOM_DATA_SIZE) {
if (data.custom_data_size > ADF_MAX_CUSTOM_DATA_SIZE) {
ret = -EINVAL;
goto err_get_user;
}
if (n_intfs) {
intfs = kmalloc(sizeof(intfs[0]) * n_intfs, GFP_KERNEL);
if (data.n_interfaces) {
intfs = kmalloc(sizeof(intfs[0]) * data.n_interfaces,
GFP_KERNEL);
if (!intfs) {
ret = -ENOMEM;
goto err_get_user;
}
}
for (i = 0; i < n_intfs; i++) {
for (i = 0; i < data.n_interfaces; i++) {
u32 intf_id;
if (get_user(intf_id, &arg->interfaces[i])) {
if (get_user(intf_id, &data.interfaces[i])) {
ret = -EFAULT;
goto err_get_user;
}
@ -281,31 +270,31 @@ static int adf_device_post_config(struct adf_device *dev,
}
}
if (n_bufs) {
bufs = kzalloc(sizeof(bufs[0]) * n_bufs, GFP_KERNEL);
if (data.n_bufs) {
bufs = kzalloc(sizeof(bufs[0]) * data.n_bufs, GFP_KERNEL);
if (!bufs) {
ret = -ENOMEM;
goto err_get_user;
}
}
for (i = 0; i < n_bufs; i++) {
ret = adf_buffer_import(dev, &arg->bufs[i], &bufs[i]);
for (i = 0; i < data.n_bufs; i++) {
ret = adf_buffer_import(dev, &data.bufs[i], &bufs[i]);
if (ret < 0) {
memset(&bufs[i], 0, sizeof(bufs[i]));
goto err_import;
}
}
if (custom_data_size) {
custom_data = kzalloc(custom_data_size, GFP_KERNEL);
if (data.custom_data_size) {
custom_data = kzalloc(data.custom_data_size, GFP_KERNEL);
if (!custom_data) {
ret = -ENOMEM;
goto err_import;
}
if (copy_from_user(custom_data, arg->custom_data,
custom_data_size)) {
if (copy_from_user(custom_data, data.custom_data,
data.custom_data_size)) {
ret = -EFAULT;
goto err_import;
}
@ -316,8 +305,8 @@ static int adf_device_post_config(struct adf_device *dev,
goto err_import;
}
complete_fence = adf_device_post_nocopy(dev, intfs, n_intfs, bufs,
n_bufs, custom_data, custom_data_size);
complete_fence = adf_device_post_nocopy(dev, intfs, data.n_interfaces,
bufs, data.n_bufs, custom_data, data.custom_data_size);
if (IS_ERR(complete_fence)) {
ret = PTR_ERR(complete_fence);
goto err_import;
@ -327,7 +316,7 @@ static int adf_device_post_config(struct adf_device *dev,
return 0;
err_import:
for (i = 0; i < n_bufs; i++)
for (i = 0; i < data.n_bufs; i++)
adf_buffer_cleanup(&bufs[i]);
err_get_user:
@ -481,19 +470,19 @@ static int adf_device_get_data(struct adf_device *dev,
data.n_allowed_attachments);
mutex_lock(&dev->client_lock);
ret = adf_obj_copy_custom_data_to_user(&dev->base, arg->custom_data,
ret = adf_obj_copy_custom_data_to_user(&dev->base, data.custom_data,
&data.custom_data_size);
mutex_unlock(&dev->client_lock);
if (ret < 0)
goto done;
ret = adf_copy_attachment_list_to_user(arg->attachments,
ret = adf_copy_attachment_list_to_user(data.attachments,
data.n_attachments, attach, n_attach);
if (ret < 0)
goto done;
ret = adf_copy_attachment_list_to_user(arg->allowed_attachments,
ret = adf_copy_attachment_list_to_user(data.allowed_attachments,
data.n_allowed_attachments, allowed_attach,
n_allowed_attach);
if (ret < 0)
@ -592,7 +581,7 @@ static int adf_intf_get_data(struct adf_interface *intf,
data.n_available_modes = intf->n_modes;
read_unlock_irqrestore(&intf->hotplug_modelist_lock, flags);
if (copy_to_user(arg->available_modes, modelist, modelist_size)) {
if (copy_to_user(data.available_modes, modelist, modelist_size)) {
ret = -EFAULT;
goto done;
}
@ -601,7 +590,7 @@ static int adf_intf_get_data(struct adf_interface *intf,
memcpy(&data.current_mode, &intf->current_mode,
sizeof(intf->current_mode));
ret = adf_obj_copy_custom_data_to_user(&intf->base, arg->custom_data,
ret = adf_obj_copy_custom_data_to_user(&intf->base, data.custom_data,
&data.custom_data_size);
done:
mutex_unlock(&dev->client_lock);

View file

@ -33,6 +33,8 @@ enum {
BINDER_TYPE_HANDLE = B_PACK_CHARS('s', 'h', '*', B_TYPE_LARGE),
BINDER_TYPE_WEAK_HANDLE = B_PACK_CHARS('w', 'h', '*', B_TYPE_LARGE),
BINDER_TYPE_FD = B_PACK_CHARS('f', 'd', '*', B_TYPE_LARGE),
BINDER_TYPE_FDA = B_PACK_CHARS('f', 'd', 'a', B_TYPE_LARGE),
BINDER_TYPE_PTR = B_PACK_CHARS('p', 't', '*', B_TYPE_LARGE),
};
enum {
@ -48,6 +50,14 @@ typedef __u64 binder_size_t;
typedef __u64 binder_uintptr_t;
#endif
/**
* struct binder_object_header - header shared by all binder metadata objects.
* @type: type of the object
*/
struct binder_object_header {
__u32 type;
};
/*
* This is the flattened representation of a Binder object for transfer
* between processes. The 'offsets' supplied as part of a binder transaction
@ -56,9 +66,8 @@ typedef __u64 binder_uintptr_t;
* between processes.
*/
struct flat_binder_object {
/* 8 bytes for large_flat_header. */
__u32 type;
__u32 flags;
struct binder_object_header hdr;
__u32 flags;
/* 8 bytes of data. */
union {
@ -70,6 +79,84 @@ struct flat_binder_object {
binder_uintptr_t cookie;
};
/**
* struct binder_fd_object - describes a filedescriptor to be fixed up.
* @hdr: common header structure
* @pad_flags: padding to remain compatible with old userspace code
* @pad_binder: padding to remain compatible with old userspace code
* @fd: file descriptor
* @cookie: opaque data, used by user-space
*/
struct binder_fd_object {
struct binder_object_header hdr;
__u32 pad_flags;
union {
binder_uintptr_t pad_binder;
__u32 fd;
};
binder_uintptr_t cookie;
};
/* struct binder_buffer_object - object describing a userspace buffer
* @hdr: common header structure
* @flags: one or more BINDER_BUFFER_* flags
* @buffer: address of the buffer
* @length: length of the buffer
* @parent: index in offset array pointing to parent buffer
* @parent_offset: offset in @parent pointing to this buffer
*
* A binder_buffer object represents an object that the
* binder kernel driver can copy verbatim to the target
* address space. A buffer itself may be pointed to from
* within another buffer, meaning that the pointer inside
* that other buffer needs to be fixed up as well. This
* can be done by setting the BINDER_BUFFER_FLAG_HAS_PARENT
* flag in @flags, by setting @parent buffer to the index
* in the offset array pointing to the parent binder_buffer_object,
* and by setting @parent_offset to the offset in the parent buffer
* at which the pointer to this buffer is located.
*/
struct binder_buffer_object {
struct binder_object_header hdr;
__u32 flags;
binder_uintptr_t buffer;
binder_size_t length;
binder_size_t parent;
binder_size_t parent_offset;
};
enum {
BINDER_BUFFER_FLAG_HAS_PARENT = 0x01,
};
/* struct binder_fd_array_object - object describing an array of fds in a buffer
* @hdr: common header structure
* @num_fds: number of file descriptors in the buffer
* @parent: index in offset array to buffer holding the fd array
* @parent_offset: start offset of fd array in the buffer
*
* A binder_fd_array object represents an array of file
* descriptors embedded in a binder_buffer_object. It is
* different from a regular binder_buffer_object because it
* describes a list of file descriptors to fix up, not an opaque
* blob of memory, and hence the kernel needs to treat it differently.
*
* An example of how this would be used is with Android's
* native_handle_t object, which is a struct with a list of integers
* and a list of file descriptors. The native_handle_t struct itself
* will be represented by a struct binder_buffer_objct, whereas the
* embedded list of file descriptors is represented by a
* struct binder_fd_array_object with that binder_buffer_object as
* a parent.
*/
struct binder_fd_array_object {
struct binder_object_header hdr;
binder_size_t num_fds;
binder_size_t parent;
binder_size_t parent_offset;
};
/*
* On 64-bit platforms where user code may run in 32-bits the driver must
* translate the buffer (and local binder) addresses appropriately.
@ -162,6 +249,11 @@ struct binder_transaction_data {
} data;
};
struct binder_transaction_data_sg {
struct binder_transaction_data transaction_data;
binder_size_t buffers_size;
};
struct binder_ptr_cookie {
binder_uintptr_t ptr;
binder_uintptr_t cookie;
@ -346,6 +438,12 @@ enum binder_driver_command_protocol {
/*
* void *: cookie
*/
BC_TRANSACTION_SG = _IOW('c', 17, struct binder_transaction_data_sg),
BC_REPLY_SG = _IOW('c', 18, struct binder_transaction_data_sg),
/*
* binder_transaction_data_sg: the sent command.
*/
};
#endif /* _UAPI_LINUX_BINDER_H */