Hi!

Currently I'm trying to istall a Devolo dLAN-USB adapter, also known as Power 
Line. [1]

They even provide an open source driver for Linux as a 400kb tarball [2]. 
Unfortunately "make" isn't successful (see make_1.txt). I'll attach the 
problematic devolo_usb.c file and their readme, too.

I hope you can help me.

Thanks in advance!

Florian Philipp

[1] http://en.wikipedia.org/wiki/Power_line_communication
[2] 
http://download.devolo.biz/webcms/0518732001164965747/dLAN-linux-package-v3.tar.gz
                        README file for

        USB drivers and dlanconfig for devolo dLAN; 

                tested under SUSE Linux and Debian Linux 
                   with kernel versions 2.4 and 2.6

01.03.2005

--------------------------------------------------------------------------------

        Contents

        1.      Overview
        
        2.      Requirements    
          2.1   SUSE
          2.2   Debian
          2.3   libpcap
        
        3.      USB-driver installation (for USB connection)
                and the configuration program dlanconfig
          3.1   Unpack the compressed tar file
          3.2   Installation
        
        4.      dLAN duo
          4.1   Configuration - one-time application 
                (e.g. to test the installation)
          4.2   Configuration under SUSE Linux — permanent installation 
          4.3   Configuration under Debian Linux — permanent installation
        
        5.      dlanconfig    
          5.1   Change password
          5.2   Overview of the dLAN network

--------------------------------------------------------------------------------

1.      Overview

        This readme file contains information about installing the USB driver 
        and the configuration program dlanconfig under SUSE Linux and 
        Debian Linux.

        We also describe the configuration of the dLAN adapters.
        The dLAN duo can be connected either via Ethernet or USB ports.
        If both are installed, USB has priority.

        
        More detailed information about Linux commands is available in the 
        man pages. These are accessed by entering: man ifconfig.  

        
--------------------------------------------------------------------------------
2.      Requirements
        
        First of all check that your system and installation are optimised:


        2.1     SUSE


        SUSE users can use the YAST program to set up the required system 
        components or to check that they are selected in advance. Use the SUSE 
        menu system to select -> Yast and enter your “root” password. In the 
        selection dialogue 'Install and Remove software' choose the 
'Selections' 
        filter for a list of all of the system components. 

        To install the USB driver and the configuration program dlanconfig, 
        the following system components must be selected: 
   
                'C/C++ Compiler and Tools' 
                
                'Kernel Development'    (for installing the USB driver)


        2.2     Debian

        Debian users wishing to install the USB driver need the appropriate 
        kernel-headers-xxx, which must be installed in advance. You will find 
        the exact description (e.g. kernel-headers-2.4.27) by entering 
        'uname -a'. Type in the following command to install the kernel 
        headers:
                
                apt-get install kernel-headers-xxx 

        Depending on the configuration, the subsequent installation takes place 
        either automatically from the CD or from the Internet, assuming you 
        have access.


        2.3     libpcap

        libpcap is a library used by network sniffer programs. It offers these 
        programs an interface for processing and analysing data packets in 
        networks. You will need this library if you translate or write this 
        type of software yourself or if you wish to use the dlanconfig 
        configuration program. 

        Under SuSE Linux, the latest libpcap library is installed as standard. 
        We advise you to check you installation anyway.

        Debian users will have to install the libpcab library themselves. Do 
        this by entering the following command:
                
                apt-get install libpcap0.8-dev 

        Depending on the configuration, the subsequent installation takes place 
        either automatically from the CD or from the Internet, assuming you 
have 
        access. 

        Note: The devolo package includes a source text version of the libpcap 
        library. You should use this source text version if you have a 
different 
        distribution which does not include libpcap.  
          
--------------------------------------------------------------------------------

