How to detect the usb gadget connected to host from application

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Greg KH,

                  I am using usb gadget printer driver for iMX25(ARM9)
board and the kernel version is 2.6.31, now i have made an application
which will open the driver from user space as "/dev/g_printer"
whenever i connect the usb gadget to the host i need to detect from my
application. I have made an switch case in ioctl function of
/driver/usb/gadget/printer.c as

 switch (code) {
        case GADGET_GET_PRINTER_STATUS:
                status = (int)dev->printer_status;
                break;
        case GADGET_SET_PRINTER_STATUS:
                dev->printer_status = (u8)arg;
                break;
        case ATTACHED:
               PrintMessage("ioctl:Before usb_gadget_vbus_draw\n");
               status = usb_gadget_connect(dev->gadget);
               PrintMessage("ioctl:After usb_gadget_vbus_draw\n");
                break;
    default:
                /* could not handle ioctl */
                DBG(dev, "IntelliBar printer_ioctl: ERROR
cmd=0x%4.4xis not supported\n",
                                code);
                status = -ENOTTY;
        }

in my application i have used the driver ioctl as

        static int attach;
        attach = ioctl(fd[0].fd, ATTACHED);
        printf("Attached=%d\n", attach);
        if(attach < 0)
        {
           printf("Printer Dettached\n");
        }
        else
        {
          printf("Printer Attached\n");
         }

Now the question is whenever i connect the usb gadget to host the case
ATTACHED is called from driver and it should return zero on success
and -ve on error, when i will get attach = 0 always even if i connect
to host or not.

How to resolve this issue. Please help me asap.


-- 
Thanks & Regards,
SANDEEP G R,
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux