From patchwork Fri Jun 11 20:39:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 458520 Delivered-To: patch@linaro.org Received: by 2002:a02:735a:0:0:0:0:0 with SMTP id a26csp1269527jae; Fri, 11 Jun 2021 13:41:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAOD0RmQrqqUi/iq+QFzww+4q4qbbC2yILgTdvh8ziL8reSxrGlt7hlYsPN28P0d5WAG2g X-Received: by 2002:a50:afe2:: with SMTP id h89mr5679457edd.308.1623444100715; Fri, 11 Jun 2021 13:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623444100; cv=none; d=google.com; s=arc-20160816; b=lxkdBZkHT9aIZ2AKj3P9DkpU0HKDaNDsVo7pdpYIoPojHNYiK74f6bFMP1f82WWH2n DcJpCPOX7GSJVutMpYNPZdoE/hO6O+ZPfPtk0idhes3fLKujVsvD8g8gcvWCnjY8i3Wx kVBd0taVbjzdDoOdLneyA6oVpuKnIEC/mU+3XICTj12F+eMCF+3kf9KFrkHwKUGm+WBa GvIq2P6c2PpStcTkSio8huEoxDLkwumNQsL1Qh+57ehnsnjTAbficoDP4kBcPkOjpwLV 2z0+g/ZaGucDvXzbxKrLXiPyc8FJtam480tekvgzE6JTkyEBrxqUdtvmPH4w9DI88BHb 0+8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IyNK4kzyW6w6CpdFLaV1AjbEu9O4dvUnAZHNcKqiDrc=; b=AuawrbpTlXKjmCdxNmRxAWkdHt7CMTz/yNcFOUYbXgDx0Wd8zgoEB/vdna6pRTjMgV MFOyTNQag9BV87aATxwqmFPE0y+7Mi4ub46WbJew/y/XDIQQe3XLY5PzoHP6GWTuh056 6lUMyyY1u6/1OBRIoAx3ZrihKo8IsOpW0Wy8Ne/smR1xIqt23+/JhIZ8v/KyP1dPT6dM hNKnaKw7SmIu5q3d1ESD4jF8SCkgdJUv+Enkzkq3UK3kfppQtDcxh47hunIw+w3vQFhp enMVhfPTtfAYww0JvOsJz/7isVOKgtpMHP2TMO8xUGTjqj6OyXI7BNY7uwmL6Rt4jVyp X8Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pg6BXOoH; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jj27si5502461ejc.580.2021.06.11.13.41.40; Fri, 11 Jun 2021 13:41:40 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pg6BXOoH; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231327AbhFKUm7 (ORCPT + 8 others); Fri, 11 Jun 2021 16:42:59 -0400 Received: from mail-il1-f170.google.com ([209.85.166.170]:41644 "EHLO mail-il1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231265AbhFKUm6 (ORCPT ); Fri, 11 Jun 2021 16:42:58 -0400 Received: by mail-il1-f170.google.com with SMTP id t6so6326739iln.8 for ; Fri, 11 Jun 2021 13:40:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IyNK4kzyW6w6CpdFLaV1AjbEu9O4dvUnAZHNcKqiDrc=; b=Pg6BXOoHn2/9V19Rwq7rqEsrnCWv/wINZ2Crxj6EZOVsyTbEte0oSWJUDUN4QPowsx g/pztumsI5nh1Dlyw2lxMFUZ/l5FXEOB2lDNRBain5Zss2o9hx0B/MLJUxsuDjlsqZDk ADnmLOReBBO+aUnfOmm/jKltU2Z/twUfDG7oWxTMY5y4msmfXk+9ZMyUA3OiuDWFd8h1 CCsvDMF8RCr6lmD6bRUffB1yy9XeSFK3ARQoEEX3fTQKHvBAYH3S6w0jnKS6n50BSD6v zY8OAMEMIF4Qyj+h3b7fYob62Hd6NuT2n2u+fQPFKNLpjveOsHm8zSxxCz6xOfrMVTCn mnnw== 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IyNK4kzyW6w6CpdFLaV1AjbEu9O4dvUnAZHNcKqiDrc=; b=tsfkmS1Frw+Zkrr2riKc6BhGPIqtE+ql3ZnCVAsElvMasQzX6Ai3j8OR3rgZAR8+JT 9S9yPZDZXgN43Mp57EBJ0MEWgAQIktNMGGn4PQzTBL+dISV4e7acaT3YnLm6mC3/Y2jI IAHZbJ9tZsoKna7ASRlhv2Rc73AXv51/4VN75+egjqer3346AD6vkBekt/06/z69tiV2 kC35NuB1r0Y8+Xdkv5R06JpgAU37sbjANPenQCa8iXKG6s3CgKWeunKavapGI928XS1M tzzGQivanWgROq6spMdeGFUwKBvhYbAVPIXlR5YrhHzpdSkHn+znxVoqEpPHmCxwj4Lo x9hA== X-Gm-Message-State: AOAM531b096b0yqSmwIcuyY04QyQLfgEJz5vn2fvuTJFbo82n+u+gm4N lJs7icD2bbf6S5smUGFXC9IGAQ== X-Received: by 2002:a05:6e02:1248:: with SMTP id j8mr4603939ilq.217.1623443985751; Fri, 11 Jun 2021 13:39:45 -0700 (PDT) Received: from presto.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id y9sm3761544ilp.58.2021.06.11.13.39.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 13:39:45 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: leon@kernel.org, bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, aleksander@aleksander.es, ejcaruso@google.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/3] net: ipa: introduce ipa_version_valid() Date: Fri, 11 Jun 2021 15:39:39 -0500 Message-Id: <20210611203940.3171057-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210611203940.3171057-1-elder@linaro.org> References: <20210611203940.3171057-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Define and use a new function that just validates the version defined in configuration data. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_main.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c index 9915603ed10ba..cbd39e4667a32 100644 --- a/drivers/net/ipa/ipa_main.c +++ b/drivers/net/ipa/ipa_main.c @@ -639,6 +639,27 @@ static void ipa_validate_build(void) #endif /* IPA_VALIDATE */ } +static bool ipa_version_valid(enum ipa_version version) +{ + switch (version) { + case IPA_VERSION_3_0: + case IPA_VERSION_3_1: + case IPA_VERSION_3_5: + case IPA_VERSION_3_5_1: + case IPA_VERSION_4_0: + case IPA_VERSION_4_1: + case IPA_VERSION_4_2: + case IPA_VERSION_4_5: + case IPA_VERSION_4_7: + case IPA_VERSION_4_9: + case IPA_VERSION_4_11: + return true; + + default: + return false; + } +} + /** * ipa_probe() - IPA platform driver probe function * @pdev: Platform device pointer @@ -676,11 +697,15 @@ static int ipa_probe(struct platform_device *pdev) /* Get configuration data early; needed for clock initialization */ data = of_device_get_match_data(dev); if (!data) { - /* This is really IPA_VALIDATE (should never happen) */ dev_err(dev, "matched hardware not supported\n"); return -ENODEV; } + if (!ipa_version_valid(data->version)) { + dev_err(dev, "invalid IPA version\n"); + return -EINVAL; + } + /* If we need Trust Zone, make sure it's available */ modem_init = of_property_read_bool(dev->of_node, "modem-init"); if (!modem_init)