From patchwork Thu Feb 22 20:57:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 205051 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp205351dyb; Thu, 22 Feb 2024 12:58:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWBLv89J0RUrG3VgF6xSt2Z83uZ5pGasv0QNx/E5yRtZDxw6t8aM28uc52wkhjMXbbY3T9iopCMQ1PPylw7I5b+gVy1iw== X-Google-Smtp-Source: AGHT+IFOfLnXSdjSNOqcaViCBkIrgmu3gumJxsKmP7k6fK3JgRF+lUUkIvFAvko5UdZ2v9Uag0+q X-Received: by 2002:ac8:44b3:0:b0:42e:5f2b:7e45 with SMTP id a19-20020ac844b3000000b0042e5f2b7e45mr122538qto.49.1708635519811; Thu, 22 Feb 2024 12:58:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708635519; cv=pass; d=google.com; s=arc-20160816; b=WadgYMh+liydzSGI/58TvB834FAX8JVPVz7vHIEq/lu56VpUuNSPiI02NgKBe8fd5p KMYAy+zui8Zj0Gguz+MJ/vPISzpw9RfBGKCiAo6Tsvox9n6q73xwEQyRKouQPiFfbwnb GaDVS4ejgBdnpEsXpGZ1iGGs/+nqV1f8KgvdqNDOqbHh+OHvuFuJv1/S1KyR4X+xvakF v1YxAorvxX19HTCoAKIZfpFCCadzdP78AmUmMdLB0xpXoGfdf7OQpAucnIZ//9zbk5DC 4tbrGd9vwm2AAIZGen1gunzkKSHam3zZBGdO+jfnMtCc6p7UZZxzdXuXYmp+eocr71V0 w5Nw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=vnuwxZrLi92WYaoyoAhB2T7aK4APtF+lWO0JDf5B6mU=; fh=l74HcAni2UfQJngIxo7C8HfGMgimKQ1jenNpkLLX2CQ=; b=ZXXIApiQUVhBffinRDGBJCHXeqA0yHA8R+HhXGiWWkn1h+1qDcFjvq2CVbWTtOCamQ ReE8qQTO38vEf69RmbH0aFy+2OcK9yDLkt2oQq+4mtIn/4WQZJ/9CLPpqteGKLkNBD54 igUNvL4HM5R/Waj3qt3/3hu/RV4ndytLHxtlSUJst9MAHaKFE0L8zZtxYmR3I/38n6+l S/EeGoRbdUOUZ7nX6cLduw5tmNoT9W5BACqhqpc1jTggJ1IKyUUDWoKFLLLtLAMElUHf Xi0FIGK2LuxgKcVsxB72DdeRpZfNR1qsV13wXYZk4VovRTrHcxbim8uprKey8sh2QJHl dEtQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DcofIHS8; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-77348-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77348-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id k7-20020ac85fc7000000b0042e1b85483esi9101941qta.87.2024.02.22.12.58.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:58:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77348-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DcofIHS8; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-77348-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77348-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8AE441C256CD for ; Thu, 22 Feb 2024 20:58:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A198171750; Thu, 22 Feb 2024 20:58:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DcofIHS8" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5FA771758 for ; Thu, 22 Feb 2024 20:58:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708635485; cv=none; b=MzJY25cf9l8Aqk1rwDZSNFfR0CQzj96rVnfoVUFY98f08m5GCc7fPS1XEC8y+o39grruIWaFc+4eHylF3d+aTaaTvt5t/rZSQzQ2c5xYkviBWFs9Rbs5ZgkLmfS3IWLYo/P/ZEDrEMrDH0rRizSA4/d7nQZz7nZzZO/77fZONIQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708635485; c=relaxed/simple; bh=RYF/zx8lxVWlX0R60jvZqrw1QrH/wfXhiW3cenHTKEo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c7VHlnkg4lto4voWgxy4g3Sm94amGaMyTo8s8GmZw26eOz4o11YBmkcjZqyij8fmkaBm0jsS+iK4ZeYiHU/Ia5DYWYj9o/Zd5YHcwhs/SDmHrLHp3d0d4KvoosBvQdl8wezZ0Vb/Ku9SxRGpKQJrJvwZsnm3xCQZxogt8f/gSAM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DcofIHS8; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708635482; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vnuwxZrLi92WYaoyoAhB2T7aK4APtF+lWO0JDf5B6mU=; b=DcofIHS8GlItP4dmmXWttfVVk1SZVDbTiHSqfnyvhQ2p36v1+UHEX5UGHJaVdtpAjPffRY 5S+LMIo7tc6jTp4cfRjVzfmSiJnU3oiGjexmxfFYDP6nfRTehIcxqc20YZvB87X4whHlO6 8HqaS8A0U/bjTeY+L0VboYI0qRNt4jY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-fF_JvuC2OfKQu_nuUtCNjw-1; Thu, 22 Feb 2024 15:57:59 -0500 X-MC-Unique: fF_JvuC2OfKQu_nuUtCNjw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 179AA1065221; Thu, 22 Feb 2024 20:57:59 +0000 (UTC) Received: from ibm-p8-16-fsp.mgmt.pnr.lab.eng.rdu2.redhat.com (unknown [10.22.8.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5B66D10800; Thu, 22 Feb 2024 20:57:58 +0000 (UTC) From: Luiz Capitulino To: ilpo.jarvinen@linux.intel.com, shravankr@nvidia.com Cc: davthompson@nvidia.com, ndalvi@redhat.com, linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, Luiz Capitulino Subject: [PATCH 1/2] platform/mellanox: mlxbf-pmc: mlxbf_pmc_event_list(): make size ptr optional Date: Thu, 22 Feb 2024 15:57:29 -0500 Message-ID: <182de8ec6b9c33152f2ba6b248c35b0311abf5e4.1708635408.git.luizcap@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791634198762391796 X-GMAIL-MSGID: 1791634198762391796 The mlxbf_pmc_event_list() function returns a pointer to an array of supported events and the array size. The array size is returned via a pointer passed as an argument, which is mandatory. However, we want to be able to use mlxbf_pmc_event_list() just to check if a block name is implemented/supported. For this usage passing the size argument is not necessary so let's make it optional. Signed-off-by: Luiz Capitulino Reviewed-by: Hans de Goede --- drivers/platform/mellanox/mlxbf-pmc.c | 40 +++++++++++++++------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/platform/mellanox/mlxbf-pmc.c b/drivers/platform/mellanox/mlxbf-pmc.c index 250405bb59a7..b71636eb3db1 100644 --- a/drivers/platform/mellanox/mlxbf-pmc.c +++ b/drivers/platform/mellanox/mlxbf-pmc.c @@ -966,32 +966,33 @@ static bool mlxbf_pmc_valid_range(unsigned int blk_num, u32 offset) } /* Get the event list corresponding to a certain block */ -static const struct mlxbf_pmc_events *mlxbf_pmc_event_list(const char *blk, size_t *size) +static const struct mlxbf_pmc_events *mlxbf_pmc_event_list(const char *blk, size_t *psize) { const struct mlxbf_pmc_events *events; + size_t size; if (strstr(blk, "tilenet")) { events = mlxbf_pmc_hnfnet_events; - *size = ARRAY_SIZE(mlxbf_pmc_hnfnet_events); + size = ARRAY_SIZE(mlxbf_pmc_hnfnet_events); } else if (strstr(blk, "tile")) { events = mlxbf_pmc_hnf_events; - *size = ARRAY_SIZE(mlxbf_pmc_hnf_events); + size = ARRAY_SIZE(mlxbf_pmc_hnf_events); } else if (strstr(blk, "triogen")) { events = mlxbf_pmc_smgen_events; - *size = ARRAY_SIZE(mlxbf_pmc_smgen_events); + size = ARRAY_SIZE(mlxbf_pmc_smgen_events); } else if (strstr(blk, "trio")) { switch (pmc->event_set) { case MLXBF_PMC_EVENT_SET_BF1: events = mlxbf_pmc_trio_events_1; - *size = ARRAY_SIZE(mlxbf_pmc_trio_events_1); + size = ARRAY_SIZE(mlxbf_pmc_trio_events_1); break; case MLXBF_PMC_EVENT_SET_BF2: events = mlxbf_pmc_trio_events_2; - *size = ARRAY_SIZE(mlxbf_pmc_trio_events_2); + size = ARRAY_SIZE(mlxbf_pmc_trio_events_2); break; default: events = NULL; - *size = 0; + size = 0; break; } } else if (strstr(blk, "mss")) { @@ -999,43 +1000,46 @@ static const struct mlxbf_pmc_events *mlxbf_pmc_event_list(const char *blk, size case MLXBF_PMC_EVENT_SET_BF1: case MLXBF_PMC_EVENT_SET_BF2: events = mlxbf_pmc_mss_events_1; - *size = ARRAY_SIZE(mlxbf_pmc_mss_events_1); + size = ARRAY_SIZE(mlxbf_pmc_mss_events_1); break; case MLXBF_PMC_EVENT_SET_BF3: events = mlxbf_pmc_mss_events_3; - *size = ARRAY_SIZE(mlxbf_pmc_mss_events_3); + size = ARRAY_SIZE(mlxbf_pmc_mss_events_3); break; default: events = NULL; - *size = 0; + size = 0; break; } } else if (strstr(blk, "ecc")) { events = mlxbf_pmc_ecc_events; - *size = ARRAY_SIZE(mlxbf_pmc_ecc_events); + size = ARRAY_SIZE(mlxbf_pmc_ecc_events); } else if (strstr(blk, "pcie")) { events = mlxbf_pmc_pcie_events; - *size = ARRAY_SIZE(mlxbf_pmc_pcie_events); + size = ARRAY_SIZE(mlxbf_pmc_pcie_events); } else if (strstr(blk, "l3cache")) { events = mlxbf_pmc_l3c_events; - *size = ARRAY_SIZE(mlxbf_pmc_l3c_events); + size = ARRAY_SIZE(mlxbf_pmc_l3c_events); } else if (strstr(blk, "gic")) { events = mlxbf_pmc_smgen_events; - *size = ARRAY_SIZE(mlxbf_pmc_smgen_events); + size = ARRAY_SIZE(mlxbf_pmc_smgen_events); } else if (strstr(blk, "smmu")) { events = mlxbf_pmc_smgen_events; - *size = ARRAY_SIZE(mlxbf_pmc_smgen_events); + size = ARRAY_SIZE(mlxbf_pmc_smgen_events); } else if (strstr(blk, "llt_miss")) { events = mlxbf_pmc_llt_miss_events; - *size = ARRAY_SIZE(mlxbf_pmc_llt_miss_events); + size = ARRAY_SIZE(mlxbf_pmc_llt_miss_events); } else if (strstr(blk, "llt")) { events = mlxbf_pmc_llt_events; - *size = ARRAY_SIZE(mlxbf_pmc_llt_events); + size = ARRAY_SIZE(mlxbf_pmc_llt_events); } else { events = NULL; - *size = 0; + size = 0; } + if (psize) + *psize = size; + return events; }