From nobody Mon Oct 6 03:02:01 2025 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EE6D2E36EC; Fri, 25 Jul 2025 13:55:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753451714; cv=none; b=MuXCYVs+9SPdUykVUidlrgfQQx0BOPFUuzK82Pvi8QzsJcwJJ2V90OKIe+DNLqB8PkF61YZN+UjCvcLuH89qldpfviVWl8weWuPqn9mbzEeHtJXY5rJb23Ab+4RJuzgmF1FhtIi/KDl7ougJBTgVRwV4YQhwAwW7NFerglM4hFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753451714; c=relaxed/simple; bh=1QGaiJuXGooJbjDTXt8uTgaAYzOPuDwwDL5PCOM4O+I=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=HilI0sm/wFCE/SzozI5tQWJHRhjb+Y5M9/r/fMreCk47Yfuriu2W9K4c/Q/IvWNyOPrF4CUqh+V1bnXLJyZFG9BLvt2w7gAWM0A3EzBF3OfsJJz+Cb0cg1BzDyGIgSuM2qpCP5tRxZYIe4Kv/1Kugtc9NWBlXZHsr+RVuS9MZbM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NKBTVhP4; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NKBTVhP4" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-311e2cc157bso1945517a91.2; Fri, 25 Jul 2025 06:55:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753451710; x=1754056510; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=WNTDfjxhZB9Hjmc5HFtSd7mAOD+kVA3++KbmQ5chN8w=; b=NKBTVhP4SBzimb3WBJC65IOvMpPP+w5EyZQisXfXWSPykdlPealfGOwLPlzSOCnDAm pP7UjqtXVsv/vwHTr+QY3amMn7M3KWd/lufZSmqlHS067V6l/3vwwA3ISErWEPag9WaU UwND+0lMTcw4XTl0IcaZj4ixFgisatlRTf/D7bzyjk8xmvmgN6r29rmiiHrJnUi7DNZk yd8RvFOE90KiGsYibiqnEP0F1ZgxolusvkfdXep7PEJhIOYgJNq6NubIu0yUPIq8scLT iMmxw9GXPxZe9IvAD1Vv/RG0DMTldLZ4SeIfmInuS8n+zrRkjOZCI93NGWZPUOFAdZuF mS/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753451710; x=1754056510; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WNTDfjxhZB9Hjmc5HFtSd7mAOD+kVA3++KbmQ5chN8w=; b=VVX+HhpfO/qMcuF8peGeRIcisVRzjIMJ1Z3Eop6HQYE5H+BtrZ0q67vDknnxczxmWB jGTHWjFlshMl7aZFE/jFSnivEfRfhDfyR0MxtrjJXy+MxZ55UragSYI1bdpO+gpWa6er mopksf7QqetJ3vr0VWjEKIkg5XZWc/XTamyYFhX1gI/NRrHcKwD6Lbu+njvlIVhB89eb 1tnBVivsL+jyQmbzaSgs9XauGWK532MLohbIPaHERteGYeZXOLAcj8HMPB6U8tiv06dh i2WRI9k2fQ6WQIE+rlpSSR+bLW+2DI9/QnXs3vNH390YEgvijqjXWp9J8t6Mah1p8YqZ B1ww== X-Forwarded-Encrypted: i=1; AJvYcCVR5VxL7g5F1bYm+mdrmvr78vQZmpKlTQtVQG0XrgyUBP3+YGd2HSSMx0vxGc8WAqYOU4dXucrzbdzF@vger.kernel.org, AJvYcCWnyDSUAjq5wr3Ovm1/XNPC1qSyboRKn2deBWlxPWJyI/zlsOukv3U1zj/u41FS7ef6wXeE+UB3TG+dB7A=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6vJb3/OMLcdnmYut6frzkCHYIqAIrxGIRPdHDtpxkE9mobSjH CmK4AAfCs994s5cxTn73my0rn7KeMvVV6hI63SDnAbg3FB4Qd4sekxEusMH0khAt X-Gm-Gg: ASbGncu6/CspKKAqD8wh4uJrOhuRcxmwoIlNS/QMtZIdRLL/oRSGRKMy8A4x7sMNtNF hfJo6BgEm6yAs4KrDawlCfgtBdInChufYKHZm1dQ85vvLG+mLOugOmUO9pkbjSgFMhnTd63kOY0 khykRpzBdQOsqjdaWwP8Vrp2g92hTeJut8oPX2r4sD+h/K1PgjWG29UTM4ZXXWmTIf9JEvu7jCU mSx0wvIUDBrNa9cHyvCW8yiW6hOJ6Bs3UQ+eGF7C3qY1BNY4algEDWJRVBH2fbSp/flZAsLje9I U2/IP+f2ifK86AreKzUUesHESyGKoSU1tQytXmk8DNMBA/k8du6Fn6/JsSe06ArpBTmO5WMz5+m MGBid+AelYc5W0M95hvwsfa+2Ioa6LJQIe81MKfhFvgHQY75US/Hr6GTz3u2CazqhEWDruwrQp6 lx7w== X-Google-Smtp-Source: AGHT+IHPMuDw156nJnJs5OgyJZThkk3pLHkyqwdIWaDAQFK8CUMKxMGvzXSy8IV1gB0tySPdyAa+hg== X-Received: by 2002:a17:90a:fc4e:b0:313:d79d:87eb with SMTP id 98e67ed59e1d1-31e77a32a33mr3207824a91.35.1753451710127; Fri, 25 Jul 2025 06:55:10 -0700 (PDT) Received: from SIQOL-WIN-0002-DARSHAN.localdomain ([49.36.70.207]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-31e63a766d9sm2797962a91.2.2025.07.25.06.55.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jul 2025 06:55:09 -0700 (PDT) From: "Darshan R." To: stern@rowland.harvard.edu Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-kernel@vger.kernel.org, "Darshan R." Subject: [PATCH] usb: storage: Checkpatch fix done and Clean up coding style Date: Fri, 25 Jul 2025 13:55:33 +0000 Message-ID: <20250725135533.8410-1-rathod.darshan.0896@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The shuttle_usbat.c driver has several coding style inconsistencies that de= viate from the Linux kernel standard. This makes the code harder to read and maintain. This patch is a pure cleanup effort to address these style issues. The changes include: - Adding proper spacing around operators (=3D, *, +, !=3D, etc.). - Adjusting pointer declarations to the standard type *var style. - Fixing spacing in pointer casts, e.g., (struct usbat_info *). - Removing the redundant =3D 0 initializer for the static transferred variable, as it's guaranteed to be zero-initialized. - Tidying up miscellaneous whitespace and removing extra blank lines. These changes were guided by checkpatch.pl. No functional changes have been made. Signed-off-by: Darshan R. --- drivers/usb/storage/shuttle_usbat.c | 252 +++++++++++++--------------- 1 file changed, 120 insertions(+), 132 deletions(-) diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shut= tle_usbat.c index 27faa0ead11d..d4a5ad500886 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c @@ -16,7 +16,7 @@ * market by using some kind of translation from ATAPI to USB on the host, * and the peripheral would translate from USB back to ATAPI. * - * SCM Microsystems (www.scmmicro.com) makes a device, sold to OEM's only,=20 + * SCM Microsystems (www.scmmicro.com) makes a device, sold to OEM's only, * which does the USB-to-ATAPI conversion. By obtaining the data sheet on * their device under nondisclosure agreement, I have been able to write * this driver for Linux. @@ -141,19 +141,18 @@ struct usbat_info { unsigned long sense_ascq; /* additional sense code qualifier */ }; =20 -#define short_pack(LSB,MSB) ( ((u16)(LSB)) | ( ((u16)(MSB))<<8 ) ) -#define LSB_of(s) ((s)&0xFF) -#define MSB_of(s) ((s)>>8) +#define short_pack(LSB, MSB) (((u16)(LSB)) | (((u16)(MSB)) << 8)) +#define LSB_of(s) ((s) & 0xFF) +#define MSB_of(s) ((s) >> 8) =20 -static int transferred =3D 0; +static int transferred; =20 -static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *u= s); +static int usbat_flash_transport(struct scsi_cmnd *srb, struct us_data *us= ); static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *= us); =20 static int init_usbat_cd(struct us_data *us); static int init_usbat_flash(struct us_data *us); =20 - /* * The table of devices */ @@ -214,7 +213,7 @@ static void usbat_pack_ata_sector_cmd(unsigned char *bu= f, */ static int usbat_get_device_type(struct us_data *us) { - return ((struct usbat_info*)us->extra)->devicetype; + return ((struct usbat_info *)us->extra)->devicetype; } =20 /* @@ -257,7 +256,7 @@ static int usbat_write(struct us_data *us, * Convenience function to perform a bulk read */ static int usbat_bulk_read(struct us_data *us, - void* buf, + void *buf, unsigned int len, int use_sg) { @@ -272,7 +271,7 @@ static int usbat_bulk_read(struct us_data *us, * Convenience function to perform a bulk write */ static int usbat_bulk_write(struct us_data *us, - void* buf, + void *buf, unsigned int len, int use_sg) { @@ -303,6 +302,7 @@ static int usbat_execute_command(struct us_data *us, static int usbat_get_status(struct us_data *us, unsigned char *status) { int rc; + rc =3D usbat_read(us, USBAT_ATA, USBAT_ATA_STATUS, status); =20 usb_stor_dbg(us, "0x%02X\n", *status); @@ -405,11 +405,10 @@ static int usbat_wait_not_busy(struct us_data *us, in= t minutes) * minutes! */ =20 - for (i=3D0; i<1200+minutes*60; i++) { - - result =3D usbat_get_status(us, status); + for (i =3D 0; i < 1200 + minutes * 60; i++) { + result =3D usbat_get_status(us, status); =20 - if (result!=3DUSB_STOR_XFER_GOOD) + if (result !=3D USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; if (*status & 0x01) { /* check condition */ result =3D usbat_read(us, USBAT_ATA, 0x10, status); @@ -418,16 +417,16 @@ static int usbat_wait_not_busy(struct us_data *us, in= t minutes) if (*status & 0x20) /* device fault */ return USB_STOR_TRANSPORT_FAILED; =20 - if ((*status & 0x80)=3D=3D0x00) { /* not busy */ + if ((*status & 0x80) =3D=3D 0x00) { /* not busy */ usb_stor_dbg(us, "Waited not busy for %d steps\n", i); return USB_STOR_TRANSPORT_GOOD; } =20 - if (i<500) + if (i < 500) msleep(10); /* 5 seconds */ - else if (i<700) + else if (i < 700) msleep(50); /* 10 seconds */ - else if (i<1200) + else if (i < 1200) msleep(100); /* 50 seconds */ else msleep(1000); /* X minutes */ @@ -442,7 +441,7 @@ static int usbat_wait_not_busy(struct us_data *us, int = minutes) * Read block data from the data register */ static int usbat_read_block(struct us_data *us, - void* buf, + void *buf, unsigned short len, int use_sg) { @@ -475,7 +474,7 @@ static int usbat_read_block(struct us_data *us, */ static int usbat_write_block(struct us_data *us, unsigned char access, - void* buf, + void *buf, unsigned short len, int minutes, int use_sg) @@ -535,22 +534,21 @@ static int usbat_hp8200e_rw_block_test(struct us_data= *us, unsigned char *data =3D us->iobuf; unsigned char *status =3D us->iobuf; =20 - BUG_ON(num_registers > US_IOBUF_SIZE/2); - - for (i=3D0; i<20; i++) { + BUG_ON(num_registers > US_IOBUF_SIZE / 2); =20 + for (i =3D 0; i < 20; i++) { /* * The first time we send the full command, which consists * of downloading the SCSI command followed by downloading * the data via a write-and-test. Any other time we only * send the command to download the data -- the SCSI command * is still 'active' in some sense in the device. - *=20 + * * We're only going to try sending the data 10 times. After * that, we just return a failure. */ =20 - if (i=3D=3D0) { + if (i =3D=3D 0) { cmdlen =3D 16; /* * Write to multiple registers @@ -564,39 +562,37 @@ static int usbat_hp8200e_rw_block_test(struct us_data= *us, command[3] =3D 0x17; command[4] =3D 0xFC; command[5] =3D 0xE7; - command[6] =3D LSB_of(num_registers*2); - command[7] =3D MSB_of(num_registers*2); + command[6] =3D LSB_of(num_registers * 2); + command[7] =3D MSB_of(num_registers * 2); } else cmdlen =3D 8; =20 /* Conditionally read or write blocks */ - command[cmdlen-8] =3D (direction=3D=3DDMA_TO_DEVICE ? 0x40 : 0xC0); - command[cmdlen-7] =3D access | - (direction=3D=3DDMA_TO_DEVICE ? + command[cmdlen - 8] =3D (direction =3D=3D DMA_TO_DEVICE ? 0x40 : 0xC0); + command[cmdlen - 7] =3D access | + (direction =3D=3D DMA_TO_DEVICE ? USBAT_CMD_COND_WRITE_BLOCK : USBAT_CMD_COND_READ_BLOCK); - command[cmdlen-6] =3D data_reg; - command[cmdlen-5] =3D status_reg; - command[cmdlen-4] =3D timeout; - command[cmdlen-3] =3D qualifier; - command[cmdlen-2] =3D LSB_of(len); - command[cmdlen-1] =3D MSB_of(len); + command[cmdlen - 6] =3D data_reg; + command[cmdlen - 5] =3D status_reg; + command[cmdlen - 4] =3D timeout; + command[cmdlen - 3] =3D qualifier; + command[cmdlen - 2] =3D LSB_of(len); + command[cmdlen - 1] =3D MSB_of(len); =20 result =3D usbat_execute_command(us, command, cmdlen); =20 if (result !=3D USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; =20 - if (i=3D=3D0) { - - for (j=3D0; jsend_bulk_pipe) < 0) return USB_STOR_TRANSPORT_ERROR; @@ -639,12 +635,12 @@ static int usbat_hp8200e_rw_block_test(struct us_data= *us, * Read status: is the device angry, or just busy? */ =20 - result =3D usbat_read(us, USBAT_ATA,=20 - direction=3D=3DDMA_TO_DEVICE ? + result =3D usbat_read(us, USBAT_ATA, + direction =3D=3D DMA_TO_DEVICE ? USBAT_ATA_STATUS : USBAT_ATA_ALTSTATUS, status); =20 - if (result!=3DUSB_STOR_XFER_GOOD) + if (result !=3D USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; if (*status & 0x01) /* check condition */ return USB_STOR_TRANSPORT_FAILED; @@ -683,7 +679,7 @@ static int usbat_multiple_write(struct us_data *us, unsigned char *data =3D us->iobuf; unsigned char *command =3D us->iobuf; =20 - BUG_ON(num_registers > US_IOBUF_SIZE/2); + BUG_ON(num_registers > US_IOBUF_SIZE / 2); =20 /* Write to multiple registers, ATA access */ command[0] =3D 0x40; @@ -696,8 +692,8 @@ static int usbat_multiple_write(struct us_data *us, command[5] =3D 0; =20 /* Number of bytes to be transferred (incl. addresses and data) */ - command[6] =3D LSB_of(num_registers*2); - command[7] =3D MSB_of(num_registers*2); + command[6] =3D LSB_of(num_registers * 2); + command[7] =3D MSB_of(num_registers * 2); =20 /* The setup command */ result =3D usbat_execute_command(us, command, 8); @@ -705,13 +701,13 @@ static int usbat_multiple_write(struct us_data *us, return USB_STOR_TRANSPORT_ERROR; =20 /* Create the reg/data, reg/data sequence */ - for (i=3D0; isense_key =3D UNIT_ATTENTION; info->sense_asc =3D 0x28; info->sense_ascq =3D 0x00; @@ -994,12 +990,12 @@ static int usbat_identify_device(struct us_data *us, * CDROM drives), it should succeed. */ rc =3D usbat_write(us, USBAT_ATA, USBAT_ATA_CMD, 0xA1); - if (rc !=3D USB_STOR_XFER_GOOD) - return USB_STOR_TRANSPORT_ERROR; + if (rc !=3D USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; =20 rc =3D usbat_get_status(us, &status); - if (rc !=3D USB_STOR_XFER_GOOD) - return USB_STOR_TRANSPORT_ERROR; + if (rc !=3D USB_STOR_XFER_GOOD) + return USB_STOR_TRANSPORT_ERROR; =20 /* Check for error bit, or if the command 'fell through' */ if (status =3D=3D 0xA1 || !(status & 0x01)) { @@ -1092,7 +1088,7 @@ static int usbat_flash_get_sector_count(struct us_dat= a *us, info->sectors =3D ((u32)(reply[117]) << 24) | ((u32)(reply[116]) << 16) | ((u32)(reply[115]) << 8) | - ((u32)(reply[114]) ); + ((u32)(reply[114])); =20 rc =3D USB_STOR_TRANSPORT_GOOD; =20 @@ -1160,7 +1156,7 @@ static int usbat_flash_read_data(struct us_data *us, */ len =3D min(totallen, alloclen); thistime =3D (len / info->ssize) & 0xff; -=20 + /* ATA command 0x20 (READ SECTORS) */ usbat_pack_ata_sector_cmd(command, thistime, sector, 0x20); =20 @@ -1173,9 +1169,9 @@ static int usbat_flash_read_data(struct us_data *us, result =3D usbat_read_blocks(us, buffer, len, 0); if (result !=3D USB_STOR_TRANSPORT_GOOD) goto leave; - =20 + usb_stor_dbg(us, "%d bytes\n", len); -=09 + /* Store the data in the transfer buffer */ usb_stor_access_xfer_buf(buffer, len, us->srb, &sg, &sg_offset, TO_XFER_BUF); @@ -1301,7 +1297,7 @@ static int usbat_hp8200e_handle_read10(struct us_data= *us, =20 if (scsi_bufflen(srb) < 0x10000) { =20 - result =3D usbat_hp8200e_rw_block_test(us, USBAT_ATA,=20 + result =3D usbat_hp8200e_rw_block_test(us, USBAT_ATA, registers, data, 19, USBAT_ATA_DATA, USBAT_ATA_STATUS, 0xFD, (USBAT_QUAL_FCQ | USBAT_QUAL_ALQ), @@ -1320,10 +1316,10 @@ static int usbat_hp8200e_handle_read10(struct us_da= ta *us, * (see linux/drivers/scsi/sr.c). */ =20 - if (data[7+0] =3D=3D GPCMD_READ_CD) { - len =3D short_pack(data[7+9], data[7+8]); + if (data[7 + 0] =3D=3D GPCMD_READ_CD) { + len =3D short_pack(data[7 + 9], data[7 + 8]); len <<=3D 16; - len |=3D data[7+7]; + len |=3D data[7 + 7]; usb_stor_dbg(us, "GPCMD_READ_CD: len %d\n", len); srb->transfersize =3D scsi_bufflen(srb)/len; } @@ -1340,15 +1336,15 @@ static int usbat_hp8200e_handle_read10(struct us_da= ta *us, * bounce buffer and the actual transfer buffer. */ =20 - len =3D (65535/srb->transfersize) * srb->transfersize; + len =3D (65535 / srb->transfersize) * srb->transfersize; usb_stor_dbg(us, "Max read is %d bytes\n", len); len =3D min(len, scsi_bufflen(srb)); buffer =3D kmalloc(len, GFP_NOIO); if (buffer =3D=3D NULL) /* bloody hell! */ return USB_STOR_TRANSPORT_FAILED; - sector =3D short_pack(data[7+3], data[7+2]); + sector =3D short_pack(data[7 + 3], data[7 + 2]); sector <<=3D 16; - sector |=3D short_pack(data[7+5], data[7+4]); + sector |=3D short_pack(data[7 + 5], data[7 + 4]); transferred =3D 0; =20 while (transferred !=3D scsi_bufflen(srb)) { @@ -1356,27 +1352,26 @@ static int usbat_hp8200e_handle_read10(struct us_da= ta *us, if (len > scsi_bufflen(srb) - transferred) len =3D scsi_bufflen(srb) - transferred; =20 - data[3] =3D len&0xFF; /* (cylL) =3D expected length (L) */ - data[4] =3D (len>>8)&0xFF; /* (cylH) =3D expected length (H) */ + data[3] =3D len & 0xFF; /* (cylL) =3D expected length (L) */ + data[4] =3D (len >> 8) & 0xFF; /* (cylH) =3D expected length (H) */ =20 /* Fix up the SCSI command sector and num sectors */ =20 - data[7+2] =3D MSB_of(sector>>16); /* SCSI command sector */ - data[7+3] =3D LSB_of(sector>>16); - data[7+4] =3D MSB_of(sector&0xFFFF); - data[7+5] =3D LSB_of(sector&0xFFFF); - if (data[7+0] =3D=3D GPCMD_READ_CD) - data[7+6] =3D 0; - data[7+7] =3D MSB_of(len / srb->transfersize); /* SCSI command */ - data[7+8] =3D LSB_of(len / srb->transfersize); /* num sectors */ - - result =3D usbat_hp8200e_rw_block_test(us, USBAT_ATA,=20 - registers, data, 19, - USBAT_ATA_DATA, USBAT_ATA_STATUS, 0xFD,=20 - (USBAT_QUAL_FCQ | USBAT_QUAL_ALQ), - DMA_FROM_DEVICE, - buffer, - len, 0, 1); + data[7 + 2] =3D MSB_of(sector >> 16); /* SCSI command sector */ + data[7 + 3] =3D LSB_of(sector >> 16); + data[7 + 4] =3D MSB_of(sector & 0xFFFF); + data[7 + 5] =3D LSB_of(sector & 0xFFFF); + if (data[7 + 0] =3D=3D GPCMD_READ_CD) + data[7 + 6] =3D 0; + data[7 + 7] =3D MSB_of(len / srb->transfersize); /* SCSI command */ + data[7 + 8] =3D LSB_of(len / srb->transfersize); /* num sectors */ + + result =3D usbat_hp8200e_rw_block_test(us, USBAT_ATA, + registers, data, 19, + USBAT_ATA_DATA, USBAT_ATA_STATUS, 0xFD, + (USBAT_QUAL_FCQ | USBAT_QUAL_ALQ), + DMA_FROM_DEVICE, + buffer, len, 0, 1); =20 if (result !=3D USB_STOR_TRANSPORT_GOOD) break; @@ -1407,35 +1402,35 @@ static int usbat_select_and_test_registers(struct u= s_data *us) USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; =20 - if (usbat_read(us, USBAT_ATA, USBAT_ATA_STATUS, status) !=3D=20 + if (usbat_read(us, USBAT_ATA, USBAT_ATA_STATUS, status) !=3D USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; =20 - if (usbat_read(us, USBAT_ATA, USBAT_ATA_DEVICE, status) !=3D=20 + if (usbat_read(us, USBAT_ATA, USBAT_ATA_DEVICE, status) !=3D USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; =20 - if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_ME, status) !=3D=20 + if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_ME, status) !=3D USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; =20 - if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_HI, status) !=3D=20 + if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_HI, status) !=3D USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; =20 - if (usbat_write(us, USBAT_ATA, USBAT_ATA_LBA_ME, 0x55) !=3D=20 + if (usbat_write(us, USBAT_ATA, USBAT_ATA_LBA_ME, 0x55) !=3D USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; =20 - if (usbat_write(us, USBAT_ATA, USBAT_ATA_LBA_HI, 0xAA) !=3D=20 + if (usbat_write(us, USBAT_ATA, USBAT_ATA_LBA_HI, 0xAA) !=3D USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; =20 - if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_ME, status) !=3D=20 + if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_ME, status) !=3D USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; =20 - if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_ME, status) !=3D=20 + if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_ME, status) !=3D USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; } @@ -1458,7 +1453,7 @@ static int init_usbat(struct us_data *us, int devicet= ype) if (!us->extra) return -ENOMEM; =20 - info =3D (struct usbat_info *) (us->extra); + info =3D (struct usbat_info *)(us->extra); =20 /* Enable peripheral control signals */ rc =3D usbat_write_user_io(us, @@ -1532,7 +1527,7 @@ static int init_usbat(struct us_data *us, int devicet= ype) =20 usb_stor_dbg(us, "INIT 10\n"); =20 - if (usbat_get_device_type(us) =3D=3D USBAT_DEV_FLASH) {=20 + if (usbat_get_device_type(us) =3D=3D USBAT_DEV_FLASH) { subcountH =3D 0x02; subcountL =3D 0x00; } @@ -1564,7 +1559,7 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *= srb, struct us_data *us) * Send A0 (ATA PACKET COMMAND). * Note: I guess we're never going to get any of the ATA * commands... just ATA Packet Commands. - */ + */ =20 registers[0] =3D USBAT_ATA_FEATURES; registers[1] =3D USBAT_ATA_SECCNT; @@ -1576,14 +1571,14 @@ static int usbat_hp8200e_transport(struct scsi_cmnd= *srb, struct us_data *us) data[0] =3D 0x00; data[1] =3D 0x00; data[2] =3D 0x00; - data[3] =3D len&0xFF; /* (cylL) =3D expected length (L) */ - data[4] =3D (len>>8)&0xFF; /* (cylH) =3D expected length (H) */ - data[5] =3D 0xB0; /* (device sel) =3D slave */ - data[6] =3D 0xA0; /* (command) =3D ATA PACKET COMMAND */ + data[3] =3D len & 0xFF; /* (cylL) =3D expected length (L) */ + data[4] =3D (len >> 8) & 0xFF; /* (cylH) =3D expected length (H) */ + data[5] =3D 0xB0; /* (device sel) =3D slave */ + data[6] =3D 0xA0; /* (command) =3D ATA PACKET COMMAND */ =20 - for (i=3D7; i<19; i++) { + for (i =3D 7; i < 19; i++) { registers[i] =3D 0x10; - data[i] =3D (i-7 >=3D srb->cmd_len) ? 0 : srb->cmnd[i-7]; + data[i] =3D (i - 7 >=3D srb->cmd_len) ? 0 : srb->cmnd[i - 7]; } =20 result =3D usbat_get_status(us, status); @@ -1594,8 +1589,7 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *= srb, struct us_data *us) transferred =3D 0; =20 if (srb->sc_data_direction =3D=3D DMA_TO_DEVICE) { - - result =3D usbat_hp8200e_rw_block_test(us, USBAT_ATA,=20 + result =3D usbat_hp8200e_rw_block_test(us, USBAT_ATA, registers, data, 19, USBAT_ATA_DATA, USBAT_ATA_STATUS, 0xFD, (USBAT_QUAL_FCQ | USBAT_QUAL_ALQ), @@ -1614,7 +1608,6 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *= srb, struct us_data *us) srb->cmnd[0] =3D=3D GPCMD_READ_CD) { =20 return usbat_hp8200e_handle_read10(us, registers, data, srb); - } =20 if (len > 0xFFFF) { @@ -1647,28 +1640,24 @@ static int usbat_hp8200e_transport(struct scsi_cmnd= *srb, struct us_data *us) /* If there is response data to be read in then do it here. */ =20 if (len !=3D 0 && (srb->sc_data_direction =3D=3D DMA_FROM_DEVICE)) { - /* How many bytes to read in? Check cylL register */ - - if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_ME, status) !=3D=20 - USB_STOR_XFER_GOOD) { + if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_ME, status) !=3D + USB_STOR_XFER_GOOD) { return USB_STOR_TRANSPORT_ERROR; } =20 if (len > 0xFF) { /* need to read cylH also */ len =3D *status; if (usbat_read(us, USBAT_ATA, USBAT_ATA_LBA_HI, status) !=3D - USB_STOR_XFER_GOOD) { + USB_STOR_XFER_GOOD) { return USB_STOR_TRANSPORT_ERROR; } - len +=3D ((unsigned int) *status)<<8; - } - else + len +=3D ((unsigned int)*status) << 8; + } else len =3D *status; =20 - result =3D usbat_read_block(us, scsi_sglist(srb), len, - scsi_sg_count(srb)); + scsi_sg_count(srb)); } =20 return result; @@ -1677,10 +1666,10 @@ static int usbat_hp8200e_transport(struct scsi_cmnd= *srb, struct us_data *us) /* * Transport for USBAT02-based CompactFlash and similar storage devices */ -static int usbat_flash_transport(struct scsi_cmnd * srb, struct us_data *u= s) +static int usbat_flash_transport(struct scsi_cmnd *srb, struct us_data *us) { int rc; - struct usbat_info *info =3D (struct usbat_info *) (us->extra); + struct usbat_info *info =3D (struct usbat_info *)(us->extra); unsigned long block, blocks; unsigned char *ptr =3D us->iobuf; static const unsigned char inquiry_response[36] =3D { @@ -1713,8 +1702,8 @@ static int usbat_flash_transport(struct scsi_cmnd * s= rb, struct us_data *us) * note: must return the sector number of the last sector, * *not* the total number of sectors */ - ((__be32 *) ptr)[0] =3D cpu_to_be32(info->sectors - 1); - ((__be32 *) ptr)[1] =3D cpu_to_be32(info->ssize); + ((__be32 *)ptr)[0] =3D cpu_to_be32(info->sectors - 1); + ((__be32 *)ptr)[1] =3D cpu_to_be32(info->ssize); usb_stor_set_xfer_buf(ptr, 8, srb); =20 return USB_STOR_TRANSPORT_GOOD; @@ -1741,10 +1730,10 @@ static int usbat_flash_transport(struct scsi_cmnd *= srb, struct us_data *us) * I don't think we'll ever see a READ_12 but support it anyway */ block =3D ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) | - ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); + ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); =20 blocks =3D ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) | - ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); + ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); =20 usb_stor_dbg(us, "READ_12: read block 0x%04lx count %ld\n", block, blocks); @@ -1753,7 +1742,7 @@ static int usbat_flash_transport(struct scsi_cmnd * s= rb, struct us_data *us) =20 if (srb->cmnd[0] =3D=3D WRITE_10) { block =3D ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) | - ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); + ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); =20 blocks =3D ((u32)(srb->cmnd[7]) << 8) | ((u32)(srb->cmnd[8])); =20 @@ -1767,17 +1756,16 @@ static int usbat_flash_transport(struct scsi_cmnd *= srb, struct us_data *us) * I don't think we'll ever see a WRITE_12 but support it anyway */ block =3D ((u32)(srb->cmnd[2]) << 24) | ((u32)(srb->cmnd[3]) << 16) | - ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); + ((u32)(srb->cmnd[4]) << 8) | ((u32)(srb->cmnd[5])); =20 blocks =3D ((u32)(srb->cmnd[6]) << 24) | ((u32)(srb->cmnd[7]) << 16) | - ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); + ((u32)(srb->cmnd[8]) << 8) | ((u32)(srb->cmnd[9])); =20 usb_stor_dbg(us, "WRITE_12: write block 0x%04lx count %ld\n", block, blocks); return usbat_flash_write_data(us, info, block, blocks); } =20 - if (srb->cmnd[0] =3D=3D TEST_UNIT_READY) { usb_stor_dbg(us, "TEST_UNIT_READY\n"); =20 --=20 2.43.0