Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8567541ybi; Thu, 6 Jun 2019 14:56:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzJqeLSGQuGDVa1GJl8A7GC/qE0yMWqik1Mn5rZDstEdFQzDWjc99dTgNrIVD+NH/8Qjryb X-Received: by 2002:a17:902:2883:: with SMTP id f3mr52521487plb.111.1559858196060; Thu, 06 Jun 2019 14:56:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559858196; cv=none; d=google.com; s=arc-20160816; b=khntVU+kPZGamb9OGNlYNn6aoqHLSPMKMicRzQZJs5JZzFuFyvuaHDmN77Q/u5m/jc 1Zaz7OX5ur99ES7sFPVGOfHqX/70U6zXCdOiZ2o2G0w4Juk3RbbihhGsBF8bWJlfMf1j ii/TjX3oRn67O0G4lZLpX6ZBoWjcD7L0t2Y4h35lwd62xbMA+veegbSWs4ZmtNPxuJYe pJ5TiSKkd1NdGQwWx9U2kqQmXZievO8ml16ilWXh20viUO4cAcA7IZwcBXwlcXGXv9L0 GATWd/XwLsM0nhiLSm8vZ9aw938FGYF6LlL8O7eM5jeL6MARIThgLKbewzsmzWQL3h6b OsQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=QvRzAt8oUa+QOs8oktnGNElZis2955KPPjFl8TJj1Sc=; b=Vk0E2xYW2aUN84NNXhtPCOPGStQgGh2N/OFdYh4ulWivQpRkJJPPdRm3RzwyiWeQsM Aq3fzt4ztxP3oeu26M+LrveiqbbN1eAAFjvdhn+TbrzZB8hGyAbkfpAmtDbklptKz6YN oZGwMKinXaSSxNJWDzkRhxtLgH5KvOjP09VyJIEUvCIaKvIdH5ErnROVYadsizhCPUOf AbB5ZyKVwI+vtstE6MDqRa0/lnmkYsAFgy9FGbID0Qu5PURzn1EbYHgSxTxBAvLOQwNJ h9A8UkmkTyM2OBc2st2Ofq7u8PAJYTBV297oWe55sjEsphHPAJSeCMwWPI6dW/Vapit9 bzJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=N+cqBcIV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 2si193819plc.228.2019.06.06.14.56.19; Thu, 06 Jun 2019 14:56:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=N+cqBcIV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727707AbfFFTxl (ORCPT + 99 others); Thu, 6 Jun 2019 15:53:41 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:50910 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727240AbfFFTxl (ORCPT ); Thu, 6 Jun 2019 15:53:41 -0400 Received: by mail-it1-f194.google.com with SMTP id a186so1973993itg.0 for ; Thu, 06 Jun 2019 12:53:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QvRzAt8oUa+QOs8oktnGNElZis2955KPPjFl8TJj1Sc=; b=N+cqBcIV8wCw3ILXUCLZHVe/s4oVuQ8zay6aGrYPCg/Q0/LfbnGZ3xrbjVNC2YrE+E gSa1nR+/Nq1cCJ7Jznj/Mh+Brk11hVeOkfmo7Mu9L8hig5pyoGV3hzJCKKy15b2Ux4YT zAAWOLCfUwPmGNGUKX5hvU8UhLJUAuxnsWIb0vjJMTLwE9WVVid8S/axVQwSWwX/zwPe y0b8JzAyRKGSbTtq2I4s4PrRaPLbKrmGieixcUCvQN3oCK9J8zhbUjhFim3HibPIkckH W6ktf0tSNKqYlGcNECmzAZgznIdXds66vzYJebSmZfwWa8gCf3MmmOyqUZ2k3M+KpybO +vOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=QvRzAt8oUa+QOs8oktnGNElZis2955KPPjFl8TJj1Sc=; b=pp6YcxNZVaV+BE4ayY1rCFEW5rc6onGvuTSAfODd6VwcJSD9m/bRnShZKtKQ8PREtd 5kFsAcioJggYnHTu1kP66z1LtyHawUEJ97YhO8dOo7KMSSlsfuZ+sLeiSGnPcyuwutdu 1HE5bD81ZvuzcHLMQEphboBbc+hdVfXAFTL66ovgt7Reo1cCLSoUag3wUoP7gFZRV2pi gqg1WxEkPGzRkiFdhWatFshPiBLh1ZqYRBUlsbiGoiPlJaDcMFP3P6OBVD/38i0ludPN r1WQaUtzfq2XJVBgOiIFQUX0TKSLCcMVdsHi+9adbIFP1Sa2WD29xtDrmirVVCXyNb8+ a56w== X-Gm-Message-State: APjAAAUwWkNjbcwQVfN2pVgrEBHyI/q74k494hqdcPUjryNRN1M5FuPg zuZDIia3l7cShObn9EPrcfXgEzM+i11LQ3IbSQg= X-Received: by 2002:a24:97d2:: with SMTP id k201mr1379721ite.151.1559850820180; Thu, 06 Jun 2019 12:53:40 -0700 (PDT) MIME-Version: 1.0 References: <20190605070507.11417-1-andrew.smirnov@gmail.com> <20190605070507.11417-7-andrew.smirnov@gmail.com> <28ddfb42-db9a-f095-9230-d324db5ee483@samsung.com> In-Reply-To: <28ddfb42-db9a-f095-9230-d324db5ee483@samsung.com> From: Andrey Smirnov Date: Thu, 6 Jun 2019 12:53:28 -0700 Message-ID: Subject: Re: [PATCH v3 06/15] drm/bridge: tc358767: Simplify AUX data read To: Andrzej Hajda Cc: dri-devel@lists.freedesktop.org, Archit Taneja , Laurent Pinchart , Tomi Valkeinen , Andrey Gusakov , Philipp Zabel , Cory Tusar , Chris Healy , Lucas Stach , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 6, 2019 at 3:59 AM Andrzej Hajda wrote: > > On 05.06.2019 09:04, Andrey Smirnov wrote: > > Simplify AUX data read by removing index arithmetic and shifting with > > a helper functions that does three things: > > > > 1. Fetch data from up to 4 32-bit registers from the chip > > 2. Optionally fix data endianness (not needed on LE hosts) > > 3. Copy read data into user provided array. > > > > Signed-off-by: Andrey Smirnov > > Cc: Archit Taneja > > Cc: Andrzej Hajda > > Cc: Laurent Pinchart > > Cc: Tomi Valkeinen > > Cc: Andrey Gusakov > > Cc: Philipp Zabel > > Cc: Cory Tusar > > Cc: Chris Healy > > Cc: Lucas Stach > > Cc: dri-devel@lists.freedesktop.org > > Cc: linux-kernel@vger.kernel.org > > --- > > drivers/gpu/drm/bridge/tc358767.c | 40 +++++++++++++++++++++---------- > > 1 file changed, 27 insertions(+), 13 deletions(-) > > > > diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c > > index e197ce0fb166..da47d81e7109 100644 > > --- a/drivers/gpu/drm/bridge/tc358767.c > > +++ b/drivers/gpu/drm/bridge/tc358767.c > > @@ -321,6 +321,29 @@ static int tc_aux_get_status(struct tc_data *tc, u8 *reply) > > return 0; > > } > > > > +static int tc_aux_read_data(struct tc_data *tc, void *data, size_t size) > > +{ > > + u32 auxrdata[DP_AUX_MAX_PAYLOAD_BYTES / sizeof(u32)]; > > + int ret, i, count = DIV_ROUND_UP(size, sizeof(u32)); > > + > > + ret = regmap_bulk_read(tc->regmap, DP0_AUXRDATA(0), auxrdata, count); > > + if (ret) > > + return ret; > > + > > + for (i = 0; i < count; i++) { > > + /* > > + * Our regmap is configured as LE for register data, > > + * so we need undo any byte swapping that might have > > + * happened to preserve original byte order. > > + */ > > + le32_to_cpus(&auxrdata[i]); > > + } > > + > > + memcpy(data, auxrdata, size); > > + > > + return size; > > +} > > + > > > Hmm, cannot we just use regmap_raw_read? I'll give it a try in v4. Thanks, Andrey Smirnov