Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6200057imm; Mon, 27 Aug 2018 11:25:55 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZKM/hUN9P5jCOP5C+Sr+H9DodiQDgfjwnnKIrwqFVRCxPHoWoRugemVgFi/ISoZ4rrbSb2 X-Received: by 2002:a62:198e:: with SMTP id 136-v6mr15495858pfz.103.1535394355693; Mon, 27 Aug 2018 11:25:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535394355; cv=none; d=google.com; s=arc-20160816; b=GgUyDQD2wLmK8Gb7rxnVFpMrIIgSp1u/bBF/CaaKReyeTJJHqQOp0nnuSzYQ+AsvV+ 9vXO0YQx13RAsD0vaqVaTov1XeYVcNsFeMTbZU0sUKty6LrvtZGWvqJ0nIbNJlnUynaf f57nXr65ihj8jwRSD7FwaTM/ggJB0/GZXSC6c5kTI2BiJui7BEl+9pr6N2qX/NJorQFE hpI0ByuoXY4IJK3oJXNvWMXgRPh1Exdmo2ppGVgKf58XwoFxNLg4Ys94vZtLICN+iJpm ZmAiHGP7AmVIrCUNKpVs/0bE9mbKHPVmLnoIcgHZwNPcxlBKKgjJmE1TuBFlM/FKlMzj cLBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature :arc-authentication-results; bh=QycuV7Z0qoxdNV4ujiT/ksDFrQ4kyTqiiyI9/nuk1hk=; b=FCIs8gKYxFUpUSf+zTWubzSFZqAnxVTzVTUTtFppMJONWfsL58rnGj/8NvH0TNBriO Cg/XOly3k/DogCJYYzkXqJCJjsHB0L/2YcuiAo0/jPU/1o+CulnUyEppjDIbHaIGsQn0 N5fu8Khw6PGci6SrSqA2m9TcfuGpwOajN8sFtl9lOOQmMFE5L4i3KtD6O6lacvFvJ7X5 a8rQJcpG15/MXNAm9yCPECtEE62NbYwUc/bXSUP3wnqwJNwnsvhEOJtodeaDZ3sZfR/o zmBii+WbdPX4PdU8pjBYwZSyuQwuedgPohu7cjDOgntvx0Bx0I0B0jxI0j0Je+P/rxFJ bOtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=aPieJrv2; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p64-v6si14594540pga.25.2018.08.27.11.25.40; Mon, 27 Aug 2018 11:25:55 -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=@google.com header.s=20161025 header.b=aPieJrv2; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727680AbeH0WLt (ORCPT + 99 others); Mon, 27 Aug 2018 18:11:49 -0400 Received: from mail-pf1-f202.google.com ([209.85.210.202]:40710 "EHLO mail-pf1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726895AbeH0WLs (ORCPT ); Mon, 27 Aug 2018 18:11:48 -0400 Received: by mail-pf1-f202.google.com with SMTP id p22-v6so10267166pfj.7 for ; Mon, 27 Aug 2018 11:24:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=QycuV7Z0qoxdNV4ujiT/ksDFrQ4kyTqiiyI9/nuk1hk=; b=aPieJrv2+CwsqMMOqmR+PBgiKjfuY1P3izBZyZYYxuLnCb3G76tgbNTuHx8pDFl24K jnSQ+k2EBv8qbsbq2EsXAxFn6TVt9NSc9PVPqAF4Bf+DlF1nQV4uJg9kmkknEqclIlnU UI0u6YaagL3wJC9mxOYcJ7AGBlPh7OaceUB6vTpuJlj6CDFyFOfGg8a4SsTWNXtBZctv BTAWKYsQqp8wGfe5YwnV1tqxCoEZ8XU1R4BRhMvMWhikMwzIOA56AfUrsE8qypb7xNAD 1/N7v+tAnb+iylTbRr/t7KhBUK4A7i/zTdKc+pk1A/lrTX54dkLEzMzBUjaWK5oxgMa1 TZOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=QycuV7Z0qoxdNV4ujiT/ksDFrQ4kyTqiiyI9/nuk1hk=; b=dcHCHJm53WPoaXGyM3yp+sLmgzV5I9SoF2OxmWL4I3WAaa5B0lnPxx2f7S+wIVhZYC I3U4n5VVTCCiX9cgZlgVCpZOIAXYCaLpkmmS4PxlQxdp49mR2zK74fYDstzm2zYkaS9T KaEJcnE0kgGLbX242yz4I/69iaAdTikybh5bCF7XFc+ZrsVOThcJ1Dgm7F3e4friX9yo D6apWazmlhobNoVaE1n7QkuFI6SUANK6hHPaF50ZlC0oz15VHEECW/8g1+bhgfIscBGy TgLvwpM7qgGSOQp9Zbe40wur9W/KaFmrQA/9X97nWabA4WrtLhMJEAVsFlIlAjhhVHVB DONg== X-Gm-Message-State: APzg51ASbpxFn2RB1cTN7t8qzBrSJGZls+Rftubx5KzvGr26VKZk1vs9 bDO9jNNGzclG7+6LEPsv9wl5AfNG X-Received: by 2002:a65:655a:: with SMTP id a26-v6mr3317875pgw.15.1535394246564; Mon, 27 Aug 2018 11:24:06 -0700 (PDT) Date: Mon, 27 Aug 2018 11:23:06 -0700 In-Reply-To: <20180827182315.126345-1-rkir@google.com> Message-Id: <20180827182315.126345-11-rkir@google.com> Mime-Version: 1.0 References: <20180827182315.126345-1-rkir@google.com> X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog Subject: [PATCH 11/20] platform: goldfish: pipe: Replace two code blocks with a function call From: rkir@google.com To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, tkjos@google.com, Roman Kiryanov 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 From: Roman Kiryanov Two function calls look cleaner because the function introduces takes case of all bit shifting and casting. Signed-off-by: Roman Kiryanov --- drivers/platform/goldfish/goldfish_pipe.c | 35 ++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c index 3d28a9be5722..e3c09ff7867a 100644 --- a/drivers/platform/goldfish/goldfish_pipe.c +++ b/drivers/platform/goldfish/goldfish_pipe.c @@ -776,6 +776,14 @@ static struct miscdevice goldfish_pipe_miscdev = { .fops = &goldfish_pipe_fops, }; +static void write_pa_addr(void *addr, void __iomem *portl, void __iomem *porth) +{ + const unsigned long paddr = __pa(addr); + + writel(upper_32_bits(paddr), porth); + writel(lower_32_bits(paddr), portl); +} + static int goldfish_pipe_device_init(struct platform_device *pdev) { struct goldfish_pipe_dev *dev = &goldfish_pipe_dev; @@ -816,22 +824,17 @@ static int goldfish_pipe_device_init(struct platform_device *pdev) } /* Send the buffer addresses to the host */ - { - u64 paddr = __pa(&dev->buffers->signalled_pipe_buffers); - - writel((u32)(unsigned long)(paddr >> 32), - dev->base + PIPE_REG_SIGNAL_BUFFER_HIGH); - writel((u32)(unsigned long)paddr, - dev->base + PIPE_REG_SIGNAL_BUFFER); - writel((u32)MAX_SIGNALLED_PIPES, - dev->base + PIPE_REG_SIGNAL_BUFFER_COUNT); - - paddr = __pa(&dev->buffers->open_command_params); - writel((u32)(unsigned long)(paddr >> 32), - dev->base + PIPE_REG_OPEN_BUFFER_HIGH); - writel((u32)(unsigned long)paddr, - dev->base + PIPE_REG_OPEN_BUFFER); - } + write_pa_addr(&dev->buffers->signalled_pipe_buffers, + dev->base + PIPE_REG_SIGNAL_BUFFER, + dev->base + PIPE_REG_SIGNAL_BUFFER_HIGH); + + writel((u32)MAX_SIGNALLED_PIPES, + dev->base + PIPE_REG_SIGNAL_BUFFER_COUNT); + + write_pa_addr(&dev->buffers->open_command_params, + dev->base + PIPE_REG_OPEN_BUFFER, + dev->base + PIPE_REG_OPEN_BUFFER_HIGH); + return 0; } -- 2.19.0.rc0.228.g281dcd1b4d0-goog