Skip to content
Snippets Groups Projects
  1. Apr 05, 2023
  2. Mar 21, 2023
  3. Oct 17, 2022
  4. May 06, 2022
  5. Mar 24, 2022
  6. Jan 19, 2022
  7. Oct 20, 2021
    • Maureen Helm's avatar
      drivers: adc: Refactor drivers to use shared init priority · b0cdef3c
      Maureen Helm authored
      
      Refactors all of the ADC drivers to use a shared driver class
      initialization priority configuration, CONFIG_ADC_INIT_PRIORITY, to
      allow configuring ADC drivers separately from other devices. This is
      similar to other driver classes like I2C and SPI.
      
      The default is set to CONFIG_KERNEL_INIT_PRIORITY_DEVICE to preserve the
      existing default initialization priority for most drivers. The
      exceptions are lmp90xxx, mcp320x, and mcux_adc16 drivers which have
      dependencies on GPIO, SPI, and/or DMA drivers and must therefore
      initialize later than the default device priority.
      
      Signed-off-by: default avatarMaureen Helm <maureen.helm@intel.com>
      b0cdef3c
  8. Jun 14, 2021
  9. Apr 28, 2021
  10. Dec 10, 2020
  11. Sep 02, 2020
    • Tomasz Bursztyka's avatar
      drivers: Manual const-ification of device driver instance · ef560e0a
      Tomasz Bursztyka authored
      
      These are all the case that coccinelle cannot find as they are inside
      macro declarations.
      
      Fixed via:
      
      git grep -rlz -E "\(struct device \*" |
      	xargs -0 sed -i 's/(struct device/(const struct device/g'
      
      Fixes #27399
      
      Signed-off-by: default avatarTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
      ef560e0a
    • Tomasz Bursztyka's avatar
      isr: Normalize usage of device instance through ISR · 4dcfb553
      Tomasz Bursztyka authored
      
      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: default avatarTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
      4dcfb553
    • Tomasz Bursztyka's avatar
      device: Const-ify all device driver instance pointers · e18fcbba
      Tomasz Bursztyka authored
      
      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: default avatarTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
      e18fcbba
  12. Aug 11, 2020
    • Tomasz Bursztyka's avatar
      device: Apply driver_api/data attributes rename everywhere · 98d9b013
      Tomasz Bursztyka authored
      
      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: default avatarTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
      98d9b013
    • Tomasz Bursztyka's avatar
      device: Apply config_info rename everywhere · af6140cc
      Tomasz Bursztyka authored
      
      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: default avatarTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
      af6140cc
  13. Jun 08, 2020
  14. May 09, 2020
    • Martí Bolívar's avatar
      devicetree: allow access to all nodes · 7e0eed92
      Martí Bolívar authored
      
      Usually, we want to operate only on "available" device
      nodes ("available" means "status is okay and a matching binding is
      found"), but that's not true in all cases.
      
      Sometimes we want to operate on special nodes without matching
      bindings, such as those describing memory.
      
      To handle the distinction, change various additional devicetree APIs
      making it clear that they operate only on available device nodes,
      adjusting gen_defines and devicetree.h implementation details
      accordingly:
      
      - emit macros for all existing nodes in gen_defines.py, regardless
        of status or matching binding
      - rename DT_NUM_INST to DT_NUM_INST_STATUS_OKAY
      - rename DT_NODE_HAS_COMPAT to DT_NODE_HAS_COMPAT_STATUS_OKAY
      - rename DT_INST_FOREACH to DT_INST_FOREACH_STATUS_OKAY
      - rename DT_ANY_INST_ON_BUS to DT_ANY_INST_ON_BUS_STATUS_OKAY
      - rewrite DT_HAS_NODE_STATUS_OKAY in terms of a new DT_NODE_HAS_STATUS
      - resurrect DT_HAS_NODE in the form of DT_NODE_EXISTS
      - remove DT_COMPAT_ON_BUS as a public API
      - use the new default_prop_types edtlib parameter
      
      Signed-off-by: default avatarMartí Bolívar <marti.bolivar@nordicsemi.no>
      7e0eed92
  15. May 08, 2020
  16. Apr 23, 2020
    • Kumar Gala's avatar
      drivers: adc: adc_sam_afec: rework device tree support · 94fcf2ef
      Kumar Gala authored
      
      Reworked adc_sam_afec driver to utilize new DT_INST macros as part of
      this rework we also now get pin ctrl/mux configuration information
      from the device tree instead of via Kconfig and defines in soc_pinmap.h
      
      We remove defines from dts_fixup.h and soc_pinmap.h and associated
      Kconfig symbols that are no longer needed due to getting all that
      information from devicetree.
      
      Signed-off-by: default avatarKumar Gala <kumar.gala@linaro.org>
      94fcf2ef
  17. Jun 28, 2019
  18. Apr 02, 2019
  19. Mar 28, 2019
  20. Jan 17, 2019
  21. Dec 05, 2018
  22. Nov 21, 2018
  23. Nov 13, 2018
    • Andrzej Głąbek's avatar
      dts_fixups: Use DT_ prefix in all defined labels not related to Kconfig · 20202902
      Andrzej Głąbek authored
      
      These changes were obtained by running a script  created by
      Ulf Magnusson <Ulf.Magnusson@nordicsemi.no> for the following
      specification:
      
      1. Read the contents of all dts_fixup.h files in Zephyr
      2. Check the left-hand side of the #define macros (i.e. the X in
         #define X Y)
      3. Check if that name is also the name of a Kconfig option
         3.a If it is, then do nothing
         3.b If it is not, then replace CONFIG_ with DT_ or add DT_ if it
             has neither of these two prefixes
      4. Replace the use of the changed #define in the code itself
         (.c, .h, .ld)
      
      Additionally, some tweaks had to be added to this script to catch some
      of the macros used in the code in a parameterized form, e.g.:
      - CONFIG_GPIO_STM32_GPIO##__SUFFIX##_BASE_ADDRESS
      - CONFIG_UART_##idx##_TX_PIN
      - I2C_SBCON_##_num##_BASE_ADDR
      and to prevent adding DT_ prefix to the following symbols:
      - FLASH_START
      - FLASH_SIZE
      - SRAM_START
      - SRAM_SIZE
      - _ROM_ADDR
      - _ROM_SIZE
      - _RAM_ADDR
      - _RAM_SIZE
      which are surprisingly also defined in some dts_fixup.h files.
      
      Finally, some manual corrections had to be done as well:
      - name##_IRQ -> DT_##name##_IRQ in uart_stm32.c
      
      Signed-off-by: default avatarAndrzej Głąbek <andrzej.glabek@nordicsemi.no>
      20202902
  24. Oct 08, 2018
  25. Sep 06, 2018
  26. Aug 29, 2018
  27. Oct 10, 2017
Loading