linux/drivers/usb/core/sysfs.c

// SPDX-License-Identifier: GPL-2.0
/*
 * drivers/usb/core/sysfs.c
 *
 * (C) Copyright 2002 David Brownell
 * (C) Copyright 2002,2004 Greg Kroah-Hartman
 * (C) Copyright 2002,2004 IBM Corp.
 *
 * All of the sysfs file attributes for usb devices and interfaces.
 *
 * Released under the GPLv2 only.
 */


#include <linux/kernel.h>
#include <linux/kstrtox.h>
#include <linux/string.h>
#include <linux/usb.h>
#include <linux/usb/hcd.h>
#include <linux/usb/quirks.h>
#include <linux/of.h>
#include "usb.h"

/* Active configuration fields */
#define usb_actconfig_show(field, format_string)									\

#define usb_actconfig_attr(field, format_string)

usb_actconfig_attr();
usb_actconfig_attr();

static ssize_t bMaxPower_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(bMaxPower);

static ssize_t configuration_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(configuration);

/* configuration value is always present, and r/w */
usb_actconfig_show(bConfigurationValue, "%u\n");

static ssize_t bConfigurationValue_store(struct device *dev,
					 struct device_attribute *attr,
					 const char *buf, size_t count)
{}
static DEVICE_ATTR_IGNORE_LOCKDEP(bConfigurationValue, S_IRUGO | S_IWUSR,
		bConfigurationValue_show, bConfigurationValue_store);

#ifdef CONFIG_OF
static ssize_t devspec_show(struct device *dev, struct device_attribute *attr,
			    char *buf)
{}
static DEVICE_ATTR_RO(devspec);
#endif

/* String fields */
#define usb_string_attr(name)

usb_string_attr();
usb_string_attr();
usb_string_attr();

static ssize_t speed_show(struct device *dev, struct device_attribute *attr,
			  char *buf)
{}
static DEVICE_ATTR_RO(speed);

static ssize_t rx_lanes_show(struct device *dev, struct device_attribute *attr,
			  char *buf)
{}
static DEVICE_ATTR_RO(rx_lanes);

static ssize_t tx_lanes_show(struct device *dev, struct device_attribute *attr,
			  char *buf)
{}
static DEVICE_ATTR_RO(tx_lanes);

static ssize_t busnum_show(struct device *dev, struct device_attribute *attr,
			   char *buf)
{}
static DEVICE_ATTR_RO(busnum);

static ssize_t devnum_show(struct device *dev, struct device_attribute *attr,
			   char *buf)
{}
static DEVICE_ATTR_RO(devnum);

static ssize_t devpath_show(struct device *dev, struct device_attribute *attr,
			    char *buf)
{}
static DEVICE_ATTR_RO(devpath);

static ssize_t version_show(struct device *dev, struct device_attribute *attr,
			    char *buf)
{}
static DEVICE_ATTR_RO(version);

static ssize_t maxchild_show(struct device *dev, struct device_attribute *attr,
			     char *buf)
{}
static DEVICE_ATTR_RO(maxchild);

static ssize_t quirks_show(struct device *dev, struct device_attribute *attr,
			   char *buf)
{}
static DEVICE_ATTR_RO(quirks);

static ssize_t avoid_reset_quirk_show(struct device *dev,
				      struct device_attribute *attr, char *buf)
{}