3.      USB-driver installation (for USB connection) and the configuration 
program dlanconfig

        3.1     Unpack the compressed tar file

        The following command unpacks the compressed tar file on your local 
        computer:
                
                tar xzvf dLAN-linux-package-1.2.tar.gz


        3.2     Installation

        After unpacking the tar file, change to the subdirectory dlanconfig and 
        continue with the installation as follows:

        There are three ways to carry out the installation:

                - The dLAN configuration program dlanconfig only
                - The USB driver for dLAN duo only
                - The dLAN configuration program dlanconfig and the USB driver


        To install the program dlanconfig only:
                        
                ./configure 
        
                make cfgtool
        
                make install-cfgtool    (as root)
        

        To install the USB driver for dLAN duo only:

                ./configure 
        
                make usbdriver
        
                make install-usbdriver  (as root)


        To install dlanconfig and the USB driver:

                ./configure 
        
                make
        
                make install            (as root)
        

        Note:  Entering the following command will cause the USB driver to be 
        automatically loaded after a restart:
                
                cd driver
        
                make installboot        (as root)

        
        Note: If error messages are displayed or if the installation aborts, 
        check that your system meets with the system requirements.  
         
--------------------------------------------------------------------------------
        
4.      dLAN duo

        The dLAN duo can be connected either via Ethernet or USB ports.
        If both are installed, USB has priority.

        After you install the USB driver from devolo, your computer will 
        recognise all connected dLAN duo adapters as network 
        interfaces. This means that a dLAN duo can be treated like 
        any other interface, such as an Ethernet port, for example.
        Entering the command 'ifconfig -a' displays all network interfaces. 
        Each dLAN duo adapter has an identifier that consists of 
        'dlanusb' and  a unique number (e.g. "0" for the first device, "1" for 
        the second, etc.).

        Note: The command 'ifconfig -a' can only be executed as "root".  


        4.1     Configuration - one-time application 
                (e.g. to test the installation)

        Note: All of the IP addresses named here are examples only.


        After listing all of the network interfaces with the command 
        'ifconfig -a', continue with the configuration with the following 
        example entries: 


                ifconfig dlanusb0 198.168.0.1 netmask 255.255.255.0 up 

        
        Note: Make sure that the new IP addresses are not already being used in
        your network and that they lie within your existing range of IP
        addresses! 


        4.2     Configuration under SUSE Linux — permanent installation 

        Note: This procedure can only be executed as "root". 

        For the permanent installation of the dLAN duo under SUSE 
        Linux, you should create a text file with the necessary information for 
        the adapter. 
        Enter the following information with any text editor (e.g. edit, pico):

        - if IP addresses are to be assigned dynamically: 

                BOOTPROTO='dhcp'     
                STARTMODE='hotplug'     

        Finally, the file is saved under the unique identifier for the 
        dLAN duo adapter as follows:

        /etc/sysconfig/network/ifcfg-dlanusb0    
 
        
        - if IP addresses are to be assigned statically:

                BOOTPROTO='static'
                STARTMODE='hotplug'
                IPADDR='192.168.0.1'
                NETMASK='255.255.255.0'

        Note: Make sure that the new IP addresses are not already being used in
        your network and that they lie within your existing range of IP
        addresses!  
        
        Finally, the file is saved under the unique identifier for the 
        dLAN duo adapter as follows:
        
        /etc/sysconfig/network/ifcfg-dlanusb0    


        To define a gateway, create the file
        /etc/sysconfig/network/ifroute-dlanusb0 
        and enter the following information:


                default 192.168.0.253 - -  
 
        
        Note: Make sure that the IP address is the same as that for your 
        gateway. In most cases the network router is the gateway.

        

        To set the DNS server edit the file /etc/resolv.conf as follows:

        
                nameserver 192.168.0.253 
                (IP address corresponds to that of the DNS server)


        Note: Ensure that the IP address corresponds to that of your DNS server.
        In most cases the network router is the DNS server.


        
        Note: dLAN duo adapters cannot be configured graphically with
        Yast. 

  
        4.3     Configuration under Debian Linux — permanent installation       

        Note: This procedure can only be executed as "root".   

        Under Debian Linux, the following information is appended to the file
        '/etc/interfaces':

        - if IP addresses are to be assigned dynamically: 

                auto dlanusb0           
                iface dlanusb0 inet dhcp


        - if IP addresses are to be assigned statically:

                auto dlanusb0   
                iface dlanusb0 inet static
                address 192.168.0.1
                netmask 255.255.255.0
                gateway 192.168.0.253   (only required for Internet access)     
        


        The file '/etc/resolv.conf' must be edited to ensure that the name
        resolution is executed correctly. Enter the IP address for the DNS
        server into this file, e.g.


                nameserver 192.168.0.253        (only required for Internet
                access)


        Note: Ensure that the IP address corresponds to that of your DNS server.
        In most cases the network router is the DNS server.

        
        
        Note: Operating multiple network interfaces can potentially cause
        problems with DNS and routing. We recommend the use of DHCP for the
        assignment of IP addresses so that the DNS and gateway are adapted
        automatically.

