#include <linux/errno.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
#include <scsi/scsi_device.h>
#include "usb.h"
#include "transport.h"
#include "protocol.h"
#include "debug.h"
#include "scsiglue.h"
#define DRV_NAME …
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;
MODULE_IMPORT_NS(…);
static int usb_stor_sddr09_dpcm_init(struct us_data *us);
static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us);
static int usb_stor_sddr09_init(struct us_data *us);
#define UNUSUAL_DEV …
static struct usb_device_id sddr09_usb_ids[] = …;
MODULE_DEVICE_TABLE(usb, sddr09_usb_ids);
#undef UNUSUAL_DEV
#define UNUSUAL_DEV …
static struct us_unusual_dev sddr09_unusual_dev_list[] = …;
#undef UNUSUAL_DEV
#define short_pack(lsb,msb) …
#define LSB_of(s) …
#define MSB_of(s) …
struct nand_flash_dev { … };
#define NAND_MFR_AMD …
#define NAND_MFR_NATSEMI …
#define NAND_MFR_TOSHIBA …
#define NAND_MFR_SAMSUNG …
static inline char *nand_flash_manufacturer(int manuf_id) { … }
static struct nand_flash_dev nand_flash_ids[] = …;
static struct nand_flash_dev *
nand_find_id(unsigned char id) { … }
static unsigned char parity[256];
static unsigned char ecc2[256];
static void nand_init_ecc(void) { … }
static void nand_compute_ecc(unsigned char *data, unsigned char *ecc) { … }
static int nand_compare_ecc(unsigned char *data, unsigned char *ecc) { … }
static void nand_store_ecc(unsigned char *data, unsigned char *ecc) { … }
struct sddr09_card_info { … };
#define CONTROL_SHIFT …
#define LUN …
#define LUNBITS …
#define UNDEF …
#define SPARE …
#define UNUSABLE …
static const int erase_bad_lba_entries = …;
static int
sddr09_send_command(struct us_data *us,
unsigned char request,
unsigned char direction,
unsigned char *xfer_data,
unsigned int xfer_len) { … }
static int
sddr09_send_scsi_command(struct us_data *us,
unsigned char *command,
unsigned int command_len) { … }
#if 0
static int
sddr09_test_unit_ready(struct us_data *us) {
unsigned char *command = us->iobuf;
int result;
memset(command, 0, 6);
command[1] = LUNBITS;
result = sddr09_send_scsi_command(us, command, 6);
usb_stor_dbg(us, "sddr09_test_unit_ready returns %d\n", result);
return result;
}
#endif
static int
sddr09_request_sense(struct us_data *us, unsigned char *sensebuf, int buflen) { … }
static int
sddr09_readX(struct us_data *us, int x, unsigned long fromaddress,
int nr_of_pages, int bulklen, unsigned char *buf,
int use_sg) { … }
static int
sddr09_read20(struct us_data *us, unsigned long fromaddress,
int nr_of_pages, int pageshift, unsigned char *buf, int use_sg) { … }
static int
sddr09_read21(struct us_data *us, unsigned long fromaddress,
int count, int controlshift, unsigned char *buf, int use_sg) { … }
static int
sddr09_read22(struct us_data *us, unsigned long fromaddress,
int nr_of_pages, int pageshift, unsigned char *buf, int use_sg) { … }
#if 0
static int
sddr09_read23(struct us_data *us, unsigned long fromaddress,
int count, int controlshift, unsigned char *buf, int use_sg) {
int bulklen = (count << controlshift);
return sddr09_readX(us, 3, fromaddress, count, bulklen,
buf, use_sg);
}
#endif
static int
sddr09_erase(struct us_data *us, unsigned long Eaddress) { … }
static int
sddr09_writeX(struct us_data *us,
unsigned long Waddress, unsigned long Eaddress,
int nr_of_pages, int bulklen, unsigned char *buf, int use_sg) { … }
static int
sddr09_write_inplace(struct us_data *us, unsigned long address,
int nr_of_pages, int pageshift, unsigned char *buf,
int use_sg) { … }
#if 0
static int
sddr09_read_sg_test_only(struct us_data *us) {
unsigned char *command = us->iobuf;
int result, bulklen, nsg, ct;
unsigned char *buf;
unsigned long address;
nsg = bulklen = 0;
command[0] = 0xE7;
command[1] = LUNBITS;
command[2] = 0;
address = 040000; ct = 1;
nsg++;
bulklen += (ct << 9);
command[4*nsg+2] = ct;
command[4*nsg+1] = ((address >> 9) & 0xFF);
command[4*nsg+0] = ((address >> 17) & 0xFF);
command[4*nsg-1] = ((address >> 25) & 0xFF);
address = 0340000; ct = 1;
nsg++;
bulklen += (ct << 9);
command[4*nsg+2] = ct;
command[4*nsg+1] = ((address >> 9) & 0xFF);
command[4*nsg+0] = ((address >> 17) & 0xFF);
command[4*nsg-1] = ((address >> 25) & 0xFF);
address = 01000000; ct = 2;
nsg++;
bulklen += (ct << 9);
command[4*nsg+2] = ct;
command[4*nsg+1] = ((address >> 9) & 0xFF);
command[4*nsg+0] = ((address >> 17) & 0xFF);
command[4*nsg-1] = ((address >> 25) & 0xFF);
command[2] = nsg;
result = sddr09_send_scsi_command(us, command, 4*nsg+3);
if (result) {
usb_stor_dbg(us, "Result for send_control in sddr09_read_sg %d\n",
result);
return result;
}
buf = kmalloc(bulklen, GFP_NOIO);
if (!buf)
return -ENOMEM;
result = usb_stor_bulk_transfer_buf(us, us->recv_bulk_pipe,
buf, bulklen, NULL);
kfree(buf);
if (result != USB_STOR_XFER_GOOD) {
usb_stor_dbg(us, "Result for bulk_transfer in sddr09_read_sg %d\n",
result);
return -EIO;
}
return 0;
}
#endif
static int
sddr09_read_status(struct us_data *us, unsigned char *status) { … }
static int
sddr09_read_data(struct us_data *us,
unsigned long address,
unsigned int sectors) { … }
static unsigned int
sddr09_find_unused_pba(struct sddr09_card_info *info, unsigned int lba) { … }
static int
sddr09_write_lba(struct us_data *us, unsigned int lba,
unsigned int page, unsigned int pages,
unsigned char *ptr, unsigned char *blockbuffer) { … }
static int
sddr09_write_data(struct us_data *us,
unsigned long address,
unsigned int sectors) { … }
static int
sddr09_read_control(struct us_data *us,
unsigned long address,
unsigned int blocks,
unsigned char *content,
int use_sg) { … }
static int
sddr09_read_deviceID(struct us_data *us, unsigned char *deviceID) { … }
static int
sddr09_get_wp(struct us_data *us, struct sddr09_card_info *info) { … }
#if 0
static int
sddr09_reset(struct us_data *us) {
unsigned char *command = us->iobuf;
memset(command, 0, 12);
command[0] = 0xEB;
command[1] = LUNBITS;
return sddr09_send_scsi_command(us, command, 12);
}
#endif
static struct nand_flash_dev *
sddr09_get_cardinfo(struct us_data *us, unsigned char flags) { … }
static int
sddr09_read_map(struct us_data *us) { … }
static void
sddr09_card_info_destructor(void *extra) { … }
static int
sddr09_common_init(struct us_data *us) { … }
static int
usb_stor_sddr09_dpcm_init(struct us_data *us) { … }
static int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us)
{ … }
static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us)
{ … }
static int
usb_stor_sddr09_init(struct us_data *us) { … }
static struct scsi_host_template sddr09_host_template;
static int sddr09_probe(struct usb_interface *intf,
const struct usb_device_id *id)
{ … }
static struct usb_driver sddr09_driver = …;
module_usb_stor_driver(sddr09_driver, sddr09_host_template, DRV_NAME);