Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\power\wakelock.c Create Date:2022-07-28 10:04:23
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:wakelock_lookup_add

Proto:static struct wakelock *wakelock_lookup_add(const char *name, size_t len, bool add_if_not_found)

Type:struct wakelock

Parameter:

TypeParameterName
const char *name
size_tlen
booladd_if_not_found
153  node = rb_node
154  parent = node
157  When node cycle
160  parent = node
161  wl = rb_entry( * node, structwakelock, node)
162  diff = strncmp(name, name, len)
163  If diff == 0 Then
164  If name[len] Then diff = -1
166  Else Return wl
169  If diff < 0 Then node = rb_left
171  Else node = rb_right
174  If Not add_if_not_found Then Return ERR_PTR( - EINVAL)
177  If wakelocks_limit_exceeded() Then Return ERR_PTR( - ENOSPC)
181  wl = kzalloc - allocate memory. The memory is set to zero.*@size: how many bytes of memory are required.*@flags: the type of memory to allocate (see kmalloc).
182  If Not wl Then Return ERR_PTR( - ENOMEM)
185  name = kstrndup(name, len, GFP_KERNEL)
186  If Not name Then
187  kfree - free previously allocated memory*@objp: pointer returned by kmalloc.* If @objp is NULL, no operation is performed.* Don't free memory not originally allocated by kmalloc()* or you will run into trouble.
188  Return ERR_PTR( - ENOMEM)
191  ws = wakeup_source_register(NULL, name)
192  If Not ws Then
193  kfree - free previously allocated memory*@objp: pointer returned by kmalloc.* If @objp is NULL, no operation is performed.* Don't free memory not originally allocated by kmalloc()* or you will run into trouble.
194  kfree - free previously allocated memory*@objp: pointer returned by kmalloc.* If @objp is NULL, no operation is performed.* Don't free memory not originally allocated by kmalloc()* or you will run into trouble.
195  Return ERR_PTR( - ENOMEM)
197  last_time = ktime_get()
199  rb_link_node( & node, parent, node)
200  rb_insert_color( & node, & wakelocks_tree)
201  wakelocks_lru_add(wl)
202  increment_wakelocks_number()
203  Return wl
Caller
NameDescribe
pm_wake_lock
pm_wake_unlock