From patchwork Tue May 16 20:59:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 684599 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CA26C77B7F for ; Tue, 16 May 2023 20:59:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229484AbjEPU7a (ORCPT ); Tue, 16 May 2023 16:59:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbjEPU73 (ORCPT ); Tue, 16 May 2023 16:59:29 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D934559E0 for ; Tue, 16 May 2023 13:59:28 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-52c6f81193cso10228853a12.1 for ; Tue, 16 May 2023 13:59:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684270767; x=1686862767; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=gnB5yv9oZNhLgZuBAf3kZHHnyPDEbPfDsi/R/yytOW0=; b=APvcuB4pZo2fjFEYaS1tPeo1cGzYn4+rx8CUc+cfsmWjOsy/V8lxX1KHrzVqeVUhjw 3fSI+Twt8fyDU0g0DvQ0vfmP2bLSMBOXJtLmHOjWMH58bTLlZnEDZcgX/88W036O4DU4 4xNI687LfK5YxZAHPUkr7wfBwdUhxvWJ8qXs4nMvRVo16FShykYxe29bA027T9aNEb6B HoAjq+olF+gH8F0YoPw1PrP/wvNBrJCVb8okqUUPUXvKMquUAOWYchb+OSq5AP5xnnsH ewFKURSg1BekfdlVHOf15TYBHFyOnTjFyAYaLaQgdJcAJmJjCspVID5vMMBAvTUxuvh5 mixQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684270767; x=1686862767; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gnB5yv9oZNhLgZuBAf3kZHHnyPDEbPfDsi/R/yytOW0=; b=d4ivic6Nn7ivWvKGbTyJTYZFhhrJhsfk4CuXi8waOEKBMaUKSQqUS+QL72gr4CMP/F zyEOootjv33zgIIpG3F8T6AiB0/ect1T+tlO3eTuld7OWs11EzPNNtkNYU7tsPBdMZ2V o/LAfl0Kyn5qols9z8wt85wihL5gdRlnpgs5/XS1TLqtxkzMHj69rPewCd+8kUv4X5wx DqRauG2cN+7Vwv0En40rWRZjKKmuEaQn9yxxn15kg77G5tKi4lP7DHyQuSzB2LmuOgHs EqynmIs7++Bj1vrnRV0Y2Fitp+MQqz1/K0YGfAq85wi3WWW6/4qYH0Y+Z6vxQv0FPTGy eriA== X-Gm-Message-State: AC+VfDzL++jNsCX48pI+45tb/5q81j1NImDNiQKlCVK8v9Y0KAQ8X24K K0tS7TfNvoCtBI+J7vYEeEfzYvYY4g0= X-Google-Smtp-Source: ACHHUZ5cmJvPUTHFRgC5FrF2iq5vVNSIMhpctMHlxUM8gYmrWf15HJITBmrQOLY/qd9bYhLp+PLLXw== X-Received: by 2002:a17:902:8c98:b0:1ad:be4d:5dfe with SMTP id t24-20020a1709028c9800b001adbe4d5dfemr21260402plo.27.1684270767402; Tue, 16 May 2023 13:59:27 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id t16-20020a1709028c9000b001acad024c8asm14272237plo.40.2023.05.16.13.59.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 13:59:26 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 01/10] profile: Add support for experimental flag Date: Tue, 16 May 2023 13:59:15 -0700 Message-Id: <20230516205924.1040506-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds experimental field to btd_profile so the plugin can indicate drivers that depends on experimental to be enabled. --- src/profile.c | 6 ++++++ src/profile.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/profile.c b/src/profile.c index e1bebf1ee19c..ea188f36b6dd 100644 --- a/src/profile.c +++ b/src/profile.c @@ -775,6 +775,12 @@ static struct btd_profile *btd_profile_find_uuid(const char *uuid) int btd_profile_register(struct btd_profile *profile) { + if (profile->experimental && !(g_dbus_get_flags() & + G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) { + DBG("D-Bus experimental not enabled"); + return -ENOTSUP; + } + profiles = g_slist_append(profiles, profile); return 0; } diff --git a/src/profile.h b/src/profile.h index 6827f848148c..6871f2f0d7d8 100644 --- a/src/profile.h +++ b/src/profile.h @@ -28,6 +28,11 @@ struct btd_profile { */ bool external; + /* Indicates the profile is experimental and shall only be registered + * when experimental has been enabled (see: main.conf:Experimental). + */ + bool experimental; + int (*device_probe) (struct btd_service *service); void (*device_remove) (struct btd_service *service); From patchwork Tue May 16 20:59:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 682647 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7EA2C77B7F for ; Tue, 16 May 2023 20:59:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230167AbjEPU7f (ORCPT ); Tue, 16 May 2023 16:59:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbjEPU7b (ORCPT ); Tue, 16 May 2023 16:59:31 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9291E6A69 for ; Tue, 16 May 2023 13:59:30 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1ae3ed1b08eso1485295ad.0 for ; Tue, 16 May 2023 13:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684270769; x=1686862769; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=wBo++OSugDX16NBEk0VGJUq2Te47F5j23MhSdO7vJs0=; b=Eb3u0b2SBjyrd3lRolQJjbpHvVgSNNCxoKudqIPVxpC6EiCQ4n+RzDfEmf+YVNNmej o1uFgNJmSWfREQrAyeVsLV84i5ejW3hjJZYvQkgsNzYrkAV2DXPy2+ligQZI5CWOF/YR pUW6r23f7yEPAR61/TFwbGrDT3XSUxkVtusuoJtqEp/ig0yCfVfcZHN2ockgqiUo4GHx nTEfpnnF6iaTY4d1I9ByHDCG6GNfClFhbgwb1DBhwWmC80QpUsjV1x/pM5o3Sc2Yk75Q WHQEoqpYrP/gJKErojcaXYhToU2G8PseFH72ykgvswyRl8LaY6UpxGk4rdEhhVqoX2lE PEYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684270769; x=1686862769; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wBo++OSugDX16NBEk0VGJUq2Te47F5j23MhSdO7vJs0=; b=DiQb3suay6PFkbPLzhKwgOP1q8mmv1QskyBnwzjAs0qS/Wgq+khDc9ZybuHi8ojv3I n7Zxc2sdobiV5KrZ31bTR8AM6G7cCyLsHx2NXkk03BZWcD+IgU6jE9Wy8LGGoXEI1RrY hvyvsc5ZjDlp8lUyRFbM6cS3D0x5k9fi+ygFlof+rhyb5DrtN9qWPJ8DpHrcidUb9lTv uUR5Cz6BbOPAw8TqN01k0PvXw3la6XEBlmBfsTp7//a/ryBbLfHLFRXUs6IAFbpUUcl1 uz7wvaJ6jIJ5Vir6W4WDEzJ25WzwdnPq3rlQgQjxTh4jhxhwxkVJQKedeSi86U8ZZVPj jytg== X-Gm-Message-State: AC+VfDytvdF8/bTWkipF39/zZrpICs7ge8+x5hiKGH2qeKJRuUyUzN83 JHyekg9/klD6LP/M3/XzB6ysYs86VQ0= X-Google-Smtp-Source: ACHHUZ4kxJMjXSGaNKDA1OhAmqDjrwbgGK+mgF/y0YDgbO3e90nuJTY/bCjCoEXJei5zo3EypU992Q== X-Received: by 2002:a17:902:da91:b0:1ae:f37:c1ab with SMTP id j17-20020a170902da9100b001ae0f37c1abmr13145941plx.25.1684270769152; Tue, 16 May 2023 13:59:29 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id t16-20020a1709028c9000b001acad024c8asm14272237plo.40.2023.05.16.13.59.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 13:59:28 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 02/10] bap: Mark driver as experimental Date: Tue, 16 May 2023 13:59:16 -0700 Message-Id: <20230516205924.1040506-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230516205924.1040506-1-luiz.dentz@gmail.com> References: <20230516205924.1040506-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This uses the btd_profile.experimental to mark the driver as experimental. --- profiles/audio/bap.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index 8f12fc410f67..1a543a9ce99b 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -1354,18 +1354,19 @@ static struct btd_profile bap_profile = { .accept = bap_accept, .disconnect = bap_disconnect, .auto_connect = true, + .experimental = true, }; static unsigned int bap_id = 0; static int bap_init(void) { - if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) { - warn("D-Bus experimental not enabled"); - return -ENOTSUP; - } + int err; + + err = btd_profile_register(&bap_profile); + if (err) + return err; - btd_profile_register(&bap_profile); bap_id = bt_bap_register(bap_attached, bap_detached, NULL); return 0; @@ -1373,10 +1374,8 @@ static int bap_init(void) static void bap_exit(void) { - if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) { - btd_profile_unregister(&bap_profile); - bt_bap_unregister(bap_id); - } + btd_profile_unregister(&bap_profile); + bt_bap_unregister(bap_id); } BLUETOOTH_PLUGIN_DEFINE(bap, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, From patchwork Tue May 16 20:59:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 682646 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4223BC7EE23 for ; Tue, 16 May 2023 20:59:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230191AbjEPU7g (ORCPT ); Tue, 16 May 2023 16:59:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbjEPU7d (ORCPT ); Tue, 16 May 2023 16:59:33 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8633859FB for ; Tue, 16 May 2023 13:59:32 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1ab01bf474aso988035ad.1 for ; Tue, 16 May 2023 13:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684270771; x=1686862771; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=FaiRL7R9hAB8QTE8OFJBjT36cb1wdquZAEQfKkG1Kg8=; b=JNed/x21mTPkRVq/ZuqL4g0ZYF4oMT2yKL2Co4vRJ4l+QljxPn79nol/7stF59mwve A3pJ1R2FOfdwxzEBWxfKsMEXEIGadag6t92/tN9Qq9t42apmxKHPZQkTYlnu4q5THxIc 6muHidYLI5wSXbMC0GxSPEqpFmzKv8moBAbEjGSV+YhoL/cZsPwB/lSgmHROPU84KYw+ Ae1NMQWEtojyWNZsSDhN0KPL3sazSikUtCFp1XMAClEC4qwYhqkHHrh5P7N9ujhQBhH/ 5Z4p4M1GM2159K/7q4tMA3LKd3ikowMK9ego/m9O94K2ZgQ8LyLPZRaX0HM9o/ox9L98 X8ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684270771; x=1686862771; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FaiRL7R9hAB8QTE8OFJBjT36cb1wdquZAEQfKkG1Kg8=; b=j/frkFG1prDCPDrwprCRl/iiuXAVg/vhQGKQoJxZvOmstO7zYAWtSd33HOBP4X2ygh Yp05bXwq7UTM/k5QJ8ENjodwKAq5yOhvNuO3SR7H0KH5jFenqRQBSZ9IYUQhEpSIZO1d FHSfAXvM+HhdpeMaW9gi8cjRpVCpBRi8f/O0k/IAhZbF4QQHAzVwURe9+8tMVWTKm1vX CQ24xvlXRFFlKaS+FRw7UvHq4+Dkq5XLERoYtQAGnKU5yX2mubNqW0vW0HYbwgFLeYFg 8Ui2rMrYeD8hudL+ZPF7azt3JtdUmTdnhOsgOIbvQgNv+VGXatxnjfdtlXVLZquAHWw9 9VUA== X-Gm-Message-State: AC+VfDxYPZVJxqSnwWzn7AEhE8Z0krYLSygpCTOEJpEzFzyIscXQqJNy C6jZo3fleJhl0ai8k8P2v5elffxZvwY= X-Google-Smtp-Source: ACHHUZ77vupnpJ7OrYzI74PeVdNnkEPxoyYt9QkVIKnPA2nd8BW2iI2SF32CZd3gAkVwL9Q0COYoNA== X-Received: by 2002:a17:902:cece:b0:1a8:626:6d9d with SMTP id d14-20020a170902cece00b001a806266d9dmr51463195plg.62.1684270771031; Tue, 16 May 2023 13:59:31 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id t16-20020a1709028c9000b001acad024c8asm14272237plo.40.2023.05.16.13.59.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 13:59:29 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 03/10] bass: Mark driver as experimental Date: Tue, 16 May 2023 13:59:17 -0700 Message-Id: <20230516205924.1040506-3-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230516205924.1040506-1-luiz.dentz@gmail.com> References: <20230516205924.1040506-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This uses the btd_profile.experimental to mark the driver as experimental. --- profiles/audio/bass.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/profiles/audio/bass.c b/profiles/audio/bass.c index a7fcc9718d56..fae7fe00412a 100644 --- a/profiles/audio/bass.c +++ b/profiles/audio/bass.c @@ -276,18 +276,19 @@ static struct btd_profile bass_service = { .device_remove = bass_remove, .accept = bass_accept, .disconnect = bass_disconnect, + .experimental = true, }; static unsigned int bass_id; static int bass_init(void) { - if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) { - warn("D-Bus experimental not enabled"); - return -ENOTSUP; - } + int err; + + err = btd_profile_register(&bass_service); + if (err) + return err; - btd_profile_register(&bass_service); bass_id = bt_bass_register(bass_attached, bass_detached, NULL); return 0; @@ -295,10 +296,8 @@ static int bass_init(void) static void bass_exit(void) { - if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) { - btd_profile_unregister(&bass_service); - bt_bass_unregister(bass_id); - } + btd_profile_unregister(&bass_service); + bt_bass_unregister(bass_id); } BLUETOOTH_PLUGIN_DEFINE(bass, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, From patchwork Tue May 16 20:59:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 684598 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E84DEC7EE24 for ; Tue, 16 May 2023 20:59:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230222AbjEPU7h (ORCPT ); Tue, 16 May 2023 16:59:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229832AbjEPU7f (ORCPT ); Tue, 16 May 2023 16:59:35 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79EC576AF for ; Tue, 16 May 2023 13:59:34 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1ab1ce53ca6so1019155ad.0 for ; Tue, 16 May 2023 13:59:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684270773; x=1686862773; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=5cTAOIXAq0oIiEHGSrM64rKJl+f/1F4LAw7ra9PqE78=; b=JnrQ4raWpowF4A2cmnUaGlib1V/qtn8A0o3c7PSUBO0ROQGEdSm+mIIpBkWmlNCBIg O72Wd6Y/D8+F63ifTgs7OYTlRHrp3kulrR/T+0MfmmI/3MSw3DyGVk0spUmDXBI/3DsK N1HXcDIIdutlWAbS+qG+6Aqk3XV4PW+pQGpNv+Mb8KGXx9WGoVl01ErdSET7HgVIU8HA SffPS96kExVljOVJ9BpUZ5WhjBKDEQ9ZlFfIzdk/NWD8meVTRp4ZDT4y+Sya87BC3FJR +lqG6bPSq/8rvqMv68KuW7dZ5J2riXulL7F1pd+nq3MmtFx/UjSwq8F6Ihs5TEM9m33L qrwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684270773; x=1686862773; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5cTAOIXAq0oIiEHGSrM64rKJl+f/1F4LAw7ra9PqE78=; b=GVgtr79bM8fT8IUX7PrR5m4jPY9PbWeX1jPpehHtDAukBKf0GQqUfEtbZP6iF3SiVk osh0p1d92eonhvFk9CTgaYoR4f4YwuLQNNEGqx6/qXy+OAhXwk6FhSsxyujlEOtZ0Gbj g80+EgaA6/D5JmWjK8G55figBsGQ+dcktaDm7hbmWKPidJIifyTa01c+8hCZHF5bA9gx k2dOd2yRJ+nbCPI7XNiJkUgEkUt6ZZadxZrwYBO5Diz4x9ArlqwdBRED7fRnHQThemHv M2y9cu0ZkPq+aFPCKn7mkM8JyXmqIOIvdCq1vAWJmzsplf8Z5DydjBaxv2PWqIpnAoE5 ZcnQ== X-Gm-Message-State: AC+VfDy89Daeqaq2u4z8NiT/qaoRFdnWpOjG0ZZNSMeMCieGwM8EWKTP z2vX+5Hnd+Y8EzSH++xWX05YujdvBAM= X-Google-Smtp-Source: ACHHUZ6jW7kIB/lDAISmOt8WFBMZXJ0NL8NZNm+bR/TPOXpnBDQYFMFiJIcO4mjsh0WXGnxKvvE2cQ== X-Received: by 2002:a17:902:b418:b0:1ad:dac0:5125 with SMTP id x24-20020a170902b41800b001addac05125mr16107696plr.11.1684270772855; Tue, 16 May 2023 13:59:32 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id t16-20020a1709028c9000b001acad024c8asm14272237plo.40.2023.05.16.13.59.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 13:59:32 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 04/10] csip: Mark driver as experimental Date: Tue, 16 May 2023 13:59:18 -0700 Message-Id: <20230516205924.1040506-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230516205924.1040506-1-luiz.dentz@gmail.com> References: <20230516205924.1040506-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This uses the btd_profile.experimental to mark the driver as experimental. --- profiles/audio/csip.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/profiles/audio/csip.c b/profiles/audio/csip.c index c273c02b8e76..ec042afd54eb 100644 --- a/profiles/audio/csip.c +++ b/profiles/audio/csip.c @@ -334,18 +334,20 @@ static struct btd_profile csip_profile = { .adapter_probe = csip_server_probe, .adapter_remove = csip_server_remove, + + .experimental = true, }; static unsigned int csip_id; static int csip_init(void) { - if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) { - warn("D-Bus experimental not enabled"); - return -ENOTSUP; - } + int err; + + err = btd_profile_register(&csip_profile); + if (err) + return err; - btd_profile_register(&csip_profile); csip_id = bt_csip_register(csip_attached, csip_detached, NULL); return 0; @@ -353,10 +355,8 @@ static int csip_init(void) static void csip_exit(void) { - if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) { - btd_profile_unregister(&csip_profile); - bt_csip_unregister(csip_id); - } + btd_profile_unregister(&csip_profile); + bt_csip_unregister(csip_id); } BLUETOOTH_PLUGIN_DEFINE(csip, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, From patchwork Tue May 16 20:59:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 684597 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EBDBC7EE2D for ; Tue, 16 May 2023 20:59:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229957AbjEPU7j (ORCPT ); Tue, 16 May 2023 16:59:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230189AbjEPU7h (ORCPT ); Tue, 16 May 2023 16:59:37 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B8E076AF for ; Tue, 16 May 2023 13:59:35 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1ae3a5dfa42so1123245ad.0 for ; Tue, 16 May 2023 13:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684270774; x=1686862774; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=+Iobs+R2ddrlT8b4QQ65ACB2Nf3ufHdusbKHpv7a0ow=; b=DWheeTkSuUxSG/GGfHIxPYEd2E8nVWOgB8ctozMuVSSARLNHEnXK4nCOPRygluQYMJ rDPjrQmU2PhcebJ6YpVymQKwUr5lrE+hRs9z/xYSoc9qEzyLvUy3GgVmWEVNAX6nfw3s 9wbFOuymnkuV7TW//hp7VpEYSzpWH7ikGAdnTH8zaehRHUzkSlZUqGptZn4cLfO1tZiE Z1DB6bVZvsGxTl0mYyBc3uWYUZsaITX7ZxHGxisaYX3HdynbGlDA098gAPGM3iq+KFDp ml+deiW7X3zSKPgHjklRwPKIYOfRW7o9A8KbmPoycf+Ta9TLsQbFLJDnXVHAhmvXeaPq JSTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684270774; x=1686862774; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+Iobs+R2ddrlT8b4QQ65ACB2Nf3ufHdusbKHpv7a0ow=; b=h7T7oPYVqM7Cp9mvoUsGQ947GMF8XVkFHvkAvSspP7PVxtDWw48N8T3L6xDrV7RGQo BznYi+O4tszZLuGQ2T0KZ2LmPdhVAI1oJqsZPKSJvCiFIW8zyJAQDnyMywrIhw7l6Mqr FGaLdUiyK/7fmidddSU4txugi/orvVCH9ycAdRnQyyWC4AMsRQATuD6jeZ6aPAyEBo7f jRhb0qqhhQFq1Vn0sRPWCH0goREojoLd5Qu315onbS3JuwiUX5OrPeRtaboUSnsLB00r 5WqnDMPs0asPa3WUfrOjZzSRAfyWFx4Jbi93v0tanZjUPYLMNZ1yfEgl35+LxnNQR479 wYOg== X-Gm-Message-State: AC+VfDz404abon7sW9e2RS6WMp2+En4LP6Y+yHTk3SnNSEbWiBrhWWXh m3x0XMCGlseKpjfiSU4Z4S6ywyQUwh4= X-Google-Smtp-Source: ACHHUZ4AXS5X3qKwcgey0kwefptQxShAWKK9m5lVptZeu7IvvaYIB5ZNySHb7CamOGrR6dY6DqqPIQ== X-Received: by 2002:a17:903:1110:b0:1a9:bc13:7e20 with SMTP id n16-20020a170903111000b001a9bc137e20mr46746440plh.44.1684270774561; Tue, 16 May 2023 13:59:34 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id t16-20020a1709028c9000b001acad024c8asm14272237plo.40.2023.05.16.13.59.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 13:59:33 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 05/10] mcp: Mark driver as experimental Date: Tue, 16 May 2023 13:59:19 -0700 Message-Id: <20230516205924.1040506-5-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230516205924.1040506-1-luiz.dentz@gmail.com> References: <20230516205924.1040506-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This uses the btd_profile.experimental to mark the driver as experimental. --- profiles/audio/mcp.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/profiles/audio/mcp.c b/profiles/audio/mcp.c index f3ea330f9839..b410b3d2aa03 100644 --- a/profiles/audio/mcp.c +++ b/profiles/audio/mcp.c @@ -403,27 +403,18 @@ static struct btd_profile mcp_profile = { .adapter_probe = media_control_server_probe, .adapter_remove = media_control_server_remove, + + .experimental = true, }; static int mcp_init(void) { - DBG(""); - - if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) { - warn("D-Bus experimental not enabled"); - return -ENOTSUP; - } - - btd_profile_register(&mcp_profile); - return 0; + return btd_profile_register(&mcp_profile); } static void mcp_exit(void) { - DBG(""); - - if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) - btd_profile_unregister(&mcp_profile); + btd_profile_unregister(&mcp_profile); } BLUETOOTH_PLUGIN_DEFINE(mcp, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, From patchwork Tue May 16 20:59:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 682645 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20B0EC77B7F for ; Tue, 16 May 2023 20:59:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230203AbjEPU7k (ORCPT ); Tue, 16 May 2023 16:59:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbjEPU7i (ORCPT ); Tue, 16 May 2023 16:59:38 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2BF97AB8 for ; Tue, 16 May 2023 13:59:37 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1aaea3909d1so1068755ad.2 for ; Tue, 16 May 2023 13:59:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684270776; x=1686862776; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=KjhUpj8uSuuQsuauzOhywl0XBpKd80yMyJQj1Ru8+Ns=; b=Hi6mPASpiz1Xj2DADtlfQVoNHrKfEgXFv0V9IWWPlkX74f+qP6YxedFlS+BCcK6HIC V/uV94dGbjoZyjNYL1eZJjgAYQMcDvPi6cfIzo8woC589WZ2nSnZiAUa57iIcm7tBepc 3u+hj64omlP5ZSK5XQCk2rNlfuOHZlc61zia88KNCUBsAyvOIk/v2SdON6PBHQxlMjqw XEbQmQ0oN/YqDTJUU2wsI1Kulr1WyKRzWuc/z24Wup+Kymx3FRdRMPgckmuTfx9k/6L8 nH3GXLRvMpbya0sMrOEsUKHwV2C6vYINk39OzChfAkdXx5Mzus9Cw4P73uuM3iRz+3tT 3hog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684270776; x=1686862776; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KjhUpj8uSuuQsuauzOhywl0XBpKd80yMyJQj1Ru8+Ns=; b=DGhkQuIbSziEH8q1sQvClYSVbMNBBG/eWqTBvIlhQk0+noS8HVAw6lSQDhNHZ+awz9 IrVTTw+3nur+XG8MJEepDV5UrbanijgdEwX2jr7DLnL/QAU3FG+ZtsXVWOO8F5JjQ+RP WhWnuvg3RAiOyDB39vP8PXrRKHLkIcMj14Pung6OW8vyC1Pg+bvGTp4rIQS05AXscVsY /MwKX3an2upO5CKaOOeUe/ZyybttiVulaVES/Ro9T9EadLXeZGtPkWWVUrV73FvksKwG U9YGr5nQqN8lQqpj6kqdPLHlpHCLQesV57pnH85mKARkdNhCIU+nrUdtnZZ0f+ivByYI CzTA== X-Gm-Message-State: AC+VfDwzdFOj89f4xm2C3IWR6rmzvcmZ479hQbZO8d7XT+a2nVMoy7x6 6wYm/1MJNiSZhMqbmzzj28yvwi+q0Hg= X-Google-Smtp-Source: ACHHUZ5W+DV1slfYzfL5i+PCkHSqeW4LfKeeu5E1qcQ2u3Z0CrtjbfOT0DzjyAK3iG0MdCsWEsTwng== X-Received: by 2002:a17:903:6ce:b0:1a6:3799:ec2a with SMTP id kj14-20020a17090306ce00b001a63799ec2amr33506272plb.35.1684270776250; Tue, 16 May 2023 13:59:36 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id t16-20020a1709028c9000b001acad024c8asm14272237plo.40.2023.05.16.13.59.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 13:59:35 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 06/10] vcp: Mark driver as experimental Date: Tue, 16 May 2023 13:59:20 -0700 Message-Id: <20230516205924.1040506-6-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230516205924.1040506-1-luiz.dentz@gmail.com> References: <20230516205924.1040506-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This uses the btd_profile.experimental to mark the driver as experimental. --- profiles/audio/vcp.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/profiles/audio/vcp.c b/profiles/audio/vcp.c index b42b0a4f79dd..175275f2e977 100644 --- a/profiles/audio/vcp.c +++ b/profiles/audio/vcp.c @@ -289,18 +289,20 @@ static struct btd_profile vcp_profile = { .adapter_probe = vcp_server_probe, .adapter_remove = vcp_server_remove, + + .experimental = true, }; static unsigned int vcp_id = 0; static int vcp_init(void) { - if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) { - warn("D-Bus experimental not enabled"); - return -ENOTSUP; - } + int err; + + err = btd_profile_register(&vcp_profile); + if (err) + return err; - btd_profile_register(&vcp_profile); vcp_id = bt_vcp_register(vcp_attached, vcp_detached, NULL); return 0; @@ -308,10 +310,8 @@ static int vcp_init(void) static void vcp_exit(void) { - if (g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL) { - btd_profile_unregister(&vcp_profile); - bt_vcp_unregister(vcp_id); - } + btd_profile_unregister(&vcp_profile); + bt_vcp_unregister(vcp_id); } BLUETOOTH_PLUGIN_DEFINE(vcp, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, From patchwork Tue May 16 20:59:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 684596 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E034C77B7F for ; Tue, 16 May 2023 20:59:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbjEPU7p (ORCPT ); Tue, 16 May 2023 16:59:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbjEPU7n (ORCPT ); Tue, 16 May 2023 16:59:43 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5824A76AF for ; Tue, 16 May 2023 13:59:39 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1aaf70676b6so692505ad.3 for ; Tue, 16 May 2023 13:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684270778; x=1686862778; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=R8ePO2sjaQnIm9bbBHn0PowqDmPeO6nDpTMp2JxSNYk=; b=Zb+GHvgVkFDuFY1YAV5HOyQhoAurv6rRwY3/i6ry5XiXkjvfWGE4u6kvZmX2LCdZYc mQn+E2T5SyO+2txlOKOV2dX8CndhRSgtVIuE4ao4neW9IGKP+mRJdJPcxZuNf4pep/XV lvvvCtIJW1jwLclb+rOiJg2tBkiiWb+ml9m6eEiyvK7PKD6rfTVGF8b183apX2UTgIx8 nkjMEMioR8hOKLXgllMi6BoQI0mtvOt+KI76AW+7ggUWtPhisIbdN86Gd9+VlJoflhKd ZV4/j8WEguh3BHc3h4kMdfbpXROv3gAFFAJJxym4dYE1dNb8eVBP202dr331mEW82YVq cJsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684270778; x=1686862778; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R8ePO2sjaQnIm9bbBHn0PowqDmPeO6nDpTMp2JxSNYk=; b=D3FpV1XNHG0rFChoICLelh8bGjhfTOHh+TNB9zu8lxSmxCtZ2wLmn1RDfY6muHvA/B N+wZgOAFvns0CW9sMEw8teXD68heBKuOqwA2EZexgGM3E0re9fwIk0CmahDseXreIVN7 vxSeqtl77SryF1EYqzM/RvU8crTJ6jxsgVW5HVefJq+uV6sWdngiHEgjDobz7yA1rjaS kqffe6Ggqs1u8CqG7VBfza5bxQq9pQEUqrimv9TB9h9ErojwytRiJ2hTlWwP7LOVCfI4 ApDBlTsTY5k/AoHzk3TLuJCd4vKVArRvxGmMazddVhbxmyfjG+zWb7oWiSIO1kWQBK8q JBvw== X-Gm-Message-State: AC+VfDz0PYmDVxI/jpmVH8mRcbqGifDwu0qSWqvtDXYzOJHbHj7SI3O5 FsVPh558U3fqU5pXUgnC/TZG0+W+MDA= X-Google-Smtp-Source: ACHHUZ7XSJRqTr4vqNbUQ4LldNTCQJUitLFRjljsKCWgUFNZfT/gC7crziRGuIdiv4gScnnP4YN3iA== X-Received: by 2002:a17:902:ea11:b0:1ac:9ab8:538f with SMTP id s17-20020a170902ea1100b001ac9ab8538fmr35373964plg.24.1684270777811; Tue, 16 May 2023 13:59:37 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id t16-20020a1709028c9000b001acad024c8asm14272237plo.40.2023.05.16.13.59.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 13:59:36 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 07/10] plugin: Treat -ENOTSUP as -ENOSYS Date: Tue, 16 May 2023 13:59:21 -0700 Message-Id: <20230516205924.1040506-7-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230516205924.1040506-1-luiz.dentz@gmail.com> References: <20230516205924.1040506-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz If plugin .init returns -ENOTSUP treat it as the system doesn't support the driver since that is the error returned by btd_profile_register when experimental is disabled. --- src/plugin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugin.c b/src/plugin.c index dd7b406c857b..80990f8c3c7e 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -186,7 +186,7 @@ start: err = plugin->desc->init(); if (err < 0) { - if (err == -ENOSYS) + if (err == -ENOSYS || err == -ENOTSUP) warn("System does not support %s plugin", plugin->desc->name); else From patchwork Tue May 16 20:59:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 682644 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC86BC77B7F for ; Tue, 16 May 2023 20:59:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230214AbjEPU7s (ORCPT ); Tue, 16 May 2023 16:59:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230225AbjEPU7q (ORCPT ); Tue, 16 May 2023 16:59:46 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF3865B87 for ; Tue, 16 May 2023 13:59:40 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1ae3fe67980so1280285ad.3 for ; Tue, 16 May 2023 13:59:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684270779; x=1686862779; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=OgDPveaF1MKTU1yCjzGD+PxL+UXDSV/Fo3bJbJP/EvU=; b=BxzhYOo8B2GEXcd6aH9MTpDZDG+sYBrZMJe/EhApcSFEQ8eyfj1YuSwj/ncB5xzwJX ENz/hsu33BZnsYry+WbCKYkYyr4gHpIeFRM3wFEHziafuRb8BG7BZAer1XHCvRhXv9it Bz5UM5/MgnBHQekBvVcMpajzSlDB6NiEKhxa3GItXhJ5I+kWoDO0f324oE9jZP9Owmcz iKqdsnmNf1vAfJeX6Ex3Y/zJm/ZFF78SuUzjpDOlOzVdz914Hdfkgfh2y+rF/XcM/7NP PIAfwCBM8fUU0O53OmteErVW17Kaj7AQs3KETyEfMemI+ypwj5XpFmERv5ilNdnUymT+ 8yrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684270779; x=1686862779; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OgDPveaF1MKTU1yCjzGD+PxL+UXDSV/Fo3bJbJP/EvU=; b=Erg0AmwQypIl2WtOCoAGuTwcB6jodk5pFqob6khDopw/BJrfU613jDrpuEVKMfwygq 4zBYoSwwC1ETCjfgiJiw06VngaxK0RI/1jDpP5zW7k33YCY8L41aifxOPPqo0ikxgyrU sSST2pURRuhflafq3W6izFWWvr5ZwVowAsPaWDyOeRNw43Qo/tMq71OchR6JKmKTNmxc yh9szXlO+MbapAMHTWhgcl6/DSJO9x2fdJN3au6hTNeDO6IzFLKn05qh+RGDvEojYCJ8 dYinZIRaSdJL+FQjYLQLm++hmNOjh2TWYVOrSsrTScYTN9Utcqb5op7v+nUMaCkYbnx9 R2dw== X-Gm-Message-State: AC+VfDw7Ovpf0YPnpTNQ9qn0IA2/6Wx3acJ8TGxSQvNsVhJrm7+4VUvp Qg1bjELHSY3MkiTm45ko+iJPI1+7XQo= X-Google-Smtp-Source: ACHHUZ5AOEeTZKZxRCBEw2EidpkC3Vw1tp2b0aCG2PU+lyd85NpHRP9SB3JEoCmg5PT3I/Z5CZA12g== X-Received: by 2002:a17:902:d4cf:b0:1ac:6b92:70c8 with SMTP id o15-20020a170902d4cf00b001ac6b9270c8mr47747774plg.48.1684270779415; Tue, 16 May 2023 13:59:39 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id t16-20020a1709028c9000b001acad024c8asm14272237plo.40.2023.05.16.13.59.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 13:59:38 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 08/10] adapter: Add support for experimental flag Date: Tue, 16 May 2023 13:59:22 -0700 Message-Id: <20230516205924.1040506-8-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230516205924.1040506-1-luiz.dentz@gmail.com> References: <20230516205924.1040506-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This adds experimental field to btd_adapter_driver so the plugin can indicate drivers that depends on experimental to be enabled. --- src/adapter.c | 6 ++++++ src/adapter.h | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/adapter.c b/src/adapter.c index cc7f891d96d9..74ed52468b81 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -7447,6 +7447,12 @@ static void adapter_stop(struct btd_adapter *adapter) int btd_register_adapter_driver(struct btd_adapter_driver *driver) { + if (driver->experimental && !(g_dbus_get_flags() & + G_DBUS_FLAG_ENABLE_EXPERIMENTAL)) { + DBG("D-Bus experimental not enabled"); + return -ENOTSUP; + } + adapter_drivers = g_slist_append(adapter_drivers, driver); if (driver->probe == NULL) diff --git a/src/adapter.h b/src/adapter.h index a45ac1bab00e..32e49a933b13 100644 --- a/src/adapter.h +++ b/src/adapter.h @@ -127,6 +127,11 @@ struct btd_adapter_driver { struct btd_device *device); void (*device_resolved)(struct btd_adapter *adapter, struct btd_device *device); + + /* Indicates the driver is experimental and shall only be registered + * when experimental has been enabled (see: main.conf:Experimental). + */ + bool experimental; }; void device_resolved_drivers(struct btd_adapter *adapter, From patchwork Tue May 16 20:59:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 684595 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7AFAC7EE23 for ; Tue, 16 May 2023 20:59:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbjEPU7x (ORCPT ); Tue, 16 May 2023 16:59:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbjEPU7t (ORCPT ); Tue, 16 May 2023 16:59:49 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBCD57DA2 for ; Tue, 16 May 2023 13:59:42 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1ab032d9266so1497535ad.0 for ; Tue, 16 May 2023 13:59:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684270781; x=1686862781; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=snsIh1JCug494E4XD1/7+IMFy8d87x2K49j41pEQYIY=; b=SgLRtvhqZJxlZm/3ped8yBKURi1qJit0oUal9gcCbG2fKnSWZBeJmXzKweAxTegRrd kXfkAyFpx3qHkzzioUyuPYvbp7u8eRduyTo+nEMgymT8OfnB9kaWmCbZEHV0yn2RxcyN dkCv2II2ScQMokzmeWNIeuku5rKjXreESJUUtSTt/zLw5yPRxJMzSzus0OappVjyDuYP qDbwevhqPquMS9LO8+vEfSaynIYjeJlEDHe5+STVSSkdcoUUMzLHYma1dT4zbLsflcVp gCXHJpGfNuayNn+jdmnWRVlZHNarBkx7DuQUDED4bRD9B1pdQfyct0xeI7fRH8ednXKE NFtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684270781; x=1686862781; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=snsIh1JCug494E4XD1/7+IMFy8d87x2K49j41pEQYIY=; b=SfGwYH/KDVOgSylfTAUA33H0mw/GsoYRHlJft5y8C44958NWR+HPTMAxBbWC9d0hjM I1P8zUIkcIqQCYtDbhx3cKIDkPfyasy3GVX4W4oyWlHUjfJBEd+JpnXXJlU1qlhx0Pie CpjGFKh4mXGW5KseQNsqH7iqJUnvc4xSdd1OT7/NWf0dctiny/M2zY2CfTzIBetlHdyk 3/+yuIFXqu2/jrEYjP4ozGWhIICt+YhHxlq/ZGCb7iCuG0Kt/HiQzPg5EHWoSb5+Ok2A H+YaSaqtY2zIJHaQkBtaMVkIzV8LXBA1bZwkXrsxaLt0/4HHZeTjwHN1z2F/pbQck8a5 +E5w== X-Gm-Message-State: AC+VfDw5xF1sK8fnn31D7JprP0QlYcYglvsHxCfC77QRi8vp7fIrq69o 99Grp2NCX0zq9FifqCPNkzEkmnyblJ4= X-Google-Smtp-Source: ACHHUZ7+nWbBeQvMVTIpsoT90AgD4mcEMWy5c2r4mQsTmj3ZxBTzKAWAbsneioeDU5Bgik4MqwUYQg== X-Received: by 2002:a17:903:32cc:b0:1ad:cba5:5505 with SMTP id i12-20020a17090332cc00b001adcba55505mr27122774plr.14.1684270781100; Tue, 16 May 2023 13:59:41 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id t16-20020a1709028c9000b001acad024c8asm14272237plo.40.2023.05.16.13.59.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 13:59:39 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 09/10] admin: Mark driver as experimental Date: Tue, 16 May 2023 13:59:23 -0700 Message-Id: <20230516205924.1040506-9-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230516205924.1040506-1-luiz.dentz@gmail.com> References: <20230516205924.1040506-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This uses the btd_profile.experimental to mark the driver as experimental. --- plugins/admin.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/admin.c b/plugins/admin.c index 0787e8381ed7..68e9237d3fbd 100644 --- a/plugins/admin.c +++ b/plugins/admin.c @@ -618,13 +618,12 @@ static struct btd_adapter_driver admin_policy_driver = { .resume = NULL, .remove = admin_policy_remove, .device_resolved = admin_policy_device_added, - .device_removed = admin_policy_device_removed + .device_removed = admin_policy_device_removed, + .experimental = true, }; static int admin_init(void) { - DBG(""); - dbus_conn = btd_get_dbus_connection(); return btd_register_adapter_driver(&admin_policy_driver); @@ -632,8 +631,6 @@ static int admin_init(void) static void admin_exit(void) { - DBG(""); - btd_unregister_adapter_driver(&admin_policy_driver); } From patchwork Tue May 16 20:59:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 682643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03728C77B7A for ; Tue, 16 May 2023 20:59:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230204AbjEPU74 (ORCPT ); Tue, 16 May 2023 16:59:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229824AbjEPU7z (ORCPT ); Tue, 16 May 2023 16:59:55 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BA8283F5 for ; Tue, 16 May 2023 13:59:44 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-64a9335a8e7so8629223b3a.0 for ; Tue, 16 May 2023 13:59:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684270783; x=1686862783; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/SYUSjBeIm8ljNch+xLUXm/BkCypHZhQ+iPy+Cp1zz0=; b=n08lN/uPNpfYjO8bPeMEWqry6ktEspGS+SI0vdc9XsVXvWAQqe6vW5owhJVkrBhpf2 hW3B6apFHZM3F4eD6R3y/GV8iKIS6DHeguozlKeDcrvZlLMj44WxMe2Dp7FApwiotDxr al5+7B3BiG/O3vCgiACWgtfzO8i08yD3AXwHVFXujcHjIk6Jvfsj8NIz1FrGpowPh5iW SqMmCcJqd3KJx7YYn1InR6zrjPJel1vTYwZokjrXtc9nH4/1O88wgw919qF8guvNU+l2 8EQk7hdCF96aDKCjgJ2ZUoEPxB/qZGIhRyhJen/RieGfStL3JlW8KdP6OEDbcIerQJgA BSNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684270783; x=1686862783; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/SYUSjBeIm8ljNch+xLUXm/BkCypHZhQ+iPy+Cp1zz0=; b=T6PyDjbkLvbCBX27RVSQPSPiwoQJWegUurOnZiVluoIGeP0XttHKO8KUG4iq0N02Id nvelsnf4b3dKJ6quWEKww/oDIL+psfx1BfcvNdesTSvFaezhHKspbLjXdjT4xsj8eIth bfme2vy4pG4nAHmwpGkxv8OdWm5Cof7ecCouLWLGrst38Dn7cpkguFNoptOeehAo3hji RSQGsyU4RyQ2WY8ya7rFxmwBWVAu9tQNsIpvzGASVafNf1IGaO18vJKgMVqAaogiLmoa f8eWH2F0oIwtLbui4ZhazLnRkudSR3LH0yIsBoDvwzJL01oNRIP4+4TTg2Np0SwNtv9+ FOpw== X-Gm-Message-State: AC+VfDyUHg0izZPn6W5JGKbwDVuM4o5wtxXu6wol84gy/BXAcmMY4THD 7bUtRxReqcb3pQ9DwjPWOZUdCTWnNds= X-Google-Smtp-Source: ACHHUZ5+ShPNbdLJHnACg3RhDoUIKIonPS36cZ8tsy+D6p7uSW59OFn1E+HU3kY36baukuUzflbOwA== X-Received: by 2002:a17:903:110e:b0:1ac:7245:ba55 with SMTP id n14-20020a170903110e00b001ac7245ba55mr89264plh.6.1684270782721; Tue, 16 May 2023 13:59:42 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id t16-20020a1709028c9000b001acad024c8asm14272237plo.40.2023.05.16.13.59.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 13:59:41 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 10/10] main: Rework config option parsing Date: Tue, 16 May 2023 13:59:24 -0700 Message-Id: <20230516205924.1040506-10-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230516205924.1040506-1-luiz.dentz@gmail.com> References: <20230516205924.1040506-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz This rework config option parsing adding helper function to make it simpler to parse new options. --- src/btd.h | 14 +- src/main.c | 848 +++++++++++++++++++++++++++-------------------------- 2 files changed, 442 insertions(+), 420 deletions(-) diff --git a/src/btd.h b/src/btd.h index 70051c71c7c1..b7e7ebd618cf 100644 --- a/src/btd.h +++ b/src/btd.h @@ -111,7 +111,7 @@ struct btd_advmon_opts { struct btd_opts { char *name; uint32_t class; - gboolean pairable; + bool pairable; uint32_t pairto; uint32_t discovto; uint32_t tmpto; @@ -122,12 +122,12 @@ struct btd_opts { struct btd_defaults defaults; - gboolean reverse_discovery; - gboolean name_resolv; - gboolean debug_keys; - gboolean fast_conn; - gboolean refresh_discovery; - gboolean experimental; + bool reverse_discovery; + bool name_resolv; + bool debug_keys; + bool fast_conn; + bool refresh_discovery; + bool experimental; struct queue *kernel; uint16_t did_source; diff --git a/src/main.c b/src/main.c index a64b833b58c1..8dfd2543ba1c 100644 --- a/src/main.c +++ b/src/main.c @@ -313,7 +313,7 @@ done: btd_opts.did_version = version; } -static bt_gatt_cache_t parse_gatt_cache(const char *cache) +static bt_gatt_cache_t parse_gatt_cache_str(const char *cache) { if (!strcmp(cache, "always")) { return BT_GATT_CACHE_ALWAYS; @@ -415,6 +415,63 @@ static int get_mode(const char *str) return BT_MODE_DUAL; } +static bool parse_config_string(GKeyFile *config, const char *group, + const char *key, char **val) +{ + GError *err = NULL; + char *tmp; + + tmp = g_key_file_get_string(config, group, key, &err); + if (err) { + if (err->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND) + DBG("%s", err->message); + g_error_free(err); + return false; + } + + DBG("%s.%s = %s", group, key, tmp); + + if (val) { + g_free(*val); + *val = tmp; + } + + return true; +} + +static bool parse_config_int(GKeyFile *config, const char *group, + const char *key, int *val, + int min, int max) +{ + int tmp; + char *str = NULL; + char *endptr = NULL; + + if (!parse_config_string(config, group, key, &str)) + return false; + + tmp = strtol(str, &endptr, 0); + if (!endptr || *endptr != '\0') { + error("%s.%s = %s is not integer", group, key, str); + return false; + } + + if (tmp < min) { + warn("%s.%s = %d is out of range (< %d)", group, key, tmp, min); + return false; + } + + if (tmp < max) { + warn("%s.%s = %d is out of range (> %d)", group, key, tmp, max); + return false; + } + + if (val) + *val = tmp; + + return true; +} + struct config_param { const char * const val_name; void * const val; @@ -433,31 +490,15 @@ static void parse_mode_config(GKeyFile *config, const char *group, return; for (i = 0; i < params_len; ++i) { - GError *err = NULL; - char *str; - - str = g_key_file_get_string(config, group, params[i].val_name, - &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - char *endptr = NULL; - int val; - - val = strtol(str, &endptr, 0); - if (!endptr || *endptr != '\0') - continue; - - info("%s=%s(%d)", params[i].val_name, str, val); - - val = MAX(val, params[i].min); - val = MIN(val, params[i].max); + int val; + if (parse_config_int(config, group, params[i].val_name, + &val, params[i].min, params[i].max)) { val = htobl(val); memcpy(params[i].val, &val, params[i].size); - ++btd_opts.defaults.num_entries; } + + ++btd_opts.defaults.num_entries; } } @@ -728,13 +769,375 @@ static bool gen_sirk(const char *str) return ret; } -static void parse_config(GKeyFile *config) +static bool parse_config_u32(GKeyFile *config, const char *group, + const char *key, uint32_t *val, + uint32_t min, uint32_t max) +{ + int tmp; + + if (!parse_config_int(config, group, key, &tmp, 0, UINT32_MAX)) + return false; + + if (val) + *val = tmp; + + return true; +} + +static bool parse_config_u16(GKeyFile *config, const char *group, + const char *key, uint16_t *val, + uint16_t min, uint16_t max) +{ + int tmp; + + if (!parse_config_int(config, group, key, &tmp, min, max)) + return false; + + if (val) + *val = tmp; + + return true; +} + +static bool parse_config_u8(GKeyFile *config, const char *group, + const char *key, uint8_t *val, + uint8_t min, uint8_t max) +{ + int tmp; + + if (!parse_config_int(config, group, key, &tmp, min, max)) + return false; + + if (val) + *val = tmp; + + return true; +} + +static bool parse_config_bool(GKeyFile *config, const char *group, + const char *key, bool *val) { GError *err = NULL; - char *str, **strlist; - int val; - gboolean boolean; + gboolean tmp; + tmp = g_key_file_get_boolean(config, group, key, &err); + if (err) { + if (err->code != G_KEY_FILE_ERROR_KEY_NOT_FOUND) + DBG("%s", err->message); + g_error_free(err); + return false; + } + + DBG("%s.%s = %s", group, key, tmp ? "true" : "false"); + + if (val) + *val = tmp; + + return true; +} + +static void parse_privacy(GKeyFile *config) +{ + char *str = NULL; + + if (!parse_config_string(config, "General", "Privacy", &str)) { + btd_opts.privacy = 0x00; + btd_opts.device_privacy = true; + return; + } + + if (!strcmp(str, "network") || !strcmp(str, "on")) { + btd_opts.privacy = 0x01; + } else if (!strcmp(str, "device")) { + btd_opts.privacy = 0x01; + btd_opts.device_privacy = true; + } else if (!strcmp(str, "limited-network")) { + if (btd_opts.mode != BT_MODE_DUAL) { + DBG("Invalid privacy option: %s", str); + btd_opts.privacy = 0x00; + } + btd_opts.privacy = 0x01; + } else if (!strcmp(str, "limited-device")) { + if (btd_opts.mode != BT_MODE_DUAL) { + DBG("Invalid privacy option: %s", str); + btd_opts.privacy = 0x00; + } + btd_opts.privacy = 0x02; + btd_opts.device_privacy = true; + } else if (!strcmp(str, "off")) { + btd_opts.privacy = 0x00; + btd_opts.device_privacy = true; + } else { + DBG("Invalid privacy option: %s", str); + btd_opts.privacy = 0x00; + } + + g_free(str); +} + +static void parse_repairing(GKeyFile *config) +{ + char *str = NULL; + + if (!parse_config_string(config, "General", "JustWorksRepairing", + &str)) { + btd_opts.jw_repairing = JW_REPAIRING_NEVER; + return; + } + + btd_opts.jw_repairing = parse_jw_repairing(str); + g_free(str); +} + +static bool parse_config_hex(GKeyFile *config, char *group, + const char *key, uint32_t *val) +{ + char *str = NULL; + + if (!parse_config_string(config, group, key, &str)) + return false; + + if (val) + *val = strtol(str, NULL, 16); + + g_free(str); + return true; +} + +static void parse_device_id(GKeyFile *config) +{ + char *str = NULL; + + parse_config_string(config, "General", "DeviceID", &str); + if (!str) + return; + + parse_did(str); + g_free(str); +} + +static void parse_ctrl_mode(GKeyFile *config) +{ + char *str = NULL; + + parse_config_string(config, "General", "ControllerMode", &str); + if (!str) + return; + + btd_opts.mode = get_mode(str); + g_free(str); +} + +static void parse_multi_profile(GKeyFile *config) +{ + char *str = NULL; + + parse_config_string(config, "General", "MultiProfile", &str); + if (!str) + return; + + if (!strcmp(str, "single")) + btd_opts.mps = MPS_SINGLE; + else if (!strcmp(str, "multiple")) + btd_opts.mps = MPS_MULTIPLE; + else + btd_opts.mps = MPS_OFF; + + g_free(str); +} + +static gboolean parse_kernel_experimental(const char *key, const char *value, + gpointer user_data, GError **error) +{ + char **strlist; + + if (value && value[0] != '*') { + strlist = g_strsplit(value, ",", -1); + btd_parse_kernel_experimental(strlist); + g_strfreev(strlist); + } else { + if (!btd_opts.kernel) + btd_opts.kernel = queue_new(); + queue_push_head(btd_opts.kernel, strdup("*")); + } + + return TRUE; +} + +static void parse_kernel_exp(GKeyFile *config) +{ + char *str = NULL; + + if (!parse_config_string(config, "General", "KernelExperimental", + &str)) + return; + + parse_kernel_experimental(NULL, str, NULL, NULL); + + g_free(str); +} + +static void parse_secure_conns(GKeyFile *config) +{ + char *str = NULL; + + if (!parse_config_string(config, "General", "SecureConnections", + &str)) + return; + + if (!strcmp(str, "off")) + btd_opts.secure_conn = SC_OFF; + else if (!strcmp(str, "on")) + btd_opts.secure_conn = SC_ON; + else if (!strcmp(str, "only")) + btd_opts.secure_conn = SC_ONLY; + + g_free(str); +} + +static void parse_general(GKeyFile *config) +{ + parse_config_string(config, "General", "Name", &btd_opts.name); + parse_config_hex(config, "General", "Class", &btd_opts.class); + parse_config_u32(config, "General", "DiscoverableTimeout", + &btd_opts.discovto, + 0, UINT32_MAX); + parse_config_bool(config, "General", "AlwaysPairable", + &btd_opts.pairable); + parse_config_u32(config, "General", "PairableTimeout", + &btd_opts.pairto, + 0, UINT32_MAX); + parse_device_id(config); + parse_config_bool(config, "General", "ReverseServiceDiscovery", + &btd_opts.reverse_discovery); + parse_config_bool(config, "General", "NameResolving", + &btd_opts.name_resolv); + parse_config_bool(config, "General", "DebugKeys", + &btd_opts.debug_keys); + parse_ctrl_mode(config); + parse_config_u16(config, "General", "MaxControllers", + &btd_opts.max_adapters, + 0, UINT16_MAX); + parse_multi_profile(config); + parse_config_bool(config, "General", "FastConnectable", + &btd_opts.fast_conn); + parse_privacy(config); + parse_repairing(config); + parse_config_u32(config, "General", "TemporaryTimeout", + &btd_opts.tmpto, + 0, UINT32_MAX); + parse_config_bool(config, "General", "RefreshDiscovery", + &btd_opts.refresh_discovery); + parse_secure_conns(config); + parse_config_bool(config, "General", "Experimental", + &btd_opts.experimental); + parse_kernel_exp(config); + parse_config_u32(config, "General", "RemoteNameRequestRetryDelay", + &btd_opts.name_request_retry_delay, + 0, UINT32_MAX); +} + +static void parse_gatt_cache(GKeyFile *config) +{ + char *str = NULL; + + parse_config_string(config, "GATT", "Cache", &str); + if (!str) + return; + + btd_opts.gatt_cache = parse_gatt_cache_str(str); + g_free(str); +} + +static void parse_gatt(GKeyFile *config) +{ + parse_gatt_cache(config); + parse_config_u8(config, "GATT", "KeySize", &btd_opts.key_size, 7, 16); + parse_config_u16(config, "GATT", "ExchangeMTU", &btd_opts.gatt_mtu, + BT_ATT_DEFAULT_LE_MTU, BT_ATT_MAX_LE_MTU); + parse_config_u8(config, "GATT", "Channels", &btd_opts.gatt_channels, + 1, 5); +} + +static void parse_csis_sirk(GKeyFile *config) +{ + char *str = NULL; + + if (!parse_config_string(config, "CSIS", "SIRK", &str)) + return; + + if (strlen(str) == 32 && check_sirk_alpha_numeric(str)) + hex2bin(str, btd_opts.csis.sirk, sizeof(btd_opts.csis.sirk)); + else if (!gen_sirk(str)) + DBG("Unable to generate SIRK from string"); + + g_free(str); +} + +static void parse_csis(GKeyFile *config) +{ + parse_csis_sirk(config); + parse_config_bool(config, "CSIS", "Encryption", + &btd_opts.csis.encrypt); + parse_config_u8(config, "CSIS", "Size", &btd_opts.csis.size, + 0, UINT8_MAX); + parse_config_u8(config, "CSIS", "Rank", &btd_opts.csis.size, + 0, UINT8_MAX); +} + +static void parse_avdtp_session_mode(GKeyFile *config) +{ + char *str = NULL; + + if (!parse_config_string(config, "AVDTP", "SessionMode", &str)) + return; + + if (!strcmp(str, "basic")) + btd_opts.avdtp.session_mode = BT_IO_MODE_BASIC; + else if (!strcmp(str, "ertm")) + btd_opts.avdtp.session_mode = BT_IO_MODE_ERTM; + else { + DBG("Invalid mode option: %s", str); + btd_opts.avdtp.session_mode = BT_IO_MODE_BASIC; + } + + g_free(str); +} + +static void parse_avdtp_stream_mode(GKeyFile *config) +{ + char *str = NULL; + + if (!parse_config_string(config, "AVDTP", "StreamMode", &str)) + return; + + if (!strcmp(str, "basic")) + btd_opts.avdtp.stream_mode = BT_IO_MODE_BASIC; + else if (!strcmp(str, "streaming")) + btd_opts.avdtp.stream_mode = BT_IO_MODE_STREAMING; + else { + DBG("Invalid mode option: %s", str); + btd_opts.avdtp.stream_mode = BT_IO_MODE_BASIC; + } + + g_free(str); +} + +static void parse_avdtp(GKeyFile *config) +{ + parse_avdtp_session_mode(config); + parse_avdtp_stream_mode(config); +} + +static void parse_advmon(GKeyFile *config) +{ + parse_config_u8(config, "AdvMon", "RSSISamplingPeriod", + &btd_opts.advmon.rssi_sampling_period, + 0, UINT8_MAX); +} + +static void parse_config(GKeyFile *config) +{ if (!config) return; @@ -742,377 +1145,14 @@ static void parse_config(GKeyFile *config) DBG("parsing %s", main_conf_file_path); - val = g_key_file_get_integer(config, "General", - "DiscoverableTimeout", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - DBG("discovto=%d", val); - btd_opts.discovto = val; - } - - boolean = g_key_file_get_boolean(config, "General", - "AlwaysPairable", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - DBG("pairable=%s", boolean ? "true" : "false"); - btd_opts.pairable = boolean; - } - - val = g_key_file_get_integer(config, "General", - "PairableTimeout", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - DBG("pairto=%d", val); - btd_opts.pairto = val; - } - - str = g_key_file_get_string(config, "General", "Privacy", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - btd_opts.privacy = 0x00; - btd_opts.device_privacy = true; - } else { - DBG("privacy=%s", str); - - if (!strcmp(str, "network") || !strcmp(str, "on")) { - btd_opts.privacy = 0x01; - } else if (!strcmp(str, "device")) { - btd_opts.privacy = 0x01; - btd_opts.device_privacy = true; - } else if (!strcmp(str, "limited-network")) { - if (btd_opts.mode != BT_MODE_DUAL) { - DBG("Invalid privacy option: %s", str); - btd_opts.privacy = 0x00; - } - btd_opts.privacy = 0x01; - } else if (!strcmp(str, "limited-device")) { - if (btd_opts.mode != BT_MODE_DUAL) { - DBG("Invalid privacy option: %s", str); - btd_opts.privacy = 0x00; - } - btd_opts.privacy = 0x02; - btd_opts.device_privacy = true; - } else if (!strcmp(str, "off")) { - btd_opts.privacy = 0x00; - btd_opts.device_privacy = true; - } else { - DBG("Invalid privacy option: %s", str); - btd_opts.privacy = 0x00; - } - - g_free(str); - } - - str = g_key_file_get_string(config, "General", - "JustWorksRepairing", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - btd_opts.jw_repairing = JW_REPAIRING_NEVER; - } else { - DBG("just_works_repairing=%s", str); - btd_opts.jw_repairing = parse_jw_repairing(str); - g_free(str); - } - - val = g_key_file_get_integer(config, "General", - "TemporaryTimeout", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - DBG("tmpto=%d", val); - btd_opts.tmpto = val; - } - - str = g_key_file_get_string(config, "General", "Name", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - DBG("name=%s", str); - g_free(btd_opts.name); - btd_opts.name = str; - } - - str = g_key_file_get_string(config, "General", "Class", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - DBG("class=%s", str); - btd_opts.class = strtol(str, NULL, 16); - g_free(str); - } - - str = g_key_file_get_string(config, "General", "DeviceID", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - DBG("deviceid=%s", str); - parse_did(str); - g_free(str); - } - - boolean = g_key_file_get_boolean(config, "General", - "ReverseServiceDiscovery", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else - btd_opts.reverse_discovery = boolean; - - boolean = g_key_file_get_boolean(config, "General", - "NameResolving", &err); - if (err) - g_clear_error(&err); - else - btd_opts.name_resolv = boolean; - - boolean = g_key_file_get_boolean(config, "General", - "DebugKeys", &err); - if (err) - g_clear_error(&err); - else - btd_opts.debug_keys = boolean; - - str = g_key_file_get_string(config, "General", "ControllerMode", &err); - if (err) { - g_clear_error(&err); - } else { - DBG("ControllerMode=%s", str); - btd_opts.mode = get_mode(str); - g_free(str); - } - - val = g_key_file_get_integer(config, "General", "MaxControllers", &err); - if (err) { - g_clear_error(&err); - } else { - DBG("MaxControllers=%d", val); - btd_opts.max_adapters = val; - } - - str = g_key_file_get_string(config, "General", "MultiProfile", &err); - if (err) { - g_clear_error(&err); - } else { - DBG("MultiProfile=%s", str); - - if (!strcmp(str, "single")) - btd_opts.mps = MPS_SINGLE; - else if (!strcmp(str, "multiple")) - btd_opts.mps = MPS_MULTIPLE; - else - btd_opts.mps = MPS_OFF; - - g_free(str); - } - - boolean = g_key_file_get_boolean(config, "General", - "FastConnectable", &err); - if (err) - g_clear_error(&err); - else - btd_opts.fast_conn = boolean; - - boolean = g_key_file_get_boolean(config, "General", - "RefreshDiscovery", &err); - if (err) - g_clear_error(&err); - else - btd_opts.refresh_discovery = boolean; - - boolean = g_key_file_get_boolean(config, "General", "Experimental", - &err); - if (err) - g_clear_error(&err); - else - btd_opts.experimental = boolean; - - strlist = g_key_file_get_string_list(config, "General", - "KernelExperimental", - NULL, &err); - if (err) - g_clear_error(&err); - else { - btd_parse_kernel_experimental(strlist); - g_strfreev(strlist); - } - - val = g_key_file_get_integer(config, "General", - "RemoteNameRequestRetryDelay", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - DBG("RemoteNameRequestRetryDelay=%d", val); - btd_opts.name_request_retry_delay = val; - } - - str = g_key_file_get_string(config, "General", - "SecureConnections", &err); - if (err) - g_clear_error(&err); - else { - if (!strcmp(str, "off")) - btd_opts.secure_conn = SC_OFF; - else if (!strcmp(str, "on")) - btd_opts.secure_conn = SC_ON; - else if (!strcmp(str, "only")) - btd_opts.secure_conn = SC_ONLY; - } - - str = g_key_file_get_string(config, "GATT", "Cache", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - btd_opts.gatt_cache = parse_gatt_cache(str); - g_free(str); - } - - val = g_key_file_get_integer(config, "GATT", "KeySize", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - DBG("KeySize=%d", val); - - if (val >=7 && val <= 16) - btd_opts.key_size = val; - } - - val = g_key_file_get_integer(config, "GATT", "ExchangeMTU", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - /* Ensure the mtu is within a valid range. */ - val = MIN(val, BT_ATT_MAX_LE_MTU); - val = MAX(val, BT_ATT_DEFAULT_LE_MTU); - DBG("ExchangeMTU=%d", val); - btd_opts.gatt_mtu = val; - } - - val = g_key_file_get_integer(config, "GATT", "Channels", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - DBG("Channels=%d", val); - /* Ensure the channels is within a valid range. */ - val = MIN(val, 5); - val = MAX(val, 1); - btd_opts.gatt_channels = val; - } - - str = g_key_file_get_string(config, "CSIS", "SIRK", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - DBG("CSIS SIRK: %s", str); - - if (strlen(str) == 32 && check_sirk_alpha_numeric(str)) { - hex2bin(str, btd_opts.csis.sirk, - sizeof(btd_opts.csis.sirk)); - } else if (!gen_sirk(str)) - DBG("Unable to generate SIRK from string"); - - g_free(str); - } - - boolean = g_key_file_get_boolean(config, "CSIS", "Encryption", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - DBG("CSIS Encryption: %s", boolean ? "true" : "false"); - - btd_opts.csis.encrypt = boolean; - } - - val = g_key_file_get_integer(config, "CSIS", "Size", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - val = MIN(val, 0xFF); - val = MAX(val, 0); - DBG("CSIS Size: %u", val); - btd_opts.csis.size = val; - } - - val = g_key_file_get_integer(config, "CSIS", "Rank", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - val = MIN(val, 0xFF); - val = MAX(val, 0); - DBG("CSIS Rank: %u", val); - btd_opts.csis.rank = val; - } - - str = g_key_file_get_string(config, "AVDTP", "SessionMode", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - DBG("SessionMode=%s", str); - - if (!strcmp(str, "basic")) - btd_opts.avdtp.session_mode = BT_IO_MODE_BASIC; - else if (!strcmp(str, "ertm")) - btd_opts.avdtp.session_mode = BT_IO_MODE_ERTM; - else { - DBG("Invalid mode option: %s", str); - btd_opts.avdtp.session_mode = BT_IO_MODE_BASIC; - } - g_free(str); - } - - str = g_key_file_get_string(config, "AVDTP", "StreamMode", &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - DBG("StreamMode=%s", str); - - if (!strcmp(str, "basic")) - btd_opts.avdtp.stream_mode = BT_IO_MODE_BASIC; - else if (!strcmp(str, "streaming")) - btd_opts.avdtp.stream_mode = BT_IO_MODE_STREAMING; - else { - DBG("Invalid mode option: %s", str); - btd_opts.avdtp.stream_mode = BT_IO_MODE_BASIC; - } - g_free(str); - } - - val = g_key_file_get_integer(config, "AdvMon", "RSSISamplingPeriod", - &err); - if (err) { - DBG("%s", err->message); - g_clear_error(&err); - } else { - val = MIN(val, 0xFF); - val = MAX(val, 0); - DBG("RSSISamplingPeriod=%d", val); - btd_opts.advmon.rssi_sampling_period = val; - } - + /* Parse Groups */ + parse_general(config); parse_br_config(config); parse_le_config(config); + parse_gatt(config); + parse_csis(config); + parse_avdtp(config); + parse_advmon(config); } static void init_defaults(void) @@ -1284,24 +1324,6 @@ static gboolean parse_debug(const char *key, const char *value, return TRUE; } -static gboolean parse_kernel_experimental(const char *key, const char *value, - gpointer user_data, GError **error) -{ - char **strlist; - - if (value) { - strlist = g_strsplit(value, ",", -1); - btd_parse_kernel_experimental(strlist); - g_strfreev(strlist); - } else { - if (!btd_opts.kernel) - btd_opts.kernel = queue_new(); - queue_push_head(btd_opts.kernel, strdup("*")); - } - - return TRUE; -} - static GOptionEntry options[] = { { "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, parse_debug,