{"id":718922,"url":"http://patchwork.ozlabs.org/api/patches/718922/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170124065128.30280-1-wenyou.yang@atmel.com/","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":"<20170124065128.30280-1-wenyou.yang@atmel.com>","list_archive_url":null,"date":"2017-01-24T06:51:28","name":"[U-Boot] spi: atmel: check the GPIO validity before using cs_gpios","commit_ref":null,"pull_url":null,"state":"deferred","archived":false,"hash":"8e8567919394eebcd2cf14c34545527d7b76f161","submitter":{"id":16102,"url":"http://patchwork.ozlabs.org/api/people/16102/?format=json","name":"Wenyou Yang","email":"wenyou.yang@atmel.com"},"delegate":{"id":6342,"url":"http://patchwork.ozlabs.org/api/users/6342/?format=json","username":"abiessmann","first_name":"Andreas","last_name":"Bießmann","email":"andreas.biessmann@googlemail.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170124065128.30280-1-wenyou.yang@atmel.com/mbox/","series":[],"comments":"http://patchwork.ozlabs.org/api/patches/718922/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/718922/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","Received":["from theia.denx.de (theia.denx.de [85.214.87.163])\n\tby ozlabs.org (Postfix) with ESMTP id 3v6zc015B0z9t0k\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 24 Jan 2017 18:01:04 +1100 (AEDT)","from localhost (localhost [127.0.0.1])\n\tby theia.denx.de (Postfix) with ESMTP id 36B464AAA7;\n\tTue, 24 Jan 2017 08:01:02 +0100 (CET)","from theia.denx.de ([127.0.0.1])\n\tby localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id 3HtrCmW6unJ1; Tue, 24 Jan 2017 08:01:01 +0100 (CET)","from theia.denx.de (localhost [127.0.0.1])\n\tby theia.denx.de (Postfix) with ESMTP id 5827D4A068;\n\tTue, 24 Jan 2017 08:01:01 +0100 (CET)","from localhost (localhost [127.0.0.1])\n\tby theia.denx.de (Postfix) with ESMTP id 617774A068\n\tfor <u-boot@lists.denx.de>; Tue, 24 Jan 2017 08:00:57 +0100 (CET)","from theia.denx.de ([127.0.0.1])\n\tby localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id eAtvawC8Yvug for <u-boot@lists.denx.de>;\n\tTue, 24 Jan 2017 08:00:57 +0100 (CET)","from eusmtp01.atmel.com (eusmtp01.atmel.com [212.144.249.242])\n\tby theia.denx.de (Postfix) with ESMTPS id 28CE64A05F\n\tfor <u-boot@lists.denx.de>; Tue, 24 Jan 2017 08:00:57 +0100 (CET)","from apsmtp01.atmel.com (10.168.254.30) by eusmtp01.atmel.com\n\t(10.145.145.30) with Microsoft SMTP Server id 14.3.235.1;\n\tTue, 24 Jan 2017 07:55:28 +0100","from shaarm01.corp.atmel.com (10.168.254.13) by\n\tapsmtp01.corp.atmel.com (10.168.254.30) with Microsoft SMTP Server id\n\t14.3.235.1; Tue, 24 Jan 2017 14:58:58 +0800"],"X-Greylist":"delayed 324 seconds by postgrey-1.34 at theia;\n\tTue, 24 Jan 2017 08:00:57 CET","X-policyd-weight":"NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5\n\tNOT_IN_BL_NJABL=-1.5 (only DNSBL check requested)","From":"Wenyou Yang <wenyou.yang@atmel.com>","To":"U-Boot Mailing List <u-boot@lists.denx.de>","Date":"Tue, 24 Jan 2017 14:51:28 +0800","Message-ID":"<20170124065128.30280-1-wenyou.yang@atmel.com>","X-Mailer":"git-send-email 2.11.0","MIME-Version":"1.0","Subject":"[U-Boot] [PATCH] spi: atmel: check the GPIO validity before using\n\tcs_gpios","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.15","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<http://lists.denx.de/mailman/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":"<http://lists.denx.de/mailman/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"},"content":"Before using the cs_gpio, check if the GPIO is valid.\n\nSigned-off-by: Wenyou Yang <wenyou.yang@atmel.com>\n---\n\n drivers/spi/atmel_spi.c | 13 +++++++++----\n 1 file changed, 9 insertions(+), 4 deletions(-)","diff":"diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c\nindex 7649114231..8d29f7c4eb 100644\n--- a/drivers/spi/atmel_spi.c\n+++ b/drivers/spi/atmel_spi.c\n@@ -296,7 +296,8 @@ static void atmel_spi_cs_activate(struct udevice *dev)\n \tstruct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);\n \tu32 cs = slave_plat->cs;\n \n-\tdm_gpio_set_value(&priv->cs_gpios[cs], 0);\n+\tif (dm_gpio_is_valid(&priv->cs_gpios[cs]))\n+\t\tdm_gpio_set_value(&priv->cs_gpios[cs], 0);\n }\n \n static void atmel_spi_cs_deactivate(struct udevice *dev)\n@@ -306,7 +307,8 @@ static void atmel_spi_cs_deactivate(struct udevice *dev)\n \tstruct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);\n \tu32 cs = slave_plat->cs;\n \n-\tdm_gpio_set_value(&priv->cs_gpios[cs], 1);\n+\tif (dm_gpio_is_valid(&priv->cs_gpios[cs]))\n+\t\tdm_gpio_set_value(&priv->cs_gpios[cs], 1);\n }\n \n static int atmel_spi_xfer(struct udevice *dev, unsigned int bitlen,\n@@ -473,8 +475,11 @@ static int atmel_spi_probe(struct udevice *bus)\n \t}\n \n \tfor(i = 0; i < ARRAY_SIZE(priv->cs_gpios); i++) {\n-\t\tdm_gpio_set_dir_flags(&priv->cs_gpios[i],\n-\t\t\t\t      GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);\n+\t\tif (dm_gpio_is_valid(&priv->cs_gpios[i])) {\n+\t\t\tdm_gpio_set_dir_flags(&priv->cs_gpios[i],\n+\t\t\t\t\t      GPIOD_IS_OUT |\n+\t\t\t\t\t      GPIOD_IS_OUT_ACTIVE);\n+\t\t}\n \t}\n \n \twritel(ATMEL_SPI_CR_SWRST, &bus_plat->regs->cr);\n","prefixes":["U-Boot"]}