Commit 70d837075852f1f10178e5d57b852b035ac1ed97

Authored by Cho, Yu-Chen
Committed by Greg Kroah-Hartman
1 parent 333c5ec018

staging/keucr: fix keucr msscsi coding style

Fix keucr msscsi.c coding style.
Remove externs ,and move MS_SCSIIrp to end,
because there are not necessary to add extern for MS_SCSIIrp function.

Signed-off-by: Cho, Yu-Chen <acho@novell.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 1 changed file with 117 additions and 102 deletions Side-by-side Diff

drivers/staging/keucr/msscsi.c
... ... @@ -12,68 +12,48 @@
12 12 #include "scsiglue.h"
13 13 #include "transport.h"
14 14  
15   -int MS_SCSI_Test_Unit_Ready (struct us_data *us, struct scsi_cmnd *srb);
16   -int MS_SCSI_Inquiry (struct us_data *us, struct scsi_cmnd *srb);
17   -int MS_SCSI_Mode_Sense (struct us_data *us, struct scsi_cmnd *srb);
18   -int MS_SCSI_Start_Stop (struct us_data *us, struct scsi_cmnd *srb);
19   -int MS_SCSI_Read_Capacity (struct us_data *us, struct scsi_cmnd *srb);
20   -int MS_SCSI_Read (struct us_data *us, struct scsi_cmnd *srb);
21   -int MS_SCSI_Write (struct us_data *us, struct scsi_cmnd *srb);
22   -
23   -//----- MS_SCSIIrp() --------------------------------------------------
24   -int MS_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb)
25   -{
26   - int result;
27   -
28   - us->SrbStatus = SS_SUCCESS;
29   - switch (srb->cmnd[0])
30   - {
31   - case TEST_UNIT_READY : result = MS_SCSI_Test_Unit_Ready (us, srb); break; //0x00
32   - case INQUIRY : result = MS_SCSI_Inquiry (us, srb); break; //0x12
33   - case MODE_SENSE : result = MS_SCSI_Mode_Sense (us, srb); break; //0x1A
34   - case READ_CAPACITY : result = MS_SCSI_Read_Capacity (us, srb); break; //0x25
35   - case READ_10 : result = MS_SCSI_Read (us, srb); break; //0x28
36   - case WRITE_10 : result = MS_SCSI_Write (us, srb); break; //0x2A
37   -
38   - default:
39   - us->SrbStatus = SS_ILLEGAL_REQUEST;
40   - result = USB_STOR_TRANSPORT_FAILED;
41   - break;
42   - }
43   - return result;
44   -}
45   -
46   -//----- MS_SCSI_Test_Unit_Ready() --------------------------------------------------
  15 +/*
  16 + * MS_SCSI_Test_Unit_Ready()
  17 + */
