Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7930273ybi; Thu, 6 Jun 2019 04:01:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqzmwUoZat4xsfnaaOXSkhSI3FSLyWHzF7tbu5i3iZW+qQEglnvp4cfL4PZ+92oYuyYBqXvc X-Received: by 2002:a17:902:24c7:: with SMTP id l7mr50305210plg.192.1559818894135; Thu, 06 Jun 2019 04:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559818894; cv=none; d=google.com; s=arc-20160816; b=AWoIPaU8WYzZ7D8OcLzDjA+JcLxnflkIWjnms1ClBwhGVVG4mXsRcyG3N/bRYUbe1+ QeOrVwTAKVmNL1EAfOm06cx7WAyxzXXGZJST66aE+GHcdo/FNOHFkilHFm0YDhJJbVJw O2vG91UNu+Es7mvQE6Jc+uBURkxeNn6CI/Fm/C+F4woyiSgzQd5/tJuUntbdWC+vlhEj x00vCFR1fePmd3+KSnnQ/dXmi/o+st8l54FMg2sobE3EPdqSiGbDex+CPHp9U/4tsbbk RTS72NVZoCL8TgTn+SRraZbqEAi2gvWxeFEBcnnV9Ej/VY9Kvg064HeyPs3hzHEUydFN sEWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:cc:to:subject:dkim-signature:dkim-filter; bh=v865NwK69lmWWiFDGUwndz3M24HjP/DKAiXeTb9R+XY=; b=jkA2dU0EQWOoT0BJTJUhKEDu9ONvaZu0j+narcSphYCQhTncYMIxTPL80J7w7yvyn4 VxoFyDW7KsyA7a6ryXlGqCijWji6FhlDBD69aocLga0JWkZ3YjNRd8Bqtz+yyvPZEuZT +5PmaO9Y+9h8O7SpOcVSDlsFSf1QTjjsZX/k2Ez5ZF4FczCQqunFcsdv5teyQtuGbTna 60ZeHtxRuQEMGroWbHzqn9SPeo9GFQkpKTel+G0XKeLKd3A3G94tAjrzp7uv1wN5b55/ 82y1anxEtYO8JGNTnuTFEDVQYNakGVt30J9/92goVhxAdyeYCAKK67Pc82DxBXmdVjW3 zpag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=vXOnQFA6; 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=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bh2si1582661plb.430.2019.06.06.04.01.16; Thu, 06 Jun 2019 04:01:34 -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=@samsung.com header.s=mail20170921 header.b=vXOnQFA6; 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=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727857AbfFFK7a (ORCPT + 99 others); Thu, 6 Jun 2019 06:59:30 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:60549 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727026AbfFFK7a (ORCPT ); Thu, 6 Jun 2019 06:59:30 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190606105928euoutp01b388cc1b9a2ec560c76f0634500fd814~llufdCmQD0167201672euoutp01B for ; Thu, 6 Jun 2019 10:59:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190606105928euoutp01b388cc1b9a2ec560c76f0634500fd814~llufdCmQD0167201672euoutp01B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1559818768; bh=v865NwK69lmWWiFDGUwndz3M24HjP/DKAiXeTb9R+XY=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=vXOnQFA6eivxdFqvIdMpY2L9vdZR0latyl4V5W2qLPKTLtil6U9q3OvLyz5D84mdu LjaDwmK3spZp1mSeSVi9k7U+SgAfHmUTI9D8APG3CA+cMj7KGchGWv0OgxSdNJtRd4 iqVcGedVchJCuioVdyM9izcWDbp3UrUBUZTRBuSs= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190606105927eucas1p207368fec01de0de674da641c99c17c43~lluedOQor1211012110eucas1p2D; Thu, 6 Jun 2019 10:59:27 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id C9.06.04325.F02F8FC5; Thu, 6 Jun 2019 11:59:27 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20190606105926eucas1p2e613ca3e2c9c6537877273c2cca2c3fd~lluduH-sm1527315273eucas1p2e; Thu, 6 Jun 2019 10:59:26 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20190606105926eusmtrp24bf3dc59fa000e86ce44dd1d377cc89e~lludejPW10645406454eusmtrp2D; Thu, 6 Jun 2019 10:59:26 +0000 (GMT) X-AuditID: cbfec7f5-b75ff700000010e5-87-5cf8f20f72b7 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id AB.69.04140.E02F8FC5; Thu, 6 Jun 2019 11:59:26 +0100 (BST) Received: from [106.120.51.74] (unknown [106.120.51.74]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20190606105925eusmtip20b1887ab1b662bf9c2940fda64356a1d~lluctXinr2753927539eusmtip2H; Thu, 6 Jun 2019 10:59:25 +0000 (GMT) Subject: Re: [PATCH v3 06/15] drm/bridge: tc358767: Simplify AUX data read To: Andrey Smirnov , dri-devel@lists.freedesktop.org Cc: Archit Taneja , Laurent Pinchart , Tomi Valkeinen , Andrey Gusakov , Philipp Zabel , Cory Tusar , Chris Healy , Lucas Stach , linux-kernel@vger.kernel.org From: Andrzej Hajda Message-ID: <28ddfb42-db9a-f095-9230-d324db5ee483@samsung.com> Date: Thu, 6 Jun 2019 12:59:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190605070507.11417-7-andrew.smirnov@gmail.com> Content-Transfer-Encoding: 8bit Content-Language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA01SbUhTYRjtvffu7jqbXaflg0XSMEjLL4q6ZIlBxC36EQUSNbCll6m5GZuu LKg5JaeVtlKW07JAaVSizY+cpOUEV+h0+VEm2STsh8WIMlMxM7er5L/DOc95zznwUrjEJQil 0lXZnFolz5SSIqKle64/at3PWVmsftKfyTfsZ/R2nYDRGzwCZnaoi2A6XzgwZmj6O8mM3/uA MUXGGiEz2FZFMmOfXhNMffUomejPDpbcxNjx8kWMtZnHhGyloULAuq87MLZ0IZZ1jDzH2Cnr Zrav3Ikd8zsl2pfKZaZrOXVMwhlR2tjUADo/tuGi8dUkrkPfAouRHwX0LtC/a8OLkYiS0BYE rSUWzCtI6F8I7swn88IUggLTALHiqHeWIV54hKDR04d4hweB6ckhLw6ij4AzbxD34mD6GPzU 20ivAaenMXg1YPRFkHQELDR+IL1YTCdAo+uez0DQ4TD8vt3Hr6dPgru7QcDfBMKbiglfC7+l +6df6nzBOB0G+c2VOI9DYHSiGvOGAe0RQvvdESFf+yAMzxsRj4Pgq6Npmd8Ei7Zq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EhzMSiK8ZRd+xAjxpiRWVqUW 5ccXleakFh9iNAV6biKzlGhyPjDB5JXEG5oamltYGpobmxubWSiJ83YIHIwREkhPLEnNTk0t SC2C6WPi4JRqYDyiLF0p0BnsedB3e6nnnu8TlSqjkj55zNYSYJG5FK3JdeD9lWyW2S8feK2I Xly8oKR+n/jFnz/VxY/xxqcdDts949B+5le7a/4GGR/l254S4/b81zaRq8lBC6zLfzQ6eagd 3SkR1Xyd4/y2nfc4npbcdL+8MMi0i5VT5tmeTl/JR+vnqa038lBiKc5INNRiLipOBACvrHZ6 +AIAAA== X-CMS-MailID: 20190606105926eucas1p2e613ca3e2c9c6537877273c2cca2c3fd X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20190605070535epcas2p36fee13315966e45d425c073162aa1aae X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190605070535epcas2p36fee13315966e45d425c073162aa1aae References: <20190605070507.11417-1-andrew.smirnov@gmail.com> <20190605070507.11417-7-andrew.smirnov@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Beside this: Reviewed-by: Andrzej Hajda  -- Regards Andrzej > static ssize_t tc_aux_transfer(struct drm_dp_aux *aux, > struct drm_dp_aux_msg *msg) > { > @@ -379,19 +402,10 @@ static ssize_t tc_aux_transfer(struct drm_dp_aux *aux, > if (ret) > return ret; > > - if (request == DP_AUX_I2C_READ || request == DP_AUX_NATIVE_READ) { > - /* Read data */ > - while (i < size) { > - if ((i % 4) == 0) { > - ret = regmap_read(tc->regmap, > - DP0_AUXRDATA(i >> 2), &tmp); > - if (ret) > - return ret; > - } > - buf[i] = tmp & 0xff; > - tmp = tmp >> 8; > - i++; > - } > + switch (request) { > + case DP_AUX_NATIVE_READ: > + case DP_AUX_I2C_READ: > + return tc_aux_read_data(tc, msg->buffer, size); > } > > return size;