linux/drivers/ata/libata-transport.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *  Copyright 2008 ioogle, Inc.  All rights reserved.
 *
 * Libata transport class.
 *
 * The ATA transport class contains common code to deal with ATA HBAs,
 * an approximated representation of ATA topologies in the driver model,
 * and various sysfs attributes to expose these topologies and management
 * interfaces to user-space.
 *
 * There are 3 objects defined in this class:
 * - ata_port
 * - ata_link
 * - ata_device
 * Each port has a link object. Each link can have up to two devices for PATA
 * and generally one for SATA.
 * If there is SATA port multiplier [PMP], 15 additional ata_link object are
 * created.
 *
 * These objects are created when the ata host is initialized and when a PMP is
 * found. They are removed only when the HBA is removed, cleaned before the
 * error handler runs.
 */


#include <linux/kernel.h>
#include <linux/blkdev.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <scsi/scsi_transport.h>
#include <linux/libata.h>
#include <linux/hdreg.h>
#include <linux/uaccess.h>
#include <linux/pm_runtime.h>

#include "libata.h"
#include "libata-transport.h"

#define ATA_PORT_ATTRS
#define ATA_LINK_ATTRS
#define ATA_DEV_ATTRS

struct scsi_transport_template;
struct scsi_transport_template *ata_scsi_transport_template;

struct ata_internal {};
#define to_ata_internal(tmpl)


#define tdev_to_device(d)
#define transport_class_to_dev(dev)

#define tdev_to_link(d)
#define transport_class_to_link(dev)

#define tdev_to_port(d)
#define transport_class_to_port(dev)


/* Device objects are always created whit link objects */
static int ata_tdev_add(struct ata_device *dev);
static void ata_tdev_delete(struct ata_device *dev);


/*
 * Hack to allow attributes of the same name in different objects.
 */
#define ATA_DEVICE_ATTR(_prefix,_name,_mode,_show,_store)

#define ata_bitfield_name_match(title, table)

#define ata_bitfield_name_search(title, table)

static struct {} ata_class_names[] =;
ata_bitfield_name_search(class, ata_class_names)


static struct {} ata_err_names[] =;
ata_bitfield_name_match(err, ata_err_names)

static struct {} ata_xfer_names[] =;
ata_bitfield_name_search(xfer, ata_xfer_names)

/*
 * ATA Port attributes
 */
#define ata_port_show_simple(field, name, format_string, cast)

#define ata_port_simple_attr(field, name, format_string, type)

ata_port_simple_attr();
ata_port_simple_attr();
/* We want the port_no sysfs attibute to start at 1 (ap->port_no starts at 0) */
ata_port_simple_attr();

static DECLARE_TRANSPORT_CLASS(ata_port_class,
			       "ata_port", NULL, NULL, NULL);

static void ata_tport_release(struct device *dev)
{}

/**
 * ata_is_port --  check if a struct device represents a ATA port
 * @dev:	device to check
 *
 * Returns:
 *	%1 if the device represents a ATA Port, %0 else
 */
static int ata_is_port(const struct device *dev)
{}

static int ata_tport_match(struct attribute_container *cont,
			   struct device *dev)
{}

/**
 * ata_tport_delete  --  remove ATA PORT
 * @ap:	ATA PORT to remove
 *
 * Removes the specified ATA PORT.  Remove the associated link as well.
 */
void ata_tport_delete(struct ata_port *ap)
{}
EXPORT_SYMBOL_GPL();

static const struct device_type ata_port_sas_type =;

/** ata_tport_add - initialize a transport ATA port structure
 *
 * @parent:	parent device
 * @ap:		existing ata_port structure
 *
 * Initialize a ATA port structure for sysfs.  It will be added to the device
 * tree below the device specified by @parent which could be a PCI device.
 *
 * Returns %0 on success
 */
int ata_tport_add(struct device *parent,
		  struct ata_port *ap)
{}
EXPORT_SYMBOL_GPL();

/**
 *     ata_port_classify - determine device type based on ATA-spec signature
 *     @ap: ATA port device on which the classification should be run
 *     @tf: ATA taskfile register set for device to be identified
 *
 *     A wrapper around ata_dev_classify() to provide additional logging
 *
 *     RETURNS:
 *     Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP,
 *     %ATA_DEV_ZAC, or %ATA_DEV_UNKNOWN the event of failure.
 */
unsigned int ata_port_classify(struct ata_port *ap,
			       const struct ata_taskfile *tf)
{}
EXPORT_SYMBOL_GPL();