--------------------------------------------------------------------------------

5.      dlanconfig    

        Note: The following procedure can only be executed as "root". 

        Entering 'dlanconfig' allows you to configure a HomePlug network. The
        following entry is an example that adds your first local dLAN adapter
       (dlanusb0) to your network:      

                /usr/local/sbin/dlanconfig dlanusb0

        Note: If a local dLAN adapter is connected via Ethernet, then
        dlanconfig will be started with the identifier of the appropriate
        network card, i.e. if it is connected to the first network card, 
        then the entry is as follows:

                 /usr/local/sbin/dlanconfig eth0
        
        A menu assists you to set the network password for the local and/or
        remote dLAN devices. You also have an overview of all dLAN devices
        installed in your network.  

        5.1     Change password

        You can change the HomePlug password for the local dLAN adapter in the
        menu by selecting the option 'Set local network password' and entering
        the new network password. You will then see a brief confirmation if the
        password was changed without error.
        
        You can change the HomePlug password for a remote dLAN adapter in the
        menu by selecting the option 'Set remote network password'. Enter the
        new network password and the Security ID of the remote dLAN adapter. The
        Security ID is printed on the back of every dLAN adapter. Please observe
        that entering the Security ID (XXXX-XXXX-XXXX-XXXX) is case sensitive.
        You will then see a brief confirmation if the password was changed
        without error.

        5.2     Overview of the dLAN network

        For an overview of all of the remote dLAN adapters installed in your
        dLAN network, use the menu to access the option 'List remote devices'.
        dlanconfig also displays the connection rates between the local and the
        remote dLAN devices.
        If a remote dLAN adapter is highlighted with the * symbol, then the
        connection rate value has not been updated.

--------------------------------------------------------------------------------
/* 
   devolo_usb.c: dLAN USB driver for linux. 

   Only for use with dLAN adaptors from devolo.
   Copyright 2006 devolo AG

*/
    
/*
 *   Include
 */
#include </usr/include/linux/sched.h>
#include </usr/include/linux/slab.h>
#include </usr/include/linux/init.h>
#include </usr/include/linux/delay.h>
#include </usr/include/linux/netdevice.h>
#include </usr/include/linux/etherdevice.h>
#include </usr/include/linux/usb.h>
#include </usr/include/linux/module.h>
#include </usr/include/linux/ethtool.h>
#include </usr/include/asm/uaccess.h>
#include </usr/include/linux/config.h>
#include </usr/include/linux/kmod.h>
#include </usr/include/linux/random.h>
#include </usr/include/asm/unaligned.h>
#include </usr/include/linux/netdevice.h>
#include </usr/include/linux/rtnetlink.h>
#include "devolo_usb.h"


static int multicast_filter_limit = 32;

/*
 *   List of supported vendor_id/device_id
 */
static struct usb_device_id plUsb_ids[] = {
  {
    USB_DEVICE (USB_INTELLON_VENDOR_ID, USB_INTELLON_PRODUCT_ID),
  },
  {},	       
};

#if defined(MODULE_LICENSE)
MODULE_LICENSE ("devolo AG");
#endif


MODULE_AUTHOR (DRIVER_AUTHOR);
MODULE_DESCRIPTION (DRIVER_DESC);
MODULE_DEVICE_TABLE (usb, plUsb_ids);

