diff options
author | Jarod Wilson <jarod@redhat.com> | 2011-05-26 14:51:11 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-06-11 08:01:22 -0400 |
commit | 5ae8f9a3757e4010c7ea9c07c047088fb812335e (patch) | |
tree | 2475d37285fb19953dcebba83fc105ae3374b0a2 | |
parent | d364ee4fdb33a329b16cdf9342e9770b4d4ddc83 (diff) |
[media] mceusb: add and use mce_dbg printk macro
Using dev_dbg is more complexity than many users are able to deal with.
Make it easier to get debug spew feedback from them by adding an mce_dbg
printk macro that spews using dev_info when debug=1 is set for the
mceusb module.
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/rc/mceusb.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c index ad927fcaa020..10ec54b93d26 100644 --- a/drivers/media/rc/mceusb.c +++ b/drivers/media/rc/mceusb.c | |||
@@ -108,6 +108,12 @@ static int debug = 1; | |||
108 | static int debug; | 108 | static int debug; |
109 | #endif | 109 | #endif |
110 | 110 | ||
111 | #define mce_dbg(dev, fmt, ...) \ | ||
112 | do { \ | ||
113 | if (debug) \ | ||
114 | dev_info(dev, fmt, ## __VA_ARGS__); \ | ||
115 | } while (0) | ||
116 | |||
111 | /* general constants */ | 117 | /* general constants */ |
112 | #define SEND_FLAG_IN_PROGRESS 1 | 118 | #define SEND_FLAG_IN_PROGRESS 1 |
113 | #define SEND_FLAG_COMPLETE 2 | 119 | #define SEND_FLAG_COMPLETE 2 |
@@ -606,7 +612,7 @@ static void mce_async_callback(struct urb *urb, struct pt_regs *regs) | |||
606 | if (ir) { | 612 | if (ir) { |
607 | len = urb->actual_length; | 613 | len = urb->actual_length; |
608 | 614 | ||
609 | dev_dbg(ir->dev, "callback called (status=%d len=%d)\n", | 615 | mce_dbg(ir->dev, "callback called (status=%d len=%d)\n", |
610 | urb->status, len); | 616 | urb->status, len); |
611 | 617 | ||
612 | mceusb_dev_printdata(ir, urb->transfer_buffer, 0, len, true); | 618 | mceusb_dev_printdata(ir, urb->transfer_buffer, 0, len, true); |
@@ -655,17 +661,17 @@ static void mce_request_packet(struct mceusb_dev *ir, unsigned char *data, | |||
655 | return; | 661 | return; |
656 | } | 662 | } |
657 | 663 | ||
658 | dev_dbg(dev, "receive request called (size=%#x)\n", size); | 664 | mce_dbg(dev, "receive request called (size=%#x)\n", size); |
659 | 665 | ||
660 | async_urb->transfer_buffer_length = size; | 666 | async_urb->transfer_buffer_length = size; |
661 | async_urb->dev = ir->usbdev; | 667 | async_urb->dev = ir->usbdev; |
662 | 668 | ||
663 | res = usb_submit_urb(async_urb, GFP_ATOMIC); | 669 | res = usb_submit_urb(async_urb, GFP_ATOMIC); |
664 | if (res) { | 670 | if (res) { |
665 | dev_dbg(dev, "receive request FAILED! (res=%d)\n", res); | 671 | mce_dbg(dev, "receive request FAILED! (res=%d)\n", res); |
666 | return; | 672 | return; |
667 | } | 673 | } |
668 | dev_dbg(dev, "receive request complete (res=%d)\n", res); | 674 | mce_dbg(dev, "receive request complete (res=%d)\n", res); |
669 | } | 675 | } |
670 | 676 | ||
671 | static void mce_async_out(struct mceusb_dev *ir, unsigned char *data, int size) | 677 | static void mce_async_out(struct mceusb_dev *ir, unsigned char *data, int size) |
@@ -794,7 +800,7 @@ static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 carrier) | |||
794 | ir->carrier = carrier; | 800 | ir->carrier = carrier; |
795 | cmdbuf[2] = MCE_CMD_SIG_END; | 801 | cmdbuf[2] = MCE_CMD_SIG_END; |
796 | cmdbuf[3] = MCE_IRDATA_TRAILER; | 802 | cmdbuf[3] = MCE_IRDATA_TRAILER; |
797 | dev_dbg(ir->dev, "%s: disabling carrier " | 803 | mce_dbg(ir->dev, "%s: disabling carrier " |
798 | "modulation\n", __func__); | 804 | "modulation\n", __func__); |
799 | mce_async_out(ir, cmdbuf, sizeof(cmdbuf)); | 805 | mce_async_out(ir, cmdbuf, sizeof(cmdbuf)); |
800 | return carrier; | 806 | return carrier; |
@@ -806,7 +812,7 @@ static int mceusb_set_tx_carrier(struct rc_dev *dev, u32 carrier) | |||
806 | ir->carrier = carrier; | 812 | ir->carrier = carrier; |
807 | cmdbuf[2] = prescaler; | 813 | cmdbuf[2] = prescaler; |
808 | cmdbuf[3] = divisor; | 814 | cmdbuf[3] = divisor; |
809 | dev_dbg(ir->dev, "%s: requesting %u HZ " | 815 | mce_dbg(ir->dev, "%s: requesting %u HZ " |
810 | "carrier\n", __func__, carrier); | 816 | "carrier\n", __func__, carrier); |
811 | 817 | ||
812 | /* Transmit new carrier to mce device */ | 818 | /* Transmit new carrier to mce device */ |
@@ -879,7 +885,7 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) | |||
879 | rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK) | 885 | rawir.duration = (ir->buf_in[i] & MCE_PULSE_MASK) |
880 | * US_TO_NS(MCE_TIME_UNIT); | 886 | * US_TO_NS(MCE_TIME_UNIT); |
881 | 887 | ||
882 | dev_dbg(ir->dev, "Storing %s with duration %d\n", | 888 | mce_dbg(ir->dev, "Storing %s with duration %d\n", |
883 | rawir.pulse ? "pulse" : "space", | 889 | rawir.pulse ? "pulse" : "space", |
884 | rawir.duration); | 890 | rawir.duration); |
885 | 891 | ||
@@ -911,7 +917,7 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) | |||
911 | if (ir->parser_state != CMD_HEADER && !ir->rem) | 917 | if (ir->parser_state != CMD_HEADER && !ir->rem) |
912 | ir->parser_state = CMD_HEADER; | 918 | ir->parser_state = CMD_HEADER; |
913 | } | 919 | } |
914 | dev_dbg(ir->dev, "processed IR data, calling ir_raw_event_handle\n"); | 920 | mce_dbg(ir->dev, "processed IR data, calling ir_raw_event_handle\n"); |
915 | ir_raw_event_handle(ir->rc); | 921 | ir_raw_event_handle(ir->rc); |
916 | } | 922 | } |
917 | 923 | ||
@@ -933,7 +939,7 @@ static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs) | |||
933 | 939 | ||
934 | if (ir->send_flags == RECV_FLAG_IN_PROGRESS) { | 940 | if (ir->send_flags == RECV_FLAG_IN_PROGRESS) { |
935 | ir->send_flags = SEND_FLAG_COMPLETE; | 941 | ir->send_flags = SEND_FLAG_COMPLETE; |
936 | dev_dbg(ir->dev, "setup answer received %d bytes\n", | 942 | mce_dbg(ir->dev, "setup answer received %d bytes\n", |
937 | buf_len); | 943 | buf_len); |
938 | } | 944 | } |
939 | 945 | ||
@@ -951,7 +957,7 @@ static void mceusb_dev_recv(struct urb *urb, struct pt_regs *regs) | |||
951 | 957 | ||
952 | case -EPIPE: | 958 | case -EPIPE: |
953 | default: | 959 | default: |
954 | dev_dbg(ir->dev, "Error: urb status = %d\n", urb->status); | 960 | mce_dbg(ir->dev, "Error: urb status = %d\n", urb->status); |
955 | break; | 961 | break; |
956 | } | 962 | } |
957 | 963 | ||
@@ -978,8 +984,8 @@ static void mceusb_gen1_init(struct mceusb_dev *ir) | |||
978 | ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0), | 984 | ret = usb_control_msg(ir->usbdev, usb_rcvctrlpipe(ir->usbdev, 0), |
979 | USB_REQ_SET_ADDRESS, USB_TYPE_VENDOR, 0, 0, | 985 | USB_REQ_SET_ADDRESS, USB_TYPE_VENDOR, 0, 0, |
980 | data, USB_CTRL_MSG_SZ, HZ * 3); | 986 | data, USB_CTRL_MSG_SZ, HZ * 3); |
981 | dev_dbg(dev, "%s - ret = %d\n", __func__, ret); | 987 | mce_dbg(dev, "%s - ret = %d\n", __func__, ret); |
982 | dev_dbg(dev, "%s - data[0] = %d, data[1] = %d\n", | 988 | mce_dbg(dev, "%s - data[0] = %d, data[1] = %d\n", |
983 | __func__, data[0], data[1]); | 989 | __func__, data[0], data[1]); |
984 | 990 | ||
985 | /* set feature: bit rate 38400 bps */ | 991 | /* set feature: bit rate 38400 bps */ |
@@ -987,19 +993,19 @@ static void mceusb_gen1_init(struct mceusb_dev *ir) | |||
987 | USB_REQ_SET_FEATURE, USB_TYPE_VENDOR, | 993 | USB_REQ_SET_FEATURE, USB_TYPE_VENDOR, |
988 | 0xc04e, 0x0000, NULL, 0, HZ * 3); | 994 | 0xc04e, 0x0000, NULL, 0, HZ * 3); |
989 | 995 | ||
990 | dev_dbg(dev, "%s - ret = %d\n", __func__, ret); | 996 | mce_dbg(dev, "%s - ret = %d\n", __func__, ret); |
991 | 997 | ||
992 | /* bRequest 4: set char length to 8 bits */ | 998 | /* bRequest 4: set char length to 8 bits */ |
993 | ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0), | 999 | ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0), |
994 | 4, USB_TYPE_VENDOR, | 1000 | 4, USB_TYPE_VENDOR, |
995 | 0x0808, 0x0000, NULL, 0, HZ * 3); | 1001 | 0x0808, 0x0000, NULL, 0, HZ * 3); |
996 | dev_dbg(dev, "%s - retB = %d\n", __func__, ret); | 1002 | mce_dbg(dev, "%s - retB = %d\n", __func__, ret); |
997 | 1003 | ||
998 | /* bRequest 2: set handshaking to use DTR/DSR */ | 1004 | /* bRequest 2: set handshaking to use DTR/DSR */ |
999 | ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0), | 1005 | ret = usb_control_msg(ir->usbdev, usb_sndctrlpipe(ir->usbdev, 0), |
1000 | 2, USB_TYPE_VENDOR, | 1006 | 2, USB_TYPE_VENDOR, |
1001 | 0x0000, 0x0100, NULL, 0, HZ * 3); | 1007 | 0x0000, 0x0100, NULL, 0, HZ * 3); |
1002 | dev_dbg(dev, "%s - retC = %d\n", __func__, ret); | 1008 | mce_dbg(dev, "%s - retC = %d\n", __func__, ret); |
1003 | 1009 | ||
1004 | /* device reset */ | 1010 | /* device reset */ |
1005 | mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET)); | 1011 | mce_async_out(ir, DEVICE_RESET, sizeof(DEVICE_RESET)); |
@@ -1122,7 +1128,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, | |||
1122 | bool tx_mask_normal; | 1128 | bool tx_mask_normal; |
1123 | int ir_intfnum; | 1129 | int ir_intfnum; |
1124 | 1130 | ||
1125 | dev_dbg(&intf->dev, "%s called\n", __func__); | 1131 | mce_dbg(&intf->dev, "%s called\n", __func__); |
1126 | 1132 | ||
1127 | idesc = intf->cur_altsetting; | 1133 | idesc = intf->cur_altsetting; |
1128 | 1134 | ||
@@ -1150,7 +1156,7 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, | |||
1150 | ep_in = ep; | 1156 | ep_in = ep; |
1151 | ep_in->bmAttributes = USB_ENDPOINT_XFER_INT; | 1157 | ep_in->bmAttributes = USB_ENDPOINT_XFER_INT; |
1152 | ep_in->bInterval = 1; | 1158 | ep_in->bInterval = 1; |
1153 | dev_dbg(&intf->dev, "acceptable inbound endpoint " | 1159 | mce_dbg(&intf->dev, "acceptable inbound endpoint " |
1154 | "found\n"); | 1160 | "found\n"); |
1155 | } | 1161 | } |
1156 | 1162 | ||
@@ -1165,12 +1171,12 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, | |||
1165 | ep_out = ep; | 1171 | ep_out = ep; |
1166 | ep_out->bmAttributes = USB_ENDPOINT_XFER_INT; | 1172 | ep_out->bmAttributes = USB_ENDPOINT_XFER_INT; |
1167 | ep_out->bInterval = 1; | 1173 | ep_out->bInterval = 1; |
1168 | dev_dbg(&intf->dev, "acceptable outbound endpoint " | 1174 | mce_dbg(&intf->dev, "acceptable outbound endpoint " |
1169 | "found\n"); | 1175 | "found\n"); |
1170 | } | 1176 | } |
1171 | } | 1177 | } |
1172 | if (ep_in == NULL) { | 1178 | if (ep_in == NULL) { |
1173 | dev_dbg(&intf->dev, "inbound and/or endpoint not found\n"); | 1179 | mce_dbg(&intf->dev, "inbound and/or endpoint not found\n"); |
1174 | return -ENODEV; | 1180 | return -ENODEV; |
1175 | } | 1181 | } |
1176 | 1182 | ||