/*
 * ATA link attributes
 */
static int noop(int x) {}

#define ata_link_show_linkspeed(field, format)

#define ata_link_linkspeed_attr(field, format)

ata_link_linkspeed_attr();
ata_link_linkspeed_attr();
ata_link_linkspeed_attr();


static DECLARE_TRANSPORT_CLASS(ata_link_class,
		"ata_link", NULL, NULL, NULL);

static void ata_tlink_release(struct device *dev)
{}

/**
 * ata_is_link --  check if a struct device represents a ATA link
 * @dev:	device to check
 *
 * Returns:
 *	%1 if the device represents a ATA link, %0 else
 */
static int ata_is_link(const struct device *dev)
{}

static int ata_tlink_match(struct attribute_container *cont,
			   struct device *dev)
{}

/**
 * ata_tlink_delete  --  remove ATA LINK
 * @link:	ATA LINK to remove
 *
 * Removes the specified ATA LINK.  remove associated ATA device(s) as well.
 */
void ata_tlink_delete(struct ata_link *link)
{}

/**
 * ata_tlink_add  --  initialize a transport ATA link structure
 * @link:	allocated ata_link structure.
 *
 * Initialize an ATA LINK structure for sysfs.  It will be added in the
 * device tree below the ATA PORT it belongs to.
 *
 * Returns %0 on success
 */
int ata_tlink_add(struct ata_link *link)
{}

/*
 * ATA device attributes
 */

#define ata_dev_show_class(title, field)

#define ata_dev_attr(title, field)

ata_dev_attr();
ata_dev_attr();
ata_dev_attr();
ata_dev_attr();


#define ata_dev_show_simple(field, format_string, cast)

#define ata_dev_simple_attr(field, format_string, type)

ata_dev_simple_attr();

struct ata_show_ering_arg {};

static int ata_show_ering(struct ata_ering_entry *ent, void *void_arg)
{}

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


static DEVICE_ATTR(ering, S_IRUGO, show_ata_dev_ering, NULL);

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

static DEVICE_ATTR(id, S_IRUGO, show_ata_dev_id, NULL);

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

static DEVICE_ATTR(gscr, S_IRUGO, show_ata_dev_gscr, NULL);

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

static DEVICE_ATTR(trim, S_IRUGO, show_ata_dev_trim, NULL);

static DECLARE_TRANSPORT_CLASS(ata_dev_class,
			       "ata_device", NULL, NULL, NULL);

static void ata_tdev_release(struct device *dev)
{}

/**
 * ata_is_ata_dev  --  check if a struct device represents a ATA device
 * @dev:	device to check
 *
 * Returns:
 *	%1 if the device represents a ATA device, %0 else
 */
static int ata_is_ata_dev(const struct device *dev)
{}

static int ata_tdev_match(struct attribute_container *cont,
			  struct device *dev)
{}

/**
 * ata_tdev_free  --  free a ATA LINK
 * @dev:	ATA PHY to free
 *
 * Frees the specified ATA PHY.
 *
 * Note:
 *   This function must only be called on a PHY that has not
 *   successfully been added using ata_tdev_add().
 */
static void ata_tdev_free(struct ata_device *dev)
{}

/**
 * ata_tdev_delete  --  remove ATA device
 * @ata_dev:	ATA device to remove
 *
 * Removes the specified ATA device.
 */
static void ata_tdev_delete(struct ata_device *ata_dev)
{}


/**
 * ata_tdev_add  --  initialize a transport ATA device structure.
 * @ata_dev:	ata_dev structure.
 *
 * Initialize an ATA device structure for sysfs.  It will be added in the
 * device tree below the ATA LINK device it belongs to.
 *
 * Returns %0 on success
 */
static int ata_tdev_add(struct ata_device *ata_dev)
{}


/*
 * Setup / Teardown code
 */

#define SETUP_TEMPLATE(attrb, field, perm, test)

#define SETUP_LINK_ATTRIBUTE(field)

#define SETUP_PORT_ATTRIBUTE(field)

#define SETUP_DEV_ATTRIBUTE(field)

/**
 * ata_attach_transport  --  instantiate ATA transport template
 */
struct scsi_transport_template *ata_attach_transport(void)
{}

/**
 * ata_release_transport  --  release ATA transport template instance
 * @t:		transport template instance
 */
void ata_release_transport(struct scsi_transport_template *t)
{}

__init int libata_transport_init(void)
{}

void __exit libata_transport_exit(void)
{}