//
// Copyright (c) 1999-2004 Darius Rad
//
// This file is part of the OpenOtto project.
//
// OpenOtto is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//

/// \file
/// \brief Dummy device driver
/// \todo


#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <unistd.h>
#include <stdio.h>

#include <otto/otto.h>
#include <otto/packet.h>
#include <otto/device.h>
#include <otto/control.h>


static const char _ID_[] __attribute__ ((unused)) =
"$Id: dummy.c,v 1.2 2004/07/07 22:07:11 alpha Exp $";


struct otto_device *
dummy_open(
  const char *fname
)
{
  assert( fname != NULL );

  struct otto_device *dev;

  dev = malloc(sizeof(struct otto_device));
  if( dev == NULL )
  {
    perror("malloc");
    return(NULL);
  }

  memset( dev, 0, sizeof(struct otto_device) );

  return(dev);
}


static int
dummy_close(
  struct otto_device *dev
)
{
  assert( dev != NULL );

  free(dev);

  return(0);
}


static int
dummy_write(
  struct otto_device *dev,
  int bus,
  union otto_packet *pkt
)
{
  assert( dev != NULL );
  assert( pkt != NULL );

  return(0);
}


static int
dummy_read(
  struct otto_device *dev,
  int bus,
  union otto_packet *pkt
)
{
  assert( dev != NULL );
  assert( pkt != NULL );

  return(0);
}


static int
dummy_control(
  struct otto_device *dev,
  int bus,
  void *data,
  int cmd
)
{
  assert( dev != NULL );

  return(0);
}


static struct otto_driver dummy_drv =
{
  .name = "dummy",
  .desc = "Dummy device driver",
  .author = "Darius Rad <alpha@area49.net>",
  .license = "GPL",
  .open = dummy_open,
  .close = dummy_close,
  .write = dummy_write,
  .read = dummy_read,
  .control = dummy_control,
};


static void __attribute((constructor))
uart_serial_constructor(void)
{
  otto_register(&dummy_drv);
}