static void
ctrl_callback (struct urb * urb)
{
  devoloUSB_t *devolo = urb->context;

  if (!devolo)
    return;

  switch (urb->status)
    {
    case 0:
      break;
    case -EINPROGRESS:
      return;
    case -ENOENT:
      break;
    default:
      warn("%s: status %d",__FUNCTION__, urb->status);
    }

  wake_up (&devolo->ctrl_wait);

}


/*
 *   Function that send packet to upper level
 */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
static void devolo_read_bulk_callback (struct urb *urb, struct pt_regs * unused)
#else
static void devolo_read_bulk_callback (struct urb *urb)
#endif
{
  devoloUSB_t *devolo = urb->context;
  struct net_device *net;

  int count = urb->actual_length;
  int res;
  struct sk_buff *skb;  
  
  if (!devolo || !(devolo->flags & DEVOLO_RUNNING))
    return;
  
  net = devolo->net;
  if (!netif_device_present (net))
    return;

  if (devolo->flags & DEVOLO_RX_BUSY){
    /*
     *  Update stats
     */
    devolo->stats.rx_errors++;
    return;
  }
  devolo->flags |= DEVOLO_RX_BUSY;
  
  switch (urb->status){
  case 0:
    break;
  case -ETIMEDOUT:
    devolo->flags &= ~DEVOLO_RX_BUSY;
    break;
  case -EPIPE:
    /* stall or disconnect */
    warn("%s: no rx stall recovery", net->name);
    return;
  case -ENOENT:
  case -ECONNRESET:
  case -ESHUTDOWN:
    return;
  default:
    goto goon;
  }
  
  if (!count)
    goto goon;

  if (!(skb = dev_alloc_skb (count)))
    goto goon;

  skb->dev = net;

  eth_copy_and_sum (skb, devolo->rx_buff, count, 0);
  /* bug 1180*/
  skb_put (skb, count-2);

  skb->protocol = eth_type_trans (skb, net);

  /*
   *  Sending packet to upper level
   */
  netif_rx (skb);

  /*
   *  Update stats
   */
  devolo->stats.rx_packets++;
  devolo->stats.rx_bytes += count;

 goon:
  FILL_BULK_URB (devolo->rx_urb, devolo->usb,
		 usb_rcvbulkpipe (devolo->usb, 1), devolo->rx_buff,
		 DEVOLO_MAX_MTU, devolo_read_bulk_callback, devolo);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
  if ((res = usb_submit_urb (devolo->rx_urb,GFP_ATOMIC)))
#else
  if ((res = usb_submit_urb (devolo->rx_urb)))
#endif
    printk(KERN_ERR "Failed submit rx_urb %d\n", res);
  devolo->flags &= ~DEVOLO_RX_BUSY;
  return;
}


/*
 *   Callback called after packet transmission
 */ 
static void 
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
devolo_write_bulk_callback (struct urb *urb,struct pt_regs * unused)
#else
devolo_write_bulk_callback (struct urb *urb)
#endif
{

  devoloUSB_t *devolo = urb->context;

  if (!devolo || !(devolo->flags & DEVOLO_RUNNING))
    return;

  if (!netif_device_present (devolo->net))
    return;

  devolo->net->trans_start = jiffies;
  /*
   *   Restart packet queue
   */
  netif_wake_queue (devolo->net);

}


/*
 *   Timeout function
 */
static void
devolo_tx_timeout (struct net_device *net)
{
  devoloUSB_t * devolo = net->priv;
  if (!devolo)
    return;
#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)) && (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,14)))
  devolo->tx_urb->transfer_flags |= URB_ASYNC_UNLINK;
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
  devolo->tx_urb->transfer_flags |= USB_ASYNC_UNLINK;
#endif
  usb_unlink_urb (devolo->tx_urb);

  /*
   *  Update stats
   */
  devolo->stats.tx_errors++;
}


/*
 *  Function called when kernel need to transmit a packet
 */
