linux/drivers/firewire/core-device.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Device probing and sysfs code.
 *
 * Copyright (C) 2005-2006  Kristian Hoegsberg <[email protected]>
 */

#include <linux/bug.h>
#include <linux/ctype.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/errno.h>
#include <linux/firewire.h>
#include <linux/firewire-constants.h>
#include <linux/idr.h>
#include <linux/jiffies.h>
#include <linux/kobject.h>
#include <linux/list.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/random.h>
#include <linux/rwsem.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/workqueue.h>

#include <linux/atomic.h>
#include <asm/byteorder.h>

#include "core.h"

#define ROOT_DIR_OFFSET

void fw_csr_iterator_init(struct fw_csr_iterator *ci, const u32 *p)
{}
EXPORT_SYMBOL();

int fw_csr_iterator_next(struct fw_csr_iterator *ci, int *key, int *value)
{}
EXPORT_SYMBOL();

static const u32 *search_directory(const u32 *directory, int search_key)
{}

static const u32 *search_leaf(const u32 *directory, int search_key)
{}

static int textual_leaf_to_string(const u32 *block, char *buf, size_t size)
{}

/**
 * fw_csr_string() - reads a string from the configuration ROM
 * @directory:	e.g. root directory or unit directory
 * @key:	the key of the preceding directory entry
 * @buf:	where to put the string
 * @size:	size of @buf, in bytes
 *
 * The string is taken from a minimal ASCII text descriptor leaf just after the entry with the
 * @key. The string is zero-terminated. An overlong string is silently truncated such that it
 * and the zero byte fit into @size.
 *
 * Returns strlen(buf) or a negative error code.
 */
int fw_csr_string(const u32 *directory, int key, char *buf, size_t size)
{}
EXPORT_SYMBOL();

static void get_ids(const u32 *directory, int *id)
{}

static void get_modalias_ids(const struct fw_unit *unit, int *id)
{}

static bool match_ids(const struct ieee1394_device_id *id_table, int *id)
{}

static const struct ieee1394_device_id *unit_match(struct device *dev,
						   const struct device_driver *drv)
{}

static bool is_fw_unit(const struct device *dev);

static int fw_unit_match(struct device *dev, const struct device_driver *drv)
{}

static int fw_unit_probe(struct device *dev)
{}

static void fw_unit_remove(struct device *dev)
{}

static int get_modalias(const struct fw_unit *unit, char *buffer, size_t buffer_size)
{}

static int fw_unit_uevent(const struct device *dev, struct kobj_uevent_env *env)
{}

const struct bus_type fw_bus_type =;
EXPORT_SYMBOL();

int fw_device_enable_phys_dma(struct fw_device *device)
{}
EXPORT_SYMBOL();

struct config_rom_attribute {};

static ssize_t show_immediate(struct device *dev,
			      struct device_attribute *dattr, char *buf)
{}

#define IMMEDIATE_ATTR(name, key)

static ssize_t show_text_leaf(struct device *dev,
			      struct device_attribute *dattr, char *buf)
{}

#define TEXT_LEAF_ATTR(name, key)

static struct config_rom_attribute config_rom_attributes[] =;

static void init_fw_attribute_group(struct device *dev,
				    struct device_attribute *attrs,
				    struct fw_attribute_group *group)
{}

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

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

static struct device_attribute fw_unit_attributes[] =;

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

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

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

static int units_sprintf(char *buf, const u32 *directory)
{}

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

static struct device_attribute fw_device_attributes[] =;

static int read_rom(struct fw_device *device,
		    int generation, int index, u32 *data)
{}

#define MAX_CONFIG_ROM_SIZE

/*
 * Read the bus info block, perform a speed probe, and read all of the rest of
 * the config ROM.  We do all this with a cached bus generation.  If the bus
 * generation changes under us, read_config_rom will fail and get retried.
 * It's better to start all over in this case because the node from which we
 * are reading the ROM may have changed the ROM during the reset.
 * Returns either a result code or a negative error code.
 */
static int read_config_rom(struct fw_device *device, int generation)
{}

static void fw_unit_release(struct device *dev)
{}

static struct device_type fw_unit_type =;

static bool is_fw_unit(const struct device *dev)
{}

static void create_units(struct fw_device *device)
{}

static int shutdown_unit(struct device *device, void *data)
{}

/*
 * fw_device_rwsem acts as dual purpose mutex:
 *   - serializes accesses to fw_device_idr,
 *   - serializes accesses to fw_device.config_rom/.config_rom_length and
 *     fw_unit.directory, unless those accesses happen at safe occasions
 */
DECLARE_RWSEM();

DEFINE_IDR();
int fw_cdev_major;

struct fw_device *fw_device_get_by_devt(dev_t devt)
{}

struct workqueue_struct *fw_workqueue;
EXPORT_SYMBOL();

static void fw_schedule_device_work(struct fw_device *device,
				    unsigned long delay)
{}

/*
 * These defines control the retry behavior for reading the config
 * rom.  It shouldn't be necessary to tweak these; if the device
 * doesn't respond to a config rom read within 10 seconds, it's not
 * going to respond at all.  As for the initial delay, a lot of
 * devices will be able to respond within half a second after bus
 * reset.  On the other hand, it's not really worth being more
 * aggressive than that, since it scales pretty well; if 10 devices
 * are plugged in, they're all getting read within one second.
 */

#define MAX_RETRIES
#define RETRY_DELAY
#define INITIAL_DELAY
#define SHUTDOWN_DELAY

static void fw_device_shutdown(struct work_struct *work)
{}

static void fw_device_release(struct device *dev)
{}

static struct device_type fw_device_type =;

static bool is_fw_device(const struct device *dev)
{}

static int update_unit(struct device *dev, void *data)
{}

static void fw_device_update(struct work_struct *work)
{}

/*
 * If a device was pending for deletion because its node went away but its
 * bus info block and root directory header matches that of a newly discovered
 * device, revive the existing fw_device.
 * The newly allocated fw_device becomes obsolete instead.
 */
static int lookup_existing_device(struct device *dev, void *data)
{}

enum {};

static void set_broadcast_channel(struct fw_device *device, int generation)
{}

int fw_device_set_broadcast_channel(struct device *dev, void *gen)
{}

static void fw_device_init(struct work_struct *work)
{}

/* Reread and compare bus info block and header of root directory */
static int reread_config_rom(struct fw_device *device, int generation,
			     bool *changed)
{}

static void fw_device_refresh(struct work_struct *work)
{}

static void fw_device_workfn(struct work_struct *work)
{}

void fw_node_event(struct fw_card *card, struct fw_node *node, int event)
{}

#ifdef CONFIG_FIREWIRE_KUNIT_DEVICE_ATTRIBUTE_TEST
#include "device-attribute-test.c"
#endif