mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-26 19:00:25 +00:00
gpu: host1x: Split up client initalization and registration
[ Upstream commit 0cfe5a6e75
]
In some cases we may need to initialize the host1x client first before
registering it. This commit adds a new helper that will do nothing but
the initialization of the data structure.
At the same time, the initialization is removed from the registration
function. Note, however, that for simplicity we explicitly initialize
the client when the host1x_client_register() function is called, as
opposed to the low-level __host1x_client_register() function. This
allows existing callers to remain unchanged.
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
570b3e4020
commit
9c1d492baa
2 changed files with 48 additions and 12 deletions
|
@ -703,6 +703,29 @@ void host1x_driver_unregister(struct host1x_driver *driver)
|
|||
}
|
||||
EXPORT_SYMBOL(host1x_driver_unregister);
|
||||
|
||||
/**
|
||||
* __host1x_client_init() - initialize a host1x client
|
||||
* @client: host1x client
|
||||
* @key: lock class key for the client-specific mutex
|
||||
*/
|
||||
void __host1x_client_init(struct host1x_client *client, struct lock_class_key *key)
|
||||
{
|
||||
INIT_LIST_HEAD(&client->list);
|
||||
__mutex_init(&client->lock, "host1x client lock", key);
|
||||
client->usecount = 0;
|
||||
}
|
||||
EXPORT_SYMBOL(__host1x_client_init);
|
||||
|
||||
/**
|
||||
* host1x_client_exit() - uninitialize a host1x client
|
||||
* @client: host1x client
|
||||
*/
|
||||
void host1x_client_exit(struct host1x_client *client)
|
||||
{
|
||||
mutex_destroy(&client->lock);
|
||||
}
|
||||
EXPORT_SYMBOL(host1x_client_exit);
|
||||
|
||||
/**
|
||||
* __host1x_client_register() - register a host1x client
|
||||
* @client: host1x client
|
||||
|
@ -715,16 +738,11 @@ EXPORT_SYMBOL(host1x_driver_unregister);
|
|||
* device and call host1x_device_init(), which will in turn call each client's
|
||||
* &host1x_client_ops.init implementation.
|
||||
*/
|
||||
int __host1x_client_register(struct host1x_client *client,
|
||||
struct lock_class_key *key)
|
||||
int __host1x_client_register(struct host1x_client *client)
|
||||
{
|
||||
struct host1x *host1x;
|
||||
int err;
|
||||
|
||||
INIT_LIST_HEAD(&client->list);
|
||||
__mutex_init(&client->lock, "host1x client lock", key);
|
||||
client->usecount = 0;
|
||||
|
||||
mutex_lock(&devices_lock);
|
||||
|
||||
list_for_each_entry(host1x, &devices, list) {
|
||||
|
|
|
@ -320,12 +320,30 @@ static inline struct host1x_device *to_host1x_device(struct device *dev)
|
|||
int host1x_device_init(struct host1x_device *device);
|
||||
int host1x_device_exit(struct host1x_device *device);
|
||||
|
||||
int __host1x_client_register(struct host1x_client *client,
|
||||
struct lock_class_key *key);
|
||||
#define host1x_client_register(class) \
|
||||
({ \
|
||||
static struct lock_class_key __key; \
|
||||
__host1x_client_register(class, &__key); \
|
||||
void __host1x_client_init(struct host1x_client *client, struct lock_class_key *key);
|
||||
void host1x_client_exit(struct host1x_client *client);
|
||||
|
||||
#define host1x_client_init(client) \
|
||||
({ \
|
||||
static struct lock_class_key __key; \
|
||||
__host1x_client_init(client, &__key); \
|
||||
})
|
||||
|
||||
int __host1x_client_register(struct host1x_client *client);
|
||||
|
||||
/*
|
||||
* Note that this wrapper calls __host1x_client_init() for compatibility
|
||||
* with existing callers. Callers that want to separately initialize and
|
||||
* register a host1x client must first initialize using either of the
|
||||
* __host1x_client_init() or host1x_client_init() functions and then use
|
||||
* the low-level __host1x_client_register() function to avoid the client
|
||||
* getting reinitialized.
|
||||
*/
|
||||
#define host1x_client_register(client) \
|
||||
({ \
|
||||
static struct lock_class_key __key; \
|
||||
__host1x_client_init(client, &__key); \
|
||||
__host1x_client_register(client); \
|
||||
})
|
||||
|
||||
int host1x_client_unregister(struct host1x_client *client);
|
||||
|
|
Loading…
Reference in a new issue