static int
devolo_start_xmit (struct sk_buff *skb, struct net_device *net)
{

  devoloUSB_t *devolo = net->priv;
  int count = skb->len+2;
  int res;
  __u16 l16 = skb->len;

  if (!(count % 64)){
      count++;
      l16++;
    }

  if (count < 64){
      count=65;
      l16=63;
    }

  /*
   *   Stop packet queue
   */
  netif_stop_queue (net);

  ((unsigned char *) devolo->tx_buff)[0] = l16 & 0xFF;
  ((unsigned char *) devolo->tx_buff)[1] = (l16 & 0x700) >> 8;
  memcpy (devolo->tx_buff+2, skb->data, skb->len);
 
  FILL_BULK_URB (devolo->tx_urb, devolo->usb,
		 usb_sndbulkpipe (devolo->usb, 2), devolo->tx_buff,
		 count, devolo_write_bulk_callback, devolo);

  /*
   *  Submit urb and update stats
   */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
  if ((res = usb_submit_urb (devolo->tx_urb,GFP_ATOMIC))){
#else
  if ((res = usb_submit_urb (devolo->tx_urb))){
#endif
    warn("failed tx_urb %d",res);
    switch (res){
    case -EPIPE:
      /* stall or disconnect... cleanup should 
	 already have been scheduled           */
      break;
    case -ENODEV:
      /* disconnect() upcoming */
      break;
    default:
      devolo->stats.tx_errors++;
      netif_start_queue (net);
    }
  }else{
    devolo->stats.tx_packets++;
    devolo->stats.tx_bytes += skb->len;
    net->trans_start = jiffies;
  }

  dev_kfree_skb (skb);

  return 0;
}


/*
 *   Function that manage stats of the device
 */
static struct net_device_stats *
devolo_netdev_stats (struct net_device *dev)
{
  return &((devoloUSB_t *) dev->priv)->stats;
}


/*
 *   Function that convert hex value to decimal value
 */
static inline unsigned char hex2dec( unsigned char digit )
{
  if ( (digit >= '0') && (digit <= '9') )	
    return (digit - '0');
  
  if ( (digit >= 'a') && (digit <= 'f') )	
    return (digit - 'a' + 10);
  
  if ( (digit >= 'A') && (digit <= 'F') )	
    return (digit - 'A' + 10);
  
  return 16;
}


/*
 *   Function that fill MAC address 
 */
static void set_ethernet_addr( devoloUSB_t *devolo)
{
  int i;
  int len;
  unsigned char buffer[13];
  unsigned char	mac_addr[6];

  len = usb_string(devolo->usb, 3, buffer, 13);
	
  if (len != 12) {
    printk(KERN_ERR "Attempting to get MAC address returned %d bytes\n", len);
    return;
  }
	
  /* 
   *  Fill in the mac_addr 
   */
  for (i = 0; i < 6; i++){
    mac_addr[i] = ( hex2dec( buffer[2 * i] ) << 4 ) + hex2dec( buffer[2 * i + 1] );
  }
	
  /* 
   *  Now copy into the kernel's network driver. 
   */
  memcpy(devolo->net->dev_addr, mac_addr, SIZEOF_MAC);

}

/*
 *  Open function called every time you plug a device
 */ 
static int
devolo_open (struct net_device *net)
{
  devoloUSB_t *devolo = (devoloUSB_t *) net->priv;
  int res;


  // set_ethernet_addr(devolo);

  devolo->flags &= ~DEVOLO_RX_BUSY;
  FILL_BULK_URB (devolo->rx_urb, devolo->usb,
		 usb_rcvbulkpipe (devolo->usb, 1),
		 devolo->rx_buff, DEVOLO_MAX_MTU,
		 devolo_read_bulk_callback,devolo); 

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
  if ((res = usb_submit_urb (devolo->rx_urb,GFP_KERNEL/*GFP_ATOMIC??*/)))
#else
  if ((res = usb_submit_urb (devolo->rx_urb)))
#endif
    {
      printk(KERN_ERR "Failed rx_urb %d\n", res);
    }

  netif_start_queue (net);
  devolo->flags |= DEVOLO_RUNNING;

  return 0;
}


/*
 * Close function called every time you unplug a device
 */
static int 
devolo_close (struct net_device *net)
{
  devoloUSB_t * devolo = net->priv;


  devolo->flags &= ~DEVOLO_RUNNING;
  netif_stop_queue (net);

  usb_unlink_urb (devolo->rx_urb);
  usb_unlink_urb (devolo->tx_urb);
  usb_unlink_urb (devolo->ctrl_urb);

  return 0;
}


/*
 *  Manager for ethernet ioctl
 */
static int
netdev_ethtool_ioctl (struct net_device *dev, void *useraddr)
{
  u32 ethcmd;

  if (copy_from_user (&ethcmd, useraddr, sizeof (ethcmd)))
    return -EFAULT;
  switch (ethcmd)
    {
    case ETHTOOL_GDRVINFO:
      {
	struct ethtool_drvinfo info = { ETHTOOL_GDRVINFO };
	strncpy (info.driver, "devolo", sizeof (info.driver) - 1);
	if (copy_to_user (useraddr, &info, sizeof (info)))
	  return -EFAULT;
	return 0;
      }
    }
  return -EOPNOTSUPP;
}


static int read_mii_word( devoloUSB_t *devolo, __u8 phy, __u8 indx, __u16 *regd ){
  return 0;
}

static int write_mii_word( devoloUSB_t *devolo, __u8 phy, __u8 indx, __u16 regd ){
  return 0;
}


/*
 *  Function that manage standard ioctl system calls
 */
static int
devolo_ioctl (struct net_device *net, struct ifreq *rq, int cmd)
{
  __u16 *data = (__u16 *) & rq->ifr_data;
  devoloUSB_t *devolo = net->priv;

  switch (cmd)
    {
    case SIOCETHTOOL:
      return netdev_ethtool_ioctl (net, (void *) rq->ifr_data);
    case SIOCDEVPRIVATE:
      data[0] = devolo->phy;
    case SIOCDEVPRIVATE + 1:
      read_mii_word (devolo, data[0], data[1] & 0x1f, &data[3]);
      return 0;
    case SIOCDEVPRIVATE + 2:
      if (!capable (CAP_NET_ADMIN))
	return -EPERM;
      write_mii_word (devolo, devolo->phy, data[1] & 0x1f, data[2]);
      return 0;
    default:
      return -EOPNOTSUPP;
    }
}


/*
 *   Function for multicast set
 */ 
static void
devolo_set_multicast (struct net_device *net)
{
  devoloUSB_t *devolo = net->priv;

  /*
   *   Stop packet queue
   */
  netif_stop_queue (net);

  if (net->flags & IFF_PROMISC)
    printk(KERN_INFO "%s: Promiscuous mode enabled\n", net->name);
  
  else if ((net->mc_count > multicast_filter_limit) ||
	   (net->flags & IFF_ALLMULTI))
    printk(KERN_INFO "%s set allmulti\n", net->name);
  
  devolo->flags |= ETH_REGS_CHANGE;
  ctrl_callback (devolo->ctrl_urb);

  /*
   *   Restart packet queue
   */
  netif_wake_queue (net);
  
}


/*
 *   Function that allocate, initialize
 *   and register a new device
 */
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
static int 
devolo_probe (struct usb_interface* intf,
	      const struct usb_device_id *id)
{
  struct usb_device *dev=interface_to_usbdev(intf);
#else 
static void *
  devolo_probe (struct usb_device *dev, unsigned int ifnum,
	      const struct usb_device_id *id)
{
#endif
  struct net_device *net;
  devoloUSB_t *devolo;
  int dev_index = 0;
  int err;
  
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
  if (usb_reset_configuration (dev))
#else
  if (usb_set_configuration (dev, dev->config[0].bConfigurationValue))
#endif
    {
      printk(KERN_ERR "usb_set_configuration failed\n");
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
      return -ENODEV;
#else
      return NULL;
#endif
    }

  if (!(devolo = kmalloc (sizeof (struct devoloUSB), GFP_KERNEL)))
    {
      printk(KERN_ERR "Out of memory allocating device structure\n");
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
      return -ENOMEM;
#else
      return NULL;
#endif
    }

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
  usb_get_dev(dev);
#else
  usb_inc_dev_use (dev);
#endif
  memset (devolo, 0, sizeof (struct devoloUSB));
  devolo->dev_index = dev_index;
  init_waitqueue_head (&devolo->ctrl_wait);

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))

  devolo->ctrl_urb=usb_alloc_urb(0,GFP_KERNEL);
  if(!devolo->ctrl_urb) return -ENOMEM;
  devolo->rx_urb=usb_alloc_urb(0,GFP_KERNEL);
  if(!devolo->rx_urb) {
    usb_free_urb(devolo->ctrl_urb);
    return -ENOMEM;
  }
  devolo->tx_urb=usb_alloc_urb(0,GFP_KERNEL);
  if(!devolo->tx_urb) {
    usb_free_urb(devolo->ctrl_urb);
    usb_free_urb(devolo->rx_urb);
    return -ENOMEM;
  }
  devolo->intr_urb=usb_alloc_urb(0,GFP_KERNEL);
  if(!devolo->intr_urb) {
    usb_free_urb(devolo->ctrl_urb);
    usb_free_urb(devolo->rx_urb);
    usb_free_urb(devolo->tx_urb);
    return -ENOMEM;
  }
#else
  devolo->ctrl_urb=usb_alloc_urb(0);
  devolo->rx_urb=usb_alloc_urb(0);
  devolo->tx_urb=usb_alloc_urb(0);
  devolo->intr_urb=usb_alloc_urb(0);
#endif


  /*
   *	Allocate a device
   */
  net = alloc_etherdev(NET_SIZE_OF_PRIV);
  if(net==NULL)
    {
      usb_free_urb(devolo->ctrl_urb);
      usb_free_urb(devolo->rx_urb);
      usb_free_urb(devolo->tx_urb);
      usb_free_urb(devolo->intr_urb);
      kfree (devolo);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
      return -ENOMEM;
#else
      return NULL;
#endif
    }

  /*
   *  Allocate a name
   */
  strcpy(net->name, DEVICE_NAME_MASK);
  if (dev_alloc_name(net, DEVICE_NAME_MASK)<0) {
    usb_free_urb(devolo->ctrl_urb);
    usb_free_urb(devolo->rx_urb);
    usb_free_urb(devolo->tx_urb);
    usb_free_urb(devolo->intr_urb);
    kfree(net);
    kfree (devolo);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
      return -ENOMEM;
#else
      return NULL;
#endif
  }

#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
  init_etherdev (net, NET_SIZE_OF_PRIV);
#endif
  /*
   *  Register the device
   */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
  rtnl_lock();
  err = register_netdevice(net);
  rtnl_unlock();
  if (err < 0)
    {
      usb_free_urb(devolo->ctrl_urb);
      usb_free_urb(devolo->rx_urb);
      usb_free_urb(devolo->tx_urb);
      usb_free_urb(devolo->intr_urb);
      kfree(net);
      kfree(devolo);
      net = NULL;
      return NULL;
    }
#endif

  /*
   *  Implement operations needed by the device
   */
  ether_setup (net);
  devolo->usb = dev;
  devolo->net = net;
  SET_MODULE_OWNER (net);
  net->priv = devolo;
  net->open = devolo_open;
  net->stop = devolo_close;
  net->watchdog_timeo = DEVOLO_TX_TIMEOUT;
  net->tx_timeout = devolo_tx_timeout;
  net->do_ioctl = devolo_ioctl;
  net->hard_start_xmit = devolo_start_xmit;
  net->set_multicast_list = devolo_set_multicast;
  net->get_stats = devolo_netdev_stats;
  net->mtu = DEVOLO_MTU;
  devolo->phy = 1;

  set_ethernet_addr(devolo);

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
  usb_set_intfdata(intf, devolo);
  SET_NETDEV_DEV(net, &intf->dev);
  rtnl_lock();
  err = register_netdevice(net);
  rtnl_unlock();
  return 0;
#else
  return devolo;
#endif
}


