Re: How to detect the usb gadget connected to host from application

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

 



 attach = ioctl(fd[0].fd, ATTACHED);
ioctl wil return  '0' on success. so my understanding is you need to
pass the address of "status" to the ioctl and get the value.

eg: ioctl(fd, ATTACHED, &status);
if (status < 0)
{
 printf("Printer Dettached\n");
}

On Thu, Jun 24, 2010 at 1:25 PM, Sandeep G.R <grsandeep85@xxxxxxxxx> wrote:
> 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
>
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux