* No. 450, Shenhu Road, Suzhou Industry Park, Suzhou, China
*/
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
#include <linux/blkdev.h>
#include <linux/kthread.h>
#include <linux/sched.h>
static void rts51x_try_to_enter_ss(struct rts51x_chip *chip)
{
- RTS51X_DEBUGP("Ready to enter SS state\n");
+ pr_debug("Ready to enter SS state\n");
usb_autopm_enable(chip->usb->pusb_intf);
}
void rts51x_try_to_exit_ss(struct rts51x_chip *chip)
{
- RTS51X_DEBUGP("Exit from SS state\n");
+ pr_debug("Exit from SS state\n");
usb_autopm_disable(chip->usb->pusb_intf);
}
{
struct rts51x_chip *chip = usb_get_intfdata(iface);
- RTS51X_DEBUGP("%s, message.event = 0x%x\n", __func__, message.event);
+ pr_debug("%s, message.event = 0x%x\n", __func__, message.event);
/* Wait until no command is running */
mutex_lock(&chip->usb->dev_mutex);
rts51x_do_before_power_down(chip);
if (message.event == PM_EVENT_AUTO_SUSPEND) {
- RTS51X_DEBUGP("Enter SS state");
+ pr_debug("Enter SS state");
chip->resume_from_scsi = 0;
RTS51X_SET_STAT(chip, STAT_SS);
} else {
- RTS51X_DEBUGP("Enter SUSPEND state");
+ pr_debug("Enter SUSPEND state");
RTS51X_SET_STAT(chip, STAT_SUSPEND);
}
{
struct rts51x_chip *chip = usb_get_intfdata(iface);
- RTS51X_DEBUGP("%s\n", __func__);
+ pr_debug("%s\n", __func__);
if (!RTS51X_CHK_STAT(chip, STAT_SS) || !chip->resume_from_scsi) {
mutex_lock(&chip->usb->dev_mutex);
if (chip->option.ss_en) {
if (GET_PM_USAGE_CNT(chip) <= 0) {
/* Remote wake up, increase pm_usage_cnt */
- RTS51X_DEBUGP("Incr pm_usage_cnt\n");
+ pr_debug("Incr pm_usage_cnt\n");
SET_PM_USAGE_CNT(chip, 1);
}
}
{
struct rts51x_chip *chip = usb_get_intfdata(iface);
- RTS51X_DEBUGP("%s\n", __func__);
+ pr_debug("%s\n", __func__);
mutex_lock(&chip->usb->dev_mutex);
{
struct rts51x_chip *chip = usb_get_intfdata(iface);
- RTS51X_DEBUGP("%s\n", __func__);
+ pr_debug("%s\n", __func__);
/* Make sure no command runs during the reset */
mutex_lock(&chip->usb->dev_mutex);
{
struct rts51x_chip *chip = usb_get_intfdata(iface);
- RTS51X_DEBUGP("%s\n", __func__);
+ pr_debug("%s\n", __func__);
/* Report the reset to the SCSI core */
/* usb_stor_report_bus_reset(us); */
break;
if (test_bit(FLIDX_DISCONNECTING, &chip->usb->dflags)) {
- RTS51X_DEBUGP("-- exiting from rts51x-control\n");
+ pr_debug("-- exiting from rts51x-control\n");
break;
}
if (chip->srb == NULL) {
scsi_unlock(host);
mutex_unlock(&chip->usb->dev_mutex);
- RTS51X_DEBUGP("-- exiting from control thread\n");
+ pr_debug("-- exiting from control thread\n");
break;
}
* is UNKNOWN
*/
if (chip->srb->sc_data_direction == DMA_BIDIRECTIONAL) {
- RTS51X_DEBUGP("UNKNOWN data direction\n");
+ pr_debug("UNKNOWN data direction\n");
chip->srb->result = DID_ERROR << 16;
}
* the maximum known LUN
*/
else if (chip->srb->device->id) {
- RTS51X_DEBUGP("Bad target number (%d:%d)\n",
- chip->srb->device->id,
- chip->srb->device->lun);
+ pr_debug("Bad target number (%d:%d)\n",
+ chip->srb->device->id,
+ chip->srb->device->lun);
chip->srb->result = DID_BAD_TARGET << 16;
}
else if (chip->srb->device->lun > chip->max_lun) {
- RTS51X_DEBUGP("Bad LUN (%d:%d)\n",
- chip->srb->device->id,
- chip->srb->device->lun);
+ pr_debug("Bad LUN (%d:%d)\n",
+ chip->srb->device->id,
+ chip->srb->device->lun);
chip->srb->result = DID_BAD_TARGET << 16;
}
chip->srb->scsi_done(chip->srb);
else
abort :
- RTS51X_DEBUGP("scsi command aborted\n");
+ pr_debug("scsi command aborted\n");
/* If an abort request was received we need to signal that
* the abort has finished. The proper test for this is
/* if the device has disconnected, we are free to exit */
if (test_bit(FLIDX_DISCONNECTING, &chip->usb->dflags)) {
- RTS51X_DEBUGP("-- exiting from rts51x-polling\n");
+ pr_debug("-- exiting from rts51x-polling\n");
break;
}
rts51x->pusb_dev = interface_to_usbdev(intf);
rts51x->pusb_intf = intf;
rts51x->ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
- RTS51X_DEBUGP("Vendor: 0x%04x, Product: 0x%04x, Revision: 0x%04x\n",
- le16_to_cpu(rts51x->pusb_dev->descriptor.idVendor),
- le16_to_cpu(rts51x->pusb_dev->descriptor.idProduct),
- le16_to_cpu(rts51x->pusb_dev->descriptor.bcdDevice));
- RTS51X_DEBUGP("Interface Subclass: 0x%02x, Protocol: 0x%02x\n",
- intf->cur_altsetting->desc.bInterfaceSubClass,
- intf->cur_altsetting->desc.bInterfaceProtocol);
+ pr_debug("Vendor: 0x%04x, Product: 0x%04x, Revision: 0x%04x\n",
+ le16_to_cpu(rts51x->pusb_dev->descriptor.idVendor),
+ le16_to_cpu(rts51x->pusb_dev->descriptor.idProduct),
+ le16_to_cpu(rts51x->pusb_dev->descriptor.bcdDevice));
+ pr_debug("Interface Subclass: 0x%02x, Protocol: 0x%02x\n",
+ intf->cur_altsetting->desc.bInterfaceSubClass,
+ intf->cur_altsetting->desc.bInterfaceProtocol);
/* Store our private data in the interface */
usb_set_intfdata(intf, chip);
retval = usb_register_dev(intf, &rts51x_class);
if (retval) {
/* something prevented us from registering this driver */
- RTS51X_DEBUGP("Not able to get a minor for this device.");
+ pr_debug("Not able to get a minor for this device.");
usb_set_intfdata(intf, NULL);
return -ENOMEM;
}
rts51x->cr = usb_buffer_alloc(rts51x->pusb_dev, sizeof(*rts51x->cr),
GFP_KERNEL, &rts51x->cr_dma);
if (!rts51x->cr) {
- RTS51X_DEBUGP("usb_ctrlrequest allocation failed\n");
+ pr_debug("usb_ctrlrequest allocation failed\n");
usb_set_intfdata(intf, NULL);
return -ENOMEM;
}
rts51x->iobuf = usb_buffer_alloc(rts51x->pusb_dev, RTS51X_IOBUF_SIZE,
GFP_KERNEL, &rts51x->iobuf_dma);
if (!rts51x->iobuf) {
- RTS51X_DEBUGP("I/O buffer allocation failed\n");
+ pr_debug("I/O buffer allocation failed\n");
usb_set_intfdata(intf, NULL);
return -ENOMEM;
}
}
if (!ep_in || !ep_out) {
- RTS51X_DEBUGP("Endpoint sanity check failed! Rejecting dev.\n");
+ pr_debug("Endpoint sanity check failed! Rejecting dev.\n");
return -EIO;
}
rts51x->current_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!rts51x->current_urb) {
- RTS51X_DEBUGP("URB allocation failed\n");
+ pr_debug("URB allocation failed\n");
return -ENOMEM;
}
rts51x->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!rts51x->intr_urb) {
- RTS51X_DEBUGP("URB allocation failed\n");
+ pr_debug("URB allocation failed\n");
return -ENOMEM;
}
/* Release all our dynamic resources */
static void rts51x_release_resources(struct rts51x_chip *chip)
{
- RTS51X_DEBUGP("-- %s\n", __func__);
+ pr_debug("-- %s\n", __func__);
/* Tell the control thread to exit. The SCSI host must
* already have been removed and the DISCONNECTING flag set
* so that we won't accept any more commands.
*/
- RTS51X_DEBUGP("-- sending exit command to thread\n");
+ pr_debug("-- sending exit command to thread\n");
complete(&chip->usb->cmnd_ready);
if (chip->usb->ctl_thread)
wait_for_completion(&chip->usb->control_exit);
{
struct rts51x_usb *rts51x = chip->usb;
- RTS51X_DEBUGP("-- %s\n", __func__);
+ pr_debug("-- %s\n", __func__);
/* Free the device-related DMA-mapped buffers */
if (rts51x->cr)
int result;
struct task_struct *th;
- RTS51X_DEBUGP("%s detected\n", RTS51X_NAME);
+ pr_debug("%s detected\n", RTS51X_NAME);
rts51x = kzalloc(sizeof(struct rts51x_usb), GFP_KERNEL);
if (!rts51x) {
- printk(KERN_WARNING RTS51X_TIP
- "Unable to allocate rts51x_usb\n");
+ pr_warn(RTS51X_TIP
+ "Unable to allocate rts51x_usb\n");
return -ENOMEM;
}
*/
host = scsi_host_alloc(&rts51x_host_template, sizeof(*chip));
if (!host) {
- printk(KERN_WARNING RTS51X_TIP
- "Unable to allocate the scsi host\n");
+ pr_warn(RTS51X_TIP
+ "Unable to allocate the scsi host\n");
kfree(rts51x);
return -ENOMEM;
}
/* Start up our control thread */
th = kthread_run(rts51x_control_thread, chip, RTS51X_CTL_THREAD);
if (IS_ERR(th)) {
- printk(KERN_WARNING RTS51X_TIP
- "Unable to start control thread\n");
+ pr_warn("Unable to start control thread\n");
result = PTR_ERR(th);
goto bad_device;
}
result = scsi_add_host(rts51x_to_host(chip), &rts51x->pusb_intf->dev);
if (result) {
- printk(KERN_WARNING RTS51X_TIP "Unable to add the scsi host\n");
+ pr_warn("Unable to add the scsi host\n");
goto bad_device;
}
scsi_scan_host(rts51x_to_host(chip));
/* Start up our polling thread */
th = kthread_run(rts51x_polling_thread, chip, RTS51X_POLLING_THREAD);
if (IS_ERR(th)) {
- printk(KERN_WARNING RTS51X_TIP
- "Unable to start polling thread\n");
+ pr_warn("Unable to start polling thread\n");
result = PTR_ERR(th);
goto bad_device;
}
if (ss_en) {
rts51x->pusb_intf->needs_remote_wakeup = needs_remote_wakeup;
SET_PM_USAGE_CNT(chip, 1);
- RTS51X_DEBUGP("pm_usage_cnt = %d\n", GET_PM_USAGE_CNT(chip));
+ pr_debug("pm_usage_cnt = %d\n", GET_PM_USAGE_CNT(chip));
}
#endif
/* We come here if there are any problems */
bad_device:
- RTS51X_DEBUGP("rts51x_probe() failed\n");
+ pr_debug("rts51x_probe() failed\n");
release_everything(chip);
return result;
}
{
struct rts51x_chip *chip = (struct rts51x_chip *)usb_get_intfdata(intf);
- RTS51X_DEBUGP("rts51x_disconnect() called\n");
+ pr_debug("rts51x_disconnect() called\n");
quiesce_and_remove_host(chip);
release_everything(chip);
}