Commit d7db5843 authored by Todd Poynor's avatar Todd Poynor Committed by Greg Kroah-Hartman

staging: gasket: drop gasket_cdev_get_info, use container_of

Remove gasket_cdev_get_info(), use container_of() directly instead,
drop unnecessary NULL checks.
Reported-by: default avatarDmitry Torokhov <dtor@chromium.org>
Signed-off-by: default avatarZhongze Hu <frankhu@chromium.org>
Signed-off-by: default avatarTodd Poynor <toddpoynor@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 45042402
...@@ -233,18 +233,6 @@ static inline int gasket_check_and_invoke_callback_nolock( ...@@ -233,18 +233,6 @@ static inline int gasket_check_and_invoke_callback_nolock(
return ret; return ret;
} }
/*
* Retrieve device-specific data via cdev pointer.
* @cdev_ptr: Character device pointer associated with the device.
*
* This function returns the pointer to the device-specific data allocated in
* add_dev_cb for the device associated with cdev_ptr.
*/
static struct gasket_cdev_info *gasket_cdev_get_info(struct cdev *cdev_ptr)
{
return container_of(cdev_ptr, struct gasket_cdev_info, cdev);
}
/* /*
* Returns nonzero if the gasket_cdev_info is owned by the current thread group * Returns nonzero if the gasket_cdev_info is owned by the current thread group
* ID. * ID.
...@@ -1095,12 +1083,9 @@ static int gasket_open(struct inode *inode, struct file *filp) ...@@ -1095,12 +1083,9 @@ static int gasket_open(struct inode *inode, struct file *filp)
const struct gasket_driver_desc *driver_desc; const struct gasket_driver_desc *driver_desc;
struct gasket_ownership *ownership; struct gasket_ownership *ownership;
char task_name[TASK_COMM_LEN]; char task_name[TASK_COMM_LEN];
struct gasket_cdev_info *dev_info = gasket_cdev_get_info(inode->i_cdev); struct gasket_cdev_info *dev_info =
container_of(inode->i_cdev, struct gasket_cdev_info, cdev);
if (!dev_info) {
gasket_nodev_error("Unable to retrieve device data");
return -EINVAL;
}
gasket_dev = dev_info->gasket_dev_ptr; gasket_dev = dev_info->gasket_dev_ptr;
driver_desc = gasket_dev->internal_desc->driver_desc; driver_desc = gasket_dev->internal_desc->driver_desc;
ownership = &dev_info->ownership; ownership = &dev_info->ownership;
...@@ -1182,11 +1167,8 @@ static int gasket_release(struct inode *inode, struct file *file) ...@@ -1182,11 +1167,8 @@ static int gasket_release(struct inode *inode, struct file *file)
const struct gasket_driver_desc *driver_desc; const struct gasket_driver_desc *driver_desc;
char task_name[TASK_COMM_LEN]; char task_name[TASK_COMM_LEN];
struct gasket_cdev_info *dev_info = struct gasket_cdev_info *dev_info =
(struct gasket_cdev_info *)gasket_cdev_get_info(inode->i_cdev); container_of(inode->i_cdev, struct gasket_cdev_info, cdev);
if (!dev_info) {
gasket_nodev_error("Unable to retrieve device data");
return -EINVAL;
}
gasket_dev = dev_info->gasket_dev_ptr; gasket_dev = dev_info->gasket_dev_ptr;
driver_desc = gasket_dev->internal_desc->driver_desc; driver_desc = gasket_dev->internal_desc->driver_desc;
ownership = &dev_info->ownership; ownership = &dev_info->ownership;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment