Gerard Marull-Paretas
178bdc4afc
include: add missing zephyr/irq.h include
...
Change automated searching for files using "IRQ_CONNECT()" API not
including <zephyr/irq.h>.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-10-17 22:57:39 +09:00
Henrik Brix Andersen
b5a79fa4ad
drivers: watchdog: check if clock device is ready before accessing
...
Add check for device_is_ready() before accessing clock control devices.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-09 17:16:16 +02:00
Gerard Marull-Paretas
fb60aab245
drivers: migrate includes to <zephyr/...>
...
In order to bring consistency in-tree, migrate all drivers to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 19:58:21 +02:00
Gerard Marull-Paretas
621d1d45f2
drivers: watchdog: remove usage of device_pm_control_nop
...
device_pm_control_nop is now deprecated in favour of NULL.
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 12:25:39 -04:00
Kumar Gala
99d1b292cc
drivers: watchdog: NXP: Convert clock control to use DEVICE_DT_GET
...
Replace device_get_binding with DEVICE_DT_GET for getting access
to the clock controller device.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-19 05:02:52 -06:00
Kumar Gala
e376b9417b
drivers: watchdog: Convert drivers to new DT device macros
...
Convert watchdog drivers to use new DT variants of the DEVICE APIs.
DEVICE_AND_API_INIT -> DEVICE_DT_DEFINE
DEVICE_GET -> DEVICE_DT_GET
DEVICE_DECLARE -> DEVICE_DT_INST_DECLARE
etc..
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-11 08:14:23 -06:00
Tomasz Bursztyka
4dcfb5531c
isr: Normalize usage of device instance through ISR
...
The goal of this patch is to replace the 'void *' parameter by 'struct
device *' if they use such variable or just 'const void *' on all
relevant ISRs
This will avoid not-so-nice const qualifier tweaks when device instances
will be constant.
Note that only the ISR passed to IRQ_CONNECT are of interest here.
In order to do so, the script fix_isr.py below is necessary:
from pathlib import Path
import subprocess
import pickle
import mmap
import sys
import re
import os
cocci_template = """
@r_fix_isr_0
@
type ret_type;
identifier P;
identifier D;
@@
-ret_type <!fn!>(void *P)
+ret_type <!fn!>(const struct device *P)
{
...
(
const struct device *D = (const struct device *)P;
|
const struct device *D = P;
)
...
}
@r_fix_isr_1
@
type ret_type;
identifier P;
identifier D;
@@
-ret_type <!fn!>(void *P)
+ret_type <!fn!>(const struct device *P)
{
...
const struct device *D;
...
(
D = (const struct device *)P;
|
D = P;
)
...
}
@r_fix_isr_2
@
type ret_type;
identifier A;
@@
-ret_type <!fn!>(void *A)
+ret_type <!fn!>(const void *A)
{
...
}
@r_fix_isr_3
@
const struct device *D;
@@
-<!fn!>((void *)D);
+<!fn!>(D);
@r_fix_isr_4
@
type ret_type;
identifier D;
identifier P;
@@
-ret_type <!fn!>(const struct device *P)
+ret_type <!fn!>(const struct device *D)
{
...
(
-const struct device *D = (const struct device *)P;
|
-const struct device *D = P;
)
...
}
@r_fix_isr_5
@
type ret_type;
identifier D;
identifier P;
@@
-ret_type <!fn!>(const struct device *P)
+ret_type <!fn!>(const struct device *D)
{
...
-const struct device *D;
...
(
-D = (const struct device *)P;
|
-D = P;
)
...
}
"""
def find_isr(fn):
db = []
data = None
start = 0
try:
with open(fn, 'r+') as f:
data = str(mmap.mmap(f.fileno(), 0).read())
except Exception as e:
return db
while True:
isr = ""
irq = data.find('IRQ_CONNECT', start)
while irq > -1:
p = 1
arg = 1
p_o = data.find('(', irq)
if p_o < 0:
irq = -1
break;
pos = p_o + 1
while p > 0:
if data[pos] == ')':
p -= 1
elif data[pos] == '(':
p += 1
elif data[pos] == ',' and p == 1:
arg += 1
if arg == 3:
isr += data[pos]
pos += 1
isr = isr.strip(',\\n\\t ')
if isr not in db and len(isr) > 0:
db.append(isr)
start = pos
break
if irq < 0:
break
return db
def patch_isr(fn, isr_list):
if len(isr_list) <= 0:
return
for isr in isr_list:
tmplt = cocci_template.replace('<!fn!>', isr)
with open('/tmp/isr_fix.cocci', 'w') as f:
f.write(tmplt)
cmd = ['spatch', '--sp-file', '/tmp/isr_fix.cocci', '--in-place', fn]
subprocess.run(cmd)
def process_files(path):
if path.is_file() and path.suffix in ['.h', '.c']:
p = str(path.parent) + '/' + path.name
isr_list = find_isr(p)
patch_isr(p, isr_list)
elif path.is_dir():
for p in path.iterdir():
process_files(p)
if len(sys.argv) < 2:
print("You need to provide a dir/file path")
sys.exit(1)
process_files(Path(sys.argv[1]))
And is run: ./fix_isr.py <zephyr root directory>
Finally, some files needed manual fixes such.
Fixes #27399
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka
e18fcbba5a
device: Const-ify all device driver instance pointers
...
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.
A coccinelle rule is used for this:
@r_const_dev_1
disable optional_qualifier
@
@@
-struct device *
+const struct device *
@r_const_dev_2
disable optional_qualifier
@
@@
-struct device * const
+const struct device *
Fixes #27399
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka
98d9b01322
device: Apply driver_api/data attributes rename everywhere
...
Via coccinelle:
@r_device_driver_api_and_data_1@
struct device *D;
@@
(
D->
- driver_api
+ api
|
D->
- driver_data
+ data
)
@r_device_driver_api_and_data_2@
expression E;
@@
(
net_if_get_device(E)->
- driver_api
+ api
|
net_if_get_device(E)->
- driver_data
+ data
)
And grep/sed rules for macros:
git grep -rlz 'dev)->driver_data' |
xargs -0 sed -i 's/dev)->driver_data/dev)->data/g'
git grep -rlz 'dev->driver_data' |
xargs -0 sed -i 's/dev->driver_data/dev->data/g'
git grep -rlz 'device->driver_data' |
xargs -0 sed -i 's/device->driver_data/device->data/g'
Fixes #27397
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Tomasz Bursztyka
af6140cc0d
device: Apply config_info rename everywhere
...
Via coccinelle:
@r_device_config@
struct device *D;
@@
D->
- config_info
+ config
And 2 grep/sed rules for macros:
git grep -rlz 'dev)->config_info' |
xargs -0 sed -i 's/dev)->config_info/dev)->config/g'
git grep -rlz 'dev->config_info' |
xargs -0 sed -i 's/dev->config_info/dev->config/g'
Fixes #27397
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-08-11 19:30:53 +02:00
Kumar Gala
a1b77fd589
zephyr: replace zephyr integer types with C99 types
...
git grep -l 'u\(8\|16\|32\|64\)_t' | \
xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
git grep -l 's\(8\|16\|32\|64\)_t' | \
xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Tomasz Bursztyka
97326c0445
device: Fix structure attributes access
...
Since struct devconfig was merged earlier into struct device, let's fix
accessing config_info, name, ... attributes everywhere via:
grep -rlZ 'dev->config->' | xargs -0 sed -i 's/dev->config->/dev->/g'
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-05-08 23:07:44 +02:00
Kumar Gala
4b9fe8a24e
drivers: mcux: Convert MCUX drivers to new DT_INST macros
...
Convert older DT_INST_ macro use in MCUX drivers to the new
include/devicetree.h DT_INST macro APIs.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-03-26 03:40:09 -05:00
Henrik Brix Andersen
7cb92552f3
drivers: watchdog: mcux_wdog32: add driver for the NXP Kinetis WDOG32
...
Add driver shim for the NXP Kinetis WDOG32 module.
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2019-07-02 18:00:16 -05:00