Commit 0ec3c7e8 authored by Duncan Sands's avatar Duncan Sands Committed by Greg Kroah-Hartman

[PATCH] USBATM: trivial modifications

Formatting, changes to variable names, comments, log level changes,
printk rate limiting.
Signed-off-by: default avatarDuncan Sands <baldrick@free.fr>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7ce08c93
...@@ -352,7 +352,6 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance, ...@@ -352,7 +352,6 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
struct atm_dev *atm_dev) struct atm_dev *atm_dev)
{ {
struct cxacru_data *instance = usbatm_instance->driver_data; struct cxacru_data *instance = usbatm_instance->driver_data;
struct device *dev = &usbatm_instance->usb_intf->dev;
/* /*
struct atm_dev *atm_dev = usbatm_instance->atm_dev; struct atm_dev *atm_dev = usbatm_instance->atm_dev;
*/ */
...@@ -364,14 +363,14 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance, ...@@ -364,14 +363,14 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_MAC_ADDRESS, NULL, 0, ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_MAC_ADDRESS, NULL, 0,
atm_dev->esi, sizeof(atm_dev->esi)); atm_dev->esi, sizeof(atm_dev->esi));
if (ret < 0) { if (ret < 0) {
dev_err(dev, "cxacru_atm_start: CARD_GET_MAC_ADDRESS returned %d\n", ret); atm_err(usbatm_instance, "cxacru_atm_start: CARD_GET_MAC_ADDRESS returned %d\n", ret);
return ret; return ret;
} }
/* start ADSL */ /* start ADSL */
ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0); ret = cxacru_cm(instance, CM_REQUEST_CHIP_ADSL_LINE_START, NULL, 0, NULL, 0);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "cxacru_atm_start: CHIP_ADSL_LINE_START returned %d\n", ret); atm_err(usbatm_instance, "cxacru_atm_start: CHIP_ADSL_LINE_START returned %d\n", ret);
return ret; return ret;
} }
...@@ -383,13 +382,13 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance, ...@@ -383,13 +382,13 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,
static void cxacru_poll_status(struct cxacru_data *instance) static void cxacru_poll_status(struct cxacru_data *instance)
{ {
u32 buf[CXINF_MAX] = {}; u32 buf[CXINF_MAX] = {};
struct device *dev = &instance->usbatm->usb_intf->dev; struct usbatm_data *usbatm = instance->usbatm;
struct atm_dev *atm_dev = instance->usbatm->atm_dev; struct atm_dev *atm_dev = usbatm->atm_dev;
int ret; int ret;
ret = cxacru_cm_get_array(instance, CM_REQUEST_CARD_INFO_GET, buf, CXINF_MAX); ret = cxacru_cm_get_array(instance, CM_REQUEST_CARD_INFO_GET, buf, CXINF_MAX);
if (ret < 0) { if (ret < 0) {
dev_warn(dev, "poll status: error %d\n", ret); atm_warn(usbatm, "poll status: error %d\n", ret);
goto reschedule; goto reschedule;
} }
...@@ -400,50 +399,50 @@ static void cxacru_poll_status(struct cxacru_data *instance) ...@@ -400,50 +399,50 @@ static void cxacru_poll_status(struct cxacru_data *instance)
switch (instance->line_status) { switch (instance->line_status) {
case 0: case 0:
atm_dev->signal = ATM_PHY_SIG_LOST; atm_dev->signal = ATM_PHY_SIG_LOST;
dev_info(dev, "ADSL line: down\n"); atm_info(usbatm, "ADSL line: down\n");
break; break;
case 1: case 1:
atm_dev->signal = ATM_PHY_SIG_LOST; atm_dev->signal = ATM_PHY_SIG_LOST;
dev_info(dev, "ADSL line: attemtping to activate\n"); atm_info(usbatm, "ADSL line: attempting to activate\n");
break; break;
case 2: case 2:
atm_dev->signal = ATM_PHY_SIG_LOST; atm_dev->signal = ATM_PHY_SIG_LOST;
dev_info(dev, "ADSL line: training\n"); atm_info(usbatm, "ADSL line: training\n");
break; break;
case 3: case 3:
atm_dev->signal = ATM_PHY_SIG_LOST; atm_dev->signal = ATM_PHY_SIG_LOST;
dev_info(dev, "ADSL line: channel analysis\n"); atm_info(usbatm, "ADSL line: channel analysis\n");
break; break;
case 4: case 4:
atm_dev->signal = ATM_PHY_SIG_LOST; atm_dev->signal = ATM_PHY_SIG_LOST;
dev_info(dev, "ADSL line: exchange\n"); atm_info(usbatm, "ADSL line: exchange\n");
break; break;
case 5: case 5:
atm_dev->link_rate = buf[CXINF_DOWNSTREAM_RATE] * 1000 / 424; atm_dev->link_rate = buf[CXINF_DOWNSTREAM_RATE] * 1000 / 424;
atm_dev->signal = ATM_PHY_SIG_FOUND; atm_dev->signal = ATM_PHY_SIG_FOUND;
dev_info(dev, "ADSL line: up (%d kb/s down | %d kb/s up)\n", atm_info(usbatm, "ADSL line: up (%d kb/s down | %d kb/s up)\n",
buf[CXINF_DOWNSTREAM_RATE], buf[CXINF_UPSTREAM_RATE]); buf[CXINF_DOWNSTREAM_RATE], buf[CXINF_UPSTREAM_RATE]);
break; break;
case 6: case 6:
atm_dev->signal = ATM_PHY_SIG_LOST; atm_dev->signal = ATM_PHY_SIG_LOST;
dev_info(dev, "ADSL line: waiting\n"); atm_info(usbatm, "ADSL line: waiting\n");
break; break;
case 7: case 7:
atm_dev->signal = ATM_PHY_SIG_LOST; atm_dev->signal = ATM_PHY_SIG_LOST;
dev_info(dev, "ADSL line: initializing\n"); atm_info(usbatm, "ADSL line: initializing\n");
break; break;
default: default:
atm_dev->signal = ATM_PHY_SIG_UNKNOWN; atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
dev_info(dev, "Unknown line state %02x\n", instance->line_status); atm_info(usbatm, "Unknown line state %02x\n", instance->line_status);
break; break;
} }
reschedule: reschedule:
...@@ -504,8 +503,8 @@ static void cxacru_upload_firmware(struct cxacru_data *instance, ...@@ -504,8 +503,8 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
{ {
int ret; int ret;
int off; int off;
struct usb_device *usb_dev = instance->usbatm->usb_dev; struct usbatm_data *usbatm = instance->usbatm;
struct device *dev = &instance->usbatm->usb_intf->dev; struct usb_device *usb_dev = usbatm->usb_dev;
u16 signature[] = { usb_dev->descriptor.idVendor, usb_dev->descriptor.idProduct }; u16 signature[] = { usb_dev->descriptor.idVendor, usb_dev->descriptor.idProduct };
u32 val; u32 val;
...@@ -515,7 +514,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance, ...@@ -515,7 +514,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
val = cpu_to_le32(instance->modem_type->pll_f_clk); val = cpu_to_le32(instance->modem_type->pll_f_clk);
ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLFCLK_ADDR, (u8 *) &val, 4); ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLFCLK_ADDR, (u8 *) &val, 4);
if (ret) { if (ret) {
dev_err(dev, "FirmwarePllFClkValue failed: %d\n", ret); usb_err(usbatm, "FirmwarePllFClkValue failed: %d\n", ret);
return; return;
} }
...@@ -523,7 +522,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance, ...@@ -523,7 +522,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
val = cpu_to_le32(instance->modem_type->pll_b_clk); val = cpu_to_le32(instance->modem_type->pll_b_clk);
ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLBCLK_ADDR, (u8 *) &val, 4); ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, PLLBCLK_ADDR, (u8 *) &val, 4);
if (ret) { if (ret) {
dev_err(dev, "FirmwarePllBClkValue failed: %d\n", ret); usb_err(usbatm, "FirmwarePllBClkValue failed: %d\n", ret);
return; return;
} }
...@@ -531,14 +530,14 @@ static void cxacru_upload_firmware(struct cxacru_data *instance, ...@@ -531,14 +530,14 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
val = cpu_to_le32(SDRAM_ENA); val = cpu_to_le32(SDRAM_ENA);
ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SDRAMEN_ADDR, (u8 *) &val, 4); ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SDRAMEN_ADDR, (u8 *) &val, 4);
if (ret) { if (ret) {
dev_err(dev, "Enable SDRAM failed: %d\n", ret); usb_err(usbatm, "Enable SDRAM failed: %d\n", ret);
return; return;
} }
/* Firmware */ /* Firmware */
ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, FW_ADDR, fw->data, fw->size); ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, FW_ADDR, fw->data, fw->size);
if (ret) { if (ret) {
dev_err(dev, "Firmware upload failed: %d\n", ret); usb_err(usbatm, "Firmware upload failed: %d\n", ret);
return; return;
} }
...@@ -546,7 +545,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance, ...@@ -546,7 +545,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
if (instance->modem_type->boot_rom_patch) { if (instance->modem_type->boot_rom_patch) {
ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_ADDR, bp->data, bp->size); ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, BR_ADDR, bp->data, bp->size);
if (ret) { if (ret) {
dev_err(dev, "Boot ROM patching failed: %d\n", ret); usb_err(usbatm, "Boot ROM patching failed: %d\n", ret);
return; return;
} }
} }
...@@ -554,7 +553,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance, ...@@ -554,7 +553,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
/* Signature */ /* Signature */
ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SIG_ADDR, (u8 *) signature, 4); ret = cxacru_fw(usb_dev, FW_WRITE_MEM, 0x2, 0x0, SIG_ADDR, (u8 *) signature, 4);
if (ret) { if (ret) {
dev_err(dev, "Signature storing failed: %d\n", ret); usb_err(usbatm, "Signature storing failed: %d\n", ret);
return; return;
} }
...@@ -566,7 +565,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance, ...@@ -566,7 +565,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
ret = cxacru_fw(usb_dev, FW_GOTO_MEM, 0x0, 0x0, FW_ADDR, NULL, 0); ret = cxacru_fw(usb_dev, FW_GOTO_MEM, 0x0, 0x0, FW_ADDR, NULL, 0);
} }
if (ret) { if (ret) {
dev_err(dev, "Passing control to firmware failed: %d\n", ret); usb_err(usbatm, "Passing control to firmware failed: %d\n", ret);
return; return;
} }
...@@ -580,7 +579,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance, ...@@ -580,7 +579,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_STATUS, NULL, 0, NULL, 0); ret = cxacru_cm(instance, CM_REQUEST_CARD_GET_STATUS, NULL, 0, NULL, 0);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "modem failed to initialize: %d\n", ret); usb_err(usbatm, "modem failed to initialize: %d\n", ret);
return; return;
} }
...@@ -597,7 +596,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance, ...@@ -597,7 +596,7 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
ret = cxacru_cm(instance, CM_REQUEST_CARD_DATA_SET, ret = cxacru_cm(instance, CM_REQUEST_CARD_DATA_SET,
(u8 *) buf, len, NULL, 0); (u8 *) buf, len, NULL, 0);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "load config data failed: %d\n", ret); usb_err(usbatm, "load config data failed: %d\n", ret);
return; return;
} }
} }
...@@ -608,18 +607,19 @@ static void cxacru_upload_firmware(struct cxacru_data *instance, ...@@ -608,18 +607,19 @@ static void cxacru_upload_firmware(struct cxacru_data *instance,
static int cxacru_find_firmware(struct cxacru_data *instance, static int cxacru_find_firmware(struct cxacru_data *instance,
char* phase, const struct firmware **fw_p) char* phase, const struct firmware **fw_p)
{ {
struct device *dev = &instance->usbatm->usb_intf->dev; struct usbatm_data *usbatm = instance->usbatm;
struct device *dev = &usbatm->usb_intf->dev;
char buf[16]; char buf[16];
sprintf(buf, "cxacru-%s.bin", phase); sprintf(buf, "cxacru-%s.bin", phase);
dbg("cxacru_find_firmware: looking for %s", buf); dbg("cxacru_find_firmware: looking for %s", buf);
if (request_firmware(fw_p, buf, dev)) { if (request_firmware(fw_p, buf, dev)) {
dev_dbg(dev, "no stage %s firmware found\n", phase); usb_dbg(usbatm, "no stage %s firmware found\n", phase);
return -ENOENT; return -ENOENT;
} }
dev_info(dev, "found firmware %s\n", buf); usb_info(usbatm, "found firmware %s\n", buf);
return 0; return 0;
} }
...@@ -627,20 +627,19 @@ static int cxacru_find_firmware(struct cxacru_data *instance, ...@@ -627,20 +627,19 @@ static int cxacru_find_firmware(struct cxacru_data *instance,
static int cxacru_heavy_init(struct usbatm_data *usbatm_instance, static int cxacru_heavy_init(struct usbatm_data *usbatm_instance,
struct usb_interface *usb_intf) struct usb_interface *usb_intf)
{ {
struct device *dev = &usbatm_instance->usb_intf->dev;
const struct firmware *fw, *bp, *cf; const struct firmware *fw, *bp, *cf;
struct cxacru_data *instance = usbatm_instance->driver_data; struct cxacru_data *instance = usbatm_instance->driver_data;
int ret = cxacru_find_firmware(instance, "fw", &fw); int ret = cxacru_find_firmware(instance, "fw", &fw);
if (ret) { if (ret) {
dev_warn(dev, "firmware (cxacru-fw.bin) unavailable (hotplug misconfiguration?)\n"); usb_warn(usbatm_instance, "firmware (cxacru-fw.bin) unavailable (system misconfigured?)\n");
return ret; return ret;
} }
if (instance->modem_type->boot_rom_patch) { if (instance->modem_type->boot_rom_patch) {
ret = cxacru_find_firmware(instance, "bp", &bp); ret = cxacru_find_firmware(instance, "bp", &bp);
if (ret) { if (ret) {
dev_warn(dev, "boot ROM patch (cxacru-bp.bin) unavailable (hotplug misconfiguration?)\n"); usb_warn(usbatm_instance, "boot ROM patch (cxacru-bp.bin) unavailable (system misconfigured?)\n");
release_firmware(fw); release_firmware(fw);
return ret; return ret;
} }
...@@ -787,12 +786,12 @@ static const struct usb_device_id cxacru_usb_ids[] = { ...@@ -787,12 +786,12 @@ static const struct usb_device_id cxacru_usb_ids[] = {
{ /* V = Conexant P = ADSL modem (Hasbani project) */ { /* V = Conexant P = ADSL modem (Hasbani project) */
USB_DEVICE(0x0572, 0xcb00), .driver_info = (unsigned long) &cxacru_cb00 USB_DEVICE(0x0572, 0xcb00), .driver_info = (unsigned long) &cxacru_cb00
}, },
{ /* V = Conexant P = ADSL modem (Well PTI-800 */
USB_DEVICE(0x0572, 0xcb02), .driver_info = (unsigned long) &cxacru_cb00
},
{ /* V = Conexant P = ADSL modem */ { /* V = Conexant P = ADSL modem */
USB_DEVICE(0x0572, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00 USB_DEVICE(0x0572, 0xcb01), .driver_info = (unsigned long) &cxacru_cb00
}, },
{ /* V = Conexant P = ADSL modem (Well PTI-800) */
USB_DEVICE(0x0572, 0xcb02), .driver_info = (unsigned long) &cxacru_cb00
},
{ /* V = Conexant P = ADSL modem */ { /* V = Conexant P = ADSL modem */
USB_DEVICE(0x0572, 0xcb06), .driver_info = (unsigned long) &cxacru_cb00 USB_DEVICE(0x0572, 0xcb06), .driver_info = (unsigned long) &cxacru_cb00
}, },
......
...@@ -205,7 +205,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance, ...@@ -205,7 +205,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
buffer, 0x200, &actual_length, 2000); buffer, 0x200, &actual_length, 2000);
if (ret < 0 && ret != -ETIMEDOUT) if (ret < 0 && ret != -ETIMEDOUT)
usb_dbg(usbatm, "%s: read BLOCK0 from modem failed (%d)!\n", __func__, ret); usb_warn(usbatm, "%s: read BLOCK0 from modem failed (%d)!\n", __func__, ret);
else else
usb_dbg(usbatm, "%s: BLOCK0 downloaded (%d bytes)\n", __func__, ret); usb_dbg(usbatm, "%s: BLOCK0 downloaded (%d bytes)\n", __func__, ret);
} }
...@@ -219,7 +219,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance, ...@@ -219,7 +219,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
buffer, thislen, &actual_length, DATA_TIMEOUT); buffer, thislen, &actual_length, DATA_TIMEOUT);
if (ret < 0) { if (ret < 0) {
usb_dbg(usbatm, "%s: write BLOCK1 to modem failed (%d)!\n", __func__, ret); usb_err(usbatm, "%s: write BLOCK1 to modem failed (%d)!\n", __func__, ret);
goto out_free; goto out_free;
} }
usb_dbg(usbatm, "%s: BLOCK1 uploaded (%zu bytes)\n", __func__, fw1->size); usb_dbg(usbatm, "%s: BLOCK1 uploaded (%zu bytes)\n", __func__, fw1->size);
...@@ -232,7 +232,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance, ...@@ -232,7 +232,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
buffer, 0x200, &actual_length, DATA_TIMEOUT); buffer, 0x200, &actual_length, DATA_TIMEOUT);
if (ret < 0) { if (ret < 0) {
usb_dbg(usbatm, "%s: read BLOCK2 from modem failed (%d)!\n", __func__, ret); usb_err(usbatm, "%s: read BLOCK2 from modem failed (%d)!\n", __func__, ret);
goto out_free; goto out_free;
} }
usb_dbg(usbatm, "%s: BLOCK2 downloaded (%d bytes)\n", __func__, actual_length); usb_dbg(usbatm, "%s: BLOCK2 downloaded (%d bytes)\n", __func__, actual_length);
...@@ -246,7 +246,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance, ...@@ -246,7 +246,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
buffer, thislen, &actual_length, DATA_TIMEOUT); buffer, thislen, &actual_length, DATA_TIMEOUT);
if (ret < 0) { if (ret < 0) {
usb_dbg(usbatm, "%s: write BLOCK3 to modem failed (%d)!\n", __func__, ret); usb_err(usbatm, "%s: write BLOCK3 to modem failed (%d)!\n", __func__, ret);
goto out_free; goto out_free;
} }
} }
...@@ -259,7 +259,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance, ...@@ -259,7 +259,7 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
buffer, 0x200, &actual_length, DATA_TIMEOUT); buffer, 0x200, &actual_length, DATA_TIMEOUT);
if (ret < 0) { if (ret < 0) {
usb_dbg(usbatm, "%s: read BLOCK4 from modem failed (%d)!\n", __func__, ret); usb_err(usbatm, "%s: read BLOCK4 from modem failed (%d)!\n", __func__, ret);
goto out_free; goto out_free;
} }
...@@ -285,8 +285,8 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance, ...@@ -285,8 +285,8 @@ static int speedtch_upload_firmware(struct speedtch_instance_data *instance,
return ret; return ret;
} }
static int speedtch_find_firmware(struct usb_interface *intf, int phase, static int speedtch_find_firmware(struct usbatm_data *usbatm, struct usb_interface *intf,
const struct firmware **fw_p) int phase, const struct firmware **fw_p)
{ {
struct device *dev = &intf->dev; struct device *dev = &intf->dev;
const u16 bcdDevice = le16_to_cpu(interface_to_usbdev(intf)->descriptor.bcdDevice); const u16 bcdDevice = le16_to_cpu(interface_to_usbdev(intf)->descriptor.bcdDevice);
...@@ -295,24 +295,24 @@ static int speedtch_find_firmware(struct usb_interface *intf, int phase, ...@@ -295,24 +295,24 @@ static int speedtch_find_firmware(struct usb_interface *intf, int phase,
char buf[24]; char buf[24];
sprintf(buf, "speedtch-%d.bin.%x.%02x", phase, major_revision, minor_revision); sprintf(buf, "speedtch-%d.bin.%x.%02x", phase, major_revision, minor_revision);
dev_dbg(dev, "%s: looking for %s\n", __func__, buf); usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
if (request_firmware(fw_p, buf, dev)) { if (request_firmware(fw_p, buf, dev)) {
sprintf(buf, "speedtch-%d.bin.%x", phase, major_revision); sprintf(buf, "speedtch-%d.bin.%x", phase, major_revision);
dev_dbg(dev, "%s: looking for %s\n", __func__, buf); usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
if (request_firmware(fw_p, buf, dev)) { if (request_firmware(fw_p, buf, dev)) {
sprintf(buf, "speedtch-%d.bin", phase); sprintf(buf, "speedtch-%d.bin", phase);
dev_dbg(dev, "%s: looking for %s\n", __func__, buf); usb_dbg(usbatm, "%s: looking for %s\n", __func__, buf);
if (request_firmware(fw_p, buf, dev)) { if (request_firmware(fw_p, buf, dev)) {
dev_warn(dev, "no stage %d firmware found!\n", phase); usb_err(usbatm, "%s: no stage %d firmware found!\n", __func__, phase);
return -ENOENT; return -ENOENT;
} }
} }
} }
dev_info(dev, "found stage %d firmware %s\n", phase, buf); usb_info(usbatm, "found stage %d firmware %s\n", phase, buf);
return 0; return 0;
} }
...@@ -323,15 +323,16 @@ static int speedtch_heavy_init(struct usbatm_data *usbatm, struct usb_interface ...@@ -323,15 +323,16 @@ static int speedtch_heavy_init(struct usbatm_data *usbatm, struct usb_interface
struct speedtch_instance_data *instance = usbatm->driver_data; struct speedtch_instance_data *instance = usbatm->driver_data;
int ret; int ret;
if ((ret = speedtch_find_firmware(intf, 1, &fw1)) < 0) if ((ret = speedtch_find_firmware(usbatm, intf, 1, &fw1)) < 0)
return ret; return ret;
if ((ret = speedtch_find_firmware(intf, 2, &fw2)) < 0) { if ((ret = speedtch_find_firmware(usbatm, intf, 2, &fw2)) < 0) {
release_firmware(fw1); release_firmware(fw1);
return ret; return ret;
} }
ret = speedtch_upload_firmware(instance, fw1, fw2); if ((ret = speedtch_upload_firmware(instance, fw1, fw2)) < 0)
usb_err(usbatm, "%s: firmware upload failed (%d)!\n", __func__, ret);
release_firmware(fw2); release_firmware(fw2);
release_firmware(fw1); release_firmware(fw1);
...@@ -428,7 +429,9 @@ static void speedtch_check_status(struct speedtch_instance_data *instance) ...@@ -428,7 +429,9 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
int down_speed, up_speed, ret; int down_speed, up_speed, ret;
unsigned char status; unsigned char status;
#ifdef VERBOSE_DEBUG
atm_dbg(usbatm, "%s entered\n", __func__); atm_dbg(usbatm, "%s entered\n", __func__);
#endif
ret = speedtch_read_status(instance); ret = speedtch_read_status(instance);
if (ret < 0) { if (ret < 0) {
...@@ -441,9 +444,9 @@ static void speedtch_check_status(struct speedtch_instance_data *instance) ...@@ -441,9 +444,9 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
status = buf[OFFSET_7]; status = buf[OFFSET_7];
atm_dbg(usbatm, "%s: line state %02x\n", __func__, status);
if ((status != instance->last_status) || !status) { if ((status != instance->last_status) || !status) {
atm_dbg(usbatm, "%s: line state 0x%02x\n", __func__, status);
switch (status) { switch (status) {
case 0: case 0:
atm_dev->signal = ATM_PHY_SIG_LOST; atm_dev->signal = ATM_PHY_SIG_LOST;
...@@ -484,7 +487,7 @@ static void speedtch_check_status(struct speedtch_instance_data *instance) ...@@ -484,7 +487,7 @@ static void speedtch_check_status(struct speedtch_instance_data *instance)
default: default:
atm_dev->signal = ATM_PHY_SIG_UNKNOWN; atm_dev->signal = ATM_PHY_SIG_UNKNOWN;
atm_info(usbatm, "Unknown line state %02x\n", status); atm_info(usbatm, "unknown line state %02x\n", status);
break; break;
} }
...@@ -690,8 +693,10 @@ static int speedtch_bind(struct usbatm_data *usbatm, ...@@ -690,8 +693,10 @@ static int speedtch_bind(struct usbatm_data *usbatm,
usb_dbg(usbatm, "%s entered\n", __func__); usb_dbg(usbatm, "%s entered\n", __func__);
/* sanity checks */
if (usb_dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) { if (usb_dev->descriptor.bDeviceClass != USB_CLASS_VENDOR_SPEC) {
usb_dbg(usbatm, "%s: wrong device class %d\n", __func__, usb_dev->descriptor.bDeviceClass); usb_err(usbatm, "%s: wrong device class %d\n", __func__, usb_dev->descriptor.bDeviceClass);
return -ENODEV; return -ENODEV;
} }
...@@ -704,7 +709,7 @@ static int speedtch_bind(struct usbatm_data *usbatm, ...@@ -704,7 +709,7 @@ static int speedtch_bind(struct usbatm_data *usbatm,
ret = usb_driver_claim_interface(&speedtch_usb_driver, cur_intf, usbatm); ret = usb_driver_claim_interface(&speedtch_usb_driver, cur_intf, usbatm);
if (ret < 0) { if (ret < 0) {
usb_dbg(usbatm, "%s: failed to claim interface %d (%d)\n", __func__, i, ret); usb_err(usbatm, "%s: failed to claim interface %2d (%d)!\n", __func__, i, ret);
speedtch_release_interfaces(usb_dev, i); speedtch_release_interfaces(usb_dev, i);
return ret; return ret;
} }
...@@ -714,7 +719,7 @@ static int speedtch_bind(struct usbatm_data *usbatm, ...@@ -714,7 +719,7 @@ static int speedtch_bind(struct usbatm_data *usbatm,
instance = kmalloc(sizeof(*instance), GFP_KERNEL); instance = kmalloc(sizeof(*instance), GFP_KERNEL);
if (!instance) { if (!instance) {
usb_dbg(usbatm, "%s: no memory for instance data!\n", __func__); usb_err(usbatm, "%s: no memory for instance data!\n", __func__);
ret = -ENOMEM; ret = -ENOMEM;
goto fail_release; goto fail_release;
} }
...@@ -754,8 +759,10 @@ static int speedtch_bind(struct usbatm_data *usbatm, ...@@ -754,8 +759,10 @@ static int speedtch_bind(struct usbatm_data *usbatm,
usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, need_heavy_init ? "not" : "already"); usb_dbg(usbatm, "%s: firmware %s loaded\n", __func__, need_heavy_init ? "not" : "already");
if (*need_heavy_init) if (*need_heavy_init)
if ((ret = usb_reset_device(usb_dev)) < 0) if ((ret = usb_reset_device(usb_dev)) < 0) {
usb_err(usbatm, "%s: device reset failed (%d)!\n", __func__, ret);
goto fail_free; goto fail_free;
}
usbatm->driver_data = instance; usbatm->driver_data = instance;
......
This diff is collapsed.
...@@ -24,22 +24,21 @@ ...@@ -24,22 +24,21 @@
#ifndef _USBATM_H_ #ifndef _USBATM_H_
#define _USBATM_H_ #define _USBATM_H_
#include <linux/config.h>
/*
#define VERBOSE_DEBUG
*/
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <linux/atm.h> #include <linux/atm.h>
#include <linux/atmdev.h> #include <linux/atmdev.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/kernel.h>
#include <linux/kref.h> #include <linux/kref.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/stringify.h> #include <linux/stringify.h>
#include <linux/usb.h> #include <linux/usb.h>
/*
#define VERBOSE_DEBUG
*/
#ifdef DEBUG #ifdef DEBUG
#define UDSL_ASSERT(x) BUG_ON(!(x)) #define UDSL_ASSERT(x) BUG_ON(!(x))
#else #else
...@@ -52,8 +51,13 @@ ...@@ -52,8 +51,13 @@
dev_info(&(instance)->usb_intf->dev , format , ## arg) dev_info(&(instance)->usb_intf->dev , format , ## arg)
#define usb_warn(instance, format, arg...) \ #define usb_warn(instance, format, arg...) \
dev_warn(&(instance)->usb_intf->dev , format , ## arg) dev_warn(&(instance)->usb_intf->dev , format , ## arg)
#ifdef DEBUG
#define usb_dbg(instance, format, arg...) \
dev_printk(KERN_DEBUG , &(instance)->usb_intf->dev , format , ## arg)
#else
#define usb_dbg(instance, format, arg...) \ #define usb_dbg(instance, format, arg...) \
dev_dbg(&(instance)->usb_intf->dev , format , ## arg) do {} while (0)
#endif
/* FIXME: move to dev_* once ATM is driver model aware */ /* FIXME: move to dev_* once ATM is driver model aware */
#define atm_printk(level, instance, format, arg...) \ #define atm_printk(level, instance, format, arg...) \
...@@ -69,9 +73,14 @@ ...@@ -69,9 +73,14 @@
#ifdef DEBUG #ifdef DEBUG
#define atm_dbg(instance, format, arg...) \ #define atm_dbg(instance, format, arg...) \
atm_printk(KERN_DEBUG, instance , format , ## arg) atm_printk(KERN_DEBUG, instance , format , ## arg)
#define atm_rldbg(instance, format, arg...) \
if (printk_ratelimit()) \
atm_printk(KERN_DEBUG, instance , format , ## arg)
#else #else
#define atm_dbg(instance, format, arg...) \ #define atm_dbg(instance, format, arg...) \
do {} while (0) do {} while (0)
#define atm_rldbg(instance, format, arg...) \
do {} while (0)
#endif #endif
......
...@@ -61,7 +61,7 @@ static int usb_intf_has_ep(const struct usb_interface *intf, u8 ep) ...@@ -61,7 +61,7 @@ static int usb_intf_has_ep(const struct usb_interface *intf, u8 ep)
return 0; return 0;
} }
static int xusbatm_bind(struct usbatm_data *usbatm_instance, static int xusbatm_bind(struct usbatm_data *usbatm,
struct usb_interface *intf, const struct usb_device_id *id, struct usb_interface *intf, const struct usb_device_id *id,
int *need_heavy_init) int *need_heavy_init)
{ {
...@@ -72,14 +72,14 @@ static int xusbatm_bind(struct usbatm_data *usbatm_instance, ...@@ -72,14 +72,14 @@ static int xusbatm_bind(struct usbatm_data *usbatm_instance,
u8 searched_ep = rx_ep_present ? tx_endpoint[drv_ix] : rx_endpoint[drv_ix]; u8 searched_ep = rx_ep_present ? tx_endpoint[drv_ix] : rx_endpoint[drv_ix];
int i, ret; int i, ret;
usb_dbg(usbatm_instance, "%s: binding driver %d: vendor %#x product %#x" usb_dbg(usbatm, "%s: binding driver %d: vendor %04x product %04x"
" rx: ep %#x padd %d tx: ep %#x padd %d\n", " rx: ep %02x padd %d tx: ep %02x padd %d\n",
__func__, drv_ix, vendor[drv_ix], product[drv_ix], __func__, drv_ix, vendor[drv_ix], product[drv_ix],
rx_endpoint[drv_ix], rx_padding[drv_ix], rx_endpoint[drv_ix], rx_padding[drv_ix],
tx_endpoint[drv_ix], tx_padding[drv_ix]); tx_endpoint[drv_ix], tx_padding[drv_ix]);
if (!rx_ep_present && !tx_ep_present) { if (!rx_ep_present && !tx_ep_present) {
usb_dbg(usbatm_instance, "%s: intf #%d has neither rx (%#x) nor tx (%#x) endpoint\n", usb_dbg(usbatm, "%s: intf #%d has neither rx (%#x) nor tx (%#x) endpoint\n",
__func__, intf->altsetting->desc.bInterfaceNumber, __func__, intf->altsetting->desc.bInterfaceNumber,
rx_endpoint[drv_ix], tx_endpoint[drv_ix]); rx_endpoint[drv_ix], tx_endpoint[drv_ix]);
return -ENODEV; return -ENODEV;
...@@ -93,25 +93,26 @@ static int xusbatm_bind(struct usbatm_data *usbatm_instance, ...@@ -93,25 +93,26 @@ static int xusbatm_bind(struct usbatm_data *usbatm_instance,
if (cur_if != intf && usb_intf_has_ep(cur_if, searched_ep)) { if (cur_if != intf && usb_intf_has_ep(cur_if, searched_ep)) {
ret = usb_driver_claim_interface(&xusbatm_usb_driver, ret = usb_driver_claim_interface(&xusbatm_usb_driver,
cur_if, usbatm_instance); cur_if, usbatm);
if (!ret) if (!ret)
usb_err(usbatm_instance, "%s: failed to claim interface #%d (%d)\n", usb_err(usbatm, "%s: failed to claim interface #%d (%d)\n",
__func__, cur_if->altsetting->desc.bInterfaceNumber, ret); __func__, cur_if->altsetting->desc.bInterfaceNumber, ret);
return ret; return ret;
} }
} }
usb_err(usbatm_instance, "%s: no interface has endpoint %#x\n", usb_err(usbatm, "%s: no interface has endpoint %#x\n",
__func__, searched_ep); __func__, searched_ep);
return -ENODEV; return -ENODEV;
} }
static void xusbatm_unbind(struct usbatm_data *usbatm_instance, static void xusbatm_unbind(struct usbatm_data *usbatm,
struct usb_interface *intf) struct usb_interface *intf)
{ {
struct usb_device *usb_dev = interface_to_usbdev(intf); struct usb_device *usb_dev = interface_to_usbdev(intf);
int i; int i;
usb_dbg(usbatm_instance, "%s entered\n", __func__);
usb_dbg(usbatm, "%s entered\n", __func__);
for(i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) { for(i = 0; i < usb_dev->actconfig->desc.bNumInterfaces; i++) {
struct usb_interface *cur_if = usb_dev->actconfig->interface[i]; struct usb_interface *cur_if = usb_dev->actconfig->interface[i];
...@@ -120,10 +121,10 @@ static void xusbatm_unbind(struct usbatm_data *usbatm_instance, ...@@ -120,10 +121,10 @@ static void xusbatm_unbind(struct usbatm_data *usbatm_instance,
} }
} }
static int xusbatm_atm_start(struct usbatm_data *usbatm_instance, static int xusbatm_atm_start(struct usbatm_data *usbatm,
struct atm_dev *atm_dev) struct atm_dev *atm_dev)
{ {
atm_dbg(usbatm_instance, "%s entered\n", __func__); atm_dbg(usbatm, "%s entered\n", __func__);
/* use random MAC as we've no way to get it from the device */ /* use random MAC as we've no way to get it from the device */
random_ether_addr(atm_dev->esi); random_ether_addr(atm_dev->esi);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment