sysfs.c (6aa7de059173a986114ac43b8f50b297a86f09a8) sysfs.c (aa1f3bb56761cf627ed53a40607bead16d6e23bc)
1// SPDX-License-Identifier: GPL-2.0
1/*
2 * drivers/usb/core/sysfs.c
3 *
4 * (C) Copyright 2002 David Brownell
5 * (C) Copyright 2002,2004 Greg Kroah-Hartman
6 * (C) Copyright 2002,2004 IBM Corp.
7 *
8 * All of the sysfs file attributes for usb devices and interfaces.
9 *
10 * Released under the GPLv2 only.
2/*
3 * drivers/usb/core/sysfs.c
4 *
5 * (C) Copyright 2002 David Brownell
6 * (C) Copyright 2002,2004 Greg Kroah-Hartman
7 * (C) Copyright 2002,2004 IBM Corp.
8 *
9 * All of the sysfs file attributes for usb devices and interfaces.
10 *
11 * Released under the GPLv2 only.
11 * SPDX-License-Identifier: GPL-2.0
12 */
13
14
15#include <linux/kernel.h>
16#include <linux/string.h>
17#include <linux/usb.h>
18#include <linux/usb/quirks.h>
19#include <linux/of.h>

--- 629 unchanged lines hidden (view full) ---

649 int rc = 0;
650
651 if (is_usb_device(dev)) {
652 struct usb_device *udev = to_usb_device(dev);
653 rc = sysfs_merge_group(&dev->kobj, &power_attr_group);
654 if (udev->usb2_hw_lpm_capable == 1)
655 rc = sysfs_merge_group(&dev->kobj,
656 &usb2_hardware_lpm_attr_group);
12 */
13
14
15#include <linux/kernel.h>
16#include <linux/string.h>
17#include <linux/usb.h>
18#include <linux/usb/quirks.h>
19#include <linux/of.h>

--- 629 unchanged lines hidden (view full) ---

649 int rc = 0;
650
651 if (is_usb_device(dev)) {
652 struct usb_device *udev = to_usb_device(dev);
653 rc = sysfs_merge_group(&dev->kobj, &power_attr_group);
654 if (udev->usb2_hw_lpm_capable == 1)
655 rc = sysfs_merge_group(&dev->kobj,
656 &usb2_hardware_lpm_attr_group);
657 if (udev->speed == USB_SPEED_SUPER &&
657 if ((udev->speed == USB_SPEED_SUPER ||
658 udev->speed == USB_SPEED_SUPER_PLUS) &&
658 udev->lpm_capable == 1)
659 rc = sysfs_merge_group(&dev->kobj,
660 &usb3_hardware_lpm_attr_group);
661 }
662
663 return rc;
664}
665

--- 302 unchanged lines hidden (view full) ---

968
969static ssize_t interface_show(struct device *dev, struct device_attribute *attr,
970 char *buf)
971{
972 struct usb_interface *intf;
973 char *string;
974
975 intf = to_usb_interface(dev);
659 udev->lpm_capable == 1)
660 rc = sysfs_merge_group(&dev->kobj,
661 &usb3_hardware_lpm_attr_group);
662 }
663
664 return rc;
665}
666

--- 302 unchanged lines hidden (view full) ---

969
970static ssize_t interface_show(struct device *dev, struct device_attribute *attr,
971 char *buf)
972{
973 struct usb_interface *intf;
974 char *string;
975
976 intf = to_usb_interface(dev);
976 string = READ_ONCE(intf->cur_altsetting->string);
977 string = ACCESS_ONCE(intf->cur_altsetting->string);
977 if (!string)
978 return 0;
979 return sprintf(buf, "%s\n", string);
980}
981static DEVICE_ATTR_RO(interface);
982
983static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
984 char *buf)
985{
986 struct usb_interface *intf;
987 struct usb_device *udev;
988 struct usb_host_interface *alt;
989
990 intf = to_usb_interface(dev);
991 udev = interface_to_usbdev(intf);
978 if (!string)
979 return 0;
980 return sprintf(buf, "%s\n", string);
981}
982static DEVICE_ATTR_RO(interface);
983
984static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
985 char *buf)
986{
987 struct usb_interface *intf;
988 struct usb_device *udev;
989 struct usb_host_interface *alt;
990
991 intf = to_usb_interface(dev);
992 udev = interface_to_usbdev(intf);
992 alt = READ_ONCE(intf->cur_altsetting);
993 alt = ACCESS_ONCE(intf->cur_altsetting);
993
994 return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02X"
995 "ic%02Xisc%02Xip%02Xin%02X\n",
996 le16_to_cpu(udev->descriptor.idVendor),
997 le16_to_cpu(udev->descriptor.idProduct),
998 le16_to_cpu(udev->descriptor.bcdDevice),
999 udev->descriptor.bDeviceClass,
1000 udev->descriptor.bDeviceSubClass,

--- 130 unchanged lines hidden ---
994
995 return sprintf(buf, "usb:v%04Xp%04Xd%04Xdc%02Xdsc%02Xdp%02X"
996 "ic%02Xisc%02Xip%02Xin%02X\n",
997 le16_to_cpu(udev->descriptor.idVendor),
998 le16_to_cpu(udev->descriptor.idProduct),
999 le16_to_cpu(udev->descriptor.bcdDevice),
1000 udev->descriptor.bDeviceClass,
1001 udev->descriptor.bDeviceSubClass,

--- 130 unchanged lines hidden ---