Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp570827lqr; Wed, 5 Jun 2024 14:29:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVPjG2lfcILRaox312VUdjWcsY3Zn7fKsFtTKrXxEWNaYiIjFYytE7+xA2UMcXEXr3SfdmBKRtwor1NXKIOhBteWBjRbIHXtTIfVwcCzA== X-Google-Smtp-Source: AGHT+IF9mu4WeD2y76k0nRFjPNhaOt2B9nEJOiHCr/aMhfdHYcgiHLbORpCleGtceLSmv2a0sbA0 X-Received: by 2002:ae9:c119:0:b0:793:1c64:131e with SMTP id af79cd13be357-79523fc28ecmr370795385a.50.1717622986693; Wed, 05 Jun 2024 14:29:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717622986; cv=pass; d=google.com; s=arc-20160816; b=jeADvxmDbT6woi2iHdVsgf/8QzCicZuxdBBJ6rflBaAJJREZDjGMet5c5DM+xdVJdH rV2BaPlStzcNKpxi1vN62or2hvfzqwUs+QhLv2ZDWnw55dENHcUQIAwmeWG/OKxRiz7q fGomqcrX9qBNdJEIysnD2rzz5TkNksAnjNbRhgz6OelzhMWHjerGLQClyHZZ0rTm4jKR Cw/1EEBCsoaA1gMjfO+qRnK0LM8ADeshtNHyyI7sOCI0T4zMCCGJ+OQdSlVAnhAzaD6+ 88pmRmkYtizFZAuzusHe71XIVfgZxel/c9Dm1MvMfitTu17I+j/RkmmfMV7q/2bwxrYC Qd7g== 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=cejzBxtcEByI+xMESV4H8QqE4nNOLYSRaK7OFmvEFBE=; fh=F5i+rNW4hjf57QJHDx14Nq4Eso4Z4OyY/LhC2i40VT4=; b=HYSIFzN4CdPSt67OxLcCnG7M9+DTi/6NIS5NPB1LU/KBPTkwOcdeQdog0DfoGFN6Zg Fv42O/x0swns7Dj0LrvLyxsuw0bUmgRSoEm0WnnLICtWZJ5Wfn5W0vc5VuFPMSTBRp+t /ELQ/9PTUJabLI5rGzkS1CTJdwBwmLnafSjr10hqm7MjN/uVzFfTL5I5uAQJ4X/1LRfh dxR3rkFyYE650rMIEBIE0tg+41E9O/RBcMyyOSsxOiNBUBFKLDQr+OG8V0E3eoCHkQ9m v8TcULC4nWY0wSZOwjrzFOZWSn6IMan9t22Z+JG3eN1TUp0xTaz15WMWLlwKFCTDbHfX Wxcg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ioyAb1w0; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-203284-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203284-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-79516fa5ce7si405042285a.44.2024.06.05.14.29.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 14:29:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203284-linux.lists.archive=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=@ibm.com header.s=pp1 header.b=ioyAb1w0; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-203284-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203284-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.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 5E1511C21BB5 for ; Wed, 5 Jun 2024 21:29:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 454EA18629A; Wed, 5 Jun 2024 21:23:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="ioyAb1w0" Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 0F2D316FF22; Wed, 5 Jun 2024 21:23:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622627; cv=none; b=qUWESTge3Us3+Apqs7SI05lb+Y9LpuohaZSdVXLXPTkeQsJiCrOCGAxOyCwCArzrw3uPI+K+t4pM4NuOJdSJ0IpCsBJKXIlJhEMQHZZPY1R2hlyM1BpxwxB4WkIYSV/gkC/wixJkZUUt5aPKcmq4bv+WKJdUuDJ1GtEOBRK+sfs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622627; c=relaxed/simple; bh=XNrRONtL68Pz4zCpeEiE+IkzuNnZ7Cayb/AUOF/wCFs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JrG7yRCAwMldLhICMlaZZ0Ojs0nSoWuuk9DQejQFJjfCSLE8a/YwFNuamDK1mn5zGQYmUZxXayhMFAnXrfl6B7YJe6mUECMQJXcD/6cAZAuQROezxqwNYjRqzDwF3nHohVgOymjKfP9RE8vchtyQSLs/XgYQboy92fFkua8bD/A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=ioyAb1w0; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455L225X000941; Wed, 5 Jun 2024 21:23:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc : content-transfer-encoding : date : from : in-reply-to : message-id : mime-version : references : subject : to; s=pp1; bh=cejzBxtcEByI+xMESV4H8QqE4nNOLYSRaK7OFmvEFBE=; b=ioyAb1w0585qU6CaHMcgcicOMtHeMUvRmJDSfhWxR5cwxKvFkB4CIBxDOB+MPhaBwdMh UpnrB7rGC1utOLVe/oqGQaCVVtMPf5amf29IuAuJBfwUEmD4mTLYaq9u8kZcbh/mZBTH PFRWzgU+Jv9m4Z6Fd6KF7cB9aaoeNjq5v2WhiYaheg3pE76wGDf6r4OfBaRIeu7pdVyM nBKbDH1w3s/5nanjTR3VRNM56KLPYu3iL/Ka/OWCD4pfCGJYEc8Ory30/a+h75ICPX5F 3ycmYsW48iWjqJaROatnQDCBTzeyh+SDUrWcq1t1SCKUSh7lWD8hIkYcuqJ3hyC1Appd Ug== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yjxbg09vp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:21 +0000 Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 455KMO2f022835; Wed, 5 Jun 2024 21:23:21 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ygg6med3x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:21 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNIfs57934222 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:20 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B204A5806F; Wed, 5 Jun 2024 21:23:16 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 75F925806D; Wed, 5 Jun 2024 21:23:16 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.121.242]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Wed, 5 Jun 2024 21:23:16 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: eajames@linux.ibm.com, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, broonie@kernel.org, andi.shyti@kernel.org, joel@jms.id.au, alistair@popple.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, linux-aspeed@lists.ozlabs.org, ninad@linux.ibm.com, lakshmiy@us.ibm.com Subject: [PATCH v4 11/40] fsi: core: Allow cfam device type aliases Date: Wed, 5 Jun 2024 16:22:43 -0500 Message-Id: <20240605212312.349188-12-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240605212312.349188-1-eajames@linux.ibm.com> References: <20240605212312.349188-1-eajames@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: L36lbHd8U_-4VPslOZbKWIRElqd6FP7j X-Proofpoint-ORIG-GUID: L36lbHd8U_-4VPslOZbKWIRElqd6FP7j X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-05_02,2024-06-05_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 malwarescore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 Other FSI devices can uses aliases for the device numbering, so modify the function to get a new minor to allow the cfam type to use aliases too. Signed-off-by: Eddie James --- drivers/fsi/fsi-core.c | 59 +++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c index 660f89b743235..36e31eafad3d0 100644 --- a/drivers/fsi/fsi-core.c +++ b/drivers/fsi/fsi-core.c @@ -884,12 +884,37 @@ static int fsi_adjust_index(int index) #endif } -static int __fsi_get_new_minor(struct fsi_slave *slave, enum fsi_dev_type type, - dev_t *out_dev, int *out_index) +static const char *const fsi_dev_type_names[] = { + "cfam", + "sbefifo", + "scom", + "occ", +}; + +static int __fsi_get_new_minor(struct fsi_slave *slave, struct device_node *np, + enum fsi_dev_type type, dev_t *out_dev, int *out_index) { int cid = slave->chip_id; int id; + if (np && type < 4) { + int aid = of_alias_get_id(np, fsi_dev_type_names[type]); + + if (aid >= 0) { + /* Use the same scheme as the legacy numbers. */ + id = (aid << 2) | type; + id = ida_alloc_range(&fsi_minor_ida, id, id, GFP_KERNEL); + if (id >= 0) { + *out_index = aid; + *out_dev = fsi_base_dev + id; + return 0; + } + + if (id != -ENOSPC) + return id; + } + } + /* Check if we qualify for legacy numbering */ if (cid >= 0 && cid < 16 && type < 4) { /* @@ -918,36 +943,10 @@ static int __fsi_get_new_minor(struct fsi_slave *slave, enum fsi_dev_type type, return 0; } -static const char *const fsi_dev_type_names[] = { - "cfam", - "sbefifo", - "scom", - "occ", -}; - int fsi_get_new_minor(struct fsi_device *fdev, enum fsi_dev_type type, dev_t *out_dev, int *out_index) { - if (fdev->dev.of_node) { - int aid = of_alias_get_id(fdev->dev.of_node, fsi_dev_type_names[type]); - - if (aid >= 0) { - /* Use the same scheme as the legacy numbers. */ - int id = (aid << 2) | type; - - id = ida_alloc_range(&fsi_minor_ida, id, id, GFP_KERNEL); - if (id >= 0) { - *out_index = aid; - *out_dev = fsi_base_dev + id; - return 0; - } - - if (id != -ENOSPC) - return id; - } - } - - return __fsi_get_new_minor(fdev->slave, type, out_dev, out_index); + return __fsi_get_new_minor(fdev->slave, fdev->dev.of_node, type, out_dev, out_index); } EXPORT_SYMBOL_GPL(fsi_get_new_minor); @@ -1059,7 +1058,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) } /* Allocate a minor in the FSI space */ - rc = __fsi_get_new_minor(slave, fsi_dev_cfam, &slave->dev.devt, + rc = __fsi_get_new_minor(slave, slave->dev.of_node, fsi_dev_cfam, &slave->dev.devt, &slave->cdev_idx); if (rc) goto err_free; -- 2.39.3