sddr09.c (6f8aa65b52037123beab573432e371c0f70b7b9a) | sddr09.c (0ff71883b2d60136430458413c135d545c69b0c4) |
---|---|
1/* Driver for SanDisk SDDR-09 SmartMedia reader 2 * 3 * (c) 2000, 2001 Robert Baruch (autophile@starband.net) 4 * (c) 2002 Andries Brouwer (aeb@cwi.nl) 5 * Developed with the assistance of: 6 * (c) 2002 Alan Stern <stern@rowland.org> 7 * 8 * The SanDisk SDDR-09 SmartMedia reader uses the Shuttle EUSB-01 chip. --- 27 unchanged lines hidden (view full) --- 36 * EB: reset 37 * EC: read status 38 * ED: read ID 39 * EE: write CIS (?) 40 * EF: compute checksum (?) 41 */ 42 43#include <linux/errno.h> | 1/* Driver for SanDisk SDDR-09 SmartMedia reader 2 * 3 * (c) 2000, 2001 Robert Baruch (autophile@starband.net) 4 * (c) 2002 Andries Brouwer (aeb@cwi.nl) 5 * Developed with the assistance of: 6 * (c) 2002 Alan Stern <stern@rowland.org> 7 * 8 * The SanDisk SDDR-09 SmartMedia reader uses the Shuttle EUSB-01 chip. --- 27 unchanged lines hidden (view full) --- 36 * EB: reset 37 * EC: read status 38 * ED: read ID 39 * EE: write CIS (?) 40 * EF: compute checksum (?) 41 */ 42 43#include <linux/errno.h> |
44#include <linux/module.h> |
|
44#include <linux/slab.h> 45 46#include <scsi/scsi.h> 47#include <scsi/scsi_cmnd.h> 48#include <scsi/scsi_device.h> 49 50#include "usb.h" 51#include "transport.h" 52#include "protocol.h" 53#include "debug.h" | 45#include <linux/slab.h> 46 47#include <scsi/scsi.h> 48#include <scsi/scsi_cmnd.h> 49#include <scsi/scsi_device.h> 50 51#include "usb.h" 52#include "transport.h" 53#include "protocol.h" 54#include "debug.h" |
54#include "sddr09.h" | |
55 56 | 55 56 |
57static int usb_stor_sddr09_dpcm_init(struct us_data *us); 58static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us); 59static int usb_stor_sddr09_init(struct us_data *us); 60 61 62/* 63 * The table of devices 64 */ 65#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ 66 vendorName, productName, useProtocol, useTransport, \ 67 initFunction, flags) \ 68{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \ 69 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } 70 71struct usb_device_id sddr09_usb_ids[] = { 72# include "unusual_sddr09.h" 73 { } /* Terminating entry */ 74}; 75MODULE_DEVICE_TABLE(usb, sddr09_usb_ids); 76 77#undef UNUSUAL_DEV 78 79/* 80 * The flags table 81 */ 82#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \ 83 vendor_name, product_name, use_protocol, use_transport, \ 84 init_function, Flags) \ 85{ \ 86 .vendorName = vendor_name, \ 87 .productName = product_name, \ 88 .useProtocol = use_protocol, \ 89 .useTransport = use_transport, \ 90 .initFunction = init_function, \ 91} 92 93static struct us_unusual_dev sddr09_unusual_dev_list[] = { 94# include "unusual_sddr09.h" 95 { } /* Terminating entry */ 96}; 97 98#undef UNUSUAL_DEV 99 100 |
|
57#define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) ) 58#define LSB_of(s) ((s)&0xFF) 59#define MSB_of(s) ((s)>>8) 60 61/* #define US_DEBUGP printk */ 62 63/* 64 * First some stuff that does not belong here: --- 1336 unchanged lines hidden (view full) --- 1401} 1402 1403 1404/* 1405 * This is needed at a very early stage. If this is not listed in the 1406 * unusual devices list but called from here then LUN 0 of the combo reader 1407 * is not recognized. But I do not know what precisely these calls do. 1408 */ | 101#define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) ) 102#define LSB_of(s) ((s)&0xFF) 103#define MSB_of(s) ((s)>>8) 104 105/* #define US_DEBUGP printk */ 106 107/* 108 * First some stuff that does not belong here: --- 1336 unchanged lines hidden (view full) --- 1445} 1446 1447 1448/* 1449 * This is needed at a very early stage. If this is not listed in the 1450 * unusual devices list but called from here then LUN 0 of the combo reader 1451 * is not recognized. But I do not know what precisely these calls do. 1452 */ |
1409int | 1453static int |
1410usb_stor_sddr09_dpcm_init(struct us_data *us) { 1411 int result; 1412 unsigned char *data = us->iobuf; 1413 1414 result = sddr09_common_init(us); 1415 if (result) 1416 return result; 1417 --- 33 unchanged lines hidden (view full) --- 1451 // test unit ready 1452 1453 return 0; /* not result */ 1454} 1455 1456/* 1457 * Transport for the Microtech DPCM-USB 1458 */ | 1454usb_stor_sddr09_dpcm_init(struct us_data *us) { 1455 int result; 1456 unsigned char *data = us->iobuf; 1457 1458 result = sddr09_common_init(us); 1459 if (result) 1460 return result; 1461 --- 33 unchanged lines hidden (view full) --- 1495 // test unit ready 1496 1497 return 0; /* not result */ 1498} 1499 1500/* 1501 * Transport for the Microtech DPCM-USB 1502 */ |
1459int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us) | 1503static int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us) |
1460{ 1461 int ret; 1462 1463 US_DEBUGP("dpcm_transport: LUN=%d\n", srb->device->lun); 1464 1465 switch (srb->device->lun) { 1466 case 0: 1467 --- 25 unchanged lines hidden (view full) --- 1493 } 1494 return ret; 1495} 1496 1497 1498/* 1499 * Transport for the Sandisk SDDR-09 1500 */ | 1504{ 1505 int ret; 1506 1507 US_DEBUGP("dpcm_transport: LUN=%d\n", srb->device->lun); 1508 1509 switch (srb->device->lun) { 1510 case 0: 1511 --- 25 unchanged lines hidden (view full) --- 1537 } 1538 return ret; 1539} 1540 1541 1542/* 1543 * Transport for the Sandisk SDDR-09 1544 */ |
1501int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) | 1545static int sddr09_transport(struct scsi_cmnd *srb, struct us_data *us) |
1502{ 1503 static unsigned char sensekey = 0, sensecode = 0; 1504 static unsigned char havefakesense = 0; 1505 int result, i; 1506 unsigned char *ptr = us->iobuf; 1507 unsigned long capacity; 1508 unsigned int page, pages; 1509 --- 182 unchanged lines hidden (view full) --- 1692 } 1693 1694 return USB_STOR_TRANSPORT_GOOD; 1695} 1696 1697/* 1698 * Initialization routine for the sddr09 subdriver 1699 */ | 1546{ 1547 static unsigned char sensekey = 0, sensecode = 0; 1548 static unsigned char havefakesense = 0; 1549 int result, i; 1550 unsigned char *ptr = us->iobuf; 1551 unsigned long capacity; 1552 unsigned int page, pages; 1553 --- 182 unchanged lines hidden (view full) --- 1736 } 1737 1738 return USB_STOR_TRANSPORT_GOOD; 1739} 1740 1741/* 1742 * Initialization routine for the sddr09 subdriver 1743 */ |
1700int | 1744static int |
1701usb_stor_sddr09_init(struct us_data *us) { 1702 return sddr09_common_init(us); 1703} | 1745usb_stor_sddr09_init(struct us_data *us) { 1746 return sddr09_common_init(us); 1747} |
1748 1749static int sddr09_probe(struct usb_interface *intf, 1750 const struct usb_device_id *id) 1751{ 1752 struct us_data *us; 1753 int result; 1754 1755 result = usb_stor_probe1(&us, intf, id, 1756 (id - sddr09_usb_ids) + sddr09_unusual_dev_list); 1757 if (result) 1758 return result; 1759 1760 if (us->protocol == US_PR_DPCM_USB) { 1761 us->transport_name = "Control/Bulk-EUSB/SDDR09"; 1762 us->transport = dpcm_transport; 1763 us->transport_reset = usb_stor_CB_reset; 1764 us->max_lun = 1; 1765 } else { 1766 us->transport_name = "EUSB/SDDR09"; 1767 us->transport = sddr09_transport; 1768 us->transport_reset = usb_stor_CB_reset; 1769 us->max_lun = 0; 1770 } 1771 1772 result = usb_stor_probe2(us); 1773 return result; 1774} 1775 1776static struct usb_driver sddr09_driver = { 1777 .name = "ums-sddr09", 1778 .probe = sddr09_probe, 1779 .disconnect = usb_stor_disconnect, 1780 .suspend = usb_stor_suspend, 1781 .resume = usb_stor_resume, 1782 .reset_resume = usb_stor_reset_resume, 1783 .pre_reset = usb_stor_pre_reset, 1784 .post_reset = usb_stor_post_reset, 1785 .id_table = sddr09_usb_ids, 1786 .soft_unbind = 1, 1787}; 1788 1789static int __init sddr09_init(void) 1790{ 1791 return usb_register(&sddr09_driver); 1792} 1793 1794static void __exit sddr09_exit(void) 1795{ 1796 usb_deregister(&sddr09_driver); 1797} 1798 1799module_init(sddr09_init); 1800module_exit(sddr09_exit); |
|