{"id":815814,"url":"http://patchwork.ozlabs.org/api/patches/815814/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170919201808.11433-4-tuomas.tynkkynen@iki.fi/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170919201808.11433-4-tuomas.tynkkynen@iki.fi>","list_archive_url":null,"date":"2017-09-19T20:18:05","name":"[U-Boot,v2,3/6] pci: layerscape: Use pci_generic_mmap_{read, write}_config","commit_ref":"e434a90ec43e1905d1f853f2355e973dfb83143b","pull_url":null,"state":"accepted","archived":false,"hash":"e71990a4eaa18e62cbbf59de24a7223fa1a2c20b","submitter":{"id":32296,"url":"http://patchwork.ozlabs.org/api/people/32296/?format=json","name":"Tuomas Tynkkynen","email":"tuomas.tynkkynen@iki.fi"},"delegate":{"id":3651,"url":"http://patchwork.ozlabs.org/api/users/3651/?format=json","username":"trini","first_name":"Tom","last_name":"Rini","email":"trini@ti.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170919201808.11433-4-tuomas.tynkkynen@iki.fi/mbox/","series":[{"id":3961,"url":"http://patchwork.ozlabs.org/api/series/3961/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=3961","date":"2017-09-19T20:18:02","name":"Board for QEMU's '-machine virt' on ARM","version":2,"mbox":"http://patchwork.ozlabs.org/series/3961/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/815814/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/815814/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"ZA9pU+Q1\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xxZ4m4HrWz9s81\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 06:20:40 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 4BCD9C21C71; Tue, 19 Sep 2017 20:19:22 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 34374C21DA4;\n\tTue, 19 Sep 2017 20:18:48 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 00729C21DD0; Tue, 19 Sep 2017 20:18:31 +0000 (UTC)","from mail-lf0-f68.google.com (mail-lf0-f68.google.com\n\t[209.85.215.68])\n\tby lists.denx.de (Postfix) with ESMTPS id AF11AC21D78\n\tfor <u-boot@lists.denx.de>; Tue, 19 Sep 2017 20:18:27 +0000 (UTC)","by mail-lf0-f68.google.com with SMTP id l196so355791lfl.3\n\tfor <u-boot@lists.denx.de>; Tue, 19 Sep 2017 13:18:27 -0700 (PDT)","from localhost.localdomain (85-76-68-181-nat.elisa-mobile.fi.\n\t[85.76.68.181]) by smtp.gmail.com with ESMTPSA id\n\ta197sm21154lfe.95.2017.09.19.13.18.25\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 19 Sep 2017 13:18:26 -0700 (PDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID autolearn=unavailable\n\tautolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=sender:from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=sEapnjvxK5q3ivmsBoFPSQ5MHwKpwGTKa5giLpnU3L0=;\n\tb=ZA9pU+Q1/WBx1jfoE/XFeCU+zNakKcPAqOVcaV12xN41QbZ+ZlMEzA+9tqYIzNJzlB\n\tILS0DMWF4qfNmLTWGwsG79GkBfQ3N000gWjrMn5a7zSfn+d7d4F685MNwz+g94VFepo9\n\tN0z5oTiujkP6M7t1hELlmJDo3e8xM6qnCtGj+gjtTLHQOjRO/9fBwiL/2s1bNhsoLzva\n\t0yKv4HXoY/xTZjKiUxJZgXzHqtDUQovFLKtqKDnK+9Ub9jy10WJ/9wa2l76mQIMzrkPz\n\tDOctATR703SdrzQ1CtU2Yf9UtOIFWG4DEzfNQcDJwTCydBfxz7PJV9MwZEv1FQIIcpUA\n\t8GGw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:sender:from:to:cc:subject:date:message-id\n\t:in-reply-to:references;\n\tbh=sEapnjvxK5q3ivmsBoFPSQ5MHwKpwGTKa5giLpnU3L0=;\n\tb=ebGjKiCsPVtPqhjB3/JcTvKV+hCHcsba0oLOg3ykHWi3E1pKhmNEU1jV1QTUh1wmCe\n\tMf17FeYja3upAaipEzBlsizN77Sa37OJl/Kjjr8G9GSm/drddYkWE9JKpJbKcoE15IWg\n\tJV5c7PFk8WQ9XxJG2LOnXqkt6Ow75xbOSzHpLphz4ol/vxyXx6K6Iq5DnkSCBXJyXmyl\n\tin+XagbkNW9Z4SJzHwjEAENGBhWyIG3vW8ooW37kmWw1AaNxXkZoGiTYzR0NsEDnlqRo\n\tkwD1/67u8dd+DZBrIWx5eb9dT2A6QCvNWidP6Dx2cjJLTjZBp9iNonv4bhjpPOA2a6op\n\tIVFw==","X-Gm-Message-State":"AHPjjUjbz9nUAyehBbka9S1NEXUlGWbU4TrT2zTuCfkNc1u3mdQadoG3\n\tV1aV6MroAzDWswbUO+8xpnjVPg==","X-Google-Smtp-Source":"AOwi7QAqv+RLaCA7wvRjAaVjBNOlJPkSCq8MolfDJUQInjD7caPZXNem2Fov814EMg2BQioykEoqBw==","X-Received":"by 10.25.161.129 with SMTP id k123mr881629lfe.166.1505852306960; \n\tTue, 19 Sep 2017 13:18:26 -0700 (PDT)","From":"Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>","To":"u-boot@lists.denx.de","Date":"Tue, 19 Sep 2017 23:18:05 +0300","Message-Id":"<20170919201808.11433-4-tuomas.tynkkynen@iki.fi>","X-Mailer":"git-send-email 2.13.0","In-Reply-To":"<20170919201808.11433-1-tuomas.tynkkynen@iki.fi>","References":"<20170919201808.11433-1-tuomas.tynkkynen@iki.fi>","Cc":"Tom Rini <trini@konsulko.com>","Subject":"[U-Boot] [PATCH v2 3/6] pci: layerscape: Use pci_generic_mmap_{read,\n\twrite}_config","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"Use the new helpers to avoid boilerplate in the driver.\n\nSigned-off-by: Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>\n---\n drivers/pci/pcie_layerscape.c | 68 +++++++++++--------------------------------\n 1 file changed, 17 insertions(+), 51 deletions(-)","diff":"diff --git a/drivers/pci/pcie_layerscape.c b/drivers/pci/pcie_layerscape.c\nindex 610f85c4e8..0cb7f6d564 100644\n--- a/drivers/pci/pcie_layerscape.c\n+++ b/drivers/pci/pcie_layerscape.c\n@@ -241,14 +241,19 @@ static int ls_pcie_addr_valid(struct ls_pcie *pcie, pci_dev_t bdf)\n \treturn 0;\n }\n \n-void *ls_pcie_conf_address(struct ls_pcie *pcie, pci_dev_t bdf,\n-\t\t\t\t   int offset)\n+int ls_pcie_conf_address(struct udevice *bus, pci_dev_t bdf,\n+\t\t\t uint offset, void **paddress)\n {\n-\tstruct udevice *bus = pcie->bus;\n+\tstruct ls_pcie *pcie = dev_get_priv(bus);\n \tu32 busdev;\n \n-\tif (PCI_BUS(bdf) == bus->seq)\n-\t\treturn pcie->dbi + offset;\n+\tif (ls_pcie_addr_valid(pcie, bdf))\n+\t\treturn -EINVAL;\n+\n+\tif (PCI_BUS(bdf) == bus->seq) {\n+\t\t*paddress = pcie->dbi + offset;\n+\t\treturn 0;\n+\t}\n \n \tbusdev = PCIE_ATU_BUS(PCI_BUS(bdf)) |\n \t\t PCIE_ATU_DEV(PCI_DEV(bdf)) |\n@@ -256,67 +261,28 @@ void *ls_pcie_conf_address(struct ls_pcie *pcie, pci_dev_t bdf,\n \n \tif (PCI_BUS(bdf) == bus->seq + 1) {\n \t\tls_pcie_cfg0_set_busdev(pcie, busdev);\n-\t\treturn pcie->cfg0 + offset;\n+\t\t*paddress = pcie->cfg0 + offset;\n \t} else {\n \t\tls_pcie_cfg1_set_busdev(pcie, busdev);\n-\t\treturn pcie->cfg1 + offset;\n+\t\t*paddress = pcie->cfg1 + offset;\n \t}\n+\treturn 0;\n }\n \n static int ls_pcie_read_config(struct udevice *bus, pci_dev_t bdf,\n \t\t\t       uint offset, ulong *valuep,\n \t\t\t       enum pci_size_t size)\n {\n-\tstruct ls_pcie *pcie = dev_get_priv(bus);\n-\tvoid *address;\n-\n-\tif (ls_pcie_addr_valid(pcie, bdf)) {\n-\t\t*valuep = pci_get_ff(size);\n-\t\treturn 0;\n-\t}\n-\n-\taddress = ls_pcie_conf_address(pcie, bdf, offset);\n-\n-\tswitch (size) {\n-\tcase PCI_SIZE_8:\n-\t\t*valuep = readb(address);\n-\t\treturn 0;\n-\tcase PCI_SIZE_16:\n-\t\t*valuep = readw(address);\n-\t\treturn 0;\n-\tcase PCI_SIZE_32:\n-\t\t*valuep = readl(address);\n-\t\treturn 0;\n-\tdefault:\n-\t\treturn -EINVAL;\n-\t}\n+\treturn pci_generic_mmap_read_config(bus, ls_pcie_conf_address,\n+\t\t\t\t\t    bdf, offset, valuep, size);\n }\n \n static int ls_pcie_write_config(struct udevice *bus, pci_dev_t bdf,\n \t\t\t\tuint offset, ulong value,\n \t\t\t\tenum pci_size_t size)\n {\n-\tstruct ls_pcie *pcie = dev_get_priv(bus);\n-\tvoid *address;\n-\n-\tif (ls_pcie_addr_valid(pcie, bdf))\n-\t\treturn 0;\n-\n-\taddress = ls_pcie_conf_address(pcie, bdf, offset);\n-\n-\tswitch (size) {\n-\tcase PCI_SIZE_8:\n-\t\twriteb(value, address);\n-\t\treturn 0;\n-\tcase PCI_SIZE_16:\n-\t\twritew(value, address);\n-\t\treturn 0;\n-\tcase PCI_SIZE_32:\n-\t\twritel(value, address);\n-\t\treturn 0;\n-\tdefault:\n-\t\treturn -EINVAL;\n-\t}\n+\treturn pci_generic_mmap_write_config(bus, ls_pcie_conf_address,\n+\t\t\t\t\t     bdf, offset, value, size);\n }\n \n /* Clear multi-function bit */\n","prefixes":["U-Boot","v2","3/6"]}