linux/drivers/usb/gadget/function/storage_common.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef USB_STORAGE_COMMON_H
#define USB_STORAGE_COMMON_H

#include <linux/device.h>
#include <linux/usb/storage.h>
#include <scsi/scsi.h>
#include <linux/unaligned.h>

#ifndef DEBUG
#undef VERBOSE_DEBUG
#undef DUMP_MSGS
#endif /* !DEBUG */

#ifdef VERBOSE_DEBUG
#define VLDBG
#else
#define VLDBG
#endif /* VERBOSE_DEBUG */

#define _LMSG(func, lun, fmt, args...)

#define LDBG(lun, fmt, args...)
#define LERROR(lun, fmt, args...)
#define LWARN(lun, fmt, args...)
#define LINFO(lun, fmt, args...)


#ifdef DUMP_MSGS

#define dump_msg

#define dump_cdb

#else

#define dump_msg(fsg, /* const char * */ label, \
		   /* const u8 * */ buf, /* unsigned */ length)

#  ifdef VERBOSE_DEBUG

#define dump_cdb(fsg)		\

#  else

#define dump_cdb

#  endif /* VERBOSE_DEBUG */

#endif /* DUMP_MSGS */

/* Length of a SCSI Command Data Block */
#define MAX_COMMAND_SIZE

/* SCSI Sense Key/Additional Sense Code/ASC Qualifier values */
#define SS_NO_SENSE
#define SS_COMMUNICATION_FAILURE
#define SS_INVALID_COMMAND
#define SS_INVALID_FIELD_IN_CDB
#define SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE
#define SS_LOGICAL_UNIT_NOT_SUPPORTED
#define SS_MEDIUM_NOT_PRESENT
#define SS_MEDIUM_REMOVAL_PREVENTED
#define SS_NOT_READY_TO_READY_TRANSITION
#define SS_RESET_OCCURRED
#define SS_SAVING_PARAMETERS_NOT_SUPPORTED
#define SS_UNRECOVERED_READ_ERROR
#define SS_WRITE_ERROR
#define SS_WRITE_PROTECTED

#define SK(x)
#define ASC(x)
#define ASCQ(x)

/*
 * Vendor (8 chars), product (16 chars), release (4 hexadecimal digits) and NUL
 * byte
 */
#define INQUIRY_STRING_LEN

struct fsg_lun {};

static inline bool fsg_lun_is_open(struct fsg_lun *curlun)
{}

/* Default size of buffer length. */
#define FSG_BUFLEN

/* Maximal number of LUNs supported in mass storage function */
#define FSG_MAX_LUNS

enum fsg_buffer_state {};

struct fsg_buffhd {};

enum fsg_state {};

enum data_direction {};

static inline struct fsg_lun *fsg_lun_from_dev(struct device *dev)
{}

enum {};

extern struct usb_interface_descriptor fsg_intf_desc;

extern struct usb_endpoint_descriptor fsg_fs_bulk_in_desc;
extern struct usb_endpoint_descriptor fsg_fs_bulk_out_desc;
extern struct usb_descriptor_header *fsg_fs_function[];

extern struct usb_endpoint_descriptor fsg_hs_bulk_in_desc;
extern struct usb_endpoint_descriptor fsg_hs_bulk_out_desc;
extern struct usb_descriptor_header *fsg_hs_function[];

extern struct usb_endpoint_descriptor fsg_ss_bulk_in_desc;
extern struct usb_ss_ep_comp_descriptor fsg_ss_bulk_in_comp_desc;
extern struct usb_endpoint_descriptor fsg_ss_bulk_out_desc;
extern struct usb_ss_ep_comp_descriptor fsg_ss_bulk_out_comp_desc;
extern struct usb_descriptor_header *fsg_ss_function[];

void fsg_lun_close(struct fsg_lun *curlun);
int fsg_lun_open(struct fsg_lun *curlun, const char *filename);
int fsg_lun_fsync_sub(struct fsg_lun *curlun);
void store_cdrom_address(u8 *dest, int msf, u32 addr);
ssize_t fsg_show_ro(struct fsg_lun *curlun, char *buf);
ssize_t fsg_show_nofua(struct fsg_lun *curlun, char *buf);
ssize_t fsg_show_file(struct fsg_lun *curlun, struct rw_semaphore *filesem,
		      char *buf);
ssize_t fsg_show_inquiry_string(struct fsg_lun *curlun, char *buf);
ssize_t fsg_show_cdrom(struct fsg_lun *curlun, char *buf);
ssize_t fsg_show_removable(struct fsg_lun *curlun, char *buf);
ssize_t fsg_store_ro(struct fsg_lun *curlun, struct rw_semaphore *filesem,
		     const char *buf, size_t count);
ssize_t fsg_store_nofua(struct fsg_lun *curlun, const char *buf, size_t count);
ssize_t fsg_store_file(struct fsg_lun *curlun, struct rw_semaphore *filesem,
		       const char *buf, size_t count);
ssize_t fsg_store_cdrom(struct fsg_lun *curlun, struct rw_semaphore *filesem,
			const char *buf, size_t count);
ssize_t fsg_store_removable(struct fsg_lun *curlun, const char *buf,
			    size_t count);
ssize_t fsg_store_inquiry_string(struct fsg_lun *curlun, const char *buf,
				 size_t count);
ssize_t fsg_store_forced_eject(struct fsg_lun *curlun, struct rw_semaphore *filesem,
			       const char *buf, size_t count);

#endif /* USB_STORAGE_COMMON_H */