You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
Revert "driver core: Move the "removable" attribute from USB to core"
This reverts commit2df04d76c9which is commit70f400d4d9upstream. It breaks the current Android ABI, and if needed, can be brought back in an abi-safe way in the future. Bug: 161946584 Change-Id: I0d2a53863c50129aef373dafe91d4554d71f54a8 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
@@ -154,6 +154,17 @@ Description:
|
||||
files hold a string value (enable or disable) indicating whether
|
||||
or not USB3 hardware LPM U1 or U2 is enabled for the device.
|
||||
|
||||
What: /sys/bus/usb/devices/.../removable
|
||||
Date: February 2012
|
||||
Contact: Matthew Garrett <mjg@redhat.com>
|
||||
Description:
|
||||
Some information about whether a given USB device is
|
||||
physically fixed to the platform can be inferred from a
|
||||
combination of hub descriptor bits and platform-specific data
|
||||
such as ACPI. This file will read either "removable" or
|
||||
"fixed" if the information is available, and "unknown"
|
||||
otherwise.
|
||||
|
||||
What: /sys/bus/usb/devices/.../ltm_capable
|
||||
Date: July 2012
|
||||
Contact: Sarah Sharp <sarah.a.sharp@linux.intel.com>
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
What: /sys/devices/.../removable
|
||||
Date: May 2021
|
||||
Contact: Rajat Jain <rajatxjain@gmail.com>
|
||||
Description:
|
||||
Information about whether a given device can be removed from the
|
||||
platform by the user. This is determined by its subsystem in a
|
||||
bus / platform-specific way. This attribute is only present for
|
||||
devices that can support determining such information:
|
||||
|
||||
"removable": device can be removed from the platform by the user
|
||||
"fixed": device is fixed to the platform / cannot be removed
|
||||
by the user.
|
||||
"unknown": The information is unavailable / cannot be deduced.
|
||||
|
||||
Currently this is only supported by USB (which infers the
|
||||
information from a combination of hub descriptor bits and
|
||||
platform-specific data such as ACPI).
|
||||
@@ -2338,25 +2338,6 @@ static ssize_t online_store(struct device *dev, struct device_attribute *attr,
|
||||
}
|
||||
static DEVICE_ATTR_RW(online);
|
||||
|
||||
static ssize_t removable_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
const char *loc;
|
||||
|
||||
switch (dev->removable) {
|
||||
case DEVICE_REMOVABLE:
|
||||
loc = "removable";
|
||||
break;
|
||||
case DEVICE_FIXED:
|
||||
loc = "fixed";
|
||||
break;
|
||||
default:
|
||||
loc = "unknown";
|
||||
}
|
||||
return sysfs_emit(buf, "%s\n", loc);
|
||||
}
|
||||
static DEVICE_ATTR_RO(removable);
|
||||
|
||||
int device_add_groups(struct device *dev, const struct attribute_group **groups)
|
||||
{
|
||||
return sysfs_create_groups(&dev->kobj, groups);
|
||||
@@ -2534,16 +2515,8 @@ static int device_add_attrs(struct device *dev)
|
||||
goto err_remove_dev_online;
|
||||
}
|
||||
|
||||
if (dev_removable_is_valid(dev)) {
|
||||
error = device_create_file(dev, &dev_attr_removable);
|
||||
if (error)
|
||||
goto err_remove_dev_waiting_for_supplier;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_remove_dev_waiting_for_supplier:
|
||||
device_remove_file(dev, &dev_attr_waiting_for_supplier);
|
||||
err_remove_dev_online:
|
||||
device_remove_file(dev, &dev_attr_online);
|
||||
err_remove_dev_groups:
|
||||
@@ -2563,7 +2536,6 @@ static void device_remove_attrs(struct device *dev)
|
||||
struct class *class = dev->class;
|
||||
const struct device_type *type = dev->type;
|
||||
|
||||
device_remove_file(dev, &dev_attr_removable);
|
||||
device_remove_file(dev, &dev_attr_waiting_for_supplier);
|
||||
device_remove_file(dev, &dev_attr_online);
|
||||
device_remove_groups(dev, dev->groups);
|
||||
|
||||
@@ -2449,8 +2449,6 @@ static void set_usb_port_removable(struct usb_device *udev)
|
||||
u16 wHubCharacteristics;
|
||||
bool removable = true;
|
||||
|
||||
dev_set_removable(&udev->dev, DEVICE_REMOVABLE_UNKNOWN);
|
||||
|
||||
if (!hdev)
|
||||
return;
|
||||
|
||||
@@ -2462,11 +2460,11 @@ static void set_usb_port_removable(struct usb_device *udev)
|
||||
*/
|
||||
switch (hub->ports[udev->portnum - 1]->connect_type) {
|
||||
case USB_PORT_CONNECT_TYPE_HOT_PLUG:
|
||||
dev_set_removable(&udev->dev, DEVICE_REMOVABLE);
|
||||
udev->removable = USB_DEVICE_REMOVABLE;
|
||||
return;
|
||||
case USB_PORT_CONNECT_TYPE_HARD_WIRED:
|
||||
case USB_PORT_NOT_USED:
|
||||
dev_set_removable(&udev->dev, DEVICE_FIXED);
|
||||
udev->removable = USB_DEVICE_FIXED;
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
@@ -2491,9 +2489,9 @@ static void set_usb_port_removable(struct usb_device *udev)
|
||||
}
|
||||
|
||||
if (removable)
|
||||
dev_set_removable(&udev->dev, DEVICE_REMOVABLE);
|
||||
udev->removable = USB_DEVICE_REMOVABLE;
|
||||
else
|
||||
dev_set_removable(&udev->dev, DEVICE_FIXED);
|
||||
udev->removable = USB_DEVICE_FIXED;
|
||||
|
||||
}
|
||||
|
||||
@@ -2565,7 +2563,8 @@ int usb_new_device(struct usb_device *udev)
|
||||
device_enable_async_suspend(&udev->dev);
|
||||
|
||||
/* check whether the hub or firmware marks this port as non-removable */
|
||||
set_usb_port_removable(udev);
|
||||
if (udev->parent)
|
||||
set_usb_port_removable(udev);
|
||||
|
||||
/* Register the device. The device driver is responsible
|
||||
* for configuring the device and invoking the add-device
|
||||
|
||||
@@ -298,6 +298,29 @@ static ssize_t urbnum_show(struct device *dev, struct device_attribute *attr,
|
||||
}
|
||||
static DEVICE_ATTR_RO(urbnum);
|
||||
|
||||
static ssize_t removable_show(struct device *dev, struct device_attribute *attr,
|
||||
char *buf)
|
||||
{
|
||||
struct usb_device *udev;
|
||||
char *state;
|
||||
|
||||
udev = to_usb_device(dev);
|
||||
|
||||
switch (udev->removable) {
|
||||
case USB_DEVICE_REMOVABLE:
|
||||
state = "removable";
|
||||
break;
|
||||
case USB_DEVICE_FIXED:
|
||||
state = "fixed";
|
||||
break;
|
||||
default:
|
||||
state = "unknown";
|
||||
}
|
||||
|
||||
return sprintf(buf, "%s\n", state);
|
||||
}
|
||||
static DEVICE_ATTR_RO(removable);
|
||||
|
||||
static ssize_t ltm_capable_show(struct device *dev,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
@@ -802,6 +825,7 @@ static struct attribute *dev_attrs[] = {
|
||||
&dev_attr_avoid_reset_quirk.attr,
|
||||
&dev_attr_authorized.attr,
|
||||
&dev_attr_remove.attr,
|
||||
&dev_attr_removable.attr,
|
||||
&dev_attr_ltm_capable.attr,
|
||||
#ifdef CONFIG_OF
|
||||
&dev_attr_devspec.attr,
|
||||
|
||||
@@ -351,22 +351,6 @@ enum dl_dev_state {
|
||||
DL_DEV_UNBINDING,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum device_removable - Whether the device is removable. The criteria for a
|
||||
* device to be classified as removable is determined by its subsystem or bus.
|
||||
* @DEVICE_REMOVABLE_NOT_SUPPORTED: This attribute is not supported for this
|
||||
* device (default).
|
||||
* @DEVICE_REMOVABLE_UNKNOWN: Device location is Unknown.
|
||||
* @DEVICE_FIXED: Device is not removable by the user.
|
||||
* @DEVICE_REMOVABLE: Device is removable by the user.
|
||||
*/
|
||||
enum device_removable {
|
||||
DEVICE_REMOVABLE_NOT_SUPPORTED = 0, /* must be 0 */
|
||||
DEVICE_REMOVABLE_UNKNOWN,
|
||||
DEVICE_FIXED,
|
||||
DEVICE_REMOVABLE,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct dev_links_info - Device data related to device links.
|
||||
* @suppliers: List of links to supplier devices.
|
||||
@@ -448,9 +432,6 @@ struct dev_links_info {
|
||||
* device (i.e. the bus driver that discovered the device).
|
||||
* @iommu_group: IOMMU group the device belongs to.
|
||||
* @iommu: Per device generic IOMMU runtime data
|
||||
* @removable: Whether the device can be removed from the system. This
|
||||
* should be set by the subsystem / bus driver that discovered
|
||||
* the device.
|
||||
*
|
||||
* @offline_disabled: If set, the device is permanently online.
|
||||
* @offline: Set after successful invocation of bus type's .offline().
|
||||
@@ -561,8 +542,6 @@ struct device {
|
||||
struct iommu_group *iommu_group;
|
||||
struct dev_iommu *iommu;
|
||||
|
||||
enum device_removable removable;
|
||||
|
||||
bool offline_disabled:1;
|
||||
bool offline:1;
|
||||
bool of_node_reused:1;
|
||||
@@ -812,22 +791,6 @@ static inline bool dev_has_sync_state(struct device *dev)
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline void dev_set_removable(struct device *dev,
|
||||
enum device_removable removable)
|
||||
{
|
||||
dev->removable = removable;
|
||||
}
|
||||
|
||||
static inline bool dev_is_removable(struct device *dev)
|
||||
{
|
||||
return dev->removable == DEVICE_REMOVABLE;
|
||||
}
|
||||
|
||||
static inline bool dev_removable_is_valid(struct device *dev)
|
||||
{
|
||||
return dev->removable != DEVICE_REMOVABLE_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* High level routines for use by the bus drivers
|
||||
*/
|
||||
|
||||
@@ -494,6 +494,12 @@ struct usb_dev_state;
|
||||
|
||||
struct usb_tt;
|
||||
|
||||
enum usb_device_removable {
|
||||
USB_DEVICE_REMOVABLE_UNKNOWN = 0,
|
||||
USB_DEVICE_REMOVABLE,
|
||||
USB_DEVICE_FIXED,
|
||||
};
|
||||
|
||||
enum usb_port_connect_type {
|
||||
USB_PORT_CONNECT_TYPE_UNKNOWN = 0,
|
||||
USB_PORT_CONNECT_TYPE_HOT_PLUG,
|
||||
@@ -716,6 +722,7 @@ struct usb_device {
|
||||
#endif
|
||||
struct wusb_dev *wusb_dev;
|
||||
int slot_id;
|
||||
enum usb_device_removable removable;
|
||||
struct usb2_lpm_parameters l1_params;
|
||||
struct usb3_lpm_parameters u1_params;
|
||||
struct usb3_lpm_parameters u2_params;
|
||||
|
||||
Reference in New Issue
Block a user