Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp571631lqr; Wed, 5 Jun 2024 14:31:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUDJ5ok4GTjecedgThdg+YtH+NSUJn0krDg7TrS9tHZc9/feOX+a2jiiPolJPaG8z/1/8UYxHc0yNQVHIEPRUd0VtKba851HegPa38Lwg== X-Google-Smtp-Source: AGHT+IGMbtcFHhWdhvYjRO1nAwMK4X1y4hJzIlrquhGCiH3PJOAqzf0j+1v77nUY74mcQ9GeQIof X-Received: by 2002:a17:90a:6586:b0:2bd:85bc:5986 with SMTP id 98e67ed59e1d1-2c27db01384mr4394244a91.9.1717623090868; Wed, 05 Jun 2024 14:31:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717623090; cv=pass; d=google.com; s=arc-20160816; b=rm4PVRPSyT4CctOLe8weWOZrTCag9XgGNqR6wMomV9leRQXTi7zUBxPQpO3dBxuSHJ KmH9QYFQQSBghwNe+2mUy1zXyNOqqzN0FKfNr66+P2hgyswVF+ZGwS62cPSpaypNo3A5 rhwuom9peF1/2n7s5Y26sMvjUdGKqM2KlPsFdij+keleJY8J9iPI91zHGSpBwX/0wYBo ZGU1FHB3qke/6INAhEb0ApAyd6zNqeUOLlD1V8BQQo5O98mi+sCxmoqesbX0tFFf7OBL F1F4EfkKGT7UuJP+jLb055bWFudY4lZfv27tMIq2Jcnu4qIXi3mrn2fuxfUmVY1NB40f M+6g== 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=6pwGrpGa/9FUM1RJLI4c4OWS/mHbmuo48TsghubX0+s=; fh=F5i+rNW4hjf57QJHDx14Nq4Eso4Z4OyY/LhC2i40VT4=; b=c46qOoYY+U+e9QvYcMgCq1CpOSMt/sXhgUN8dAzbGciwIPN53CqrknHOi0SHTwFy5t bgAvdDJJrnZfJhqOezsaKHWjLDej5Gv0YXJE/LMpj4olaO0xKuOhrVf7fELZhvNYRb2V ix+PuRaRDmUOx6ViF1hH2xjtng5CcRHkbgxlHMTArG/OpmmNxzd+uEx2foP2rUH35Eqf 63NweXmQ0lKpA1CI9hWD7OmhcIjvdqNsm47b6T/3ElnYtfOrRPx0aEpPZAhl3Fgm3ObO 84umtDmYe5g1B3p6CJCDBKfqtdB5KNtIOsE0H2PwWMitW3Nshck2Br4emAeVPCxATnW+ EksQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=I5DLkfUE; 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-203271-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203271-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c28066e8d9si456093a91.60.2024.06.05.14.31.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 14:31:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-203271-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=I5DLkfUE; 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-203271-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-203271-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id BA62828ABEA for ; Wed, 5 Jun 2024 21:28:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4F19183A62; Wed, 5 Jun 2024 21:23:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="I5DLkfUE" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 50E1416192D; Wed, 5 Jun 2024 21:23:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622622; cv=none; b=gOki69COySTJxFIFxQBCEkjDir3lqUXITgxip2fgii3TF6J3dQjokLbAzHEt+LLIdYhqjnEU2zYK8qapP95XczOc5AFvASeBJnPl4atngRhQCpeOUPH9hBHhIzHnzKEp+HmQfQYCzd866kR6lgDu8u+KTn+Omwp/lFjToWR1Rgs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717622622; c=relaxed/simple; bh=p7IE1f7B3E4HXLYKDsiggW4zvHAZ9T9oqWSSmLtsBtQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BfczUL/0S8G57huVg6N1ToyRaOOuu2rdCX5fNiONZ1zIq+VgE1OcXHtDVnFCZ4mXAPJaDDPoNIqA2VbsjpfbDpBIw42oit3HoHrav1Ttyz/BQb7GyAkCAzJpSxtVWz1C91zZdVBOT798EEAV/xglckp0Y0otjvg+NIKa70fAZHA= 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=I5DLkfUE; arc=none smtp.client-ip=148.163.156.1 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 (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 455KvCZp013933; Wed, 5 Jun 2024 21:23:27 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=6pwGrpGa/9FUM1RJLI4c4OWS/mHbmuo48TsghubX0+s=; b=I5DLkfUE4u5IcJHzxz9ruTvrBKV8DpAPJ0I4VvwEOQFmUjNiFhOVNeLu6EvHSM4PGQse TZaMneqVG+dGNpOQHRur+yw5taBugkeIDRlE98Dlrei/uB6Wp+WOP1ToRtNGVcvTDhXZ wCeHNxcmHQfrEHk28tuh8hkXLntj2isM+mZIAPbyDfVA0dUHqzl6+a0hWwjMyMzfG5QD CR35GxWPK97aaqPjn+UfhXq1K32Ggxf1NXLvO6n8H1xvbo///L6CwXNKg9CoQefWYZho JXnzzg9H4h32hZITahnmFuVyxSIGCewxAuTTpB5ffdZ5cyHya87FlrzsRp4qts9kkMt0 BA== 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 3yjygp81uj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:26 +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 455JVcNJ031129; Wed, 5 Jun 2024 21:23:25 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ygeyppnug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 05 Jun 2024 21:23:25 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 455LNMMr63373712 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 5 Jun 2024 21:23:24 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 25F5158069; Wed, 5 Jun 2024 21:23:22 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCCDA58063; Wed, 5 Jun 2024 21:23:21 +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:21 +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 29/40] i2c: fsi: Remove list structure of ports Date: Wed, 5 Jun 2024 16:23:01 -0500 Message-Id: <20240605212312.349188-30-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: bZdKl0u6-FzW7c0GBFM5rWEosqz9SKV- X-Proofpoint-ORIG-GUID: bZdKl0u6-FzW7c0GBFM5rWEosqz9SKV- 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 bulkscore=0 adultscore=0 phishscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 suspectscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406050160 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 44aa750278100..f3b97bf88d0f9 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); @@ -705,38 +701,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); @@ -745,16 +733,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