static ssize_t avoid_reset_quirk_store(struct device *dev,
				      struct device_attribute *attr,
				      const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(avoid_reset_quirk);

static ssize_t urbnum_show(struct device *dev, struct device_attribute *attr,
			   char *buf)
{}
static DEVICE_ATTR_RO(urbnum);

static ssize_t ltm_capable_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(ltm_capable);

#ifdef	CONFIG_PM

static ssize_t persist_show(struct device *dev, struct device_attribute *attr,
			    char *buf)
{}

static ssize_t persist_store(struct device *dev, struct device_attribute *attr,
			     const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(persist);

static int add_persist_attributes(struct device *dev)
{}

static void remove_persist_attributes(struct device *dev)
{}

static ssize_t connected_duration_show(struct device *dev,
				       struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(connected_duration);

/*
 * If the device is resumed, the last time the device was suspended has
 * been pre-subtracted from active_duration.  We add the current time to
 * get the duration that the device was actually active.
 *
 * If the device is suspended, the active_duration is up-to-date.
 */
static ssize_t active_duration_show(struct device *dev,
				    struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(active_duration);

static ssize_t autosuspend_show(struct device *dev,
				struct device_attribute *attr, char *buf)
{}

static ssize_t autosuspend_store(struct device *dev,
				 struct device_attribute *attr, const char *buf,
				 size_t count)
{}
static DEVICE_ATTR_RW(autosuspend);

static const char on_string[] =;
static const char auto_string[] =;

static void warn_level(void)
{}

static ssize_t level_show(struct device *dev, struct device_attribute *attr,
			  char *buf)
{}

static ssize_t level_store(struct device *dev, struct device_attribute *attr,
			   const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(level);

static ssize_t usb2_hardware_lpm_show(struct device *dev,
				      struct device_attribute *attr, char *buf)
{}

static ssize_t usb2_hardware_lpm_store(struct device *dev,
				       struct device_attribute *attr,
				       const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(usb2_hardware_lpm);

static ssize_t usb2_lpm_l1_timeout_show(struct device *dev,
					struct device_attribute *attr,
					char *buf)
{}

static ssize_t usb2_lpm_l1_timeout_store(struct device *dev,
					 struct device_attribute *attr,
					 const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(usb2_lpm_l1_timeout);

static ssize_t usb2_lpm_besl_show(struct device *dev,
				  struct device_attribute *attr, char *buf)
{}

static ssize_t usb2_lpm_besl_store(struct device *dev,
				   struct device_attribute *attr,
				   const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(usb2_lpm_besl);

static ssize_t usb3_hardware_lpm_u1_show(struct device *dev,
				      struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(usb3_hardware_lpm_u1);

static ssize_t usb3_hardware_lpm_u2_show(struct device *dev,
				      struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(usb3_hardware_lpm_u2);

static struct attribute *usb2_hardware_lpm_attr[] =;
static const struct attribute_group usb2_hardware_lpm_attr_group =;

static struct attribute *usb3_hardware_lpm_attr[] =;
static const struct attribute_group usb3_hardware_lpm_attr_group =;

static struct attribute *power_attrs[] =;
static const struct attribute_group power_attr_group =;

static int add_power_attributes(struct device *dev)
{}

static void remove_power_attributes(struct device *dev)
{}

#else

#define add_persist_attributes
#define remove_persist_attributes

#define add_power_attributes
#define remove_power_attributes

#endif	/* CONFIG_PM */


/* Descriptor fields */
#define usb_descriptor_attr_le16(field, format_string)

usb_descriptor_attr_le16();
usb_descriptor_attr_le16();
usb_descriptor_attr_le16();

#define usb_descriptor_attr(field, format_string)

usb_descriptor_attr();
usb_descriptor_attr();
usb_descriptor_attr();
usb_descriptor_attr();
usb_descriptor_attr();


/* show if the device is authorized (1) or not (0) */
static ssize_t authorized_show(struct device *dev,
			       struct device_attribute *attr, char *buf)
{}

/*
 * Authorize a device to be used in the system
 *
 * Writing a 0 deauthorizes the device, writing a 1 authorizes it.
 */
static ssize_t authorized_store(struct device *dev,
				struct device_attribute *attr, const char *buf,
				size_t size)
{}
static DEVICE_ATTR_IGNORE_LOCKDEP(authorized, S_IRUGO | S_IWUSR,
				  authorized_show, authorized_store);

/* "Safely remove a device" */
static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
			    const char *buf, size_t count)
{}
static DEVICE_ATTR_IGNORE_LOCKDEP(remove, S_IWUSR, NULL, remove_store);


static struct attribute *dev_attrs[] =;
static const struct attribute_group dev_attr_grp =;

/* When modifying this list, be sure to modify dev_string_attrs_are_visible()
 * accordingly.
 */
static struct attribute *dev_string_attrs[] =;

static umode_t dev_string_attrs_are_visible(struct kobject *kobj,
		struct attribute *a, int n)
{}

static const struct attribute_group dev_string_attr_grp =;

/* Binary descriptors */

static ssize_t
descriptors_read(struct file *filp, struct kobject *kobj,
		struct bin_attribute *attr,
		char *buf, loff_t off, size_t count)
{}
static BIN_ATTR_RO(descriptors, 18 + 65535); /* dev descr + max-size raw descriptor */

static ssize_t
bos_descriptors_read(struct file *filp, struct kobject *kobj,
		struct bin_attribute *attr,
		char *buf, loff_t off, size_t count)
{}
static BIN_ATTR_RO(bos_descriptors, 65535); /* max-size BOS */

/* When modifying this list, be sure to modify dev_bin_attrs_are_visible()
 * accordingly.
 */
static struct bin_attribute *dev_bin_attrs[] =;

static umode_t dev_bin_attrs_are_visible(struct kobject *kobj,
		struct bin_attribute *a, int n)
{}

static const struct attribute_group dev_bin_attr_grp =;

const struct attribute_group *usb_device_groups[] =;

/*
 * Show & store the current value of authorized_default
 */
static ssize_t authorized_default_show(struct device *dev,
				       struct device_attribute *attr, char *buf)
{}

static ssize_t authorized_default_store(struct device *dev,
					struct device_attribute *attr,
					const char *buf, size_t size)
{}
static DEVICE_ATTR_RW(authorized_default);

/*
 * interface_authorized_default_show - show default authorization status
 * for USB interfaces
 *
 * note: interface_authorized_default is the default value
 *       for initializing the authorized attribute of interfaces
 */
static ssize_t interface_authorized_default_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

/*
 * interface_authorized_default_store - store default authorization status
 * for USB interfaces
 *
 * note: interface_authorized_default is the default value
 *       for initializing the authorized attribute of interfaces
 */
static ssize_t interface_authorized_default_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
{}
static DEVICE_ATTR_RW(interface_authorized_default);

/* Group all the USB bus attributes */
static struct attribute *usb_bus_attrs[] =;

static const struct attribute_group usb_bus_attr_group =;


static int add_default_authorized_attributes(struct device *dev)
{}

static void remove_default_authorized_attributes(struct device *dev)
{}

int usb_create_sysfs_dev_files(struct usb_device *udev)
{}

void usb_remove_sysfs_dev_files(struct usb_device *udev)
{}

/* Interface Association Descriptor fields */
#define usb_intf_assoc_attr(field, format_string)

usb_intf_assoc_attr();
usb_intf_assoc_attr();
usb_intf_assoc_attr();
usb_intf_assoc_attr();
usb_intf_assoc_attr();

/* Interface fields */
#define usb_intf_attr(field, format_string)

usb_intf_attr();
usb_intf_attr();
usb_intf_attr();
usb_intf_attr();
usb_intf_attr();
usb_intf_attr();

static ssize_t interface_show(struct device *dev, struct device_attribute *attr,
			      char *buf)
{}
static DEVICE_ATTR_RO(interface);

static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
			     char *buf)
{}
static DEVICE_ATTR_RO(modalias);

static ssize_t supports_autosuspend_show(struct device *dev,
					 struct device_attribute *attr,
					 char *buf)
{}
static DEVICE_ATTR_RO(supports_autosuspend);

/*
 * interface_authorized_show - show authorization status of an USB interface
 * 1 is authorized, 0 is deauthorized
 */
static ssize_t interface_authorized_show(struct device *dev,
		struct device_attribute *attr, char *buf)
{}

/*
 * interface_authorized_store - authorize or deauthorize an USB interface
 */
static ssize_t interface_authorized_store(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t count)
{}
static struct device_attribute dev_attr_interface_authorized =;

static struct attribute *intf_attrs[] =;
static const struct attribute_group intf_attr_grp =;

static struct attribute *intf_assoc_attrs[] =;

static umode_t intf_assoc_attrs_are_visible(struct kobject *kobj,
		struct attribute *a, int n)
{}

static const struct attribute_group intf_assoc_attr_grp =;

static ssize_t wireless_status_show(struct device *dev,
				    struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(wireless_status);

static struct attribute *intf_wireless_status_attrs[] =;

static umode_t intf_wireless_status_attr_is_visible(struct kobject *kobj,
		struct attribute *a, int n)
{}

static const struct attribute_group intf_wireless_status_attr_grp =;

int usb_update_wireless_status_attr(struct usb_interface *intf)
{}

const struct attribute_group *usb_interface_groups[] =;

void usb_create_sysfs_intf_files(struct usb_interface *intf)
{}

void usb_remove_sysfs_intf_files(struct usb_interface *intf)
{}