--- zzzz-none-000/linux-3.10.107/drivers/usb/storage/alauda.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/usb/storage/alauda.c 2021-02-04 17:41:59.000000000 +0000 @@ -42,6 +42,9 @@ #include "transport.h" #include "protocol.h" #include "debug.h" +#include "scsiglue.h" + +#define DRV_NAME "ums-alauda" MODULE_DESCRIPTION("Driver for Alauda-based card readers"); MODULE_AUTHOR("Daniel Drake "); @@ -207,7 +210,8 @@ { 0,} }; -static struct alauda_card_info *alauda_card_find_id(unsigned char id) { +static struct alauda_card_info *alauda_card_find_id(unsigned char id) +{ int i; for (i = 0; alauda_card_ids[i].id != 0; i++) @@ -223,7 +227,8 @@ static unsigned char parity[256]; static unsigned char ecc2[256]; -static void nand_init_ecc(void) { +static void nand_init_ecc(void) +{ int i, j, a; parity[0] = 0; @@ -247,13 +252,10 @@ } /* compute 3-byte ecc on 256 bytes */ -static void nand_compute_ecc(unsigned char *data, unsigned char *ecc) { +static void nand_compute_ecc(unsigned char *data, unsigned char *ecc) +{ int i, j, a; - unsigned char par, bit, bits[8]; - - par = 0; - for (j = 0; j < 8; j++) - bits[j] = 0; + unsigned char par = 0, bit, bits[8] = {0}; /* collect 16 checksum bits */ for (i = 0; i < 256; i++) { @@ -274,11 +276,13 @@ ecc[2] = ecc2[par]; } -static int nand_compare_ecc(unsigned char *data, unsigned char *ecc) { +static int nand_compare_ecc(unsigned char *data, unsigned char *ecc) +{ return (data[0] == ecc[0] && data[1] == ecc[1] && data[2] == ecc[2]); } -static void nand_store_ecc(unsigned char *data, unsigned char *ecc) { +static void nand_store_ecc(unsigned char *data, unsigned char *ecc) +{ memcpy(data, ecc, 3); } @@ -419,14 +423,11 @@ if (alauda_get_media_signature(us, data) != USB_STOR_XFER_GOOD) return USB_STOR_TRANSPORT_ERROR; - usb_stor_dbg(us, "Media signature: %02X %02X %02X %02X\n", - data[0], data[1], data[2], data[3]); + usb_stor_dbg(us, "Media signature: %4ph\n", data); media_info = alauda_card_find_id(data[1]); if (media_info == NULL) { - printk(KERN_WARNING - "alauda_init_media: Unrecognised media signature: " - "%02X %02X %02X %02X\n", - data[0], data[1], data[2], data[3]); + pr_warn("alauda_init_media: Unrecognised media signature: %4ph\n", + data); return USB_STOR_TRANSPORT_ERROR; } @@ -517,7 +518,7 @@ if (rc != USB_STOR_XFER_GOOD) return rc; - usb_stor_dbg(us, "%02X %02X %02X\n", data[0], data[1], data[2]); + usb_stor_dbg(us, "%3ph\n", data); if (data[0] & ALAUDA_STATUS_ERROR) return USB_STOR_XFER_ERROR; @@ -1234,6 +1235,8 @@ return USB_STOR_TRANSPORT_FAILED; } +static struct scsi_host_template alauda_host_template; + static int alauda_probe(struct usb_interface *intf, const struct usb_device_id *id) { @@ -1241,7 +1244,8 @@ int result; result = usb_stor_probe1(&us, intf, id, - (id - alauda_usb_ids) + alauda_unusual_dev_list); + (id - alauda_usb_ids) + alauda_unusual_dev_list, + &alauda_host_template); if (result) return result; @@ -1255,7 +1259,7 @@ } static struct usb_driver alauda_driver = { - .name = "ums-alauda", + .name = DRV_NAME, .probe = alauda_probe, .disconnect = usb_stor_disconnect, .suspend = usb_stor_suspend, @@ -1268,4 +1272,4 @@ .no_dynamic_id = 1, }; -module_usb_driver(alauda_driver); +module_usb_stor_driver(alauda_driver, alauda_host_template, DRV_NAME);