Received: by 2002:ab2:644:0:b0:1ec:cbc4:63fb with SMTP id 4csp1150295lqn; Mon, 26 Feb 2024 09:03:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWgKFqocsy0D4fyPrW+4M+MNVwAk14RUFFS5RNXqItD/1SC97dk0YvcVooHKetAm0uMDpQqsr31ic5RROaDT0cu7P6XE4WyF5IfNcUcjw== X-Google-Smtp-Source: AGHT+IHAO4/uDVSdIjOm6JkHrrMEpAq4/cBLziZbT4oQv5BI+hXYe4N50blaI5BI/nI8CrkF0NN8 X-Received: by 2002:a05:6808:150a:b0:3c1:ab39:7ee6 with SMTP id u10-20020a056808150a00b003c1ab397ee6mr569232oiw.37.1708967033141; Mon, 26 Feb 2024 09:03:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708967033; cv=pass; d=google.com; s=arc-20160816; b=JALOHXJT24DWS+nSEWByuz7eqsRSoXFNXZ3Dv3Kn9Mix/ywsdwR+3rrpb+Fu6+T7wd 9NOuyktq2kZj0vIrewfUMJTlbcfpwYEmwPV/btM8FmZU5Df4zhbufB1UHyFOFiKxsrS+ xxbAdrjrimMOqOchbrioAvVADJOYi/3qGhkiY0gfH+FUa2+y7IoSX1/loYZ7USLIRZuo nl7bZFOLZEkcJ5cdni2Sr4OGyjMd7f9R5vhOi0m/TW7XkFIFFcMXyAHybQtZrNRcxUSz ox3/FKuSf3qUT68RsoK747r4H733ZQpkPTu0Ul2LpIkFi8CV5d0ZydkpzJATqZNqe+sE mZgw== 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=njZMmA5i9z9+KJhOIDW6auHi8a7ZavWPmGAbuJxdb8I=; fh=hD87NRI2uXFKH7lntJG4G4naYHSrGp3lxTKSbIyEdj8=; b=WgSRF72GUJLzf7uKARghBxkxI/i6n8KO+4yfRVxDIOaaPOK5xRal6T9nt0O7Q74n19 a1MPA/CStrTorlY0knaE/7snSzb8u5boH1teTpWOwcDl+FaYm9NxGvPFVOswPZFskOCT mWxRVMoD4r4FVBRpUFvmQFfshhEUvp3n0R5Bn1M9yq3FH4ddLFQc4O2Kpte1I+J2ZDO1 q75N65sXCvofOWfedrod/oF4IsmUVOaYU2kkYSjKH5AMRwCp2WE91rsKEXkBkh+z+YIh Qk/gYWy4+gS2ieRrksLSSe54xdXa/7vVMaw8gDuW3K2qDmWHXlIoOLOpU8a+BCihr9xE QXSw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Qe30t4RZ; 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-81981-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81981-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. [147.75.199.223]) by mx.google.com with ESMTPS id ch20-20020a0561300c9400b007d9d41e4f1asi741257uab.112.2024.02.26.09.03.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 09:03:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81981-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Qe30t4RZ; 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-81981-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81981-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 45DB21C29B8A for ; Mon, 26 Feb 2024 17:03:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8E06B13848B; Mon, 26 Feb 2024 16:54:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Qe30t4RZ" 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 A0C03136981; Mon, 26 Feb 2024 16:54:03 +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=1708966445; cv=none; b=fLBeijiZz83mERMf29JIib54NXtb6ElE7cFQK726sPkUyucw+GFQPSQ9xxvP3Jvm7AkGtrfL68CFt1diJTGS3N9OrZNNW4anni4PMKnRAg0t/7Du1QvhANhX9PrH4R61z6Ml86qSej8IPXy2s5eHiLusU/Dk8sGIxzwwDxGGwxA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708966445; c=relaxed/simple; bh=BmpHIcdLad4je9edWwtINpVsWPUVd4TCH6j5XSMsz9U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Q6GW6X5bkb0WEJ4hoBroUrtLByj2ZpekijsTWzRr9TtCaKYqa0vsiOCoWt0pBavDII1Zp7IudluyqppE+YeBhvrXBjbPucgrrWJwuFaVyL7gmjPa6auYyO/UkIrbi2bVLZPN7UTwSYwVMH/zWDNDqgCOoV2HAkikEc8Fm9Mz/xo= 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=Qe30t4RZ; 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 (m0353722.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 41QF2jEb021800; Mon, 26 Feb 2024 16:53: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=njZMmA5i9z9+KJhOIDW6auHi8a7ZavWPmGAbuJxdb8I=; b=Qe30t4RZTgn7Gbc1D1HLUj0HxljJjxsTLcdURZcEdvtYkkK3z6UBV6b5dqx+ucDbMn0b skdcgocXW5A9JEbAf+Ydelc/GLEqqOoncJSrz3JTntiIWf+XVvidXO1Db6pVIG0sw0dy ThG6v76ZKgAnq9Pssyud34UpGHoTIUEWH7aMH1uTUr4oWzW0UVioHjFqm3X3fqLbtovk /iBwT95QY0KNlryF3Ldk09kIofyed4fN+a6UGWzgehdfGyjjazD1I6ldB95L80dpNV1g o8bj2yfA5iLQnwbqhExk0BTNA9sFbEL8g1tD4DF9wcyVq7OF6C+FgweraKXZWcVBuoJb LQ== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wgvp6bkkf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:49 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 41QFvbie012371; Mon, 26 Feb 2024 16:53:48 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3wfwg21xxd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 16:53:48 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 41QGrjkG29622572 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Feb 2024 16:53:47 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4861C5805F; Mon, 26 Feb 2024 16:53:45 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 90ABA58043; Mon, 26 Feb 2024 16:53:44 +0000 (GMT) Received: from slate16.aus.stglabs.ibm.com (unknown [9.61.57.130]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 26 Feb 2024 16:53:44 +0000 (GMT) From: Eddie James To: linux-fsi@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, andi.shyti@kernel.org, eajames@linux.ibm.com, alistair@popple.id.au, joel@jms.id.au, jk@ozlabs.org, robh@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, lakshmiy@us.ibmcom Subject: [PATCH v2 28/31] i2c: fsi: Remove list structure of ports Date: Mon, 26 Feb 2024 10:53:18 -0600 Message-Id: <20240226165321.91976-29-eajames@linux.ibm.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240226165321.91976-1-eajames@linux.ibm.com> References: <20240226165321.91976-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: xZ5uEUdjI1YWTXrYDZb7tgB-4KZxS1SD X-Proofpoint-GUID: xZ5uEUdjI1YWTXrYDZb7tgB-4KZxS1SD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-26_11,2024-02-26_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 priorityscore=1501 spamscore=0 malwarescore=0 bulkscore=0 suspectscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2402260128 Maintaining a list of ports is unnecessary since they can be managed with the device resource framework. Signed-off-by: Eddie James --- drivers/i2c/busses/i2c-fsi.c | 44 +++++++++--------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c index f237e76d29e6..096dc7e2369f 100644 --- a/drivers/i2c/busses/i2c-fsi.c +++ b/drivers/i2c/busses/i2c-fsi.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -148,14 +147,12 @@ struct fsi_i2c_master { struct fsi_device *fsi; - struct list_head ports; struct mutex lock; u32 clock_div; u8 fifo_size; }; struct fsi_i2c_port { - struct list_head list; struct i2c_adapter adapter; struct fsi_i2c_master *master; u16 port; @@ -327,7 +324,7 @@ static int fsi_i2c_read_fifo(struct fsi_i2c_port *port, struct i2c_msg *msg, static int fsi_i2c_get_scl(struct i2c_adapter *adap) { - struct fsi_i2c_port *port = adap->algo_data; + struct fsi_i2c_port *port = i2c_get_adapdata(adap); u32 stat; fsi_i2c_read_reg(port->master->fsi, I2C_FSI_STAT, &stat); @@ -337,7 +334,7 @@ static int fsi_i2c_get_scl(struct i2c_adapter *adap) static void fsi_i2c_set_scl(struct i2c_adapter *adap, int val) { - struct fsi_i2c_port *port = adap->algo_data; + struct fsi_i2c_port *port = i2c_get_adapdata(adap); if (val) fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SCL, 0); @@ -347,7 +344,7 @@ static void fsi_i2c_set_scl(struct i2c_adapter *adap, int val) static int fsi_i2c_get_sda(struct i2c_adapter *adap) { - struct fsi_i2c_port *port = adap->algo_data; + struct fsi_i2c_port *port = i2c_get_adapdata(adap); u32 stat; fsi_i2c_read_reg(port->master->fsi, I2C_FSI_STAT, &stat); @@ -357,7 +354,7 @@ static int fsi_i2c_get_sda(struct i2c_adapter *adap) static void fsi_i2c_set_sda(struct i2c_adapter *adap, int val) { - struct fsi_i2c_port *port = adap->algo_data; + struct fsi_i2c_port *port = i2c_get_adapdata(adap); if (val) fsi_i2c_write_reg(port->master->fsi, I2C_FSI_SET_SDA, 0); @@ -367,7 +364,7 @@ static void fsi_i2c_set_sda(struct i2c_adapter *adap, int val) static void fsi_i2c_prepare_recovery(struct i2c_adapter *adap) { - struct fsi_i2c_port *port = adap->algo_data; + struct fsi_i2c_port *port = i2c_get_adapdata(adap); u32 mode; int rc; @@ -381,7 +378,7 @@ static void fsi_i2c_prepare_recovery(struct i2c_adapter *adap) static void fsi_i2c_unprepare_recovery(struct i2c_adapter *adap) { - struct fsi_i2c_port *port = adap->algo_data; + struct fsi_i2c_port *port = i2c_get_adapdata(adap); u32 mode; int rc; @@ -594,7 +591,7 @@ static int fsi_i2c_wait(struct fsi_i2c_port *port, struct i2c_msg *msg, static int fsi_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { - struct fsi_i2c_port *port = adap->algo_data; + struct fsi_i2c_port *port = i2c_get_adapdata(adap); unsigned long start_time; struct i2c_msg *msg; int rc; @@ -679,7 +676,6 @@ static int fsi_i2c_probe(struct device *dev) mutex_init(&i2c->lock); i2c->fsi = to_fsi_dev(dev); - INIT_LIST_HEAD(&i2c->ports); i2c->clock_div = I2C_DEFAULT_CLK_DIV; lbus = fsi_device_local_bus_frequency(i2c->fsi); @@ -706,38 +702,30 @@ static int fsi_i2c_probe(struct device *dev) ports = FIELD_GET(I2C_STAT_MAX_PORT, stat) + 1; dev_dbg(dev, "I2C master has %d ports\n", ports); - for (port_no = 0; port_no < ports; port_no++) { + port = devm_kzalloc(dev, sizeof(*port) * ports, GFP_KERNEL); + for (port_no = 0; port_no < ports; port_no++, port++) { np = fsi_i2c_find_port_of_node(dev->of_node, port_no); if (!of_device_is_available(np)) continue; - port = kzalloc(sizeof(*port), GFP_KERNEL); - if (!port) { - of_node_put(np); - break; - } - port->master = i2c; port->port = port_no; + i2c_set_adapdata(&port->adapter, port); port->adapter.owner = THIS_MODULE; port->adapter.dev.of_node = np; port->adapter.dev.parent = dev; port->adapter.algo = &fsi_i2c_algorithm; port->adapter.bus_recovery_info = &fsi_i2c_bus_recovery_info; - port->adapter.algo_data = port; snprintf(port->adapter.name, sizeof(port->adapter.name), "i2c_bus-%u", port_no); - rc = i2c_add_adapter(&port->adapter); + rc = devm_i2c_add_adapter(dev, &port->adapter); if (rc < 0) { dev_err(dev, "Failed to register adapter: %d\n", rc); - kfree(port); continue; } - - list_add(&port->list, &i2c->ports); } dev_set_drvdata(dev, i2c); @@ -746,16 +734,6 @@ static int fsi_i2c_probe(struct device *dev) static int fsi_i2c_remove(struct device *dev) { - struct fsi_i2c_master *i2c = dev_get_drvdata(dev); - struct fsi_i2c_port *port; - struct fsi_i2c_port *tmp; - - list_for_each_entry_safe(port, tmp, &i2c->ports, list) { - list_del(&port->list); - i2c_del_adapter(&port->adapter); - kfree(port); - } - return 0; } -- 2.39.3