From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=68.232.153.233 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796295263; b=XxDfWum4Nc3BhdN/GnMJ3yLzKAXjgIT39+k+ESD4Ms2ckvDnNMlhT1KicXoyXWpV9fLs WAs0nlchjAS6H6LjEuG/Pta+hQ3OeCPmHdH7PSrUq8D9dsb5QdMJ37HIV59tvJ2IihDXO a7WNWWQWerENjJuGJohIZo7idzYGibpWKU3n2gHmDbEmnCPWC5M1RRfWIr9eOsk4+fbuD Tend1BZ7MnRLJpdh+AAEgF8hWapiq9Geta/pXr5dZMiewe4c6uMEw1wvQFkeFTf8s+ASU jRJIV7xDLKKI24PrP3G2Gwx6XmFS94p6yecpjk1NVVTXxLhMo04ke6C/LrDN+GA1MBQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796295263; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-Amp-Result:Received:Received:Received:MIME-Version: Content-Transfer-Encoding:Content-Type:Date:Message-ID:CC:From:To: Subject:X-Mailer:References:In-Reply-To; bh=C39zQ4LXlPyuCpxT/WW5gm9DPnrT5xLk1GnrAGyYHXI=; b=i2VgYZZcY5f3z5UIGXPEVp4Tb6icwjfta4e2l27ptkk0Jca6ZN0m/OTc6ykL3mjn63ei uWaAlVBgUiDpGyaOFxigux62COpEEMzcClTrkLIZJDKecoXcGg/+7XmAI1LVVd3q65Sok UTrV6EmrzlICi8CrflBmnGpcSToTkNNp6i7vrPeDGs6YMGOaMScr16CKUzjhD4rR/liXa G8cuJLwvVr9ySoiwWV/L2rrwGT8hMsO1QmqSkzpnoU3DGKOPJXUOF7PH9jR2M3TECLVWI AxvTbuTRE9VJbOTV+O+Z8bkPtDd3B2bjgkABUr5WLUYmLgwQauA4p7r/LuIYtpzhE2Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=fa61Q89m; arc=none smtp.remote-ip=68.232.153.233 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B912C606A32D; Thu, 3 Dec 2026 10:54:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B912C606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=fa61Q89m DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1796295262; x=1827831262; h=mime-version:content-transfer-encoding:date:message-id: cc:from:to:subject:references:in-reply-to; bh=GnJ3RaLDs1j68Gps3HjGnQ1nTkU6K/rXpzZ4gQmpGk8=; b=fa61Q89mmK8wooxXrkXnXKF58thaYh0z0MbscI/puS6kdhTEkyoVwU/S ctfoiLroIvRYVwqLKXtUT0+O6rk+YN/VS5CJRrUj2gcmjn17eLSXDbZ8k wheDddaqKkQiU6UHOWj578m6s+Rbn1lQegguT+/9o3ptthqyjwWlfrqlv 9CAhAfOgLd4yUFHaq6tRljsHbu/jB7Nq4lmPNzeVdF95u1vBLfnUIGRut bn/QD8eHZF5Dwh6ivmxBPSTqCDftw200K5RLtFY9ZLkjzLhQ3mHoyKQnN kmkP8g7uCFmYwSwE8y0GsyyM3YYpCdK1tXFG8mgUtiuNsqQDaDScrqoEF A==; X-CSE-ConnectionGUID: 9kjz1mPHRSmrm5sfDNW8bw== X-CSE-MsgGUID: +L1aeqbaSlKEG5FBdrycxw== X-IronPort-AV: E=Sophos;i="6.27,248,1787036400"; d="scan'208";a="78293692" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 03:54:22 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.87.152) by chn-vm-ex1.mchp-main.com (10.10.87.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.57; Thu, 3 Dec 2026 03:54:21 -0700 Received: from localhost (10.10.85.11) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.58 via Frontend Transport; Thu, 3 Dec 2026 03:54:20 -0700 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Date: Thu, 3 Dec 2026 11:54:19 +0100 Message-ID: CC: Colin Foster , , Rob Herring , "Krzysztof Kozlowski" , Conor Dooley , "Richard Cochran" , , , , From: =?utf-8?q?Jens_Emil_Schulz_=C3=98stergaard?= To: Lee Jones , =?utf-8?q?Jens_Emil_Schulz_=C3=98stergaard?= Subject: Re: [PATCH 4/4] mfd: ocelot: Read LAN9645x registers in a single SPI transfer X-Mailer: aerc 0.21.0 References: <20261123-mfd-ocelot-add-lan9645x-support-v1-0-567d811fe1de@microchip.com> <20261123-mfd-ocelot-add-lan9645x-support-v1-4-567d811fe1de@microchip.com> <179568544891.32537.5068972183702816273@kernel.org> In-Reply-To: <179568544891.32537.5068972183702816273@kernel.org> On Wed Dec 2, 2026 at 2:35 PM CET, Lee Jones wrote: > On Mon, 23 Nov 2026, Jens Emil Schulz =C3=98stergaard wrote: [...] >> +static int ocelot_spi_regmap_xfer_read(void *context, const void *reg, >> + size_t reg_size, void *val, >> + size_t val_size) >> +{ >> + struct ocelot_spi_regmap_ctx *ctx =3D context; >> + struct spi_transfer xfer =3D {}; >> + struct ocelot_ddata *ddata; >> + const u8 *regu8 =3D reg; >> + u8 *buf =3D ctx->buf; >> + u8 *valu8 =3D val; >> + size_t off; >> + int err; >> + >> + ddata =3D dev_get_drvdata(ctx->dev); > > Define and initialise this at the top. Will do. >> + >> + if (reg_size !=3D OCELOT_SPI_ADDR_SIZE || val_size !=3D OCELOT_SPI_VAL= _SIZE || >> + ddata->spi_padding_bytes > OCELOT_SPI_MAX_PADDING_BYTES) >> + return -EINVAL; >> + >> + off =3D OCELOT_SPI_ADDR_SIZE + ddata->spi_padding_bytes; >> + >> + buf[0] =3D regu8[0]; >> + buf[1] =3D regu8[1]; >> + buf[2] =3D regu8[2]; >> + memset(&buf[OCELOT_SPI_ADDR_SIZE], 0, >> + ddata->spi_padding_bytes + OCELOT_SPI_VAL_SIZE); > > Why not use memcpy()? Or start from a pre-initialised space? The address will be copied with memcpy() in v2. The memset() is there because the buffer is both tx_buf and rx_buf, so every read overwrites the padding bytes with the received data. In v2 the transmit and receive buffers are separate. The transmit buffer is zeroed once when it is allocated, and a read only copies the address into it. [...] >> + valu8[0] =3D buf[off + 0]; >> + valu8[1] =3D buf[off + 1]; >> + valu8[2] =3D buf[off + 2]; >> + valu8[3] =3D buf[off + 3]; > > memcpy()? Will do. [...] >> - return devm_regmap_init(dev, &ocelot_spi_regmap_bus, dev, ®map_conf= ig); >> + if (!ocelot_spi_single_xfer_read(spi, spi_get_device_match_data(spi))) >> + return devm_regmap_init(dev, &ocelot_spi_regmap_bus, dev, ®map_con= fig); > > Needs a comment. I will add one. > >> + ctx =3D devm_kzalloc_obj(dev, *ctx); >> + if (!ctx) >> + return ERR_PTR(-ENOMEM); >> + >> + ctx->dev =3D dev; >> + >> + return devm_regmap_init(dev, &ocelot_spi_regmap_xfer_bus, ctx, ®map= _config); >> } >> EXPORT_SYMBOL_NS(ocelot_spi_init_regmap, "MFD_OCELOT_SPI"); >> >> @@ -296,7 +384,7 @@ static int ocelot_spi_probe(struct spi_device *spi) >> spi->max_speed_hz, OCELOT_SPI_MAX_PADDING_BYTES); >> >> dummy_len =3D max(padding, data->reset_padding_bytes); >> - if (dummy_len) { >> + if (!ocelot_spi_single_xfer_read(spi, data) && dummy_len) { > > Comment. I will add one.