From b6c6807adda7d07c7fd6f2c22bb0dfedb56a11c8 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Sat, 16 Mar 2024 17:47:11 +0200 Subject: [PATCH 1/7] drivers: move device / console backends to separte dir In order to stop clobbering the root directory, move all device and console backends to drivers/ subdir. Signed-off-by: Dmitry Baryshkov --- alpaca.c => drivers/alpaca.c | 0 cdb_assist.c => drivers/cdb_assist.c | 0 conmux.c => drivers/conmux.c | 0 external.c => drivers/external.c | 0 ftdi-gpio.c => drivers/ftdi-gpio.c | 0 local-gpio-v1.c => drivers/local-gpio-v1.c | 0 local-gpio-v2.c => drivers/local-gpio-v2.c | 0 local-gpio.c => drivers/local-gpio.c | 0 local-gpio.h => drivers/local-gpio.h | 0 qcomlt_dbg.c => drivers/qcomlt_dbg.c | 0 meson.build | 30 ++++++++++++---------- 11 files changed, 16 insertions(+), 14 deletions(-) rename alpaca.c => drivers/alpaca.c (100%) rename cdb_assist.c => drivers/cdb_assist.c (100%) rename conmux.c => drivers/conmux.c (100%) rename external.c => drivers/external.c (100%) rename ftdi-gpio.c => drivers/ftdi-gpio.c (100%) rename local-gpio-v1.c => drivers/local-gpio-v1.c (100%) rename local-gpio-v2.c => drivers/local-gpio-v2.c (100%) rename local-gpio.c => drivers/local-gpio.c (100%) rename local-gpio.h => drivers/local-gpio.h (100%) rename qcomlt_dbg.c => drivers/qcomlt_dbg.c (100%) diff --git a/alpaca.c b/drivers/alpaca.c similarity index 100% rename from alpaca.c rename to drivers/alpaca.c diff --git a/cdb_assist.c b/drivers/cdb_assist.c similarity index 100% rename from cdb_assist.c rename to drivers/cdb_assist.c diff --git a/conmux.c b/drivers/conmux.c similarity index 100% rename from conmux.c rename to drivers/conmux.c diff --git a/external.c b/drivers/external.c similarity index 100% rename from external.c rename to drivers/external.c diff --git a/ftdi-gpio.c b/drivers/ftdi-gpio.c similarity index 100% rename from ftdi-gpio.c rename to drivers/ftdi-gpio.c diff --git a/local-gpio-v1.c b/drivers/local-gpio-v1.c similarity index 100% rename from local-gpio-v1.c rename to drivers/local-gpio-v1.c diff --git a/local-gpio-v2.c b/drivers/local-gpio-v2.c similarity index 100% rename from local-gpio-v2.c rename to drivers/local-gpio-v2.c diff --git a/local-gpio.c b/drivers/local-gpio.c similarity index 100% rename from local-gpio.c rename to drivers/local-gpio.c diff --git a/local-gpio.h b/drivers/local-gpio.h similarity index 100% rename from local-gpio.h rename to drivers/local-gpio.h diff --git a/qcomlt_dbg.c b/drivers/qcomlt_dbg.c similarity index 100% rename from qcomlt_dbg.c rename to drivers/qcomlt_dbg.c diff --git a/meson.build b/meson.build index f1d12bd..927a2b8 100644 --- a/meson.build +++ b/meson.build @@ -65,29 +65,31 @@ if not compiler.has_function('forkpty') server_deps += util_dep endif +drivers_srcs = ['drivers/alpaca.c', + 'drivers/cdb_assist.c', + 'drivers/conmux.c', + 'drivers/external.c', + 'drivers/ftdi-gpio.c', + 'drivers/local-gpio.c', + 'drivers/qcomlt_dbg.c', + ] + +if gpiod_dep.version().version_compare('>=2.0') + drivers_srcs += ['drivers/local-gpio-v2.c'] +else + drivers_srcs += ['drivers/local-gpio-v1.c'] +endif + server_srcs = ['cdba-server.c', - 'cdb_assist.c', 'circ_buf.c', - 'conmux.c', 'device.c', 'device_parser.c', - 'external.c', 'fastboot.c', - 'alpaca.c', - 'ftdi-gpio.c', - 'local-gpio.c', 'console.c', - 'qcomlt_dbg.c', 'ppps.c', 'status.c', 'status-cmd.c'] -if gpiod_dep.version().version_compare('>=2.0') - server_srcs += ['local-gpio-v2.c'] -else - server_srcs += ['local-gpio-v1.c'] -endif - build_server = true foreach d: server_deps if not d.found() @@ -97,7 +99,7 @@ endforeach if build_server executable('cdba-server', - server_srcs, + server_srcs + drivers_srcs, dependencies : server_deps, install : true) elif not server_opt.disabled() From bde90b4a15159058f85e9f46935335f15c6797e3 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Sat, 16 Mar 2024 17:53:43 +0200 Subject: [PATCH 2/7] cdba: replace licence headers with SPDX identifiers Replace all license headers with the SPDX-License-Identitier headers to follow the current recommendations. Signed-off-by: Dmitry Baryshkov --- cdba-server.c | 26 +------------------------- cdba.c | 26 +------------------------- circ_buf.c | 26 +------------------------- circ_buf.h | 26 +------------------------- console.c | 26 +------------------------- device.c | 26 +------------------------- device_parser.c | 26 +------------------------- drivers/alpaca.c | 26 +------------------------- drivers/cdb_assist.c | 26 +------------------------- drivers/conmux.c | 26 +------------------------- drivers/external.c | 26 +------------------------- drivers/ftdi-gpio.c | 26 +------------------------- drivers/local-gpio-v1.c | 26 +------------------------- drivers/local-gpio-v2.c | 26 +------------------------- drivers/local-gpio.c | 26 +------------------------- drivers/local-gpio.h | 26 +------------------------- drivers/qcomlt_dbg.c | 26 +------------------------- fastboot.c | 26 +------------------------- list.h | 26 +------------------------- ppps.c | 26 +------------------------- status-cmd.c | 26 +------------------------- 21 files changed, 21 insertions(+), 525 deletions(-) diff --git a/cdba-server.c b/cdba-server.c index c737e5b..7a98352 100644 --- a/cdba-server.c +++ b/cdba-server.c @@ -2,31 +2,7 @@ * Copyright (c) 2016-2018, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include #include diff --git a/cdba.c b/cdba.c index 681ed78..1809423 100644 --- a/cdba.c +++ b/cdba.c @@ -2,31 +2,7 @@ * Copyright (c) 2016-2018, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include #include diff --git a/circ_buf.c b/circ_buf.c index 08766be..5cda4cf 100644 --- a/circ_buf.c +++ b/circ_buf.c @@ -2,31 +2,7 @@ * Copyright (c) 2018, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include diff --git a/circ_buf.h b/circ_buf.h index a169d04..f4a3b20 100644 --- a/circ_buf.h +++ b/circ_buf.h @@ -2,31 +2,7 @@ * Copyright (c) 2018, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #ifndef __CIRC_BUF_H__ #define __CIRC_BUF_H__ diff --git a/console.c b/console.c index d758c8b..0b3abaf 100644 --- a/console.c +++ b/console.c @@ -2,31 +2,7 @@ * Copyright (c) 2020, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include #include diff --git a/device.c b/device.c index 9f4bcab..7daffae 100644 --- a/device.c +++ b/device.c @@ -2,31 +2,7 @@ * Copyright (c) 2016-2018, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include #include diff --git a/device_parser.c b/device_parser.c index fd65816..bae07b4 100644 --- a/device_parser.c +++ b/device_parser.c @@ -2,31 +2,7 @@ * Copyright (c) 2018, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include #include diff --git a/drivers/alpaca.c b/drivers/alpaca.c index 12f4c99..a493f8d 100644 --- a/drivers/alpaca.c +++ b/drivers/alpaca.c @@ -2,31 +2,7 @@ * Copyright (c) 2018, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include #include diff --git a/drivers/cdb_assist.c b/drivers/cdb_assist.c index 40ed67c..8eaaf37 100644 --- a/drivers/cdb_assist.c +++ b/drivers/cdb_assist.c @@ -2,31 +2,7 @@ * Copyright (c) 2016-2018, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include #include diff --git a/drivers/conmux.c b/drivers/conmux.c index 1cd8504..a288c5c 100644 --- a/drivers/conmux.c +++ b/drivers/conmux.c @@ -2,31 +2,7 @@ * Copyright (c) 2018, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include #include diff --git a/drivers/external.c b/drivers/external.c index 0fb82e1..793e348 100644 --- a/drivers/external.c +++ b/drivers/external.c @@ -2,31 +2,7 @@ * Copyright (c) 2021-2023, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include diff --git a/drivers/ftdi-gpio.c b/drivers/ftdi-gpio.c index 050e2db..77e5384 100644 --- a/drivers/ftdi-gpio.c +++ b/drivers/ftdi-gpio.c @@ -2,31 +2,7 @@ * Copyright (c) 2023, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #define _GNU_SOURCE #include diff --git a/drivers/local-gpio-v1.c b/drivers/local-gpio-v1.c index b706f65..793dd1d 100644 --- a/drivers/local-gpio-v1.c +++ b/drivers/local-gpio-v1.c @@ -2,31 +2,7 @@ * Copyright (c) 2023, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include #include diff --git a/drivers/local-gpio-v2.c b/drivers/local-gpio-v2.c index 5e11c60..64cae88 100644 --- a/drivers/local-gpio-v2.c +++ b/drivers/local-gpio-v2.c @@ -2,31 +2,7 @@ * Copyright (c) 2023, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #define _GNU_SOURCE #include diff --git a/drivers/local-gpio.c b/drivers/local-gpio.c index ef1c50c..a9ddcc4 100644 --- a/drivers/local-gpio.c +++ b/drivers/local-gpio.c @@ -2,31 +2,7 @@ * Copyright (c) 2023, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include #include diff --git a/drivers/local-gpio.h b/drivers/local-gpio.h index 44d9cc6..879e51d 100644 --- a/drivers/local-gpio.h +++ b/drivers/local-gpio.h @@ -2,31 +2,7 @@ * Copyright (c) 2023, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #ifndef _LOCAL_GPIO_H_ diff --git a/drivers/qcomlt_dbg.c b/drivers/qcomlt_dbg.c index 302e77f..bab0a43 100644 --- a/drivers/qcomlt_dbg.c +++ b/drivers/qcomlt_dbg.c @@ -2,31 +2,7 @@ * Copyright (c) 2021, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include diff --git a/fastboot.c b/fastboot.c index eec8947..cfb4bc7 100644 --- a/fastboot.c +++ b/fastboot.c @@ -2,31 +2,7 @@ * Copyright (c) 2016-2018, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include #include diff --git a/list.h b/list.h index 14b9095..c6930c4 100644 --- a/list.h +++ b/list.h @@ -2,31 +2,7 @@ * Copyright (c) 2016, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #ifndef __LIST_H__ #define __LIST_H__ diff --git a/ppps.c b/ppps.c index 7d8856a..b1244fc 100644 --- a/ppps.c +++ b/ppps.c @@ -2,31 +2,7 @@ * Copyright (c) 2023, Linaro Ltd. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #define _GNU_SOURCE /* for asprintf */ diff --git a/status-cmd.c b/status-cmd.c index 3529a63..7380be6 100644 --- a/status-cmd.c +++ b/status-cmd.c @@ -2,31 +2,7 @@ * Copyright (c) 2023, Qualcomm Innovaction Center, Inc * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * 3. Neither the name of the copyright holder nor the names of its contributors - * may be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * SPDX-License-Identifier: BSD-3-Clause */ #include From f6bd2d01d76de30f81d3073bc7d39ecb8670a797 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Tue, 12 Mar 2024 20:17:22 +0200 Subject: [PATCH 3/7] watch: split implementation to aseparate file Split CDBA's watching code to a separate file. Signed-off-by: Dmitry Baryshkov --- cdba-server.c | 148 +------------------------------------ cdba-server.h | 6 -- console.c | 1 + device.c | 1 + drivers/cdb_assist.c | 1 + drivers/conmux.c | 1 + drivers/qcomlt_dbg.c | 1 + fastboot.c | 1 + meson.build | 3 +- status-cmd.c | 1 + watch.c | 172 +++++++++++++++++++++++++++++++++++++++++++ watch.h | 10 +++ 12 files changed, 195 insertions(+), 151 deletions(-) create mode 100644 watch.c create mode 100644 watch.h diff --git a/cdba-server.c b/cdba-server.c index 7a98352..e3267d8 100644 --- a/cdba-server.c +++ b/cdba-server.c @@ -4,8 +4,6 @@ * * SPDX-License-Identifier: BSD-3-Clause */ -#include -#include #include #include #include @@ -22,8 +20,8 @@ #include "device_parser.h" #include "fastboot.h" #include "list.h" +#include "watch.h" -static bool quit_invoked; static const char *username; struct device *selected_device; @@ -88,7 +86,7 @@ static void msg_select_board(const void *param) selected_device = device_open(param, username, &fastboot_ops); if (!selected_device) { fprintf(stderr, "failed to open %s\n", (const char *)param); - quit_invoked = true; + watch_quit(); } cdba_send(MSG_SELECT_BOARD); @@ -224,119 +222,14 @@ static int handle_stdin(int fd, void *buf) return 0; } -struct watch { - struct list_head node; - - int fd; - int (*cb)(int, void*); - void *data; -}; - -struct timer { - struct list_head node; - struct timeval tv; - - void (*cb)(void *); - void *data; -}; - -static struct list_head read_watches = LIST_INIT(read_watches); -static struct list_head timer_watches = LIST_INIT(timer_watches); - -void watch_add_readfd(int fd, int (*cb)(int, void*), void *data) -{ - struct watch *w; - - w = calloc(1, sizeof(*w)); - w->fd = fd; - w->cb = cb; - w->data = data; - - list_add(&read_watches, &w->node); -} - -void watch_timer_add(int timeout_ms, void (*cb)(void *), void *data) -{ - struct timeval tv_timeout; - struct timeval now; - struct timer *t; - - t = calloc(1, sizeof(*t)); - - gettimeofday(&now, NULL); - - tv_timeout.tv_sec = timeout_ms / 1000; - tv_timeout.tv_usec = (timeout_ms % 1000) * 1000; - - t->cb = cb; - t->data = data; - timeradd(&now, &tv_timeout, &t->tv); - - list_add(&timer_watches, &t->node); -} - -static struct timeval *watch_timer_next(void) -{ - static struct timeval timeout; - struct timeval now; - struct timer *next; - struct timer *t; - - if (list_empty(&timer_watches)) - return NULL; - - next = list_entry_first(&timer_watches, struct timer, node); - - list_for_each_entry(t, &timer_watches, node) { - if (timercmp(&t->tv, &next->tv, <)) - next = t; - } - - gettimeofday(&now, NULL); - timersub(&next->tv, &now, &timeout); - if (timeout.tv_sec < 0) { - timeout.tv_sec = 0; - timeout.tv_usec = 0; - } - - return &timeout; -} - -static void watch_timer_invoke(void) -{ - struct timeval now; - struct timer *tmp; - struct timer *t; - - gettimeofday(&now, NULL); - - list_for_each_entry_safe(t, tmp, &timer_watches, node) { - if (timercmp(&t->tv, &now, <)) { - t->cb(t->data); - - list_del(&t->node); - free(t); - } - } -} - static void sigpipe_handler(int signo) { - quit_invoked = true; -} - -void watch_quit(void) -{ - quit_invoked = true; + watch_quit(); } int main(int argc, char **argv) { - struct timeval *timeoutp; - struct watch *w; - fd_set rfds; int flags; - int nfds; int ret; signal(SIGPIPE, sigpipe_handler); @@ -365,40 +258,7 @@ int main(int argc, char **argv) flags = fcntl(STDIN_FILENO, F_GETFL, 0); fcntl(STDIN_FILENO, F_SETFL, flags | O_NONBLOCK); - while (!quit_invoked) { - nfds = 0; - - list_for_each_entry(w, &read_watches, node) { - nfds = MAX(nfds, w->fd); - FD_SET(w->fd, &rfds); - } - - if (!FD_ISSET(STDIN_FILENO, &rfds)) { - fprintf(stderr, "rfds is trash!\n"); - goto done; - } - - timeoutp = watch_timer_next(); - ret = select(nfds + 1, &rfds, NULL, NULL, timeoutp); - if (ret < 0 && errno == EINTR) - continue; - else if (ret < 0) - break; - - watch_timer_invoke(); - - list_for_each_entry(w, &read_watches, node) { - if (FD_ISSET(w->fd, &rfds)) { - ret = w->cb(w->fd, w->data); - if (ret < 0) { - fprintf(stderr, "cb returned %d\n", ret); - goto done; - } - } - } - } - -done: + watch_run(); /* if we got here, stdin/out/err might be not accessible anymore */ ret = open("/dev/null", O_RDWR); diff --git a/cdba-server.h b/cdba-server.h index 0dd6f26..c8e00a4 100644 --- a/cdba-server.h +++ b/cdba-server.h @@ -6,12 +6,6 @@ #include "cdba.h" -void watch_add_readfd(int fd, int (*cb)(int, void*), void *data); -int watch_add_quit(int (*cb)(int, void*), void *data); -void watch_timer_add(int timeout_ms, void (*cb)(void *), void *data); -void watch_quit(void); -int watch_run(void); - int tty_open(const char *tty, struct termios *old); void cdba_send_buf(int type, size_t len, const void *buf); diff --git a/console.c b/console.c index 0b3abaf..434ad46 100644 --- a/console.c +++ b/console.c @@ -13,6 +13,7 @@ #include "cdba-server.h" #include "device.h" +#include "watch.h" struct console { int console_fd; diff --git a/device.c b/device.c index 7daffae..5baaf76 100644 --- a/device.c +++ b/device.c @@ -23,6 +23,7 @@ #include "list.h" #include "ppps.h" #include "status-cmd.h" +#include "watch.h" #define ARRAY_SIZE(x) ((sizeof(x)/sizeof((x)[0]))) diff --git a/drivers/cdb_assist.c b/drivers/cdb_assist.c index 8eaaf37..55b17dc 100644 --- a/drivers/cdb_assist.c +++ b/drivers/cdb_assist.c @@ -20,6 +20,7 @@ #include "cdba-server.h" #include "device.h" #include "status.h" +#include "watch.h" struct cdb_assist { char serial[9]; diff --git a/drivers/conmux.c b/drivers/conmux.c index a288c5c..552f245 100644 --- a/drivers/conmux.c +++ b/drivers/conmux.c @@ -18,6 +18,7 @@ #include "cdba-server.h" #include "device.h" +#include "watch.h" extern int h_errno; diff --git a/drivers/qcomlt_dbg.c b/drivers/qcomlt_dbg.c index bab0a43..6e24ce1 100644 --- a/drivers/qcomlt_dbg.c +++ b/drivers/qcomlt_dbg.c @@ -21,6 +21,7 @@ #include "cdba-server.h" #include "device.h" #include "status.h" +#include "watch.h" enum qcomlt_parse_state { STATE_, diff --git a/fastboot.c b/fastboot.c index cfb4bc7..32f08f8 100644 --- a/fastboot.c +++ b/fastboot.c @@ -22,6 +22,7 @@ #include "cdba-server.h" #include "fastboot.h" +#include "watch.h" #define MAX_USBFS_BULK_SIZE (16*1024) diff --git a/meson.build b/meson.build index 927a2b8..ef28570 100644 --- a/meson.build +++ b/meson.build @@ -88,7 +88,8 @@ server_srcs = ['cdba-server.c', 'console.c', 'ppps.c', 'status.c', - 'status-cmd.c'] + 'status-cmd.c', + 'watch.c'] build_server = true foreach d: server_deps diff --git a/status-cmd.c b/status-cmd.c index 7380be6..09998b8 100644 --- a/status-cmd.c +++ b/status-cmd.c @@ -17,6 +17,7 @@ #include "device.h" #include "status.h" #include "status-cmd.h" +#include "watch.h" static void launch_status_cmd(struct device *dev) { diff --git a/watch.c b/watch.c new file mode 100644 index 0000000..236911b --- /dev/null +++ b/watch.c @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2016-2018, Linaro Ltd. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "cdba.h" +#include "list.h" +#include "watch.h" + +static bool quit_invoked; + +struct watch { + struct list_head node; + + int fd; + int (*cb)(int, void*); + void *data; +}; + +struct timer { + struct list_head node; + struct timeval tv; + + void (*cb)(void *); + void *data; +}; + +static struct list_head read_watches = LIST_INIT(read_watches); +static struct list_head timer_watches = LIST_INIT(timer_watches); + +void watch_add_readfd(int fd, int (*cb)(int, void*), void *data) +{ + struct watch *w; + + w = calloc(1, sizeof(*w)); + w->fd = fd; + w->cb = cb; + w->data = data; + + list_add(&read_watches, &w->node); +} + +void watch_timer_add(int timeout_ms, void (*cb)(void *), void *data) +{ + struct timeval tv_timeout; + struct timeval now; + struct timer *t; + + t = calloc(1, sizeof(*t)); + + gettimeofday(&now, NULL); + + tv_timeout.tv_sec = timeout_ms / 1000; + tv_timeout.tv_usec = (timeout_ms % 1000) * 1000; + + t->cb = cb; + t->data = data; + timeradd(&now, &tv_timeout, &t->tv); + + list_add(&timer_watches, &t->node); +} + +static struct timeval *watch_timer_next(void) +{ + static struct timeval timeout; + struct timeval now; + struct timer *next; + struct timer *t; + + if (list_empty(&timer_watches)) + return NULL; + + next = list_entry_first(&timer_watches, struct timer, node); + + list_for_each_entry(t, &timer_watches, node) { + if (timercmp(&t->tv, &next->tv, <)) + next = t; + } + + gettimeofday(&now, NULL); + timersub(&next->tv, &now, &timeout); + if (timeout.tv_sec < 0) { + timeout.tv_sec = 0; + timeout.tv_usec = 0; + } + + return &timeout; +} + +static void watch_timer_invoke(void) +{ + struct timeval now; + struct timer *tmp; + struct timer *t; + + gettimeofday(&now, NULL); + + list_for_each_entry_safe(t, tmp, &timer_watches, node) { + if (timercmp(&t->tv, &now, <)) { + t->cb(t->data); + + list_del(&t->node); + free(t); + } + } +} + +void watch_quit(void) +{ + quit_invoked = true; +} + +int watch_run(void) +{ + struct timeval *timeoutp; + struct watch *w; + fd_set rfds; + int nfds; + int ret; + + while (!quit_invoked) { + nfds = 0; + + list_for_each_entry(w, &read_watches, node) { + nfds = MAX(nfds, w->fd); + FD_SET(w->fd, &rfds); + } + + if (!FD_ISSET(STDIN_FILENO, &rfds)) { + fprintf(stderr, "rfds is trash!\n"); + return -EINVAL; + } + + timeoutp = watch_timer_next(); + ret = select(nfds + 1, &rfds, NULL, NULL, timeoutp); + if (ret < 0 && errno == EINTR) + continue; + else if (ret < 0) { + int err = errno; + fprintf(stderr, "select returned %s\n", strerror(err)); + return -err; + } + + watch_timer_invoke(); + + list_for_each_entry(w, &read_watches, node) { + if (FD_ISSET(w->fd, &rfds)) { + ret = w->cb(w->fd, w->data); + if (ret < 0) { + fprintf(stderr, "cb returned %d\n", ret); + return ret; + } + } + } + } + + return 0; +} diff --git a/watch.h b/watch.h new file mode 100644 index 0000000..22ae2bf --- /dev/null +++ b/watch.h @@ -0,0 +1,10 @@ +#ifndef __WATCH_H__ +#define __WATCH_H__ + +void watch_add_readfd(int fd, int (*cb)(int, void*), void *data); +int watch_add_quit(int (*cb)(int, void*), void *data); +void watch_timer_add(int timeout_ms, void (*cb)(void *), void *data); +void watch_quit(void); +int watch_run(void); + +#endif From 2f1caa28c0f3a5dbad4de1b24812aa695aab7540 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Tue, 12 Mar 2024 20:17:22 +0200 Subject: [PATCH 4/7] tty: split tty_open to a separate file Split the function tty_open() to a separate file. Signed-off-by: Dmitry Baryshkov --- cdba-server.c | 28 ---------------------------- cdba-server.h | 2 -- console.c | 1 + drivers/alpaca.c | 2 +- drivers/cdb_assist.c | 2 +- drivers/qcomlt_dbg.c | 1 + meson.build | 3 ++- tty.c | 42 ++++++++++++++++++++++++++++++++++++++++++ tty.h | 7 +++++++ 9 files changed, 55 insertions(+), 33 deletions(-) create mode 100644 tty.c create mode 100644 tty.h diff --git a/cdba-server.c b/cdba-server.c index e3267d8..cc538ca 100644 --- a/cdba-server.c +++ b/cdba-server.c @@ -26,34 +26,6 @@ static const char *username; struct device *selected_device; -int tty_open(const char *tty, struct termios *old) -{ - struct termios tios; - int ret; - int fd; - - fd = open(tty, O_RDWR | O_NOCTTY | O_EXCL); - if (fd < 0) - err(1, "unable to open \"%s\"", tty); - - ret = tcgetattr(fd, old); - if (ret < 0) - err(1, "unable to retrieve \"%s\" tios", tty); - - memset(&tios, 0, sizeof(tios)); - tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD; - tios.c_iflag = IGNPAR; - tios.c_oflag = 0; - - tcflush(fd, TCIFLUSH); - - ret = tcsetattr(fd, TCSANOW, &tios); - if (ret < 0) - err(1, "unable to update \"%s\" tios", tty); - - return fd; -} - static void fastboot_opened(struct fastboot *fb, void *data) { const uint8_t one = 1; diff --git a/cdba-server.h b/cdba-server.h index c8e00a4..4176311 100644 --- a/cdba-server.h +++ b/cdba-server.h @@ -6,8 +6,6 @@ #include "cdba.h" -int tty_open(const char *tty, struct termios *old); - void cdba_send_buf(int type, size_t len, const void *buf); #define cdba_send(type) cdba_send_buf(type, 0, NULL) diff --git a/console.c b/console.c index 434ad46..3ff0a2f 100644 --- a/console.c +++ b/console.c @@ -13,6 +13,7 @@ #include "cdba-server.h" #include "device.h" +#include "tty.h" #include "watch.h" struct console { diff --git a/drivers/alpaca.c b/drivers/alpaca.c index a493f8d..f720670 100644 --- a/drivers/alpaca.c +++ b/drivers/alpaca.c @@ -17,8 +17,8 @@ #include #include -#include "cdba-server.h" #include "device.h" +#include "tty.h" struct alpaca { int alpaca_fd; diff --git a/drivers/cdb_assist.c b/drivers/cdb_assist.c index 55b17dc..2a4759d 100644 --- a/drivers/cdb_assist.c +++ b/drivers/cdb_assist.c @@ -17,9 +17,9 @@ #include #include -#include "cdba-server.h" #include "device.h" #include "status.h" +#include "tty.h" #include "watch.h" struct cdb_assist { diff --git a/drivers/qcomlt_dbg.c b/drivers/qcomlt_dbg.c index 6e24ce1..fe55cf4 100644 --- a/drivers/qcomlt_dbg.c +++ b/drivers/qcomlt_dbg.c @@ -21,6 +21,7 @@ #include "cdba-server.h" #include "device.h" #include "status.h" +#include "tty.h" #include "watch.h" enum qcomlt_parse_state { diff --git a/meson.build b/meson.build index ef28570..763c32d 100644 --- a/meson.build +++ b/meson.build @@ -89,7 +89,8 @@ server_srcs = ['cdba-server.c', 'ppps.c', 'status.c', 'status-cmd.c', - 'watch.c'] + 'watch.c', + 'tty.c'] build_server = true foreach d: server_deps diff --git a/tty.c b/tty.c new file mode 100644 index 0000000..4c75cfe --- /dev/null +++ b/tty.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016-2018, Linaro Ltd. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include +#include + +#include "tty.h" + +int tty_open(const char *tty, struct termios *old) +{ + struct termios tios; + int ret; + int fd; + + fd = open(tty, O_RDWR | O_NOCTTY | O_EXCL); + if (fd < 0) + err(1, "unable to open \"%s\"", tty); + + ret = tcgetattr(fd, old); + if (ret < 0) + err(1, "unable to retrieve \"%s\" tios", tty); + + memset(&tios, 0, sizeof(tios)); + tios.c_cflag = B115200 | CS8 | CLOCAL | CREAD; + tios.c_iflag = IGNPAR; + tios.c_oflag = 0; + + tcflush(fd, TCIFLUSH); + + ret = tcsetattr(fd, TCSANOW, &tios); + if (ret < 0) + err(1, "unable to update \"%s\" tios", tty); + + return fd; +} diff --git a/tty.h b/tty.h new file mode 100644 index 0000000..6345fc0 --- /dev/null +++ b/tty.h @@ -0,0 +1,7 @@ +#ifndef __TTY_H__ +#define __TTY_H__ + +struct termios; +int tty_open(const char *tty, struct termios *old); + +#endif From 62dc594cb1949fa2c48c01fd899a52e00e894ffc Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Tue, 12 Mar 2024 20:30:25 +0200 Subject: [PATCH 5/7] device: split fastboot_open from device_open Create new function calling fastboot_open so that device_open doesn't have dependency on the fastboot_ops or udev. Signed-off-by: Dmitry Baryshkov --- cdba-server.c | 4 +++- device.c | 23 +++++++++++++++++++---- device.h | 5 +++-- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/cdba-server.c b/cdba-server.c index cc538ca..2b16661 100644 --- a/cdba-server.c +++ b/cdba-server.c @@ -55,12 +55,14 @@ static struct fastboot_ops fastboot_ops = { static void msg_select_board(const void *param) { - selected_device = device_open(param, username, &fastboot_ops); + selected_device = device_open(param, username); if (!selected_device) { fprintf(stderr, "failed to open %s\n", (const char *)param); watch_quit(); } + device_fastboot_open(selected_device, &fastboot_ops); + cdba_send(MSG_SELECT_BOARD); } diff --git a/device.c b/device.c index 5baaf76..79ce6a5 100644 --- a/device.c +++ b/device.c @@ -95,8 +95,7 @@ static bool device_check_access(struct device *device, } struct device *device_open(const char *board, - const char *username, - struct fastboot_ops *fastboot_ops) + const char *username) { struct device *device; @@ -136,8 +135,6 @@ found: if (device->usb_always_on) device_usb(device, true); - device->fastboot = fastboot_open(device->serial, fastboot_ops, NULL); - return device; } @@ -275,18 +272,36 @@ int device_write(struct device *device, const void *buf, size_t len) return device_console(device, write, buf, len); } +void device_fastboot_open(struct device *device, + struct fastboot_ops *fastboot_ops) +{ + device->fastboot = fastboot_open(device->serial, fastboot_ops, NULL); +} + void device_fastboot_boot(struct device *device) { + if (!device->fastboot) { + fprintf(stderr, "fastboot not opened\n"); + return; + } fastboot_boot(device->fastboot); } void device_fastboot_continue(struct device *device) { + if (!device->fastboot) { + fprintf(stderr, "fastboot not opened\n"); + return; + } fastboot_continue(device->fastboot); } void device_fastboot_flash_reboot(struct device *device) { + if (!device->fastboot) { + fprintf(stderr, "fastboot not opened\n"); + return; + } fastboot_flash(device->fastboot, "boot"); fastboot_reboot(device->fastboot); } diff --git a/device.h b/device.h index 6d431bc..220eeb0 100644 --- a/device.h +++ b/device.h @@ -72,8 +72,7 @@ struct device_user { void device_add(struct device *device); struct device *device_open(const char *board, - const char *username, - struct fastboot_ops *fastboot_ops); + const char *username); void device_close(struct device *dev); int device_power(struct device *device, bool on); @@ -83,6 +82,8 @@ int device_write(struct device *device, const void *buf, size_t len); void device_boot(struct device *device, const void *data, size_t len); +void device_fastboot_open(struct device *device, + struct fastboot_ops *fastboot_ops); void device_fastboot_boot(struct device *device); void device_fastboot_flash_reboot(struct device *device); void device_send_break(struct device *device); From 762879fd0cb7a02e8b6c868dfeefef9acbb8ae58 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Tue, 21 Dec 2021 02:24:52 +0300 Subject: [PATCH 6/7] device: add support for leaving device powered For some devices it might be desirable to leave device powered on after the cdba exits (e.g. to run some long-running tests). Add the 'power_always_on' option that tells cdba server to leave device powered on after exiting and to toggle power (to reset the device) when connecting. Signed-off-by: Dmitry Baryshkov --- device.c | 17 ++++++++++++++++- device.h | 1 + device_parser.c | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/device.c b/device.c index 79ce6a5..9922130 100644 --- a/device.c +++ b/device.c @@ -94,6 +94,8 @@ static bool device_check_access(struct device *device, return false; } +static int device_power_off(struct device *device); + struct device *device_open(const char *board, const char *username) { @@ -132,6 +134,18 @@ found: if (!device->console) errx(1, "failed to open device console"); + /* + * Power off before opening fastboot. Otherwise if the device is + * already in the fastboot state, CDBA will detect it, then power up + * procedure will restart the device causing fastboot to disappear and + * appear again. This will cause CDBA to exit, ending up with the + * unbreakable fastboot-reset-second_fastboot-quit cycle. + * */ + if (device->power_always_on) { + device_power_off(device); + sleep(2); + } + if (device->usb_always_on) device_usb(device, true); @@ -374,7 +388,8 @@ void device_close(struct device *dev) { if (!dev->usb_always_on) device_usb(dev, false); - device_power(dev, false); + if (!dev->power_always_on) + device_power(dev, false); if (device_has_control(dev, close)) device_control(dev, close); diff --git a/device.h b/device.h index 220eeb0..0b8d0e9 100644 --- a/device.h +++ b/device.h @@ -41,6 +41,7 @@ struct device { unsigned voltage; bool tickle_mmc; bool usb_always_on; + bool power_always_on; struct fastboot *fastboot; unsigned int fastboot_key_timeout; int state; diff --git a/device_parser.c b/device_parser.c index bae07b4..8b55741 100644 --- a/device_parser.c +++ b/device_parser.c @@ -171,6 +171,8 @@ static void parse_board(struct device_parser *dp) dev->ppps3_path = strdup(value); } else if (!strcmp(key, "status-cmd")) { dev->status_cmd = strdup(value); + } else if (!strcmp(key, "power_always_on")) { + dev->power_always_on = !strcmp(value, "true"); } else { fprintf(stderr, "device parser: unknown key \"%s\"\n", key); exit(1); From ca5f95d6cd00f0f5e4798be4e60def16a4cb4580 Mon Sep 17 00:00:00 2001 From: Dmitry Baryshkov Date: Tue, 12 Mar 2024 21:08:19 +0200 Subject: [PATCH 7/7] cdba-power: add power-on/-off tool Add simple tool reusing CDBA code to power boards on and off. Signed-off-by: Dmitry Baryshkov --- cdba-power.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++ device.c | 5 +++ device.h | 1 + meson.build | 24 ++++++++++----- watch.c | 28 +++++++++++++---- watch.h | 1 + 6 files changed, 133 insertions(+), 13 deletions(-) create mode 100644 cdba-power.c diff --git a/cdba-power.c b/cdba-power.c new file mode 100644 index 0000000..cd907bf --- /dev/null +++ b/cdba-power.c @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024, Linaro Ltd. + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include +#include +#include + +#include "cdba-server.h" +#include "device.h" +#include "device_parser.h" +#include "watch.h" + +void cdba_send_buf(int type, size_t len, const void *buf) +{ + /* ignore console messages */ +} + +static void usage(const char *name) +{ + fprintf(stderr, "Usage: %s on|off\n", name); + exit(EXIT_FAILURE); +} + +static struct device *selected_device; + +bool ready(void) +{ + return device_is_running(selected_device); +} + +int main(int argc, char **argv) +{ + const char *home; + const char *name; + bool on; + int ret; + + if (argc != 3) + usage(argv[0]); + + if (!strcmp(argv[2], "on")) + on = true; + else if (!strcmp(argv[2], "off")) + on = false; + else + usage(argv[0]); + + home = getenv("HOME"); + if (home) + chdir(home); + + ret = device_parser(".cdba"); + if (ret) { + ret = device_parser("/etc/cdba"); + if (ret) { + fprintf(stderr, "device parser: unable to open config file\n"); + exit(1); + } + } + + name = argv[1]; + selected_device = device_open(name, "nobody"); + if (!selected_device) { + fprintf(stderr, "failed to open %s\n", name); + exit(EXIT_FAILURE); + } + + if (on) { + device_power(selected_device, true); + watch_main_loop(ready); + + selected_device->usb_always_on = true; + selected_device->power_always_on = true; + } else { + device_usb(selected_device, false); + device_power(selected_device, false); + } + + device_close(selected_device); + + return 0; +} diff --git a/device.c b/device.c index 9922130..848f552 100644 --- a/device.c +++ b/device.c @@ -227,6 +227,11 @@ static void device_tick(void *data) } } +bool device_is_running(struct device *device) +{ + return device->state == DEVICE_STATE_RUNNING; +} + static int device_power_on(struct device *device) { if (!device || !device_has_control(device, power)) diff --git a/device.h b/device.h index 0b8d0e9..0edb048 100644 --- a/device.h +++ b/device.h @@ -91,6 +91,7 @@ void device_send_break(struct device *device); void device_list_devices(const char *username); void device_info(const char *username, const void *data, size_t dlen); void device_fastboot_continue(struct device *device); +bool device_is_running(struct device *device); enum { DEVICE_KEY_FASTBOOT, diff --git a/meson.build b/meson.build index 763c32d..fe03e81 100644 --- a/meson.build +++ b/meson.build @@ -54,7 +54,7 @@ if not ftdi_dep.found() endif gpiod_dep = dependency('libgpiod', required: server_opt) -server_deps = [dependency('libudev', required: server_opt), +cdbalib_deps = [dependency('libudev', required: server_opt), dependency('yaml-0.1', required: server_opt), gpiod_dep, ftdi_dep] @@ -62,7 +62,7 @@ server_deps = [dependency('libudev', required: server_opt), # E.g. Debian reuires -lutil for forkpty if not compiler.has_function('forkpty') util_dep = compiler.find_library('util') - server_deps += util_dep + cdbalib_deps += util_dep endif drivers_srcs = ['drivers/alpaca.c', @@ -80,8 +80,7 @@ else drivers_srcs += ['drivers/local-gpio-v1.c'] endif -server_srcs = ['cdba-server.c', - 'circ_buf.c', +cdbalib_srcs = ['circ_buf.c', 'device.c', 'device_parser.c', 'fastboot.c', @@ -92,17 +91,28 @@ server_srcs = ['cdba-server.c', 'watch.c', 'tty.c'] +server_srcs = ['cdba-server.c'] + build_server = true -foreach d: server_deps +foreach d: cdbalib_deps if not d.found() build_server = false endif endforeach if build_server + libcdba = static_library('cdba', + cdbalib_srcs + drivers_srcs, + dependencies : cdbalib_deps, + ) + executable('cdba-server', - server_srcs + drivers_srcs, - dependencies : server_deps, + server_srcs, + link_with : libcdba, + install : true) + executable('cdba-power', + ['cdba-power.c'], + link_with : libcdba, install : true) elif not server_opt.disabled() message('Skipping CDBA server build') diff --git a/watch.c b/watch.c index 236911b..65755f4 100644 --- a/watch.c +++ b/watch.c @@ -124,7 +124,7 @@ void watch_quit(void) quit_invoked = true; } -int watch_run(void) +int watch_main_loop(bool (*quit_cb)(void)) { struct timeval *timeoutp; struct watch *w; @@ -133,6 +133,9 @@ int watch_run(void) int ret; while (!quit_invoked) { + if (quit_cb && quit_cb()) + break; + nfds = 0; list_for_each_entry(w, &read_watches, node) { @@ -140,11 +143,6 @@ int watch_run(void) FD_SET(w->fd, &rfds); } - if (!FD_ISSET(STDIN_FILENO, &rfds)) { - fprintf(stderr, "rfds is trash!\n"); - return -EINVAL; - } - timeoutp = watch_timer_next(); ret = select(nfds + 1, &rfds, NULL, NULL, timeoutp); if (ret < 0 && errno == EINTR) @@ -170,3 +168,21 @@ int watch_run(void) return 0; } + +int watch_run(void) +{ + struct watch *w; + bool found = false; + + list_for_each_entry(w, &read_watches, node) { + if (w->fd == STDIN_FILENO) + found = true; + } + + if (!found) { + fprintf(stderr, "rfds is trash!\n"); + return -EINVAL; + } + + return watch_main_loop(NULL); +} diff --git a/watch.h b/watch.h index 22ae2bf..dde554b 100644 --- a/watch.h +++ b/watch.h @@ -5,6 +5,7 @@ void watch_add_readfd(int fd, int (*cb)(int, void*), void *data); int watch_add_quit(int (*cb)(int, void*), void *data); void watch_timer_add(int timeout_ms, void (*cb)(void *), void *data); void watch_quit(void); +int watch_main_loop(bool (*quit_cb)(void)); int watch_run(void); #endif