mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-21 00:29:10 +07:00
greybus: define greybus interface abstraction
Define new source files "interface.h" and "interface.c" to contain the definitions of the Greybus interface abstraction. A Greybus interface represents a UniPro device present in a UniPro module. For Project Ara, each interface block on a module implements a UniPro interface. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This commit is contained in:
parent
e1e9dbddfe
commit
8c12cde3c2
@ -4,6 +4,7 @@ greybus-y := core.o \
|
|||||||
debugfs.o \
|
debugfs.o \
|
||||||
ap.o \
|
ap.o \
|
||||||
module.o \
|
module.o \
|
||||||
|
interface.o \
|
||||||
i2c-gb.o \
|
i2c-gb.o \
|
||||||
gpio-gb.o \
|
gpio-gb.o \
|
||||||
sdio-gb.o \
|
sdio-gb.o \
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "greybus_id.h"
|
#include "greybus_id.h"
|
||||||
#include "greybus_manifest.h"
|
#include "greybus_manifest.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
#include "interface.h"
|
||||||
|
|
||||||
|
|
||||||
/* Matches up with the Greybus Protocol specification document */
|
/* Matches up with the Greybus Protocol specification document */
|
||||||
|
58
drivers/staging/greybus/interface.c
Normal file
58
drivers/staging/greybus/interface.c
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Greybus interfaces
|
||||||
|
*
|
||||||
|
* Copyright 2014 Google Inc.
|
||||||
|
*
|
||||||
|
* Released under the GPLv2 only.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "greybus.h"
|
||||||
|
|
||||||
|
/* XXX This could be per-host device or per-module */
|
||||||
|
static DEFINE_SPINLOCK(gb_interfaces_lock);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A Greybus interface represents a UniPro device present on a
|
||||||
|
* module. For Project Ara, each active Interface Block on a module
|
||||||
|
* implements a UniPro device, and therefore a Greybus interface. A
|
||||||
|
* Greybus module has at least one interface, but can have two (or
|
||||||
|
* even more).
|
||||||
|
*
|
||||||
|
* Create a gb_interface structure to represent a discovered
|
||||||
|
* interface. Returns a pointer to the new interface or a null
|
||||||
|
* pointer if a failure occurs due to memory exhaustion.
|
||||||
|
*/
|
||||||
|
struct gb_interface *
|
||||||
|
gb_interface_create(struct gb_module *gmod, u8 interface_id)
|
||||||
|
{
|
||||||
|
struct gb_interface *interface;
|
||||||
|
|
||||||
|
interface = kzalloc(sizeof(*interface), GFP_KERNEL);
|
||||||
|
if (!interface)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
interface->gmod = gmod; /* XXX refcount? */
|
||||||
|
interface->interface_id = interface_id;
|
||||||
|
|
||||||
|
spin_lock_irq(&gb_interfaces_lock);
|
||||||
|
list_add_tail(&interface->links, &gmod->interfaces);
|
||||||
|
spin_unlock_irq(&gb_interfaces_lock);
|
||||||
|
|
||||||
|
return interface;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Tear down a previously set up interface.
|
||||||
|
*/
|
||||||
|
void gb_interface_destroy(struct gb_interface *interface)
|
||||||
|
{
|
||||||
|
if (WARN_ON(!interface))
|
||||||
|
return;
|
||||||
|
|
||||||
|
spin_lock_irq(&gb_interfaces_lock);
|
||||||
|
list_del(&interface->links);
|
||||||
|
spin_unlock_irq(&gb_interfaces_lock);
|
||||||
|
|
||||||
|
/* kref_put(gmod); */
|
||||||
|
kfree(interface);
|
||||||
|
}
|
24
drivers/staging/greybus/interface.h
Normal file
24
drivers/staging/greybus/interface.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Greybus interfaces
|
||||||
|
*
|
||||||
|
* Copyright 2014 Google Inc.
|
||||||
|
*
|
||||||
|
* Released under the GPLv2 only.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __INTERFACE_H
|
||||||
|
#define __INTERFACE_H
|
||||||
|
|
||||||
|
#include <linux/list.h>
|
||||||
|
|
||||||
|
struct gb_interface {
|
||||||
|
struct gb_module *gmod;
|
||||||
|
u8 interface_id;
|
||||||
|
|
||||||
|
struct list_head links; /* module->interfaces */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct gb_interface *gb_interface_create(struct gb_module *gmod, u8 module_id);
|
||||||
|
void gb_interface_destroy(struct gb_interface *interface);
|
||||||
|
|
||||||
|
#endif /* __INTERFACE_H */
|
@ -67,6 +67,7 @@ struct gb_module *gb_module_create(struct greybus_host_device *hd, u8 module_id)
|
|||||||
|
|
||||||
module->hd = hd; /* XXX refcount? */
|
module->hd = hd; /* XXX refcount? */
|
||||||
module->module_id = module_id;
|
module->module_id = module_id;
|
||||||
|
INIT_LIST_HEAD(&module->interfaces);
|
||||||
|
|
||||||
spin_lock_irq(&gb_modules_lock);
|
spin_lock_irq(&gb_modules_lock);
|
||||||
list_add_tail(&module->links, &hd->modules);
|
list_add_tail(&module->links, &hd->modules);
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
struct gb_module {
|
struct gb_module {
|
||||||
struct device dev;
|
struct device dev;
|
||||||
|
|
||||||
|
struct list_head interfaces;
|
||||||
struct list_head links; /* greybus_host_device->modules */
|
struct list_head links; /* greybus_host_device->modules */
|
||||||
u8 module_id; /* Physical location within the Endo */
|
u8 module_id; /* Physical location within the Endo */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user