Re: usbserial generic driver problems with system that also has USB-serial converter

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

 



Hi Greg,

On Sun, Dec 27, 2009 at 10:40:29PM -0500, Forest Bond wrote:
> On Sat, Dec 26, 2009 at 11:51:49AM -0500, Forest Bond wrote:
> > As I understand it, the user space application wants a standard serial interface
> > to the payment processing features of the device, so I need to expose a
> > /dev/ttyUSBn device for that purpose.
> 
> ... and it seems you already wrote an article that should be sufficient for me
> to do this:
> 
>   http://www.linuxjournal.com/article/6573
> 
> Go ahead and disregard my last message.  I should be able to do what I need to
> do with what I have.

I'm new to this.  Is there anything obviously wrong with the following?  It
seems to work, FWIW.  Any comments welcome, of course.


#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/tty.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/usb/serial.h>


#define DRIVER_VERSION "v1.00"
#define DRIVER_DESC "ViVOpay Generic USB Serial Driver"

#define VIVOPAY_VENDOR_ID 0x1d5f
#define VIVOPAY_PRODUCT_ID 0x1004


static struct usb_device_id id_table [] = {
    { USB_DEVICE(VIVOPAY_VENDOR_ID, VIVOPAY_PRODUCT_ID) },
    { },
};

MODULE_DEVICE_TABLE(usb, id_table);

static struct usb_driver vivopay_driver = {
    .name =             "vivopay",
    .probe =            usb_serial_probe,
    .disconnect =       usb_serial_disconnect,
    .id_table =         id_table,
    .no_dynamic_id =    1,
};

static struct usb_serial_driver vivopay_device = {
    .driver = {
        .owner =        THIS_MODULE,
        .name =         "vivopay",
    },
    .id_table =         id_table,
    .usb_driver =       &vivopay_driver,
    .num_ports =        1,
    .num_interrupt_in = 1,
    .num_bulk_in =      1,
    .num_bulk_out =     1,
};

static int __init vivopay_init(void)
{
    int retval;
    retval = usb_serial_register(&vivopay_device);
    if (retval)
        goto failed_usb_serial_register;
    retval = usb_register(&vivopay_driver);
    if (retval)
        goto failed_usb_register;
    printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_VERSION ":"
           DRIVER_DESC "\n");
    return 0;
failed_usb_register:
    usb_serial_deregister(&vivopay_device);
failed_usb_serial_register:
    return retval;
}

static void __exit vivopay_exit(void)
{
    usb_deregister(&vivopay_driver);
    usb_serial_deregister(&vivopay_device);
}

module_init(vivopay_init);
module_exit(vivopay_exit);

MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_VERSION(DRIVER_VERSION);
MODULE_LICENSE("GPL");


Thanks,
Forest
-- 
Forest Bond
http://www.alittletooquiet.net
http://www.pytagsfs.org

Attachment: signature.asc
Description: Digital signature


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

  Powered by Linux