47 18 int MS_SCSI_Test_Unit_Ready(struct us_data *us, struct scsi_cmnd *srb)
48 19 {
49 20 /* pr_info("MS_SCSI_Test_Unit_Ready\n"); */
50 21 if (us->MS_Status.Insert && us->MS_Status.Ready)
51 22 return USB_STOR_TRANSPORT_GOOD;
52   - else
53   - {
  23 + else {
54 24 ENE_MSInit(us);
55 25 return USB_STOR_TRANSPORT_GOOD;
56 26 }
57   -
  27 +
58 28 return USB_STOR_TRANSPORT_GOOD;
59 29 }
60 30  
61   -//----- MS_SCSI_Inquiry() --------------------------------------------------
  31 +/*
  32 + * MS_SCSI_Inquiry()
  33 + */
62 34 int MS_SCSI_Inquiry(struct us_data *us, struct scsi_cmnd *srb)
63 35 {
64 36 /* pr_info("MS_SCSI_Inquiry\n"); */
65   - BYTE data_ptr[36] = {0x00, 0x80, 0x02, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x55, 0x53, 0x42, 0x32, 0x2E, 0x30, 0x20, 0x20, 0x43, 0x61, 0x72, 0x64, 0x52, 0x65, 0x61, 0x64, 0x65, 0x72, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x31, 0x30, 0x30};
  37 + BYTE data_ptr[36] = {0x00, 0x80, 0x02, 0x00, 0x1F, 0x00,
  38 + 0x00, 0x00, 0x55, 0x53, 0x42, 0x32,
  39 + 0x2E, 0x30, 0x20, 0x20, 0x43, 0x61,
  40 + 0x72, 0x64, 0x52, 0x65, 0x61, 0x64,
  41 + 0x65, 0x72, 0x20, 0x20, 0x20, 0x20,
  42 + 0x20, 0x20, 0x30, 0x31, 0x30, 0x30};
66 43  
67 44 usb_stor_set_xfer_buf(us, data_ptr, 36, srb, TO_XFER_BUF);
68 45 return USB_STOR_TRANSPORT_GOOD;
69 46 }
70 47  
71   -
72   -//----- MS_SCSI_Mode_Sense() --------------------------------------------------
  48 +/*
  49 + * MS_SCSI_Mode_Sense()
  50 + */
73 51 int MS_SCSI_Mode_Sense(struct us_data *us, struct scsi_cmnd *srb)
74 52 {
75   - BYTE mediaNoWP[12] = {0x0b,0x00,0x00,0x08,0x00,0x00,0x71,0xc0,0x00,0x00,0x02,0x00};
76   - BYTE mediaWP[12] = {0x0b,0x00,0x80,0x08,0x00,0x00,0x71,0xc0,0x00,0x00,0x02,0x00};
  53 + BYTE mediaNoWP[12] = {0x0b, 0x00, 0x00, 0x08, 0x00, 0x00,
  54 + 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00};
  55 + BYTE mediaWP[12] = {0x0b, 0x00, 0x80, 0x08, 0x00, 0x00,
  56 + 0x71, 0xc0, 0x00, 0x00, 0x02, 0x00};
77 57  
78 58 if (us->MS_Status.WtP)
79 59 usb_stor_set_xfer_buf(us, mediaWP, 12, srb, TO_XFER_BUF);
... ... @@ -84,7 +64,9 @@
84 64 return USB_STOR_TRANSPORT_GOOD;
85 65 }
86 66  
87   -//----- MS_SCSI_Read_Capacity() --------------------------------------------------
  67 +/*
  68 + * MS_SCSI_Read_Capacity()
  69 + */
88 70 int MS_SCSI_Read_Capacity(struct us_data *us, struct scsi_cmnd *srb)
89 71 {
90 72 unsigned int offset = 0;
91 73  
92 74  
93 75  
94 76  
95 77  
96 78  
97 79  
98 80  
99 81  
100 82  
... ... @@ -96,58 +78,62 @@
96 78 pr_info("MS_SCSI_Read_Capacity\n");
97 79  
98 80 bl_len = 0x200;
99   - if ( us->MS_Status.IsMSPro )
  81 + if (us->MS_Status.IsMSPro)
100 82 bl_num = us->MSP_TotalBlock - 1;
101 83 else
102   - bl_num = us->MS_Lib.NumberOfLogBlock * us->MS_Lib.blockSize * 2 - 1;
  84 + bl_num = us->MS_Lib.NumberOfLogBlock *
  85 + us->MS_Lib.blockSize * 2 - 1;
103 86  
104 87 us->bl_num = bl_num;
105 88 pr_info("bl_len = %x\n", bl_len);
106 89 pr_info("bl_num = %x\n", bl_num);
107 90  
108   - //srb->request_bufflen = 8;
109   - buf[0] = (bl_num>>24) & 0xff;
110   - buf[1] = (bl_num>>16) & 0xff;
111   - buf[2] = (bl_num>> 8) & 0xff;
112   - buf[3] = (bl_num>> 0) & 0xff;
113   - buf[4] = (bl_len>>24) & 0xff;
114   - buf[5] = (bl_len>>16) & 0xff;
115   - buf[6] = (bl_len>> 8) & 0xff;
116   - buf[7] = (bl_len>> 0) & 0xff;
117   -
  91 + /* srb->request_bufflen = 8; */
  92 + buf[0] = (bl_num >> 24) & 0xff;
  93 + buf[1] = (bl_num >> 16) & 0xff;
  94 + buf[2] = (bl_num >> 8) & 0xff;
  95 + buf[3] = (bl_num >> 0) & 0xff;
  96 + buf[4] = (bl_len >> 24) & 0xff;
  97 + buf[5] = (bl_len >> 16) & 0xff;
  98 + buf[6] = (bl_len >> 8) & 0xff;
  99 + buf[7] = (bl_len >> 0) & 0xff;
  100 +
118 101 usb_stor_access_xfer_buf(us, buf, 8, srb, &sg, &offset, TO_XFER_BUF);
119   - //usb_stor_set_xfer_buf(us, buf, srb->request_bufflen, srb, TO_XFER_BUF);
  102 + /* usb_stor_set_xfer_buf(us, buf, srb->request_bufflen,
  103 + srb, TO_XFER_BUF); */
120 104  
121 105 return USB_STOR_TRANSPORT_GOOD;
122 106 }
123 107  
124   -//----- MS_SCSI_Read() --------------------------------------------------
  108 +/*
  109 + * MS_SCSI_Read()
  110 + */
125 111 int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
126 112 {
127 113 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
128   - int result=0;
  114 + int result = 0;
129 115 PBYTE Cdb = srb->cmnd;
130   - DWORD bn = ((Cdb[2]<<24) & 0xff000000) | ((Cdb[3]<<16) & 0x00ff0000) |
131   - ((Cdb[4]<< 8) & 0x0000ff00) | ((Cdb[5]<< 0) & 0x000000ff);
132   - WORD blen = ((Cdb[7]<< 8) & 0xff00) | ((Cdb[8]<< 0) & 0x00ff);
  116 + DWORD bn = ((Cdb[2] << 24) & 0xff000000) |
  117 + ((Cdb[3] << 16) & 0x00ff0000) |
  118 + ((Cdb[4] << 8) & 0x0000ff00) |
  119 + ((Cdb[5] << 0) & 0x000000ff);
  120 + WORD blen = ((Cdb[7] << 8) & 0xff00) | ((Cdb[8] << 0) & 0x00ff);
133 121 DWORD blenByte = blen * 0x200;
134 122  
135 123 /* pr_info("SCSIOP_READ --- bn = %X, blen = %X, srb->use_sg = %X\n",
136 124 bn, blen, srb->use_sg); */
137   -
  125 +
138 126 if (bn > us->bl_num)
139 127 return USB_STOR_TRANSPORT_ERROR;
140 128  
141   - if (us->MS_Status.IsMSPro)
142   - {
  129 + if (us->MS_Status.IsMSPro) {
143 130 result = ENE_LoadBinCode(us, MSP_RW_PATTERN);
144   - if (result != USB_STOR_XFER_GOOD)
145   - {
  131 + if (result != USB_STOR_XFER_GOOD) {
146 132 pr_info("Load MSP RW pattern Fail !!\n");
147 133 return USB_STOR_TRANSPORT_ERROR;
148 134 }
149 135  
150   - // set up the command wrapper
  136 + /* set up the command wrapper */
151 137 memset(bcb, 0, sizeof(struct bulk_cb_wrap));
152 138 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
153 139 bcb->DataTransferLength = blenByte;
154 140  
... ... @@ -160,11 +146,9 @@
160 146 bcb->CDB[2] = (BYTE)(bn>>24);
161 147  
162 148 result = ENE_SendScsiCmd(us, FDIR_READ, scsi_sglist(srb), 1);
163   - }
164   - else
165   - {
  149 + } else {
166 150 void *buf;
167   - int offset=0;
  151 + int offset = 0;
168 152 WORD phyblk, logblk;
169 153 BYTE PageNum;
170 154 WORD len;
... ... @@ -175,8 +159,7 @@
175 159 return USB_STOR_TRANSPORT_ERROR;
176 160  
177 161 result = ENE_LoadBinCode(us, MS_RW_PATTERN);
178   - if (result != USB_STOR_XFER_GOOD)
179   - {
  162 + if (result != USB_STOR_XFER_GOOD) {
180 163 pr_info("Load MS RW pattern Fail !!\n");
181 164 result = USB_STOR_TRANSPORT_ERROR;
182 165 goto exit;
... ... @@ -185,9 +168,8 @@
185 168 logblk = (WORD)(bn / us->MS_Lib.PagesPerBlock);
186 169 PageNum = (BYTE)(bn % us->MS_Lib.PagesPerBlock);
187 170  
188   - while(1)
189   - {
190   - if (blen > (us->MS_Lib.PagesPerBlock-PageNum) )
  171 + while (1) {
  172 + if (blen > (us->MS_Lib.PagesPerBlock-PageNum))
191 173 len = us->MS_Lib.PagesPerBlock-PageNum;
192 174 else
193 175 len = blen;
... ... @@ -195,7 +177,7 @@
195 177 phyblk = MS_LibConv2Physical(us, logblk);
196 178 blkno = phyblk * 0x20 + PageNum;
197 179  
198   - // set up the command wrapper
  180 + /* set up the command wrapper */
199 181 memset(bcb, 0, sizeof(struct bulk_cb_wrap));
200 182 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
201 183 bcb->DataTransferLength = 0x200 * len;
... ... @@ -208,8 +190,7 @@
208 190 bcb->CDB[2] = (BYTE)(blkno>>24);
209 191  
210 192 result = ENE_SendScsiCmd(us, FDIR_READ, buf+offset, 0);
211   - if (result != USB_STOR_XFER_GOOD)
212   - {
  193 + if (result != USB_STOR_XFER_GOOD) {
213 194 pr_info("MS_SCSI_Read --- result = %x\n",
214 195 result);
215 196 result = USB_STOR_TRANSPORT_ERROR;
... ... @@ -217,7 +198,7 @@
217 198 }
218 199  
219 200 blen -= len;
220   - if (blen<=0)
  201 + if (blen <= 0)
221 202 break;
222 203 logblk++;
223 204 PageNum = 0;
224 205  
225 206  
226 207  
227 208  
228 209  
... ... @@ -230,30 +211,32 @@
230 211 return result;
231 212 }
232 213  
233   -//----- MS_SCSI_Write() --------------------------------------------------
  214 +/*
  215 + * MS_SCSI_Write()
  216 + */
234 217 int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
235 218 {
236 219 struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
237   - int result=0;
  220 + int result = 0;
238 221 PBYTE Cdb = srb->cmnd;
239   - DWORD bn = ((Cdb[2]<<24) & 0xff000000) | ((Cdb[3]<<16) & 0x00ff0000) |
240   - ((Cdb[4]<< 8) & 0x0000ff00) | ((Cdb[5]<< 0) & 0x000000ff);
241   - WORD blen = ((Cdb[7]<< 8) & 0xff00) | ((Cdb[8]<< 0) & 0x00ff);
  222 + DWORD bn = ((Cdb[2] << 24) & 0xff000000) |
  223 + ((Cdb[3] << 16) & 0x00ff0000) |
  224 + ((Cdb[4] << 8) & 0x0000ff00) |
  225 + ((Cdb[5] << 0) & 0x000000ff);
  226 + WORD blen = ((Cdb[7] << 8) & 0xff00) | ((Cdb[8] << 0) & 0x00ff);
242 227 DWORD blenByte = blen * 0x200;
243 228  
244 229 if (bn > us->bl_num)
245 230 return USB_STOR_TRANSPORT_ERROR;
246 231  
247   - if (us->MS_Status.IsMSPro)
248   - {
  232 + if (us->MS_Status.IsMSPro) {
249 233 result = ENE_LoadBinCode(us, MSP_RW_PATTERN);
250   - if (result != USB_STOR_XFER_GOOD)
251   - {
  234 + if (result != USB_STOR_XFER_GOOD) {
252 235 pr_info("Load MSP RW pattern Fail !!\n");
253 236 return USB_STOR_TRANSPORT_ERROR;
254 237 }
255 238  
256   - // set up the command wrapper
  239 + /* set up the command wrapper */
257 240 memset(bcb, 0, sizeof(struct bulk_cb_wrap));
258 241 bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
259 242 bcb->DataTransferLength = blenByte;
260 243  
... ... @@ -266,11 +249,9 @@
266 249 bcb->CDB[2] = (BYTE)(bn>>24);
267 250  
268 251 result = ENE_SendScsiCmd(us, FDIR_WRITE, scsi_sglist(srb), 1);
269   - }
270   - else
271   - {
  252 + } else {
272 253 void *buf;
273   - int offset=0;
  254 + int offset = 0;
274 255 WORD PhyBlockAddr;
275 256 BYTE PageNum;
276 257 DWORD result;
... ... @@ -282,8 +263,7 @@
282 263 usb_stor_set_xfer_buf(us, buf, blenByte, srb, FROM_XFER_BUF);
283 264  
284 265 result = ENE_LoadBinCode(us, MS_RW_PATTERN);
285   - if (result != USB_STOR_XFER_GOOD)
286   - {
  266 + if (result != USB_STOR_XFER_GOOD) {
287 267 pr_info("Load MS RW pattern Fail !!\n");
288 268 result = USB_STOR_TRANSPORT_ERROR;
289 269 goto exit;
... ... @@ -292,9 +272,8 @@
292 272 PhyBlockAddr = (WORD)(bn / us->MS_Lib.PagesPerBlock);
293 273 PageNum = (BYTE)(bn % us->MS_Lib.PagesPerBlock);
294 274  
295   - while(1)
296   - {
297   - if (blen > (us->MS_Lib.PagesPerBlock-PageNum) )
  275 + while (1) {
  276 + if (blen > (us->MS_Lib.PagesPerBlock-PageNum))
298 277 len = us->MS_Lib.PagesPerBlock-PageNum;
299 278 else
300 279 len = blen;
... ... @@ -302,9 +281,10 @@
302 281 oldphy = MS_LibConv2Physical(us, PhyBlockAddr);
303 282 newphy = MS_LibSearchBlockFromLogical(us, PhyBlockAddr);
304 283  
305   - result = MS_ReaderCopyBlock(us, oldphy, newphy, PhyBlockAddr, PageNum, buf+offset, len);
306   - if (result != USB_STOR_XFER_GOOD)
307   - {
  284 + result = MS_ReaderCopyBlock(us, oldphy, newphy,
  285 + PhyBlockAddr, PageNum,
  286 + buf+offset, len);
  287 + if (result != USB_STOR_XFER_GOOD) {
308 288 pr_info("MS_SCSI_Write --- result = %x\n",
309 289 result);
310 290 result = USB_STOR_TRANSPORT_ERROR;
... ... @@ -315,7 +295,7 @@
315 295 MS_LibForceSetLogicalPair(us, PhyBlockAddr, newphy);
316 296  
317 297 blen -= len;
318   - if (blen<=0)
  298 + if (blen <= 0)
319 299 break;
320 300 PhyBlockAddr++;
321 301 PageNum = 0;
... ... @@ -323,6 +303,41 @@
323 303 }
324 304 exit:
325 305 kfree(buf);
  306 + }
  307 + return result;
  308 +}
  309 +
  310 +/*
  311 + * MS_SCSIIrp()
  312 + */
  313 +int MS_SCSIIrp(struct us_data *us, struct scsi_cmnd *srb)
  314 +{
  315 + int result;
  316 +
  317 + us->SrbStatus = SS_SUCCESS;
  318 + switch (srb->cmnd[0]) {
  319 + case TEST_UNIT_READY:
  320 + result = MS_SCSI_Test_Unit_Ready(us, srb);
  321 + break; /* 0x00 */
  322 + case INQUIRY:
  323 + result = MS_SCSI_Inquiry(us, srb);
  324 + break; /* 0x12 */
  325 + case MODE_SENSE:
  326 + result = MS_SCSI_Mode_Sense(us, srb);
  327 + break; /* 0x1A */
  328 + case READ_CAPACITY:
  329 + result = MS_SCSI_Read_Capacity(us, srb);
  330 + break; /* 0x25 */
  331 + case READ_10:
  332 + result = MS_SCSI_Read(us, srb);
  333 + break; /* 0x28 */
  334 + case WRITE_10:
  335 + result = MS_SCSI_Write(us, srb);
  336 + break; /* 0x2A */
  337 + default:
  338 + us->SrbStatus = SS_ILLEGAL_REQUEST;
  339 + result = USB_STOR_TRANSPORT_FAILED;
  340 + break;
326 341 }
327 342 return result;
328 343 }