Some cleanups, courtesy of Jack Burton.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3449 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2003-06-08 18:37:42 +00:00
parent d37e75d958
commit c59538b901
4 changed files with 70 additions and 43 deletions

View File

@ -11,10 +11,11 @@
/
*******************************************************************************/
#include <ktypes.h>
#include <KernelExport.h>
#include <Drivers.h>
#include <debug.h>
#include <memheap.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
@ -27,10 +28,14 @@
/*********************************/
int32 api_version = B_CUR_DRIVER_API_VERSION;
struct digit_state {
uchar value;
};
static status_t
digit_open(const char *name, uint32 mode, void **cookie)
{
@ -40,7 +45,7 @@ digit_open(const char *name, uint32 mode, void **cookie)
DPRINTF(("open\n"));
s = (struct digit_state*) kmalloc(sizeof(*s));
s = (struct digit_state *)malloc(sizeof(*s));
if (!s)
return ENOMEM;
@ -48,9 +53,10 @@ digit_open(const char *name, uint32 mode, void **cookie)
*cookie = s;
return 0;
return B_OK;
}
static status_t
digit_close(void *cookie)
{
@ -58,19 +64,21 @@ digit_close(void *cookie)
TOUCH(cookie);
return 0;
return B_OK;
}
static status_t
digit_free(void *cookie)
{
DPRINTF(("free\n"));
kfree(cookie);
free(cookie);
return 0;
}
static status_t
digit_ioctl(void *cookie, uint32 op, void *data, size_t len)
{
@ -82,13 +90,14 @@ digit_ioctl(void *cookie, uint32 op, void *data, size_t len)
struct digit_state *s = (struct digit_state *)cookie;
s->value = *(uchar *)data;
DPRINTF(("Set digit to %2.2x\n", s->value));
return 0;
return B_OK;
}
return ENOSYS;
}
static ssize_t
static status_t
digit_read(void *cookie, off_t pos, void *buffer, size_t *len)
{
struct digit_state *s = (struct digit_state *)cookie;
@ -104,10 +113,11 @@ digit_read(void *cookie, off_t pos, void *buffer, size_t *len)
if (*len)
memset(buffer, s->value, *len);
return 0;
return B_OK;
}
static ssize_t
static status_t
digit_write(void *cookie, off_t pos, const void *buffer, size_t *len)
{
struct digit_state *s = (struct digit_state *)cookie;
@ -118,18 +128,21 @@ digit_write(void *cookie, off_t pos, const void *buffer, size_t *len)
DPRINTF(("write: set digit to %2.2x\n", s->value));
return 0;
return B_OK;
}
/***************************/
status_t init_hardware()
status_t
init_hardware()
{
DPRINTF(("Do you digit?\n"));
return 0;
return B_OK;
}
const char **publish_devices(void)
const char **
publish_devices(void)
{
static const char *devices[] = {
DEVICE_NAME, NULL
@ -138,7 +151,9 @@ const char **publish_devices(void)
return devices;
}
device_hooks *find_device(const char *name)
device_hooks *
find_device(const char *name)
{
static device_hooks hooks = {
&digit_open,
@ -162,11 +177,15 @@ device_hooks *find_device(const char *name)
return NULL;
}
status_t init_driver()
status_t
init_driver()
{
return 0;
return B_OK;
}
void uninit_driver()
void
uninit_driver()
{
}

View File

@ -9,26 +9,28 @@
#define DEVICE_NAME "null"
int32 api_version = B_CUR_DRIVER_API_VERSION;
static status_t
null_open(const char *name, uint32 flags, void **cookie)
{
*cookie = NULL;
return 0;
return B_OK;
}
static status_t
null_close(void *cookie)
{
return 0;
return B_OK;
}
static status_t
null_freecookie(void *cookie)
{
return 0;
return B_OK;
}
@ -39,17 +41,17 @@ null_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
}
static ssize_t
static status_t
null_read(void *cookie, off_t pos, void *buffer, size_t *length)
{
return 0;
return B_OK;
}
static ssize_t
static status_t
null_write(void * cookie, off_t pos, const void *buf, size_t *len)
{
return 0;
return B_OK;
}
@ -59,7 +61,7 @@ null_write(void * cookie, off_t pos, const void *buf, size_t *len)
status_t
init_hardware()
{
return 0;
return B_OK;
}
@ -104,7 +106,7 @@ find_device(const char *name)
status_t
init_driver(void)
{
return 0;
return B_OK;
}

View File

@ -10,26 +10,28 @@
#define DEVICE_NAME "zero"
int32 api_version = B_CUR_DRIVER_API_VERSION;
static status_t
zero_open(const char *name, uint32 flags, void **cookie)
{
*cookie = NULL;
return 0;
return B_OK;
}
static status_t
zero_close(void *cookie)
{
return 0;
return B_OK;
}
static status_t
zero_freecookie(void *cookie)
{
return 0;
return B_OK;
}
@ -40,20 +42,20 @@ zero_ioctl(void *cookie, uint32 op, void *buffer, size_t length)
}
static ssize_t
static status_t
zero_read(void *cookie, off_t pos, void *buffer, size_t *_length)
{
if (user_memset(buffer, 0, *_length) < B_OK)
return B_BAD_ADDRESS;
return 0;
return B_OK;
}
static ssize_t
static status_t
zero_write(void *cookie, off_t pos, const void *buffer, size_t *_length)
{
return 0;
return B_OK;
}
@ -63,7 +65,7 @@ zero_write(void *cookie, off_t pos, const void *buffer, size_t *_length)
status_t
init_hardware()
{
return 0;
return B_OK;
}
@ -108,7 +110,7 @@ find_device(const char *name)
status_t
init_driver()
{
return 0;
return B_OK;
}

View File

@ -13,8 +13,10 @@
#include "config_driver.h"
#define DEVICE_NAME "misc/config"
int32 api_version = B_CUR_DRIVER_API_VERSION;
struct config_manager_for_driver_module_info *gConfigManager;
@ -87,17 +89,19 @@ config_ioctl(void *cookie, uint32 op, void *buffer, size_t len)
}
static ssize_t
config_read(void * cookie, off_t pos, void *buf, size_t *len)
static status_t
config_read(void * cookie, off_t pos, void *buf, size_t *_length)
{
return 0;
*_length = 0;
return B_OK;
}
static ssize_t
config_write(void * cookie, off_t pos, const void *buf, size_t *len)
static status_t
config_write(void * cookie, off_t pos, const void *buf, size_t *_length)
{
return 0;
*_length = 0;
return B_OK;
}