/*
 *   Function that free all allocated resource
 */
 static void
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
devolo_disconnect (struct usb_interface* intf){
   struct devoloUSB *devoloUSB = usb_get_intfdata(intf);
   struct usb_device *dev=interface_to_usbdev(intf);
#else
devolo_disconnect (struct usb_device *dev, void *ptr){
  struct devoloUSB *devoloUSB = ptr;
#endif
  if (!devoloUSB)
    {
      printk(KERN_ERR "Unregistering non-existant device\n");
      return;
    }

  devoloUSB->flags |= DEVOLO_UNPLUG;
  unregister_netdev (devoloUSB->net);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
  usb_put_dev(dev);
#else
  usb_dec_dev_use (dev);
#endif
  usb_free_urb(devoloUSB->rx_urb);
  usb_free_urb(devoloUSB->tx_urb);
  usb_free_urb(devoloUSB->intr_urb);
  usb_free_urb(devoloUSB->ctrl_urb);
  kfree (devoloUSB->net);
  kfree (devoloUSB);
  devoloUSB = NULL;

}

/*
 *   Structure needed to register our objects
 *   and find our hardware device
 */
static struct usb_driver devolo_driver = {
  name:"devolo",
  probe:devolo_probe,
  disconnect:devolo_disconnect,
  id_table:plUsb_ids,
};

int __init
devolo_init (void)
{
  printk (KERN_INFO DRIVER_DESC ":" DRIVER_VERSION "\n");
/*   char usbmgr[9]={0}; */

#ifdef USBMGR

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))

