Commit Graph

113 Commits

Author SHA1 Message Date
Krzysztof Kozlowski
044be470d2 device: fix -Wsign-compare
Code should avoid comparing signed and unsigned integers, because of
implicit case.  Explicit casts are safe because 'lock' size is PATH_MAX.

  device.c: In function ‘device_lock’:
  device.c:64:15: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
     64 |         if (n >= sizeof(lock))
        |               ^~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-08 15:02:37 -05:00
Krzysztof Kozlowski
c7e7a81a6c device_parser: fix -Wformat=
Fixes:

  device_parser.c: In function ‘nextsym’:
  device_parser.c:53:56: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘unsigned int’ [-Wformat=]
     53 |                 fprintf(stderr, "device parser: error %d\n", dp->parser.error);
        |                                                       ~^     ~~~~~~~~~~~~~~~~
        |                                                        |               |
        |                                                        int             unsigned int
        |                                                       %d
  device_parser.c: In function ‘expect’:
  device_parser.c:80:58: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘unsigned int’ [-Wformat=]
     80 |         fprintf(stderr, "device parser: expected %d got %d\n", type, dp->event.type);
        |                                                         ~^           ~~~~~~~~~~~~~~
        |                                                          |                    |
        |                                                          int                  unsigned int

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-08 15:02:37 -05:00
Krzysztof Kozlowski
edb41596e5 conmux: fix -Wsign-compare
Code should avoid comparing signed and unsigned integers, because of
implicit case.  Explicit casts are safe because 'buf' size is 256.

  conmux.c: In function ‘registry_lookup’:
  conmux.c:169:17: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
    169 |         if (ret >= sizeof(buf))
        |                 ^~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-08 15:02:37 -05:00
