linux-bk/kernel/platform.c
<<
>>
Prefs
   1/*
   2 * platform driver support 
   3 */
   4
   5#include <linux/platform.h>
   6#include <linux/module.h>
   7#include <linux/errno.h>
   8
   9
  10void default_reboot(char * cmd)
  11{
  12        /* nothing */
  13}
  14
  15void default_halt(void)
  16{
  17        /* nothing */
  18}
  19
  20int default_suspend(int state, int flags)
  21{
  22        return -ENOSYS;
  23}
  24
  25static struct platform_t default_platform = {
  26        .name           = "Default Platform",
  27        .suspend_states = 0,
  28        .reboot         = default_reboot,
  29        .halt           = default_halt,
  30        .power_off      = default_halt,
  31        .suspend        = default_suspend,
  32        .idle           = default_idle,
  33};
  34
  35struct platform_t * platform = &default_platform;
  36static spinlock_t platform_lock = SPIN_LOCK_UNLOCKED;
  37
  38/**
  39 * set_platform_driver - set the platform driver.
  40 * @pf: driver to set it to
  41 *
  42 * Return -EEXIST if someone else already owns it.
  43 */
  44int set_platform_driver(struct platform_t * pf)
  45{
  46        if (!pf)
  47                return -EINVAL;
  48        spin_lock(&platform_lock);
  49        if (platform != &default_platform) {
  50                spin_unlock(&platform_lock);
  51                return -EEXIST;
  52        }
  53        platform = pf;
  54        spin_unlock(&platform_lock);
  55        return 0;
  56}
  57
  58void remove_platform_driver(struct platform_t * pf)
  59{
  60        spin_lock(&platform_lock);
  61        if (platform == pf)
  62                platform = &default_platform;
  63        spin_unlock(&platform_lock);
  64}
  65
  66EXPORT_SYMBOL(default_reboot);
  67EXPORT_SYMBOL(default_halt);
  68EXPORT_SYMBOL(default_suspend);
  69
  70EXPORT_SYMBOL(platform);
  71EXPORT_SYMBOL(set_platform_driver);
  72EXPORT_SYMBOL(remove_platform_driver);
  73
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.