#define usbmgr USBMGR"_hcd"
/*   sprintf(usbmgr,"%s_hcd",USBMGR); */
#else
#define usbmgr "usb-"USBMGR
/*   sprintf(usbmgr,"usb-%s",USBMGR); */
  
#endif

  request_module(usbmgr);
#endif
  return usb_register (&devolo_driver);
}

void __exit
devolo_exit (void)
{
  usb_deregister (&devolo_driver);
}


module_init (devolo_init);
module_exit (devolo_exit);
making all in tool
make[1]: Entering directory `/home/dsl/dLAN-linux-package-v3/tool'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/dsl/dLAN-linux-package-v3/tool'
making all in driver
make[1]: Entering directory `/home/dsl/dLAN-linux-package-v3/driver'
./kerneldir.sh /lib/modules/2.6.21-gentoo-r3/build
make[2]: Entering directory `/usr/src/linux-2.6.21-gentoo-r3'
  CC [M]  /home/dsl/dLAN-linux-package-v3/driver/devolo_usb.o
/home/dsl/dLAN-linux-package-v3/driver/devolo_usb.c:22:26: error: 
linux/config.h: No such file or directory
/home/dsl/dLAN-linux-package-v3/driver/devolo_usb.c: In function 
'devolo_read_bulk_callback':
/home/dsl/dLAN-linux-package-v3/driver/devolo_usb.c:153: warning: passing 
argument 6 of 'usb_fill_bulk_urb' from incompatible pointer type
/home/dsl/dLAN-linux-package-v3/driver/devolo_usb.c: In function 
'devolo_start_xmit':
/home/dsl/dLAN-linux-package-v3/driver/devolo_usb.c:249: warning: passing 
argument 6 of 'usb_fill_bulk_urb' from incompatible pointer type
/home/dsl/dLAN-linux-package-v3/driver/devolo_usb.c: In function 'devolo_open':
/home/dsl/dLAN-linux-package-v3/driver/devolo_usb.c:358: warning: passing 
argument 6 of 'usb_fill_bulk_urb' from incompatible pointer type
make[3]: *** [/home/dsl/dLAN-linux-package-v3/driver/devolo_usb.o] Error 1
make[2]: *** [_module_/home/dsl/dLAN-linux-package-v3/driver] Error 2
make[2]: Leaving directory `/usr/src/linux-2.6.21-gentoo-r3'
make[1]: *** [default] Error 2
make[1]: Leaving directory `/home/dsl/dLAN-linux-package-v3/driver'
make: *** [all] Error 2

Attachment: pgpRAiqrUzAgI.pgp
Description: PGP signature

Reply via email to