blob: 9a410b5a6e5b06e946cbf3865faa9961b37cd3a6 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* Driver for Microtech DPCM-USB CompactFlash/SmartMedia reader
2 *
3 * $Id: dpcm.c,v 1.4 2001/06/11 02:54:25 mdharm Exp $
4 *
5 * DPCM driver v0.1:
6 *
7 * First release
8 *
9 * Current development and maintenance by:
10 * (c) 2000 Brian Webb (webbb@earthlink.net)
11 *
12 * This device contains both a CompactFlash card reader, which
13 * uses the Control/Bulk w/o Interrupt protocol and
14 * a SmartMedia card reader that uses the same protocol
15 * as the SDDR09.
16 *
17 * This program is free software; you can redistribute it and/or modify it
18 * under the terms of the GNU General Public License as published by the
19 * Free Software Foundation; either version 2, or (at your option) any
20 * later version.
21 *
22 * This program is distributed in the hope that it will be useful, but
23 * WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License along
28 * with this program; if not, write to the Free Software Foundation, Inc.,
29 * 675 Mass Ave, Cambridge, MA 02139, USA.
30 */
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <scsi/scsi.h>
33#include <scsi/scsi_cmnd.h>
34#include <scsi/scsi_device.h>
35
36#include "usb.h"
37#include "transport.h"
38#include "protocol.h"
39#include "debug.h"
40#include "dpcm.h"
41#include "sddr09.h"
42
43/*
44 * Transport for the Microtech DPCM-USB
45 *
46 */
47int dpcm_transport(struct scsi_cmnd *srb, struct us_data *us)
48{
S.Caglar Onurd20da3c2007-07-16 13:41:45 +030049 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
S.Caglar Onurd20da3c2007-07-16 13:41:45 +030051 if (srb == NULL)
52 return USB_STOR_TRANSPORT_ERROR;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
S.Caglar Onurd20da3c2007-07-16 13:41:45 +030054 US_DEBUGP("dpcm_transport: LUN=%d\n", srb->device->lun);
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
S.Caglar Onurd20da3c2007-07-16 13:41:45 +030056 switch (srb->device->lun) {
57 case 0:
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
S.Caglar Onurd20da3c2007-07-16 13:41:45 +030059 /*
60 * LUN 0 corresponds to the CompactFlash card reader.
61 */
62 ret = usb_stor_CB_transport(srb, us);
63 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65#ifdef CONFIG_USB_STORAGE_SDDR09
S.Caglar Onurd20da3c2007-07-16 13:41:45 +030066 case 1:
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
S.Caglar Onurd20da3c2007-07-16 13:41:45 +030068 /*
69 * LUN 1 corresponds to the SmartMedia card reader.
70 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
S.Caglar Onurd20da3c2007-07-16 13:41:45 +030072 /*
73 * Set the LUN to 0 (just in case).
74 */
75 srb->device->lun = 0; us->srb->device->lun = 0;
76 ret = sddr09_transport(srb, us);
77 srb->device->lun = 1; us->srb->device->lun = 1;
78 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
80#endif
81
S.Caglar Onurd20da3c2007-07-16 13:41:45 +030082 default:
83 US_DEBUGP("dpcm_transport: Invalid LUN %d\n", srb->device->lun);
84 ret = USB_STOR_TRANSPORT_ERROR;
85 break;
86 }
87 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088}