From nobody Fri Nov 29 18:47:59 2024 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 6B6BD18D64D for ; Tue, 17 Sep 2024 17:17:06 +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=1726593428; cv=none; b=GJd5uQPwvPyDot29eiwDSbUehLT8SaU0yRJevF1oOLzI8a8B+wTesAn2w9chPOG5DwLokrYPPujYeo+8SHdA3LZlHXCNam6cWnrF7fxv9skg2GezbMNwdt+ZoienR4CvR0byl0qtq65bfkdwAPbrfzJFhhAV4N5Pu18+PqI9e4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726593428; c=relaxed/simple; bh=aDmN+JDJ2BIpO+GaUDF44DoE6sgvIZY/19vRTtDzI1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nzjTbSCVk0Ue0/wFw0rZieQ256gWHeSiz4p7kXFIcjL517c7Q82T2twSINyQc7RUH5kmFkIRX+jtSlyhyvxD69Ieb8OHnEyBSdytiTvWptfGyNWXfNT2jAMLTmmhlNtYkJZgua9qdasPK6OY+HrYnDFFyoIenVvpkJ4pEiImX4g= 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=FdpkyxSx; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="FdpkyxSx" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48H8NeA0031131; Tue, 17 Sep 2024 17:16:52 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=pp1; bh=0FCe65XpXW3TT 8WBepFrTafqyrJDuXoxXws8M69C6rQ=; b=FdpkyxSx2b6T0gullaxtchAQNcAn6 WQCGEKQxkkDW8k0d9DDrjgXTChfhnS45xFiE+54JN5kYOFHXMTDmR21KwSOUsAOT vGS2nSmoX0G5WN+yLexNpxrAOlk+XNL+LZMmnSVFQFuPPOZDPdOfz4MeiZu3WadZ Z8fdsrm/BhvbL6CISqmMJCjJ1+NZtPQ3/KHkfFNf3JuleBOmauJkkKUlCt6yRJjR zGAHpaJOqJ4gxvmyax3kcInfYwhbOSHys18h8MIRpoPIlPU2gmuYOqsVphq358XT +/UeBXdlBi4Nsk16j4/1FiRDtqB7D1kPJhAfSkl5ofMJx/7uLQScNYsbw== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 41n3vnrxu4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Sep 2024 17:16:51 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 48HF9XOD001918; Tue, 17 Sep 2024 17:16:50 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 41nmtupq76-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Sep 2024 17:16:50 +0000 Received: from smtpav01.dal12v.mail.ibm.com (smtpav01.dal12v.mail.ibm.com [10.241.53.100]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 48HHGosT61210934 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Sep 2024 17:16:50 GMT Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 15BB158057; Tue, 17 Sep 2024 17:16:50 +0000 (GMT) Received: from smtpav01.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DE18E58058; Tue, 17 Sep 2024 17:16:49 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.93.228]) by smtpav01.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 17 Sep 2024 17:16:49 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, andrew@codeconstruct.com.au, eajames@linux.ibm.com, ninad@linux.ibm.com Subject: [PATCH 10/15] fsi: core: Allow cfam device type aliases Date: Tue, 17 Sep 2024 12:16:42 -0500 Message-ID: <20240917171647.1403910-11-eajames@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240917171647.1403910-1-eajames@linux.ibm.com> References: <20240917171647.1403910-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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: N6BNQRlsPRh9CR984pyBHIAXiBqqzU2n X-Proofpoint-GUID: N6BNQRlsPRh9CR984pyBHIAXiBqqzU2n X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-17_08,2024-09-16_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=999 priorityscore=1501 phishscore=0 clxscore=1015 malwarescore=0 bulkscore=0 impostorscore=0 spamscore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2408220000 definitions=main-2409170122 Content-Type: text/plain; charset="utf-8" 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 eea5bbdb00b6..7e73dd035b4e 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 } =20 -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[] =3D { + "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 =3D slave->chip_id; int id; =20 + if (np && type < 4) { + int aid =3D of_alias_get_id(np, fsi_dev_type_names[type]); + + if (aid >=3D 0) { + /* Use the same scheme as the legacy numbers. */ + id =3D (aid << 2) | type; + id =3D ida_alloc_range(&fsi_minor_ida, id, id, GFP_KERNEL); + if (id >=3D 0) { + *out_index =3D aid; + *out_dev =3D fsi_base_dev + id; + return 0; + } + + if (id !=3D -ENOSPC) + return id; + } + } + /* Check if we qualify for legacy numbering */ if (cid >=3D 0 && cid < 16 && type < 4) { /* @@ -918,36 +943,10 @@ static int __fsi_get_new_minor(struct fsi_slave *slav= e, enum fsi_dev_type type, return 0; } =20 -static const char *const fsi_dev_type_names[] =3D { - "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 =3D of_alias_get_id(fdev->dev.of_node, fsi_dev_type_names[type]); - - if (aid >=3D 0) { - /* Use the same scheme as the legacy numbers. */ - int id =3D (aid << 2) | type; - - id =3D ida_alloc_range(&fsi_minor_ida, id, id, GFP_KERNEL); - if (id >=3D 0) { - *out_index =3D aid; - *out_dev =3D fsi_base_dev + id; - return 0; - } - - if (id !=3D -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); =20 @@ -1059,7 +1058,7 @@ static int fsi_slave_init(struct fsi_master *master, = int link, uint8_t id) } =20 /* Allocate a minor in the FSI space */ - rc =3D __fsi_get_new_minor(slave, fsi_dev_cfam, &slave->dev.devt, + rc =3D __fsi_get_new_minor(slave, slave->dev.of_node, fsi_dev_cfam, &slav= e->dev.devt, &slave->cdev_idx); if (rc) goto err_free; --=20 2.43.0