From patchwork Tue Dec 7 09:21:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 12661369 X-Patchwork-Delegate: kuba@kernel.org 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 5A66FC433EF for ; Tue, 7 Dec 2021 09:21:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233782AbhLGJZX (ORCPT ); Tue, 7 Dec 2021 04:25:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233408AbhLGJZW (ORCPT ); Tue, 7 Dec 2021 04:25:22 -0500 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E8D4C061574 for ; Tue, 7 Dec 2021 01:21:52 -0800 (PST) Received: by mail-lj1-x22b.google.com with SMTP id k23so26297504lje.1 for ; Tue, 07 Dec 2021 01:21:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jwBUn2JCyUxt/6DBJHGdGqGcL6DOG78oWiBTZowoBDE=; b=KEI0JFa8osIUK1BLx5PY3kSgipER2Lpg78kN1Mv3hD9OLtP+eo+OhKtghtBw9S+KGo uhy5gwwCwPjsPX24xqqwDMfGn5ftHISfezbdaP+6S4PCqVMbSNt6/9bWjs4t5jzZG+S4 TqFwl8cn6Rnel3BV4SKX1gyui9AudPH82D7jr6VT7vDP6fHMgZE6E+zZwJ8h3oVFKQ09 NSM8YnFJqdanGGulp5sKy84Z8moMke6IOBCkiOkP83/mCohUCI8/8MnHvYfHG3sXaY3y C8IcQqMrmbVY0aGlsSynZCdoFLQhNNGI+bD753ZOeeqID6Jiqew913svIBhXEnyOJekb fbUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jwBUn2JCyUxt/6DBJHGdGqGcL6DOG78oWiBTZowoBDE=; b=w8DmsTCkivNOQ0365T0H2vFTvm2cYwTnblPBTjrn/IW97fcurT0q95dnwKQgVAoAoA /0TaIYkPbsH9HzQzqkGDHO0gRKD5gHdkNFua3PvTqN8NpL2+1O1JtSXE1ZUeVvSG2/P5 dEbyxDgOO9mIaprnJs3/KklKdgG9dGQk0AFrgYgo1jb3FFU1CvmvuRCs6v0tCdJrLOJH B0iSEbdusZzDXqqR1hukbhDTm2fZ31ftpYk4ZjGhbNGt82Vpn3zUTn65p1w/wTn0Q3/d LZUT3Ja1qCZJccZxk2c1YlchhTzhyym7aFsvz1hrhY362eRHy8lIm39fY0NcVNv2fZsV y9nA== X-Gm-Message-State: AOAM533up7UCDJkjo5NB6tJ3DToAydnlvwZ7fQfk0AO9xR5j9Vk7BoLw p8FkV5Uh7cEDQp1KoSR4zEo= X-Google-Smtp-Source: ABdhPJwQCJPaIk5N5B0H2AYUYXjF6njmXghPacjQpxsMJC1s0XDGdFLeKr2oZpL5knjmmJxP9sTsiw== X-Received: by 2002:a2e:6e17:: with SMTP id j23mr38950803ljc.99.1638868910876; Tue, 07 Dec 2021 01:21:50 -0800 (PST) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id k11sm1620497lfo.111.2021.12.07.01.21.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Dec 2021 01:21:50 -0800 (PST) From: Sergey Ryazanov To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, M Chetan Kumar , Intel Corporation , Loic Poulain , Johannes Berg , Leon Romanovsky Subject: [PATCH RESEND net-next v2 1/4] net: wwan: iosm: consolidate trace port init code Date: Tue, 7 Dec 2021 12:21:37 +0300 Message-Id: <20211207092140.19142-2-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211207092140.19142-1-ryazanov.s.a@gmail.com> References: <20211207092140.19142-1-ryazanov.s.a@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Move the channel related structures initialization from ipc_imem_channel_init() to ipc_trace_init() and call it directly. On the one hand, this makes the trace port initialization symmetric to the deitialization, that is, it removes the additional wrapper. On the other hand, this change consolidates the trace port related code into a single source file, what facilitates an upcoming disabling of this functionality by a user choise. Signed-off-by: Sergey Ryazanov --- Changes since v1: * no changes drivers/net/wwan/iosm/iosm_ipc_imem.c | 2 +- drivers/net/wwan/iosm/iosm_ipc_imem_ops.c | 18 ------------------ drivers/net/wwan/iosm/iosm_ipc_imem_ops.h | 2 +- drivers/net/wwan/iosm/iosm_ipc_trace.c | 8 +++++++- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.c b/drivers/net/wwan/iosm/iosm_ipc_imem.c index 1be07114c85d..49bdadb855e5 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem.c +++ b/drivers/net/wwan/iosm/iosm_ipc_imem.c @@ -554,7 +554,7 @@ static void ipc_imem_run_state_worker(struct work_struct *instance) ctrl_chl_idx++; } - ipc_imem->trace = ipc_imem_trace_channel_init(ipc_imem); + ipc_imem->trace = ipc_trace_init(ipc_imem); if (!ipc_imem->trace) { dev_err(ipc_imem->dev, "trace channel init failed"); return; diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem_ops.c b/drivers/net/wwan/iosm/iosm_ipc_imem_ops.c index 43f1796a8984..d2072a84ab08 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem_ops.c +++ b/drivers/net/wwan/iosm/iosm_ipc_imem_ops.c @@ -11,7 +11,6 @@ #include "iosm_ipc_imem_ops.h" #include "iosm_ipc_port.h" #include "iosm_ipc_task_queue.h" -#include "iosm_ipc_trace.h" /* Open a packet data online channel between the network layer and CP. */ int ipc_imem_sys_wwan_open(struct iosm_imem *ipc_imem, int if_id) @@ -108,23 +107,6 @@ void ipc_imem_wwan_channel_init(struct iosm_imem *ipc_imem, "failed to register the ipc_wwan interfaces"); } -/** - * ipc_imem_trace_channel_init - Initializes trace channel. - * @ipc_imem: Pointer to iosm_imem struct. - * - * Returns: Pointer to trace instance on success else NULL - */ -struct iosm_trace *ipc_imem_trace_channel_init(struct iosm_imem *ipc_imem) -{ - struct ipc_chnl_cfg chnl_cfg = { 0 }; - - ipc_chnl_cfg_get(&chnl_cfg, IPC_MEM_CTRL_CHL_ID_3); - ipc_imem_channel_init(ipc_imem, IPC_CTYPE_CTRL, chnl_cfg, - IRQ_MOD_OFF); - - return ipc_trace_init(ipc_imem); -} - /* Map SKB to DMA for transfer */ static int ipc_imem_map_skb_to_dma(struct iosm_imem *ipc_imem, struct sk_buff *skb) diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem_ops.h b/drivers/net/wwan/iosm/iosm_ipc_imem_ops.h index e36ee2782629..f8afb217d9e2 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem_ops.h +++ b/drivers/net/wwan/iosm/iosm_ipc_imem_ops.h @@ -141,5 +141,5 @@ int ipc_imem_sys_devlink_read(struct iosm_devlink *ipc_devlink, u8 *data, */ int ipc_imem_sys_devlink_write(struct iosm_devlink *ipc_devlink, unsigned char *buf, int count); -struct iosm_trace *ipc_imem_trace_channel_init(struct iosm_imem *ipc_imem); + #endif diff --git a/drivers/net/wwan/iosm/iosm_ipc_trace.c b/drivers/net/wwan/iosm/iosm_ipc_trace.c index c5fa12599c2b..5f5cfd39bede 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_trace.c +++ b/drivers/net/wwan/iosm/iosm_ipc_trace.c @@ -132,9 +132,15 @@ static const struct file_operations ipc_trace_fops = { */ struct iosm_trace *ipc_trace_init(struct iosm_imem *ipc_imem) { - struct iosm_trace *ipc_trace = kzalloc(sizeof(*ipc_trace), GFP_KERNEL); + struct ipc_chnl_cfg chnl_cfg = { 0 }; + struct iosm_trace *ipc_trace; struct dentry *debugfs_pdev; + ipc_chnl_cfg_get(&chnl_cfg, IPC_MEM_CTRL_CHL_ID_3); + ipc_imem_channel_init(ipc_imem, IPC_CTYPE_CTRL, chnl_cfg, + IRQ_MOD_OFF); + + ipc_trace = kzalloc(sizeof(*ipc_trace), GFP_KERNEL); if (!ipc_trace) return NULL; From patchwork Tue Dec 7 09:21:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 12661371 X-Patchwork-Delegate: kuba@kernel.org 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 1BD95C4332F for ; Tue, 7 Dec 2021 09:21:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233786AbhLGJZY (ORCPT ); Tue, 7 Dec 2021 04:25:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233408AbhLGJZX (ORCPT ); Tue, 7 Dec 2021 04:25:23 -0500 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85CEAC061574 for ; Tue, 7 Dec 2021 01:21:53 -0800 (PST) Received: by mail-lf1-x12d.google.com with SMTP id z7so32012767lfi.11 for ; Tue, 07 Dec 2021 01:21:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oO56SM3oh1knOlpotzxBsJ7mXWks8VAcbwQwZRXYLnU=; b=hZRH6u6s301DV5JBklIswKkq17UW4OLwWo9rWUfqGVkk43Cdm27HK+JsSyd+phDTHF 78emQ1Z0KXBrnilqqQmm1iIZbO0FS4i7Xbb75udhy3mT3yfiL+a4/vfwvZ15q92/duDb F86VP+BQAPMlqEbXUxX7O4uQ/f/YGHO4tO5vAVn3+FGK3IVPKNfidJ7764cCuFBJotoD jXTXyiTNHtCi11Kc4tTyfOh/bm1Vn7lcsf3TTMoZ936rwe3idOzxEFcQZw00dRMf623z ARC0LKOy6BTFhbsZr1b0e1iyTpwBm+y0qN8OoY6YTtZlYEkjkpSfudzyZCQkuukCBqZ8 8/VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oO56SM3oh1knOlpotzxBsJ7mXWks8VAcbwQwZRXYLnU=; b=XU8FQ9vslOrQnLxT+/lvRx7Ts1c233tSjFkp/wh3U5odGfNCq8EdaRWMbp8yG59DbF j0HvNbqCtCWC2djUtoDWR5h7VYeixqYgH8gkDx2Srw/D8Sewv+pz3yBQfb7cPxlEPhhh tKKOQEy0C0c/yq+YOhn+OGbokz3wrmQkhBRVcCKO9NTz5LcF61yVoJWTlfOrA64Q1uXy KAoIWDa2uDRgaGzzBVQ9df+KSYCyjTNbPyEl7xOjHn8AX2bLUjw2K6bwpiac7Rek6CyO O0q2sNIO6k04NwRy80RcAF9NDdgpcnho+oboMOm95X3qg0r3QCqJBMClPFJU9vhANxy/ VInA== X-Gm-Message-State: AOAM5301oyK3g/cSOYGaISahHJ/qrMjv+fFCxDraN5UEcSsL3/l7iQow osZCc2j2ki7FxKTmSRJNLSp36cucV9Z/UQ== X-Google-Smtp-Source: ABdhPJyKulzWcdADDLek5em4cKl1W96CmJRB8ol66p347xoNX6rHRawPgnB/h/c4FKFSfl/qWC//fA== X-Received: by 2002:ac2:4568:: with SMTP id k8mr39741220lfm.80.1638868911874; Tue, 07 Dec 2021 01:21:51 -0800 (PST) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id k11sm1620497lfo.111.2021.12.07.01.21.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Dec 2021 01:21:51 -0800 (PST) From: Sergey Ryazanov To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, M Chetan Kumar , Intel Corporation , Loic Poulain , Johannes Berg , Leon Romanovsky Subject: [PATCH RESEND net-next v2 2/4] net: wwan: iosm: allow trace port be uninitialized Date: Tue, 7 Dec 2021 12:21:38 +0300 Message-Id: <20211207092140.19142-3-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211207092140.19142-1-ryazanov.s.a@gmail.com> References: <20211207092140.19142-1-ryazanov.s.a@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Collecting modem firmware traces is optional for the regular modem use. There are not many reasons for aborting device initialization due to an inability to initialize the trace port and (or) its debugfs interface. So, demote the initialization failure erro message into a warning and do not break the initialization sequence in this case. Rework packet processing and deinitialization so that they do not crash in case of uninitialized trace port. This change is mainly a preparation for an upcoming configuration option introduction that will help disable driver debugfs functionality. Signed-off-by: Sergey Ryazanov --- Changes since v1: * no changes drivers/net/wwan/iosm/iosm_ipc_imem.c | 8 +++----- drivers/net/wwan/iosm/iosm_ipc_trace.c | 3 +++ drivers/net/wwan/iosm/iosm_ipc_trace.h | 5 +++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.c b/drivers/net/wwan/iosm/iosm_ipc_imem.c index 49bdadb855e5..a60b93cefd2e 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem.c +++ b/drivers/net/wwan/iosm/iosm_ipc_imem.c @@ -272,7 +272,7 @@ static void ipc_imem_dl_skb_process(struct iosm_imem *ipc_imem, if (port_id == IPC_MEM_CTRL_CHL_ID_7) ipc_imem_sys_devlink_notify_rx(ipc_imem->ipc_devlink, skb); - else if (port_id == ipc_imem->trace->chl_id) + else if (ipc_is_trace_channel(ipc_imem, port_id)) ipc_trace_port_rx(ipc_imem->trace, skb); else wwan_port_rx(ipc_imem->ipc_port[port_id]->iosm_port, @@ -555,10 +555,8 @@ static void ipc_imem_run_state_worker(struct work_struct *instance) } ipc_imem->trace = ipc_trace_init(ipc_imem); - if (!ipc_imem->trace) { - dev_err(ipc_imem->dev, "trace channel init failed"); - return; - } + if (!ipc_imem->trace) + dev_warn(ipc_imem->dev, "trace channel init failed"); ipc_task_queue_send_task(ipc_imem, ipc_imem_send_mdm_rdy_cb, 0, NULL, 0, false); diff --git a/drivers/net/wwan/iosm/iosm_ipc_trace.c b/drivers/net/wwan/iosm/iosm_ipc_trace.c index 5f5cfd39bede..c588a394cd94 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_trace.c +++ b/drivers/net/wwan/iosm/iosm_ipc_trace.c @@ -172,6 +172,9 @@ struct iosm_trace *ipc_trace_init(struct iosm_imem *ipc_imem) */ void ipc_trace_deinit(struct iosm_trace *ipc_trace) { + if (!ipc_trace) + return; + debugfs_remove(ipc_trace->ctrl_file); relay_close(ipc_trace->ipc_rchan); mutex_destroy(&ipc_trace->trc_mutex); diff --git a/drivers/net/wwan/iosm/iosm_ipc_trace.h b/drivers/net/wwan/iosm/iosm_ipc_trace.h index 53346183af9c..419540c91219 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_trace.h +++ b/drivers/net/wwan/iosm/iosm_ipc_trace.h @@ -45,6 +45,11 @@ struct iosm_trace { enum trace_ctrl_mode mode; }; +static inline bool ipc_is_trace_channel(struct iosm_imem *ipc_mem, u16 chl_id) +{ + return ipc_mem->trace && ipc_mem->trace->chl_id == chl_id; +} + struct iosm_trace *ipc_trace_init(struct iosm_imem *ipc_imem); void ipc_trace_deinit(struct iosm_trace *ipc_trace); void ipc_trace_port_rx(struct iosm_trace *ipc_trace, struct sk_buff *skb); From patchwork Tue Dec 7 09:21:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 12661373 X-Patchwork-Delegate: kuba@kernel.org 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 A632BC433F5 for ; Tue, 7 Dec 2021 09:21:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233787AbhLGJZ2 (ORCPT ); Tue, 7 Dec 2021 04:25:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233408AbhLGJZY (ORCPT ); Tue, 7 Dec 2021 04:25:24 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99716C061574 for ; Tue, 7 Dec 2021 01:21:54 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id m27so31942466lfj.12 for ; Tue, 07 Dec 2021 01:21:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dfSeAedh+6z3xPMXJEbK39zxUF9RksqGn+LD5Z11VAk=; b=VmHrWJTCfe6oi5Ze0d+iDL7ipcbSU1QZOuddPUj1C8K++5vAnxdKYM7RFQb6X3ySzp iiDrfbwyEsSRsxvW3fsItxrr5+Sqd1f7lb4YQgyAmj+uDtYEB/wITbvlHywjF71r0DPc A/1NSsrUrYvWNc8lGbBD3I6WcxB+qkjUwpa3X2Nl2m34yO2W8EH4t4/32n2OtvxZbnMC 3FeLoigZygyRU5rkntBQQ28CsXw/GPq5+cshu/bbJAKimi2MyutLqYFw75vJNUIU7Gnj LEta/CG7k3uQZk3T0v+aVsAhR39yxTeMs9Zag9jFE+TUCs53CRl5thfAaTpaUlTDXT04 dVwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dfSeAedh+6z3xPMXJEbK39zxUF9RksqGn+LD5Z11VAk=; b=4JbeZp8jX85HYsJbYa5pASbXi3FWvQahYkYcPtW9DqIjuHM8K4JCpOH/I7nl2rEZ8m Zz5ZhRhqZroKTpOVA3dGw/fxp1gKrNZ+dnRJsazRXtAIPQ71e0ynbV310Qx4M71a+uuQ PXUGbipsvuhCKE8YseRiIZrd9yxpLHhw0v2mjch0kSiMXgPUQazTo3pMag39eXnOHYf4 p8J3LZ2OjTQjwD5VX3F69jrxPlaZidcRQQPMG5K3/XuZ+qLrsKfdscwvSpkCkFi4K87+ 52GET4QunpjsPrVFZvO5dXHUtbSWPmBMJ/JwnkvV/uKhIEEvbsOhi4Jy2re1RqEiBaEP Pe5Q== X-Gm-Message-State: AOAM531bEgvOfbGh4RSKDDuESYrez3U1+tCfEo5CZf2wocI7Aqau2PCm CFtamyIzTeK1tQEXvPO2Vsch/ePZSJnxrw== X-Google-Smtp-Source: ABdhPJzU9SyLwF2s46djexfqoxUqRH2HMw2JlptuYgYP3n08N0RI98m1iqXsb/yp9Nzu225IrPgm0w== X-Received: by 2002:a05:6512:251f:: with SMTP id be31mr12011079lfb.193.1638868912884; Tue, 07 Dec 2021 01:21:52 -0800 (PST) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id k11sm1620497lfo.111.2021.12.07.01.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Dec 2021 01:21:52 -0800 (PST) From: Sergey Ryazanov To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, M Chetan Kumar , Intel Corporation , Loic Poulain , Johannes Berg , Leon Romanovsky Subject: [PATCH RESEND net-next v2 3/4] net: wwan: iosm: move debugfs knobs into a subdir Date: Tue, 7 Dec 2021 12:21:39 +0300 Message-Id: <20211207092140.19142-4-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211207092140.19142-1-ryazanov.s.a@gmail.com> References: <20211207092140.19142-1-ryazanov.s.a@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The modem traces collection is a device (and so driver) specific option. Therefore, move the related debugfs files into a driver-specific subdirectory under the common per WWAN device directory. Signed-off-by: Sergey Ryazanov --- Changes since v1: * add missed description for a new structure field 'debugfs_dir' drivers/net/wwan/iosm/Makefile | 1 + drivers/net/wwan/iosm/iosm_ipc_debugfs.c | 29 ++++++++++++++++++++++++ drivers/net/wwan/iosm/iosm_ipc_debugfs.h | 12 ++++++++++ drivers/net/wwan/iosm/iosm_ipc_imem.c | 7 +++--- drivers/net/wwan/iosm/iosm_ipc_imem.h | 2 ++ drivers/net/wwan/iosm/iosm_ipc_trace.c | 6 ++--- 6 files changed, 49 insertions(+), 8 deletions(-) create mode 100644 drivers/net/wwan/iosm/iosm_ipc_debugfs.c create mode 100644 drivers/net/wwan/iosm/iosm_ipc_debugfs.h diff --git a/drivers/net/wwan/iosm/Makefile b/drivers/net/wwan/iosm/Makefile index 5c2528beca2a..5091f664af0d 100644 --- a/drivers/net/wwan/iosm/Makefile +++ b/drivers/net/wwan/iosm/Makefile @@ -22,6 +22,7 @@ iosm-y = \ iosm_ipc_devlink.o \ iosm_ipc_flash.o \ iosm_ipc_coredump.o \ + iosm_ipc_debugfs.o \ iosm_ipc_trace.o obj-$(CONFIG_IOSM) := iosm.o diff --git a/drivers/net/wwan/iosm/iosm_ipc_debugfs.c b/drivers/net/wwan/iosm/iosm_ipc_debugfs.c new file mode 100644 index 000000000000..f2f57751a7d2 --- /dev/null +++ b/drivers/net/wwan/iosm/iosm_ipc_debugfs.c @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (C) 2020-2021 Intel Corporation. + */ + +#include +#include + +#include "iosm_ipc_imem.h" +#include "iosm_ipc_trace.h" +#include "iosm_ipc_debugfs.h" + +void ipc_debugfs_init(struct iosm_imem *ipc_imem) +{ + struct dentry *debugfs_pdev = wwan_get_debugfs_dir(ipc_imem->dev); + + ipc_imem->debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, + debugfs_pdev); + + ipc_imem->trace = ipc_trace_init(ipc_imem); + if (!ipc_imem->trace) + dev_warn(ipc_imem->dev, "trace channel init failed"); +} + +void ipc_debugfs_deinit(struct iosm_imem *ipc_imem) +{ + ipc_trace_deinit(ipc_imem->trace); + debugfs_remove_recursive(ipc_imem->debugfs_dir); +} diff --git a/drivers/net/wwan/iosm/iosm_ipc_debugfs.h b/drivers/net/wwan/iosm/iosm_ipc_debugfs.h new file mode 100644 index 000000000000..35788039f13f --- /dev/null +++ b/drivers/net/wwan/iosm/iosm_ipc_debugfs.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0-only + * + * Copyright (C) 2020-2021 Intel Corporation. + */ + +#ifndef IOSM_IPC_DEBUGFS_H +#define IOSM_IPC_DEBUGFS_H + +void ipc_debugfs_init(struct iosm_imem *ipc_imem); +void ipc_debugfs_deinit(struct iosm_imem *ipc_imem); + +#endif diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.c b/drivers/net/wwan/iosm/iosm_ipc_imem.c index a60b93cefd2e..25b889922912 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem.c +++ b/drivers/net/wwan/iosm/iosm_ipc_imem.c @@ -11,6 +11,7 @@ #include "iosm_ipc_imem.h" #include "iosm_ipc_port.h" #include "iosm_ipc_trace.h" +#include "iosm_ipc_debugfs.h" /* Check the wwan ips if it is valid with Channel as input. */ static int ipc_imem_check_wwan_ips(struct ipc_mem_channel *chnl) @@ -554,9 +555,7 @@ static void ipc_imem_run_state_worker(struct work_struct *instance) ctrl_chl_idx++; } - ipc_imem->trace = ipc_trace_init(ipc_imem); - if (!ipc_imem->trace) - dev_warn(ipc_imem->dev, "trace channel init failed"); + ipc_debugfs_init(ipc_imem); ipc_task_queue_send_task(ipc_imem, ipc_imem_send_mdm_rdy_cb, 0, NULL, 0, false); @@ -1173,7 +1172,7 @@ void ipc_imem_cleanup(struct iosm_imem *ipc_imem) if (test_and_clear_bit(FULLY_FUNCTIONAL, &ipc_imem->flag)) { ipc_mux_deinit(ipc_imem->mux); - ipc_trace_deinit(ipc_imem->trace); + ipc_debugfs_deinit(ipc_imem); ipc_wwan_deinit(ipc_imem->wwan); ipc_port_deinit(ipc_imem->ipc_port); } diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.h b/drivers/net/wwan/iosm/iosm_ipc_imem.h index cec38009c44a..1b8c7b8959c6 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem.h +++ b/drivers/net/wwan/iosm/iosm_ipc_imem.h @@ -341,6 +341,7 @@ enum ipc_phase { * @ev_mux_net_transmit_pending:0 means inform the IPC tasklet to pass * @reset_det_n: Reset detect flag * @pcie_wake_n: Pcie wake flag + * @debugfs_dir: Debug FS directory for driver-specific entries */ struct iosm_imem { struct iosm_mmio *mmio; @@ -380,6 +381,7 @@ struct iosm_imem { ev_mux_net_transmit_pending:1, reset_det_n:1, pcie_wake_n:1; + struct dentry *debugfs_dir; }; /** diff --git a/drivers/net/wwan/iosm/iosm_ipc_trace.c b/drivers/net/wwan/iosm/iosm_ipc_trace.c index c588a394cd94..5243ead90b5f 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_trace.c +++ b/drivers/net/wwan/iosm/iosm_ipc_trace.c @@ -134,7 +134,6 @@ struct iosm_trace *ipc_trace_init(struct iosm_imem *ipc_imem) { struct ipc_chnl_cfg chnl_cfg = { 0 }; struct iosm_trace *ipc_trace; - struct dentry *debugfs_pdev; ipc_chnl_cfg_get(&chnl_cfg, IPC_MEM_CTRL_CHL_ID_3); ipc_imem_channel_init(ipc_imem, IPC_CTYPE_CTRL, chnl_cfg, @@ -150,15 +149,14 @@ struct iosm_trace *ipc_trace_init(struct iosm_imem *ipc_imem) ipc_trace->chl_id = IPC_MEM_CTRL_CHL_ID_3; mutex_init(&ipc_trace->trc_mutex); - debugfs_pdev = wwan_get_debugfs_dir(ipc_imem->dev); ipc_trace->ctrl_file = debugfs_create_file(IOSM_TRC_DEBUGFS_TRACE_CTRL, IOSM_TRC_FILE_PERM, - debugfs_pdev, + ipc_imem->debugfs_dir, ipc_trace, &ipc_trace_fops); ipc_trace->ipc_rchan = relay_open(IOSM_TRC_DEBUGFS_TRACE, - debugfs_pdev, + ipc_imem->debugfs_dir, IOSM_TRC_SUB_BUFF_SIZE, IOSM_TRC_N_SUB_BUFF, &relay_callbacks, NULL); From patchwork Tue Dec 7 09:21:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ryazanov X-Patchwork-Id: 12661375 X-Patchwork-Delegate: kuba@kernel.org 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 48DA8C433EF for ; Tue, 7 Dec 2021 09:22:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233794AbhLGJZ3 (ORCPT ); Tue, 7 Dec 2021 04:25:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233792AbhLGJZ0 (ORCPT ); Tue, 7 Dec 2021 04:25:26 -0500 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3C48C061354 for ; Tue, 7 Dec 2021 01:21:55 -0800 (PST) Received: by mail-lj1-x231.google.com with SMTP id 13so26125284ljj.11 for ; Tue, 07 Dec 2021 01:21:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iywjxGwUAAy9vBVrbH3dHVmYDYL7gPNuXg7HnA5ET3Q=; b=DOaFS3JlcG1DrlgsxOY+5Or1aSG0csEB9Q5NlCTfevjqcXbtnJTdBULiz/ZCK0+d4t BMOGQ01argGHm31lv81FZaO/D38TzZs0cdh1zGbMZSVYMNmOTP7NypRLLgcrbxpbjvBe 7wddH4e15R2a67e8Qvt6Jw1Ay/7ImhkeB3LK0GYoZ7zYaZ/mz3S4bRvB3ojMLtOlwv6L Orpwlymjo4V2Xz5LfDXbo0k3ZKVBR26GXHy2kAdJUKxpROYagcHT94RCFYs6GQ7P26S3 aVeFvT9NLGG0hWTd9SR9x8DsC2GhErFePtp4DJ80qAFQKVvXrGb6OHbUJ1dtYZy+CmXR m9qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=iywjxGwUAAy9vBVrbH3dHVmYDYL7gPNuXg7HnA5ET3Q=; b=3nAB5EST0V541H0Grl6XAWrdtOIIw0rGwuKSFaiwTPAJlICWufzfhMu6y4wly0gtn0 KDq9vs1D8sak7XlIqNk21tVXCaB8DLCUz2jfE05JOGCARuAvN0NgfCk2KTQbPtH/wfFB ad1Bt2lGgGoyAhdXogEw64Av4jAeS8LGuqWUuRMSjjiO9sbo/NWGCd5LqgQKBkcw9CVT Mg7CDXEu/rO7zcQLQnId7apgOrG0nQDrLSjZ2N67jGcDxuKyJCqbAv0bDEPOd44ZfkNW M9yvwnN5+HVUsV0Mpv+gJlVCOyf8lLM9A+e8x/+kiLIho/b4Ti1rwqnfgtIt1kcaWsUS UXdw== X-Gm-Message-State: AOAM530eYQTGUjjOi7d2sdyTohyufWsd+EsJI9nUC0Oowl8VtE7AQ3nZ dXoRyUq14pKlpOaRf/Jsch4= X-Google-Smtp-Source: ABdhPJzP4HVER4Q3eyQqOzDzucB5XAJKwCbZ9ZvR1fQvx5dUzpmAwE+7q6++uu2/GBZfwy4Mtum17Q== X-Received: by 2002:a2e:809a:: with SMTP id i26mr43705390ljg.416.1638868914166; Tue, 07 Dec 2021 01:21:54 -0800 (PST) Received: from rsa-laptop.internal.lan ([217.25.229.52]) by smtp.gmail.com with ESMTPSA id k11sm1620497lfo.111.2021.12.07.01.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Dec 2021 01:21:53 -0800 (PST) From: Sergey Ryazanov To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, M Chetan Kumar , Intel Corporation , Loic Poulain , Johannes Berg , Leon Romanovsky , Leon Romanovsky Subject: [PATCH RESEND net-next v2 4/4] net: wwan: make debugfs optional Date: Tue, 7 Dec 2021 12:21:40 +0300 Message-Id: <20211207092140.19142-5-ryazanov.s.a@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211207092140.19142-1-ryazanov.s.a@gmail.com> References: <20211207092140.19142-1-ryazanov.s.a@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Debugfs interface is optional for the regular modem use. Some distros and users will want to disable this feature for security or kernel size reasons. So add a configuration option that allows to completely disable the debugfs interface of the WWAN devices. A primary considered use case for this option was embedded firmwares. For example, in OpenWrt, you can not completely disable debugfs, as a lot of wireless stuff can only be configured and monitored with the debugfs knobs. At the same time, reducing the size of a kernel and modules is an essential task in the world of embedded software. Disabling the WWAN and IOSM debugfs interfaces allows us to save 50K (x86-64 build) of space for module storage. Not much, but already considerable when you only have 16MB of storage. So it is hard to just disable whole debugfs. Users need some fine grained set of options to control which debugfs interface is important and should be available and which is not. The new configuration symbol is enabled by default and is hidden under the EXPERT option. So a regular user would not be bothered by another one configuration question. While an embedded distro maintainer will be able to a little more reduce the final image size. Signed-off-by: Sergey Ryazanov Reviewed-by: Leon Romanovsky --- Changes since v1: * this is a merge of 4th and 5th patches * drop the IOSM specific configuration option and use the common WWAN option to control the IOSM debugfs interface build, thanks to Johannes and Leon for their recomendations * make WWAN debugfs enabled by default and hide it under EXPERT as suggested by Johannes * add a detailed rationale to the patch description to show why we need the ability to disable debugfs * return ERR_PTR(-ENODEV) instead of NULL if WWAN debugfs was disabled, thanks to Johannes for spotting this * fix unused 'wwandev_name' variable warning * expand the new configuration symbold description drivers/net/wwan/Kconfig | 13 ++++++++++++- drivers/net/wwan/iosm/Makefile | 4 +++- drivers/net/wwan/iosm/iosm_ipc_debugfs.h | 5 +++++ drivers/net/wwan/iosm/iosm_ipc_imem.c | 2 +- drivers/net/wwan/iosm/iosm_ipc_imem.h | 4 ++++ drivers/net/wwan/iosm/iosm_ipc_trace.c | 6 ++++-- drivers/net/wwan/iosm/iosm_ipc_trace.h | 20 +++++++++++++++++++- drivers/net/wwan/wwan_core.c | 17 +++++++++++++---- include/linux/wwan.h | 7 +++++++ 9 files changed, 68 insertions(+), 10 deletions(-) diff --git a/drivers/net/wwan/Kconfig b/drivers/net/wwan/Kconfig index 9f5111a77da9..609fd4a2c865 100644 --- a/drivers/net/wwan/Kconfig +++ b/drivers/net/wwan/Kconfig @@ -16,6 +16,17 @@ config WWAN if WWAN +config WWAN_DEBUGFS + bool "WWAN devices debugfs interface" if EXPERT + depends on DEBUG_FS + default y + help + Enables debugfs infrastructure for the WWAN core and device drivers. + + If this option is selected, then you can find the debug interface + elements for each WWAN device in a directory that is corresponding to + the device name: debugfs/wwan/wwanX. + config WWAN_HWSIM tristate "Simulated WWAN device" help @@ -85,7 +96,7 @@ config IOSM tristate "IOSM Driver for Intel M.2 WWAN Device" depends on INTEL_IOMMU select NET_DEVLINK - select RELAY + select RELAY if WWAN_DEBUGFS help This driver enables Intel M.2 WWAN Device communication. diff --git a/drivers/net/wwan/iosm/Makefile b/drivers/net/wwan/iosm/Makefile index 5091f664af0d..fa8d6afd18e1 100644 --- a/drivers/net/wwan/iosm/Makefile +++ b/drivers/net/wwan/iosm/Makefile @@ -21,7 +21,9 @@ iosm-y = \ iosm_ipc_mux_codec.o \ iosm_ipc_devlink.o \ iosm_ipc_flash.o \ - iosm_ipc_coredump.o \ + iosm_ipc_coredump.o + +iosm-$(CONFIG_WWAN_DEBUGFS) += \ iosm_ipc_debugfs.o \ iosm_ipc_trace.o diff --git a/drivers/net/wwan/iosm/iosm_ipc_debugfs.h b/drivers/net/wwan/iosm/iosm_ipc_debugfs.h index 35788039f13f..8a84bfa2c14a 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_debugfs.h +++ b/drivers/net/wwan/iosm/iosm_ipc_debugfs.h @@ -6,7 +6,12 @@ #ifndef IOSM_IPC_DEBUGFS_H #define IOSM_IPC_DEBUGFS_H +#ifdef CONFIG_WWAN_DEBUGFS void ipc_debugfs_init(struct iosm_imem *ipc_imem); void ipc_debugfs_deinit(struct iosm_imem *ipc_imem); +#else +static inline void ipc_debugfs_init(struct iosm_imem *ipc_imem) {} +static inline void ipc_debugfs_deinit(struct iosm_imem *ipc_imem) {} +#endif #endif diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.c b/drivers/net/wwan/iosm/iosm_ipc_imem.c index 25b889922912..2a6ddd7c6c88 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem.c +++ b/drivers/net/wwan/iosm/iosm_ipc_imem.c @@ -274,7 +274,7 @@ static void ipc_imem_dl_skb_process(struct iosm_imem *ipc_imem, ipc_imem_sys_devlink_notify_rx(ipc_imem->ipc_devlink, skb); else if (ipc_is_trace_channel(ipc_imem, port_id)) - ipc_trace_port_rx(ipc_imem->trace, skb); + ipc_trace_port_rx(ipc_imem, skb); else wwan_port_rx(ipc_imem->ipc_port[port_id]->iosm_port, skb); diff --git a/drivers/net/wwan/iosm/iosm_ipc_imem.h b/drivers/net/wwan/iosm/iosm_ipc_imem.h index 1b8c7b8959c6..86a1ffe61729 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_imem.h +++ b/drivers/net/wwan/iosm/iosm_ipc_imem.h @@ -351,7 +351,9 @@ struct iosm_imem { struct iosm_mux *mux; struct iosm_cdev *ipc_port[IPC_MEM_MAX_CHANNELS]; struct iosm_pcie *pcie; +#ifdef CONFIG_WWAN_DEBUGFS struct iosm_trace *trace; +#endif struct device *dev; enum ipc_mem_device_ipc_state ipc_requested_state; struct ipc_mem_channel channels[IPC_MEM_MAX_CHANNELS]; @@ -381,7 +383,9 @@ struct iosm_imem { ev_mux_net_transmit_pending:1, reset_det_n:1, pcie_wake_n:1; +#ifdef CONFIG_WWAN_DEBUGFS struct dentry *debugfs_dir; +#endif }; /** diff --git a/drivers/net/wwan/iosm/iosm_ipc_trace.c b/drivers/net/wwan/iosm/iosm_ipc_trace.c index 5243ead90b5f..eeecfa3d10c5 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_trace.c +++ b/drivers/net/wwan/iosm/iosm_ipc_trace.c @@ -17,11 +17,13 @@ /** * ipc_trace_port_rx - Receive trace packet from cp and write to relay buffer - * @ipc_trace: Pointer to the ipc trace data-struct + * @ipc_imem: Pointer to iosm_imem structure * @skb: Pointer to struct sk_buff */ -void ipc_trace_port_rx(struct iosm_trace *ipc_trace, struct sk_buff *skb) +void ipc_trace_port_rx(struct iosm_imem *ipc_imem, struct sk_buff *skb) { + struct iosm_trace *ipc_trace = ipc_imem->trace; + if (ipc_trace->ipc_rchan) relay_write(ipc_trace->ipc_rchan, skb->data, skb->len); diff --git a/drivers/net/wwan/iosm/iosm_ipc_trace.h b/drivers/net/wwan/iosm/iosm_ipc_trace.h index 419540c91219..5ebe7790585c 100644 --- a/drivers/net/wwan/iosm/iosm_ipc_trace.h +++ b/drivers/net/wwan/iosm/iosm_ipc_trace.h @@ -45,6 +45,8 @@ struct iosm_trace { enum trace_ctrl_mode mode; }; +#ifdef CONFIG_WWAN_DEBUGFS + static inline bool ipc_is_trace_channel(struct iosm_imem *ipc_mem, u16 chl_id) { return ipc_mem->trace && ipc_mem->trace->chl_id == chl_id; @@ -52,5 +54,21 @@ static inline bool ipc_is_trace_channel(struct iosm_imem *ipc_mem, u16 chl_id) struct iosm_trace *ipc_trace_init(struct iosm_imem *ipc_imem); void ipc_trace_deinit(struct iosm_trace *ipc_trace); -void ipc_trace_port_rx(struct iosm_trace *ipc_trace, struct sk_buff *skb); +void ipc_trace_port_rx(struct iosm_imem *ipc_imem, struct sk_buff *skb); + +#else + +static inline bool ipc_is_trace_channel(struct iosm_imem *ipc_mem, u16 chl_id) +{ + return false; +} + +static inline void ipc_trace_port_rx(struct iosm_imem *ipc_imem, + struct sk_buff *skb) +{ + dev_kfree_skb(skb); +} + +#endif + #endif diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c index 5bf62dc35ac7..1508dc2a497b 100644 --- a/drivers/net/wwan/wwan_core.c +++ b/drivers/net/wwan/wwan_core.c @@ -50,7 +50,9 @@ struct wwan_device { atomic_t port_id; const struct wwan_ops *ops; void *ops_ctxt; +#ifdef CONFIG_WWAN_DEBUGFS struct dentry *debugfs_dir; +#endif }; /** @@ -146,6 +148,7 @@ static struct wwan_device *wwan_dev_get_by_name(const char *name) return to_wwan_dev(dev); } +#ifdef CONFIG_WWAN_DEBUGFS struct dentry *wwan_get_debugfs_dir(struct device *parent) { struct wwan_device *wwandev; @@ -157,6 +160,7 @@ struct dentry *wwan_get_debugfs_dir(struct device *parent) return wwandev->debugfs_dir; } EXPORT_SYMBOL_GPL(wwan_get_debugfs_dir); +#endif /* This function allocates and registers a new WWAN device OR if a WWAN device * already exist for the given parent, it gets a reference and return it. @@ -166,7 +170,6 @@ EXPORT_SYMBOL_GPL(wwan_get_debugfs_dir); static struct wwan_device *wwan_create_dev(struct device *parent) { struct wwan_device *wwandev; - const char *wwandev_name; int err, id; /* The 'find-alloc-register' operation must be protected against @@ -206,9 +209,11 @@ static struct wwan_device *wwan_create_dev(struct device *parent) goto done_unlock; } - wwandev_name = kobject_name(&wwandev->dev.kobj); - wwandev->debugfs_dir = debugfs_create_dir(wwandev_name, - wwan_debugfs_dir); +#ifdef CONFIG_WWAN_DEBUGFS + wwandev->debugfs_dir = + debugfs_create_dir(kobject_name(&wwandev->dev.kobj), + wwan_debugfs_dir); +#endif done_unlock: mutex_unlock(&wwan_register_lock); @@ -240,7 +245,9 @@ static void wwan_remove_dev(struct wwan_device *wwandev) ret = device_for_each_child(&wwandev->dev, NULL, is_wwan_child); if (!ret) { +#ifdef CONFIG_WWAN_DEBUGFS debugfs_remove_recursive(wwandev->debugfs_dir); +#endif device_unregister(&wwandev->dev); } else { put_device(&wwandev->dev); @@ -1140,7 +1147,9 @@ static int __init wwan_init(void) goto destroy; } +#ifdef CONFIG_WWAN_DEBUGFS wwan_debugfs_dir = debugfs_create_dir("wwan", NULL); +#endif return 0; diff --git a/include/linux/wwan.h b/include/linux/wwan.h index 1646aa3e6779..e143c88bf4b0 100644 --- a/include/linux/wwan.h +++ b/include/linux/wwan.h @@ -171,6 +171,13 @@ int wwan_register_ops(struct device *parent, const struct wwan_ops *ops, void wwan_unregister_ops(struct device *parent); +#ifdef CONFIG_WWAN_DEBUGFS struct dentry *wwan_get_debugfs_dir(struct device *parent); +#else +static inline struct dentry *wwan_get_debugfs_dir(struct device *parent) +{ + return ERR_PTR(-ENODEV); +} +#endif #endif /* __WWAN_H */