Path: blob/master/drivers/hwspinlock/hwspinlock_internal.h
15109 views
/*1* Hardware spinlocks internal header2*3* Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com4*5* Contact: Ohad Ben-Cohen <[email protected]>6*7* This program is free software; you can redistribute it and/or modify it8* under the terms of the GNU General Public License version 2 as published9* by the Free Software Foundation.10*11* This program is distributed in the hope that it will be useful,12* but WITHOUT ANY WARRANTY; without even the implied warranty of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14* GNU General Public License for more details.15*/1617#ifndef __HWSPINLOCK_HWSPINLOCK_H18#define __HWSPINLOCK_HWSPINLOCK_H1920#include <linux/spinlock.h>21#include <linux/device.h>2223/**24* struct hwspinlock_ops - platform-specific hwspinlock handlers25*26* @trylock: make a single attempt to take the lock. returns 0 on27* failure and true on success. may _not_ sleep.28* @unlock: release the lock. always succeed. may _not_ sleep.29* @relax: optional, platform-specific relax handler, called by hwspinlock30* core while spinning on a lock, between two successive31* invocations of @trylock. may _not_ sleep.32*/33struct hwspinlock_ops {34int (*trylock)(struct hwspinlock *lock);35void (*unlock)(struct hwspinlock *lock);36void (*relax)(struct hwspinlock *lock);37};3839/**40* struct hwspinlock - this struct represents a single hwspinlock instance41*42* @dev: underlying device, will be used to invoke runtime PM api43* @ops: platform-specific hwspinlock handlers44* @id: a global, unique, system-wide, index of the lock.45* @lock: initialized and used by hwspinlock core46* @owner: underlying implementation module, used to maintain module ref count47*48* Note: currently simplicity was opted for, but later we can squeeze some49* memory bytes by grouping the dev, ops and owner members in a single50* per-platform struct, and have all hwspinlocks point at it.51*/52struct hwspinlock {53struct device *dev;54const struct hwspinlock_ops *ops;55int id;56spinlock_t lock;57struct module *owner;58};5960#endif /* __HWSPINLOCK_HWSPINLOCK_H */616263