Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp474958lqo; Thu, 16 May 2024 11:26:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVMvG43MsFlPy/dx2tboU69WddVP7HkeEBL90t4QssEdNdrU9rjXWSQYQTXw8gR1u1jD0To9qPwzj2hDYVKXOKNSlzDau2rW6dlKSkEOA== X-Google-Smtp-Source: AGHT+IG0y8KbzsYXqpOKOeFCjOvmWx2Htdlqga0DozqqwqAtFecHVA3wPZfdLboz+OaOZb2+b87b X-Received: by 2002:a05:6a00:391a:b0:6f3:ebb3:6bc3 with SMTP id d2e1a72fcca58-6f4e026b090mr22740509b3a.3.1715883970198; Thu, 16 May 2024 11:26:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715883970; cv=pass; d=google.com; s=arc-20160816; b=FNb4IsBXRVDMHqvTm5TnNn/qi2aqigBrcmc4GmzUUgIjsTEJMsj/pcxz2DktbQyw80 t9OBZIUf1SwW7GO+G5rSECsFqoc1pNDq9p7Zc+cpesk6ix32P4r7UsVKIQvz1IhfcgiN oTicZ4wJ4QlwgYWLKUzJtnBEc83m2dfdkjauQTozIt9w3DK3QD04nUNgDLxtVpw68mm7 s5ba5OGw/7057b5JLjwuxfM8uvyMyaRXEtmN22f9uywMi3sJ6Rhn1kKFmHTnIQSuIB/T FXr/MKQRbvZq0LQwxiJl2hAkkR6qsStUusg9v+PyDepVbzl0YPncDEUk7OKW2FZQynlT I10A== 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=r7jucx4EDwcx4QmKdJY/B/BWs7eG+xdxvoZ3FO/I2uA=; b=fSJR0tRtoT3Bc28B3EEyXVwzYmlii25NaYyoof34V2rfaLG6bfTS7dbk+myE97lBTe wUpYdkFdJCLz0yTdn0LlrAiuU3zEQ2A0MML/I+ts8aCUokkB1Jw6bK5asqf/lWuA16Of QTLDnaAE/K+8o1duKGenE/rysQoG3m6ihlusrmn+Cu5DXXgS6yb3XNXSHttJJwNzWY42 GYzuGQfSpR5a++PlowLhjGimEOYXmBQ/xY3qgbOLHqmGyrvHp2j5S1hMkl+8+Ccq9vim uu4EOFgzmK2nAjnZMAfmrTTtV4JyvDUDAxnNKbPisgd0mcbDwOuUb3Yst5xmvkchW3uR EURQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Ey1A+RcY; 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-181447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181447-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2b1de09si1428165b3a.294.2024.05.16.11.26.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 11:26:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Ey1A+RcY; 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-181447-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181447-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 6050CB231F3 for ; Thu, 16 May 2024 18:23:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C744515B129; Thu, 16 May 2024 18:19:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Ey1A+RcY" 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 B4ED015820F; Thu, 16 May 2024 18:19:34 +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=1715883576; cv=none; b=Erfs/Yu8Agj1z3VCsb7Kn/wbEfAJdv40azlxIolyCWLpD7KbsviNQwvZC6MfrKPrY5vpggtVDWpproB2KYBkADGFK7qobA2Curd8SGm2aIWkrLRWLiyvYatAPy+ECPutmtd8KyPbWpj8wXm2Kr2ooNi73xLXI4Ri9c0s8tOQgTE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715883576; c=relaxed/simple; bh=XNrRONtL68Pz4zCpeEiE+IkzuNnZ7Cayb/AUOF/wCFs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fpLq2C4gmntwD9yOGPVVUAaliamuOV8+kTAzWh9Ffn0Dfj0DOHRREjZiOM6+SDd4YbDXtG9xilD0LZdVtdqQazUUE1uOGwx7u+ipmG/gt6CRfgAmrP1X2K4WiIoxJKiT07MfwihCNNqzlf6nLIkLKy4r6NPMySb169aVigxHGdY= 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=Ey1A+RcY; 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 (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44GHgj1M003338; Thu, 16 May 2024 18:19:16 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=cejzBxtcEByI+xMESV4H8QqE4nNOLYSRaK7OFmvEFBE=; b=Ey1A+RcYq/mj91g9t8GMTZHiHVLGQ0UJvhWzQI7pD2gRfHD5jPy90uzffzYap+D5msJx W3SWH74GLFQRkEEDijAYSK25GkfqWnQFZlIpOsMgyOTHPYLbKDWdLIKHGz3ZAopbx/2p 5Daki9+KlDb5rtqPO650LYcMdjoOQhML4v5408QafgE8KDCOaGNmanBAUZe4pCESnCrm MeN/kCusiohclpoGP//XSyIV+4jDhaLNrLzpwnxjHkmj2SvVc851xaABW6GBLSx25USa 3ZySroFoBKLuBpdKHXPkXN3sPdstjZWmOb/6ghqUjfhUzLHokPtZPHr5XPoGjtIwf+FC nw== Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3y5pse82ht-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 May 2024 18:19:16 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 44GIAFtU002257; Thu, 16 May 2024 18:19:15 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3y2m0pkfug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 May 2024 18:19:15 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 44GIJChx24052232 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 May 2024 18:19:15 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D18B75808B; Thu, 16 May 2024 18:19:10 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9AF2D58072; Thu, 16 May 2024 18:19:10 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.107.19]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 16 May 2024 18:19:10 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: 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, eajames@linux.ibm.com Subject: [PATCH v3 11/40] fsi: core: Allow cfam device type aliases Date: Thu, 16 May 2024 13:18:38 -0500 Message-Id: <20240516181907.3468796-12-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240516181907.3468796-1-eajames@linux.ibm.com> References: <20240516181907.3468796-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-ORIG-GUID: 12oT6ApGIe3bN8Ru7iVyyvIOj8pZQr2B X-Proofpoint-GUID: 12oT6ApGIe3bN8Ru7iVyyvIOj8pZQr2B X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-16_07,2024-05-15_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 priorityscore=1501 spamscore=0 impostorscore=0 phishscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405160132 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