Krzysztof Kozlowski
f47098ba58 cdb_assist: fix -Wformat=
Fixes:

  cdb_assist.c: In function ‘cdb_assist_print_status’:
  cdb_assist.c:351:28: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘unsigned int’ [-Wformat=]
    351 |         n = sprintf(buf, "%dmV %dmA%s%s%s%s%s ref: %dmV",
        |                           ~^
        |                            |
        |                            int
        |                           %d
    352 |                          cdb->voltage_set,
        |                          ~~~~~~~~~~~~~~~~
        |                             |
        |                             unsigned int

  cdb_assist.c:372:29: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘unsigned int’ [-Wformat=]
    372 |         n = sprintf(buf, "u%d\r\n", mV);
        |                            ~^       ~~
        |                             |       |
        |                             int     unsigned int
        |                            %d

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-08 15:02:37 -05:00
Krzysztof Kozlowski
352dc1abca circ_buf: fix -Wpointer-arith
Pointer arithmetic should not be done on void pointers.

  circ_buf.c: In function ‘circ_read’:
  circ_buf.c:104:25: warning: pointer of type ‘void *’ used in subtraction [-Wpointer-arith]
    104 |         return (void*)p - buf;
        |                         ^

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-08 15:02:37 -05:00
Krzysztof Kozlowski
c6d97d34c3 circ_buf: fix -Wsign-compare
Code should avoid comparing signed and unsigned integers, because of
implicit case.

  circ_buf.c: In function ‘circ_fill’:
  circ_buf.c:69:20: warning: comparison of integer expressions of different signedness: ‘ssize_t’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
     69 |         } while (n != space);

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-08 15:02:37 -05:00
Krzysztof Kozlowski
647a6c59ad cdba: fix -Wpointer-arith
Pointer arithmetic should not be done on void pointers.

  cdba.c: In function ‘fastboot_work_fn’:
  cdba.c:377:38: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]
    377 |         memcpy(msg->data, work->data + work->offset, left);

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-08 15:02:37 -05:00
Krzysztof Kozlowski
2af3911be5 list: drop unneeded const to fix -Wcast-qual
Fixes:

  device.c: In function ‘device_info’:
  list.h:39:26: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
     39 |                 (type *)((char *)__mptr - offsetof(type, member)); \
        |                          ^
  list.h:85:9: note: in expansion of macro ‘container_of’
     85 |         container_of((list)->next, type, member)
        |         ^~~~~~~~~~~~
  list.h:91:21: note: in expansion of macro ‘list_entry_first’
     91 |         for (item = list_entry_first(list, typeof(*(item)), member); \
        |                     ^~~~~~~~~~~~~~~~
  device.c:303:9: note: in expansion of macro ‘list_for_each_entry’
    303 |         list_for_each_entry(device, &devices, node) {
        |         ^~~~~~~~~~~~~~~~~~~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-08 15:02:37 -05:00
Krzysztof Kozlowski
88c3196473 fastboot: fix -Wpointer-arith
Pointer arithmetic should not be done on void pointers.

  fastboot.c:223:37: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]
    223 |                                 ptr += USB_DT_SS_EP_COMP_SIZE;
        |                                     ^~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-08 15:02:37 -05:00
Krzysztof Kozlowski
33092e27b0 ftdi-gpio: fix -Wformat warning
Fixes:

  ftdi-gpio.c: In function ‘ftdi_gpio_parse_config’:
  ftdi-gpio.c:146:58: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘unsigned int’ [-Wformat=]
    146 |                         errx(1, "GPIOs offset invalid: '%d'", gpio_offset);
        |                                                         ~^    ~~~~~~~~~~~
        |                                                          |    |
        |                                                          int  unsigned int
        |                                                         %d

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-08 15:02:37 -05:00
Krzysztof Kozlowski
7bb7cc2a10 ftdi-gpio: fix -Wimplicit-function-declaration
Fixes:

  ftdi-gpio.c: In function ‘ftdi_gpio_open’:
  ftdi-gpio.c:190:9: warning: implicit declaration of function ‘usleep’ [-Wimplicit-function-declaration]

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-08 15:02:37 -05:00
Krzysztof Kozlowski
04ce8ca01d ftdi-gpio: correct the interface name and fix -Wlogical-op warning
Correct parsing of 'B' interface name from config and also fix:

  ftdi-gpio.c: In function ‘ftdi_gpio_parse_config’:
  ftdi-gpio.c:104:31: warning: logical ‘and’ of equal expressions [-Wlogical-op]
    104 |         if (*interface != 'A' &&
        |                               ^~

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-08 15:02:37 -05:00
Krzysztof Kozlowski
432e9b2192 ci: add basic Github Actions Continuous Integration builds
Add Continuous Integration using Github actions, re-using similar setup
from linux-nfc/neard [1] (dropped Alpine, Ubuntu i386, sanitizers and
few others action steps).  Since I copied most files, I retained all
original copyrights.

The CI will build cdba for several different distros and architectures.

[1] https://github.com/linux-nfc/neard

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-07 13:33:20 -05:00
Krzysztof Kozlowski
6c7aa53585 README: add new config example for Alpaca setup
Document newer boards over Alpaca.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
2023-05-01 09:39:01 -05:00
Neil Armstrong
4f4f1704bb Add generic ftdi GPIO backend
This permits driving a board controlled by GPIOs on an FTDI
interface.

Also add a sample 99-libftdi.rules to permit using the FTDI device.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
2023-01-30 16:00:46 -06:00
Bjorn Andersson
ffc91a6bf2 cdba-shell: Add some simple scripts for user maintenance
Introduce some scripts to allow storing users public keys in a git and
some hooks such that when this is pushed to the server the
authorized_keys file is re-generated.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2022-08-18 23:07:40 -05:00
Dmitry Baryshkov
42f8108e7c cdba-server: notify users when fastboot connection is opened
Notify users of cdba-server when fastboot connection is opened to ease
remote debugging of issues.

Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
2022-02-08 09:09:13 -08:00
Dmitry Baryshkov
961792677a device: notify before booting the board
Transfering the image to cdba server takes time (especially when working
with over the network). Notify users before actually booting the board
to ease detecting early boot issues.

Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
2022-02-08 09:09:13 -08:00
Bjorn Andersson
6fbc50ca58 device: Hack around EPERM issue
Opening the lock files fails on one of my boards if the files exists and
are owned by someone else, if O_CREAT is set. This doesn't make sense,
but hack around it for now by first creating the file if it's not there,
ignoring any errors and then just opening it O_RDONLY.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2021-10-05 10:41:48 -07:00
Bjorn Andersson
af03ecd94f qcomlt_dbg: Silence debug prints
Comment out some leftover debug prits in the QcomLT Debugboard support
code.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2021-03-02 12:15:45 -06:00
Bjorn Andersson
983ec44099 cdba: Support specifying cdba-server path
For debug purposes it's useful to install a user-local version of the
cdba-server and invoke this instead, rather then having to change the
code add a flag to support specifying this on the command line.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2021-02-22 11:04:09 -06:00
Bjorn Andersson
3004fdf68d device: Reintroduce the alpaca "keep-usb-on" feature
For some reason the SC8180x Primus often fails to detect the attached
USB stick if USB is toggled as part of a power cycle, so let's continue
to support the property of not toggling it.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2021-02-22 11:02:57 -06:00
Bjorn Andersson
7c231568aa cdba-server: Don't close what wasn't opened
In the case that we quit without actually having opened a device this
would dereference a NULL pointer, so check the device before doing so.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2021-01-25 18:49:21 -06:00
Bjorn Andersson
c43466a98f device: Invoke device->close on exit
Allow the control device to implement things such as flushing the
command buffer as part of the close operation. This used to be done to
ensure that any lingering power/usb off requests really where sent to
the device as we closed the control tty.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2021-01-25 18:48:04 -06:00
Bjorn Andersson
2ab5051cde alpaca: Drop forgotten fastboot_key function
The fastboot_key function is no longer used, drop the remains in the
alpaca implementation.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2021-01-25 18:47:11 -06:00