Example #1
0
static int labx_local_audio_open(struct inode *inode, struct file *filp) {
  int deviceIndex;
  struct labx_local_audio_pdev *local_audio_pdev;

  /* Search for the device amongst those which successfully were probed */
  for(deviceIndex = 0; deviceIndex < MAX_LA_DEVICES; deviceIndex++) {
    if ((devices[deviceIndex] != NULL) && (devices[deviceIndex]->miscdev.minor == iminor(inode))) {
      /* Retain the device pointer within the file pointer for future navigation */
      filp->private_data = devices[deviceIndex];
      break;
    }
  }

  /* Ensure the device was actually found */
  if(deviceIndex >= MAX_LA_DEVICES) {
    printk(KERN_WARNING DRIVER_NAME ": Could not find device for node (%d, %d)\n",
           imajor(inode), iminor(inode));
    return(-ENODEV);
  }

  /* TODO - Ensure the local audio hardware is reset */
  local_audio_pdev = (struct labx_local_audio_pdev*)filp->private_data;

  /* Also open the DMA instance, if there is one */
  if(local_audio_pdev->dma != NULL) labx_dma_open(local_audio_pdev->dma);

  /* Invoke the open() operation on the derived driver, if there is one */
  if((local_audio_pdev->derivedFops != NULL) && 
     (local_audio_pdev->derivedFops->open != NULL)) {
    local_audio_pdev->derivedFops->open(inode, filp);
  }

  return(0);
}
Example #2
0
static int labx_dma_open_cdev(struct inode *inode, struct file *filp) {
    int i;
    struct labx_dma_pdev *dma_pdev = NULL;

    for (i = 0; i<MAX_DMA_DEVICES; i++) {
        /* printk("lookup %d = %p, %d (looking for %d)\n", i, devices[i], (devices[i]) ? devices[i]->miscdev.minor : -1, iminor(inode));*/
        if ((devices[i] != NULL) && (devices[i]->miscdev.minor == iminor(inode)))
        {
            /* printk("labx_dma_open: found %p\n", devices[i]);*/
            dma_pdev = devices[i];
            filp->private_data = dma_pdev;
            break;
        }
    }

    if(dma_pdev == NULL) return(-1);

    /* Inform the encapsulated DMA driver that it is being opened */
    return(labx_dma_open(&dma_pdev->dma));
}