From patchwork Sun Aug 30 20:10:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 7098071 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1AC679F1CD for ; Sun, 30 Aug 2015 20:10:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 22FA6200DB for ; Sun, 30 Aug 2015 20:10:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1B3B1200C1 for ; Sun, 30 Aug 2015 20:10:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751365AbbH3UKU (ORCPT ); Sun, 30 Aug 2015 16:10:20 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:52516 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750953AbbH3UKT (ORCPT ); Sun, 30 Aug 2015 16:10:19 -0400 X-IronPort-AV: E=Sophos;i="5.17,435,1437429600"; d="scan'208";a="144204558" Received: from 198.67.28.109.rev.sfr.net (HELO hadrien) ([109.28.67.198]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 30 Aug 2015 22:10:16 +0200 Date: Sun, 30 Aug 2015 22:10:15 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@localhost6.localdomain6 To: walter harms cc: Mark Brown , kernel-janitors@vger.kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2 v2] spi: spi-ep93xx: fix PTR_ERR problem In-Reply-To: <55E34C0E.5000702@bfs.de> Message-ID: References: <1440957911-7687-1-git-send-email-Julia.Lawall@lip6.fr> <1440957911-7687-3-git-send-email-Julia.Lawall@lip6.fr> <55E34C0E.5000702@bfs.de> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Move initialization of msg->status up over the call to dev_err, in both calls to ep93xx_spi_dma_prepare, and change the reference in the call to dev_err to msg->status, to both fix the wrong argument to PTR_ERR in the second case and to make the dev_err line a little shorter. This required furthermore replacing %ld by %d, since msg->status is an integer. The semantic match that finds the PTR_ERR problem is as follows: (http://coccinelle.lip6.fr/) // @@ expression x,y; @@ if (IS_ERR(x) || ...) { ... when any when != IS_ERR(...) ( PTR_ERR(x) | * PTR_ERR(y) ) ... when any } // Reorganizations at the suggestion of Walter Harms. Signed-off-by: Julia Lawall --- v2: Reorganize the code, to solve the problem in a way that makes the resulting code simpler. drivers/spi/spi-ep93xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c index bb00be8..73d0df6 100644 --- a/drivers/spi/spi-ep93xx.c +++ b/drivers/spi/spi-ep93xx.c @@ -559,16 +559,16 @@ static void ep93xx_spi_dma_transfer(struct ep93xx_spi *espi) rxd = ep93xx_spi_dma_prepare(espi, DMA_DEV_TO_MEM); if (IS_ERR(rxd)) { - dev_err(&espi->pdev->dev, "DMA RX failed: %ld\n", PTR_ERR(rxd)); msg->status = PTR_ERR(rxd); + dev_err(&espi->pdev->dev, "DMA RX failed: %d\n", msg->status); return; } txd = ep93xx_spi_dma_prepare(espi, DMA_MEM_TO_DEV); if (IS_ERR(txd)) { ep93xx_spi_dma_finish(espi, DMA_DEV_TO_MEM); - dev_err(&espi->pdev->dev, "DMA TX failed: %ld\n", PTR_ERR(rxd)); msg->status = PTR_ERR(txd); + dev_err(&espi->pdev->dev, "DMA TX failed: %d\n", msg->status); return; }