Skip to content
Snippets Groups Projects
Select Git revision
  • b616cf53aa7aaf7c7e09c851807ebf1ce566e297
  • master default
  • android-container
  • nanopc-t4
  • for-kernelci
  • WIP-syscall
  • v4.16-rc5
  • v4.16-rc4
  • v4.16-rc3
  • v4.16-rc2
  • v4.16-rc1
  • v4.15
  • v4.15-rc9
  • v4.15-rc8
  • v4.15-rc7
  • v4.15-rc6
  • v4.15-rc5
  • v4.15-rc4
  • v4.15-rc3
  • v4.15-rc2
  • v4.15-rc1
  • v4.14
  • v4.14-rc8
  • v4.14-rc7
  • v4.14-rc6
  • v4.14-rc5
26 results

coreboot_table.c

Blame
  • coreboot_table.c 3.69 KiB
    /*
     * coreboot_table.c
     *
     * Module providing coreboot table access.
     *
     * Copyright 2017 Google Inc.
     * Copyright 2017 Samuel Holland <samuel@sholland.org>
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License v2.0 as published by
     * the Free Software Foundation.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     */
    
    #include <linux/device.h>
    #include <linux/err.h>
    #include <linux/init.h>
    #include <linux/io.h>
    #include <linux/kernel.h>
    #include <linux/module.h>
    #include <linux/slab.h>
    
    #include "coreboot_table.h"
    
    #define CB_DEV(d) container_of(d, struct coreboot_device, dev)
    #define CB_DRV(d) container_of(d, struct coreboot_driver, drv)
    
    static struct coreboot_table_header __iomem *ptr_header;
    
    static int coreboot_bus_match(struct device *dev, struct device_driver *drv)
    {
    	struct coreboot_device *device = CB_DEV(dev);
    	struct coreboot_driver *driver = CB_DRV(drv);
    
    	return device->entry.tag == driver->tag;
    }
    
    static int coreboot_bus_probe(struct device *dev)
    {
    	int ret = -ENODEV;
    	struct coreboot_device *device = CB_DEV(dev);
    	struct coreboot_driver *driver = CB_DRV(dev->driver);
    
    	if (driver->probe)
    		ret = driver->probe(device);
    
    	return ret;
    }
    
    static int coreboot_bus_remove(struct device *dev)
    {
    	int ret = 0;
    	struct coreboot_device *device = CB_DEV(dev);
    	struct coreboot_driver *driver = CB_DRV(dev->driver);
    
    	if (driver->remove)
    		ret = driver->remove(device);
    
    	return ret;
    }
    
    static struct bus_type coreboot_bus_type = {
    	.name		= "coreboot",
    	.match		= coreboot_bus_match,
    	.probe		= coreboot_bus_probe,
    	.remove		= coreboot_bus_remove,