@@ -237,36 +237,33 @@ static struct us_unusual_dev ene_ub6250_unusual_dev_list[] = {
237
237
#define memstick_logaddr (logadr1 , logadr0 ) ((((u16)(logadr1)) << 8) | (logadr0))
238
238
239
239
240
- struct SD_STATUS {
241
- u8 Insert :1 ;
242
- u8 Ready :1 ;
243
- u8 MediaChange :1 ;
244
- u8 IsMMC :1 ;
245
- u8 HiCapacity :1 ;
246
- u8 HiSpeed :1 ;
247
- u8 WtP :1 ;
248
- u8 Reserved :1 ;
249
- };
250
-
251
- struct MS_STATUS {
252
- u8 Insert :1 ;
253
- u8 Ready :1 ;
254
- u8 MediaChange :1 ;
255
- u8 IsMSPro :1 ;
256
- u8 IsMSPHG :1 ;
257
- u8 Reserved1 :1 ;
258
- u8 WtP :1 ;
259
- u8 Reserved2 :1 ;
260
- };
261
-
262
- struct SM_STATUS {
263
- u8 Insert :1 ;
264
- u8 Ready :1 ;
265
- u8 MediaChange :1 ;
266
- u8 Reserved :3 ;
267
- u8 WtP :1 ;
268
- u8 IsMS :1 ;
269
- };
240
+ /* SD_STATUS bits */
241
+ #define SD_Insert BIT(0)
242
+ #define SD_Ready BIT(1)
243
+ #define SD_MediaChange BIT(2)
244
+ #define SD_IsMMC BIT(3)
245
+ #define SD_HiCapacity BIT(4)
246
+ #define SD_HiSpeed BIT(5)
247
+ #define SD_WtP BIT(6)
248
+ /* Bit 7 reserved */
249
+
250
+ /* MS_STATUS bits */
251
+ #define MS_Insert BIT(0)
252
+ #define MS_Ready BIT(1)
253
+ #define MS_MediaChange BIT(2)
254
+ #define MS_IsMSPro BIT(3)
255
+ #define MS_IsMSPHG BIT(4)
256
+ /* Bit 5 reserved */
257
+ #define MS_WtP BIT(6)
258
+ /* Bit 7 reserved */
259
+
260
+ /* SM_STATUS bits */
261
+ #define SM_Insert BIT(0)
262
+ #define SM_Ready BIT(1)
263
+ #define SM_MediaChange BIT(2)
264
+ /* Bits 3-5 reserved */
265
+ #define SM_WtP BIT(6)
266
+ #define SM_IsMS BIT(7)
270
267
271
268
struct ms_bootblock_cis {
272
269
u8 bCistplDEVICE [6 ]; /* 0 */
@@ -437,9 +434,9 @@ struct ene_ub6250_info {
437
434
u8 * bbuf ;
438
435
439
436
/* for 6250 code */
440
- struct SD_STATUS SD_Status ;
441
- struct MS_STATUS MS_Status ;
442
- struct SM_STATUS SM_Status ;
437
+ u8 SD_Status ;
438
+ u8 MS_Status ;
439
+ u8 SM_Status ;
443
440
444
441
/* ----- SD Control Data ---------------- */
445
442
/*SD_REGISTER SD_Regs; */
@@ -602,7 +599,7 @@ static int sd_scsi_test_unit_ready(struct us_data *us, struct scsi_cmnd *srb)
602
599
{
603
600
struct ene_ub6250_info * info = (struct ene_ub6250_info * ) us -> extra ;
604
601
605
- if (info -> SD_Status . Insert && info -> SD_Status . Ready )
602
+ if (( info -> SD_Status & SD_Insert ) && ( info -> SD_Status & SD_Ready ) )
606
603
return USB_STOR_TRANSPORT_GOOD ;
607
604
else {
608
605
ene_sd_init (us );
@@ -622,7 +619,7 @@ static int sd_scsi_mode_sense(struct us_data *us, struct scsi_cmnd *srb)
622
619
0x0b , 0x00 , 0x80 , 0x08 , 0x00 , 0x00 ,
623
620
0x71 , 0xc0 , 0x00 , 0x00 , 0x02 , 0x00 };
624
621
625
- if (info -> SD_Status . WtP )
622
+ if (info -> SD_Status & SD_WtP )
626
623
usb_stor_set_xfer_buf (mediaWP , 12 , srb );
627
624
else
628
625
usb_stor_set_xfer_buf (mediaNoWP , 12 , srb );
@@ -641,9 +638,9 @@ static int sd_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb)
641
638
struct ene_ub6250_info * info = (struct ene_ub6250_info * ) us -> extra ;
642
639
643
640
usb_stor_dbg (us , "sd_scsi_read_capacity\n" );
644
- if (info -> SD_Status . HiCapacity ) {
641
+ if (info -> SD_Status & SD_HiCapacity ) {
645
642
bl_len = 0x200 ;
646
- if (info -> SD_Status . IsMMC )
643
+ if (info -> SD_Status & SD_IsMMC )
647
644
bl_num = info -> HC_C_SIZE - 1 ;
648
645
else
649
646
bl_num = (info -> HC_C_SIZE + 1 ) * 1024 - 1 ;
@@ -693,7 +690,7 @@ static int sd_scsi_read(struct us_data *us, struct scsi_cmnd *srb)
693
690
return USB_STOR_TRANSPORT_ERROR ;
694
691
}
695
692
696
- if (info -> SD_Status . HiCapacity )
693
+ if (info -> SD_Status & SD_HiCapacity )
697
694
bnByte = bn ;
698
695
699
696
/* set up the command wrapper */
@@ -733,7 +730,7 @@ static int sd_scsi_write(struct us_data *us, struct scsi_cmnd *srb)
733
730
return USB_STOR_TRANSPORT_ERROR ;
734
731
}
735
732
736
- if (info -> SD_Status . HiCapacity )
733
+ if (info -> SD_Status & SD_HiCapacity )
737
734
bnByte = bn ;
738
735
739
736
/* set up the command wrapper */
@@ -1456,7 +1453,7 @@ static int ms_scsi_test_unit_ready(struct us_data *us, struct scsi_cmnd *srb)
1456
1453
struct ene_ub6250_info * info = (struct ene_ub6250_info * )(us -> extra );
1457
1454
1458
1455
/* pr_info("MS_SCSI_Test_Unit_Ready\n"); */
1459
- if (info -> MS_Status . Insert && info -> MS_Status . Ready ) {
1456
+ if (( info -> MS_Status & MS_Insert ) && ( info -> MS_Status & MS_Ready ) ) {
1460
1457
return USB_STOR_TRANSPORT_GOOD ;
1461
1458
} else {
1462
1459
ene_ms_init (us );
@@ -1476,7 +1473,7 @@ static int ms_scsi_mode_sense(struct us_data *us, struct scsi_cmnd *srb)
1476
1473
0x0b , 0x00 , 0x80 , 0x08 , 0x00 , 0x00 ,
1477
1474
0x71 , 0xc0 , 0x00 , 0x00 , 0x02 , 0x00 };
1478
1475
1479
- if (info -> MS_Status . WtP )
1476
+ if (info -> MS_Status & MS_WtP )
1480
1477
usb_stor_set_xfer_buf (mediaWP , 12 , srb );
1481
1478
else
1482
1479
usb_stor_set_xfer_buf (mediaNoWP , 12 , srb );
@@ -1495,7 +1492,7 @@ static int ms_scsi_read_capacity(struct us_data *us, struct scsi_cmnd *srb)
1495
1492
1496
1493
usb_stor_dbg (us , "ms_scsi_read_capacity\n" );
1497
1494
bl_len = 0x200 ;
1498
- if (info -> MS_Status . IsMSPro )
1495
+ if (info -> MS_Status & MS_IsMSPro )
1499
1496
bl_num = info -> MSP_TotalBlock - 1 ;
1500
1497
else
1501
1498
bl_num = info -> MS_Lib .NumberOfLogBlock * info -> MS_Lib .blockSize * 2 - 1 ;
@@ -1650,7 +1647,7 @@ static int ms_scsi_read(struct us_data *us, struct scsi_cmnd *srb)
1650
1647
if (bn > info -> bl_num )
1651
1648
return USB_STOR_TRANSPORT_ERROR ;
1652
1649
1653
- if (info -> MS_Status . IsMSPro ) {
1650
+ if (info -> MS_Status & MS_IsMSPro ) {
1654
1651
result = ene_load_bincode (us , MSP_RW_PATTERN );
1655
1652
if (result != USB_STOR_XFER_GOOD ) {
1656
1653
usb_stor_dbg (us , "Load MPS RW pattern Fail !!\n" );
@@ -1751,7 +1748,7 @@ static int ms_scsi_write(struct us_data *us, struct scsi_cmnd *srb)
1751
1748
if (bn > info -> bl_num )
1752
1749
return USB_STOR_TRANSPORT_ERROR ;
1753
1750
1754
- if (info -> MS_Status . IsMSPro ) {
1751
+ if (info -> MS_Status & MS_IsMSPro ) {
1755
1752
result = ene_load_bincode (us , MSP_RW_PATTERN );
1756
1753
if (result != USB_STOR_XFER_GOOD ) {
1757
1754
pr_info ("Load MSP RW pattern Fail !!\n" );
@@ -1859,12 +1856,12 @@ static int ene_get_card_status(struct us_data *us, u8 *buf)
1859
1856
1860
1857
tmpreg = (u16 ) reg4b ;
1861
1858
reg4b = * (u32 * )(& buf [0x14 ]);
1862
- if (info -> SD_Status . HiCapacity && ! info -> SD_Status . IsMMC )
1859
+ if (( info -> SD_Status & SD_HiCapacity ) && !( info -> SD_Status & SD_IsMMC ) )
1863
1860
info -> HC_C_SIZE = (reg4b >> 8 ) & 0x3fffff ;
1864
1861
1865
1862
info -> SD_C_SIZE = ((tmpreg & 0x03 ) << 10 ) | (u16 )(reg4b >> 22 );
1866
1863
info -> SD_C_SIZE_MULT = (u8 )(reg4b >> 7 ) & 0x07 ;
1867
- if (info -> SD_Status . HiCapacity && info -> SD_Status . IsMMC )
1864
+ if (( info -> SD_Status & SD_HiCapacity ) && ( info -> SD_Status & SD_IsMMC ) )
1868
1865
info -> HC_C_SIZE = * (u32 * )(& buf [0x100 ]);
1869
1866
1870
1867
if (info -> SD_READ_BL_LEN > SD_BLOCK_LEN ) {
@@ -2076,6 +2073,7 @@ static int ene_ms_init(struct us_data *us)
2076
2073
u16 MSP_BlockSize , MSP_UserAreaBlocks ;
2077
2074
struct ene_ub6250_info * info = (struct ene_ub6250_info * ) us -> extra ;
2078
2075
u8 * bbuf = info -> bbuf ;
2076
+ unsigned int s ;
2079
2077
2080
2078
printk (KERN_INFO "transport --- ENE_MSInit\n" );
2081
2079
@@ -2100,15 +2098,16 @@ static int ene_ms_init(struct us_data *us)
2100
2098
return USB_STOR_TRANSPORT_ERROR ;
2101
2099
}
2102
2100
/* the same part to test ENE */
2103
- info -> MS_Status = * (struct MS_STATUS * ) bbuf ;
2104
-
2105
- if (info -> MS_Status .Insert && info -> MS_Status .Ready ) {
2106
- printk (KERN_INFO "Insert = %x\n" , info -> MS_Status .Insert );
2107
- printk (KERN_INFO "Ready = %x\n" , info -> MS_Status .Ready );
2108
- printk (KERN_INFO "IsMSPro = %x\n" , info -> MS_Status .IsMSPro );
2109
- printk (KERN_INFO "IsMSPHG = %x\n" , info -> MS_Status .IsMSPHG );
2110
- printk (KERN_INFO "WtP= %x\n" , info -> MS_Status .WtP );
2111
- if (info -> MS_Status .IsMSPro ) {
2101
+ info -> MS_Status = bbuf [0 ];
2102
+
2103
+ s = info -> MS_Status ;
2104
+ if ((s & MS_Insert ) && (s & MS_Ready )) {
2105
+ printk (KERN_INFO "Insert = %x\n" , !!(s & MS_Insert ));
2106
+ printk (KERN_INFO "Ready = %x\n" , !!(s & MS_Ready ));
2107
+ printk (KERN_INFO "IsMSPro = %x\n" , !!(s & MS_IsMSPro ));
2108
+ printk (KERN_INFO "IsMSPHG = %x\n" , !!(s & MS_IsMSPHG ));
2109
+ printk (KERN_INFO "WtP= %x\n" , !!(s & MS_WtP ));
2110
+ if (s & MS_IsMSPro ) {
2112
2111
MSP_BlockSize = (bbuf [6 ] << 8 ) | bbuf [7 ];
2113
2112
MSP_UserAreaBlocks = (bbuf [10 ] << 8 ) | bbuf [11 ];
2114
2113
info -> MSP_TotalBlock = MSP_BlockSize * MSP_UserAreaBlocks ;
@@ -2169,17 +2168,17 @@ static int ene_sd_init(struct us_data *us)
2169
2168
return USB_STOR_TRANSPORT_ERROR ;
2170
2169
}
2171
2170
2172
- info -> SD_Status = * ( struct SD_STATUS * ) bbuf ;
2173
- if (info -> SD_Status . Insert && info -> SD_Status . Ready ) {
2174
- struct SD_STATUS * s = & info -> SD_Status ;
2171
+ info -> SD_Status = bbuf [ 0 ] ;
2172
+ if (( info -> SD_Status & SD_Insert ) && ( info -> SD_Status & SD_Ready ) ) {
2173
+ unsigned int s = info -> SD_Status ;
2175
2174
2176
2175
ene_get_card_status (us , bbuf );
2177
- usb_stor_dbg (us , "Insert = %x\n" , s -> Insert );
2178
- usb_stor_dbg (us , "Ready = %x\n" , s -> Ready );
2179
- usb_stor_dbg (us , "IsMMC = %x\n" , s -> IsMMC );
2180
- usb_stor_dbg (us , "HiCapacity = %x\n" , s -> HiCapacity );
2181
- usb_stor_dbg (us , "HiSpeed = %x\n" , s -> HiSpeed );
2182
- usb_stor_dbg (us , "WtP = %x\n" , s -> WtP );
2176
+ usb_stor_dbg (us , "Insert = %x\n" , !!( s & SD_Insert ) );
2177
+ usb_stor_dbg (us , "Ready = %x\n" , !!( s & SD_Ready ) );
2178
+ usb_stor_dbg (us , "IsMMC = %x\n" , !!( s & SD_IsMMC ) );
2179
+ usb_stor_dbg (us , "HiCapacity = %x\n" , !!( s & SD_HiCapacity ) );
2180
+ usb_stor_dbg (us , "HiSpeed = %x\n" , !!( s & SD_HiSpeed ) );
2181
+ usb_stor_dbg (us , "WtP = %x\n" , !!( s & SD_WtP ) );
2183
2182
} else {
2184
2183
usb_stor_dbg (us , "SD Card Not Ready --- %x\n" , bbuf [0 ]);
2185
2184
return USB_STOR_TRANSPORT_ERROR ;
@@ -2201,14 +2200,14 @@ static int ene_init(struct us_data *us)
2201
2200
2202
2201
misc_reg03 = bbuf [0 ];
2203
2202
if (misc_reg03 & 0x01 ) {
2204
- if (!info -> SD_Status . Ready ) {
2203
+ if (!( info -> SD_Status & SD_Ready ) ) {
2205
2204
result = ene_sd_init (us );
2206
2205
if (result != USB_STOR_XFER_GOOD )
2207
2206
return USB_STOR_TRANSPORT_ERROR ;
2208
2207
}
2209
2208
}
2210
2209
if (misc_reg03 & 0x02 ) {
2211
- if (!info -> MS_Status . Ready ) {
2210
+ if (!( info -> MS_Status & MS_Ready ) ) {
2212
2211
result = ene_ms_init (us );
2213
2212
if (result != USB_STOR_XFER_GOOD )
2214
2213
return USB_STOR_TRANSPORT_ERROR ;
@@ -2307,14 +2306,14 @@ static int ene_transport(struct scsi_cmnd *srb, struct us_data *us)
2307
2306
2308
2307
/*US_DEBUG(usb_stor_show_command(us, srb)); */
2309
2308
scsi_set_resid (srb , 0 );
2310
- if (unlikely (!(info -> SD_Status . Ready || info -> MS_Status . Ready )))
2309
+ if (unlikely (!(info -> SD_Status & SD_Ready ) || ( info -> MS_Status & MS_Ready )))
2311
2310
result = ene_init (us );
2312
2311
if (result == USB_STOR_XFER_GOOD ) {
2313
2312
result = USB_STOR_TRANSPORT_ERROR ;
2314
- if (info -> SD_Status . Ready )
2313
+ if (info -> SD_Status & SD_Ready )
2315
2314
result = sd_scsi_irp (us , srb );
2316
2315
2317
- if (info -> MS_Status . Ready )
2316
+ if (info -> MS_Status & MS_Ready )
2318
2317
result = ms_scsi_irp (us , srb );
2319
2318
}
2320
2319
return result ;
@@ -2378,7 +2377,6 @@ static int ene_ub6250_probe(struct usb_interface *intf,
2378
2377
2379
2378
static int ene_ub6250_resume (struct usb_interface * iface )
2380
2379
{
2381
- u8 tmp = 0 ;
2382
2380
struct us_data * us = usb_get_intfdata (iface );
2383
2381
struct ene_ub6250_info * info = (struct ene_ub6250_info * )(us -> extra );
2384
2382
@@ -2390,17 +2388,16 @@ static int ene_ub6250_resume(struct usb_interface *iface)
2390
2388
mutex_unlock (& us -> dev_mutex );
2391
2389
2392
2390
info -> Power_IsResum = true;
2393
- /*info->SD_Status.Ready = 0 ; */
2394
- info -> SD_Status = * ( struct SD_STATUS * ) & tmp ;
2395
- info -> MS_Status = * ( struct MS_STATUS * ) & tmp ;
2396
- info -> SM_Status = * ( struct SM_STATUS * ) & tmp ;
2391
+ /* info->SD_Status &= ~SD_Ready ; */
2392
+ info -> SD_Status = 0 ;
2393
+ info -> MS_Status = 0 ;
2394
+ info -> SM_Status = 0 ;
2397
2395
2398
2396
return 0 ;
2399
2397
}
2400
2398
2401
2399
static int ene_ub6250_reset_resume (struct usb_interface * iface )
2402
2400
{
2403
- u8 tmp = 0 ;
2404
2401
struct us_data * us = usb_get_intfdata (iface );
2405
2402
struct ene_ub6250_info * info = (struct ene_ub6250_info * )(us -> extra );
2406
2403
@@ -2412,10 +2409,10 @@ static int ene_ub6250_reset_resume(struct usb_interface *iface)
2412
2409
* the device
2413
2410
*/
2414
2411
info -> Power_IsResum = true;
2415
- /*info->SD_Status.Ready = 0 ; */
2416
- info -> SD_Status = * ( struct SD_STATUS * ) & tmp ;
2417
- info -> MS_Status = * ( struct MS_STATUS * ) & tmp ;
2418
- info -> SM_Status = * ( struct SM_STATUS * ) & tmp ;
2412
+ /* info->SD_Status &= ~SD_Ready ; */
2413
+ info -> SD_Status = 0 ;
2414
+ info -> MS_Status = 0 ;
2415
+ info -> SM_Status = 0 ;
2419
2416
2420
2417
return 0 ;
2421
2418
}
0 commit comments