From patchwork Thu Feb 11 20:00:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 381483 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B28ADC433E6 for ; Thu, 11 Feb 2021 20:01:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 70CFC64DE9 for ; Thu, 11 Feb 2021 20:01:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230412AbhBKUBg (ORCPT ); Thu, 11 Feb 2021 15:01:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230265AbhBKUBW (ORCPT ); Thu, 11 Feb 2021 15:01:22 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B0EBC061574; Thu, 11 Feb 2021 12:00:42 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id r21so5370115wrr.9; Thu, 11 Feb 2021 12:00:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=bHdv3jXvDP//T4C5ZhfpHPLC2NxIN03Ob1UB8XrqyU8=; b=sAgn8JhLuTn1sERqKPOASKrStvL5IWnrtM3DoTRhTX7SM7ObJTvq2z+V6Y5ZYizRY0 aeKVsC66tWYjJQ+YAh8qL2a9fvUGbnrM4f5dfq/xhv3JeT98mgz1XB6k2JbcbjU4De0S gXDpvFcxrEpxq+dMPkXM0ONNCYFt9JNR7KKYUXa8UuQoYwVSWWYkRNaXCsbaxrQrEPmF UTvW22N7p0scNU5w7Ip9eCKqpTs8tWWmUEhKISXWcBA6v0iS16J0CdCw5ERULo4DkbEu DF9YDQYwhplzK+dXlKgxmMXVA2vCvqgFq51ajTsf+M6wq4yGdzmFUlj3bF9zz1l8NRG+ pO6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=bHdv3jXvDP//T4C5ZhfpHPLC2NxIN03Ob1UB8XrqyU8=; b=B4rXNsl/Xt7jeWVs3DcxAKvWEHrJg7ALWn+I/6lFlKnYVOpgOcSJV7MqLObU+zrH7+ bqbZ3N8am3jmEK/A8cI5ZO4X9OowdonwjhlLWJ5PE5FyrjVlVOzPmmEwT/4IdnH1/9o3 vkoW/XK0WPU322SOSSOElbOHGG3YoSakB0P1BZOZPpANzrpGqcTi22EPYqmOPjOy3yId SqeP6FtxJJuNjcJcclqGuxLhOjYMPVUAFCD/kg6zEli99qVUS8BykqzHregHoFvvu5Yc Yf3me93UMQedvBAp/ge2Pnf7CtgfrYEVWGBg5jvOWS847Whf80Edq8bQCdJ1U8jrb3uB a9Bg== X-Gm-Message-State: AOAM5303ZdkgUK3Oz/qcral2iUQfnzrLzSpC9twrBq7q0SQB85TXSH+1 h7w6vwF//CiSUUZimxMvtrQIEe/mJ3/RAA== X-Google-Smtp-Source: ABdhPJwAnIyCDkm2YCAXaYIGGmDB1fQ6MQf+97oZrjnNkcsuZFCvmPgHht1acdiKTJb459q6rVdF/w== X-Received: by 2002:adf:8104:: with SMTP id 4mr7210902wrm.265.1613073640583; Thu, 11 Feb 2021 12:00:40 -0800 (PST) Received: from ?IPv6:2003:ea:8f1f:ad00:1524:b28c:2a1c:169e? (p200300ea8f1fad001524b28c2a1c169e.dip0.t-ipconnect.de. [2003:ea:8f1f:ad00:1524:b28c:2a1c:169e]) by smtp.googlemail.com with ESMTPSA id l14sm6680079wrq.87.2021.02.11.12.00.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Feb 2021 12:00:40 -0800 (PST) From: Heiner Kallweit To: Jakub Kicinski , David Miller , Luca Coelho , Kalle Valo Cc: "netdev@vger.kernel.org" , linux-wireless Subject: [PATCH net-next] iwlwifi: improve tag handling in iwl_request_firmware Message-ID: Date: Thu, 11 Feb 2021 21:00:31 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 MIME-Version: 1.0 Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org We can remove the intermediary string conversion and use drv->fw_index in the final snprintf directly. Signed-off-by: Heiner Kallweit --- drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c index 263c3c0bb..000c0ae8d 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c @@ -161,7 +161,6 @@ static void iwl_req_fw_callback(const struct firmware *ucode_raw, static int iwl_request_firmware(struct iwl_drv *drv, bool first) { const struct iwl_cfg *cfg = drv->trans->cfg; - char tag[8]; if (drv->trans->trans_cfg->device_family == IWL_DEVICE_FAMILY_9000 && (CSR_HW_REV_STEP(drv->trans->hw_rev) != SILICON_B_STEP && @@ -172,13 +171,10 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first) return -EINVAL; } - if (first) { + if (first) drv->fw_index = cfg->ucode_api_max; - sprintf(tag, "%d", drv->fw_index); - } else { + else drv->fw_index--; - sprintf(tag, "%d", drv->fw_index); - } if (drv->fw_index < cfg->ucode_api_min) { IWL_ERR(drv, "no suitable firmware found!\n"); @@ -198,8 +194,8 @@ static int iwl_request_firmware(struct iwl_drv *drv, bool first) return -ENOENT; } - snprintf(drv->firmware_name, sizeof(drv->firmware_name), "%s%s.ucode", - cfg->fw_name_pre, tag); + snprintf(drv->firmware_name, sizeof(drv->firmware_name), "%s%d.ucode", + cfg->fw_name_pre, drv->fw_index); IWL_DEBUG_FW_INFO(drv, "attempting to load firmware '%s'\n", drv->firmware_name);