Linux USB 전송 방식 변경 ( interrupt => control ) 관련 질문입니다.

blackhush의 이미지

안녕하십니까?

Linux USB 전송 방식을 interrupt에서 control 방식으로 변경하려고 합니다.

아직 URB 구조체에 대한 개념이 부족해서 이렇게 질문드립니다.

Wireless lan usb dongle driver에서 수정을 하고 있는데요.

제품은 zydas 제품입니다.

기존 방식인 interrupt에서는 동작이 되는데 control 방식으로 변경을 하니 hw init 부분에서 error가 발생하네요.

고수님들의 의견 부탁드립니다.

struct usb_ctrlrequest1 {
char bRequestType;
char bRequest;
int wValue;
int wIndex;
int wLength;
};

int r;
struct usb_device *udev;
struct zd_usb_interrupt *intr = &usb->intr;

struct usb_ctrlrequest1 *req;

void *transfer_buffer = NULL;

struct urb *urb;

dev_dbg_f(zd_usb_dev(usb), "\n");

urb = usb_alloc_urb(0, GFP_KERNEL);

if (!urb) {
r = -ENOMEM;
goto out;
}

ZD_ASSERT(!irqs_disabled());

spin_lock_irq(&intr->lock);

if (intr->urb) {
spin_unlock_irq(&intr->lock);
r = 0;
goto error_free_urb;
}
intr->urb = urb;
spin_unlock_irq(&intr->lock);

/* TODO: make it a DMA buffer */
r = -ENOMEM;

transfer_buffer = kmalloc(USB_MAX_EP_INT_BUFFER, GFP_KERNEL);

if (!transfer_buffer) {
dev_dbg_f(zd_usb_dev(usb),
"couldn't allocate transfer_buffer\n");
goto error_set_urb_null;
}

udev = zd_usb_to_usbdev(usb);
===================================================================================================
제가 추가한 부분입니다.

req->bRequestType = 0x80;
req->bRequest = 0x06;
req->wValue = 0x0001;
req->wIndex = 0;
req->wLength =0x4000;

usb_fill_control_urb(urb, udev, usb_rcvctrlpipe(udev,EP_CTRL),(char *)req,transfer_buffer,
USB_MAX_EP_INT_BUFFER, int_urb_complete, usb);

===================================================================================================

dev_dbg_f(zd_usb_dev(usb), "submit urb %p\n", intr->urb);

r = usb_submit_urb(urb, GFP_KERNEL);

if (r) {
dev_dbg_f(zd_usb_dev(usb),
"Couldn't submit urb. Error number %d\n", r);
goto error;
}

return 0;
error:
kfree(transfer_buffer);
error_set_urb_null:
spin_lock_irq(&intr->lock);
intr->urb = NULL;
spin_unlock_irq(&intr->lock);
error_free_urb:
usb_free_urb(urb);
out:
return r;

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.