mirror of https://gitee.com/openkylin/linux.git
usb: use kobj_to_dev() API
Use kobj_to_dev() API instead of container_of(). Signed-off-by: chenqiwu <chenqiwu@xiaomi.com> Link: https://lore.kernel.org/r/1581683820-9978-1-git-send-email-qiwuchen55@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ca065bf127
commit
0616ca73fd
|
@ -849,7 +849,7 @@ static struct attribute *dev_string_attrs[] = {
|
||||||
static umode_t dev_string_attrs_are_visible(struct kobject *kobj,
|
static umode_t dev_string_attrs_are_visible(struct kobject *kobj,
|
||||||
struct attribute *a, int n)
|
struct attribute *a, int n)
|
||||||
{
|
{
|
||||||
struct device *dev = container_of(kobj, struct device, kobj);
|
struct device *dev = kobj_to_dev(kobj);
|
||||||
struct usb_device *udev = to_usb_device(dev);
|
struct usb_device *udev = to_usb_device(dev);
|
||||||
|
|
||||||
if (a == &dev_attr_manufacturer.attr) {
|
if (a == &dev_attr_manufacturer.attr) {
|
||||||
|
@ -883,7 +883,7 @@ read_descriptors(struct file *filp, struct kobject *kobj,
|
||||||
struct bin_attribute *attr,
|
struct bin_attribute *attr,
|
||||||
char *buf, loff_t off, size_t count)
|
char *buf, loff_t off, size_t count)
|
||||||
{
|
{
|
||||||
struct device *dev = container_of(kobj, struct device, kobj);
|
struct device *dev = kobj_to_dev(kobj);
|
||||||
struct usb_device *udev = to_usb_device(dev);
|
struct usb_device *udev = to_usb_device(dev);
|
||||||
size_t nleft = count;
|
size_t nleft = count;
|
||||||
size_t srclen, n;
|
size_t srclen, n;
|
||||||
|
@ -1233,7 +1233,7 @@ static struct attribute *intf_assoc_attrs[] = {
|
||||||
static umode_t intf_assoc_attrs_are_visible(struct kobject *kobj,
|
static umode_t intf_assoc_attrs_are_visible(struct kobject *kobj,
|
||||||
struct attribute *a, int n)
|
struct attribute *a, int n)
|
||||||
{
|
{
|
||||||
struct device *dev = container_of(kobj, struct device, kobj);
|
struct device *dev = kobj_to_dev(kobj);
|
||||||
struct usb_interface *intf = to_usb_interface(dev);
|
struct usb_interface *intf = to_usb_interface(dev);
|
||||||
|
|
||||||
if (intf->intf_assoc == NULL)
|
if (intf->intf_assoc == NULL)
|
||||||
|
|
|
@ -199,7 +199,7 @@ EXPORT_SYMBOL_GPL(usb_role_switch_find_by_fwnode);
|
||||||
static umode_t
|
static umode_t
|
||||||
usb_role_switch_is_visible(struct kobject *kobj, struct attribute *attr, int n)
|
usb_role_switch_is_visible(struct kobject *kobj, struct attribute *attr, int n)
|
||||||
{
|
{
|
||||||
struct device *dev = container_of(kobj, typeof(*dev), kobj);
|
struct device *dev = kobj_to_dev(kobj);
|
||||||
struct usb_role_switch *sw = to_role_switch(dev);
|
struct usb_role_switch *sw = to_role_switch(dev);
|
||||||
|
|
||||||
if (sw->allow_userspace_control)
|
if (sw->allow_userspace_control)
|
||||||
|
|
Loading…
Reference in New Issue