Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

struct net_device* flexcan_device_alloc ( struct platform_device *  pdev,
void(*)(struct net_device *dev)  setup 
) [read]

The function allocates can device.

Parameters:
pdev the pointer of platform device.
setup the initial function pointer of network device.
Returns:
none

Definition at line 548 of file dev.c.

{
      struct flexcan_device *flexcan;
      struct net_device *net;
      int i, num;

      net = alloc_netdev(sizeof(*flexcan), "can%d", setup);
      if (net == NULL) {
            printk(KERN_ERR "Allocate netdevice for FlexCAN fail!\n");
            return NULL;
      }
      flexcan = netdev_priv(net);
      memset(flexcan, 0, sizeof(*flexcan));

      mutex_init(&flexcan->mutex);
      init_timer(&flexcan->timer);

      flexcan->dev = pdev;
      if (flexcan_device_attach(flexcan)) {
            printk(KERN_ERR "Attach FlexCAN fail!\n");
            free_netdev(net);
            return NULL;
      }
      flexcan_device_default(flexcan);
      flexcan_update_bitrate(flexcan);

      num = ARRAY_SIZE(flexcan_dev_attr);

      for (i = 0; i < num; i++) {
            if (device_create_file(&pdev->dev, flexcan_dev_attr + i)) {
                  printk(KERN_ERR "Create attribute file fail!\n");
                  break;
            }
      }

      if (i != num) {
            for (; i >= 0; i--)
                  device_remove_file(&pdev->dev, flexcan_dev_attr + i);
            free_netdev(net);
            return NULL;
      }
      dev_set_drvdata(&pdev->dev, net);
      return net;
}


Generated by  Doxygen 1.6.0   Back to index