From patchwork Mon Mar 12 20:41:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 7236 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 140C823E16 for ; Mon, 12 Mar 2012 20:41:43 +0000 (UTC) Received: from mail-ee0-f52.google.com (mail-ee0-f52.google.com [74.125.83.52]) by fiordland.canonical.com (Postfix) with ESMTP id F3698A18469 for ; Mon, 12 Mar 2012 20:41:42 +0000 (UTC) Received: by eekd4 with SMTP id d4so1659264eek.11 for ; Mon, 12 Mar 2012 13:41:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=FOa5bJDkwdkx7SNRKcMgqlmMED7WGn2UuPUtBxnKVPI=; b=K8p7pN+84kqHHPvtuESEN3mQxn+L/gDhKY+h3Ng5TvDUXFqgiOb41NjdmwMxUpou/g kb/XIjNYR0ACqvAWUMGfk3kqilaiGSrQyVZ733oqgde5nCqHyw1+qe57u2V45lV/vJxC Vr8URK/VJEh3G2J8YGSN4BEIdKX09b1xt5RvShbvOoXzxYnI2vmGXwpqim9WRPNFHiC7 G1Rdlu5ly4ta9YS9NJMxj9bRJtKbIbgdTOQ9ccMMAY8xYDz+9R+f3F/H9j2k5t2K19+8 eZhesU42aiOwJDT0aHTNT+JRSs00waBwm9LbHB49dnD9Amn8P/to5CHspFUpIt2EboWd 512A== Received: by 10.50.159.135 with SMTP id xc7mr626183igb.50.1331584902291; Mon, 12 Mar 2012 13:41:42 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.53.18 with SMTP id k18csp50804ibg; Mon, 12 Mar 2012 13:41:41 -0700 (PDT) Received: by 10.14.94.134 with SMTP id n6mr1997139eef.63.1331584900419; Mon, 12 Mar 2012 13:41:40 -0700 (PDT) Received: from eu1sys200aog103.obsmtp.com (eu1sys200aog103.obsmtp.com. [207.126.144.115]) by mx.google.com with SMTP id m44si692093eeo.30.2012.03.12.13.41.23 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 12 Mar 2012 13:41:40 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.115 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.115; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.115 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob103.postini.com ([207.126.147.11]) with SMTP ID DSNKT15fcVRpWcSWGsgJqL5a3YPSookspxTR@postini.com; Mon, 12 Mar 2012 20:41:40 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 8C7D0B2; Mon, 12 Mar 2012 20:32:53 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id A98DAF3E; Mon, 12 Mar 2012 20:41:16 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id DDF1524C075; Mon, 12 Mar 2012 21:41:05 +0100 (CET) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Mon, 12 Mar 2012 21:41:15 +0100 From: Linus Walleij To: , Cc: Stephen Warren , Shawn Guo , Thomas Abraham , Dong Aisheng , Rajendra Nayak , Haojian Zhuang , Linus Walleij Subject: [PATCH] pinctrl: fix error path in pinconf_map_to_setting() Date: Mon, 12 Mar 2012 21:41:10 +0100 Message-ID: <1331584870-10077-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.8 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQm5A4Dm6duivTs82g6JU3F4fg9pArfi8xEWHPorPk0N1SoGp5CVMFm3GeyKCgQCm1ZK/ni0 From: Linus Walleij The code was using the union member setting->data.configs.group_or_pin to store a potential error code, but since that member is unsigned the < 0 comparison was not true, letting errors pass thru, ending up as mapped to pin "-22". Fix this up and print the error. Signed-off-by: Linus Walleij --- drivers/pinctrl/pinconf.c | 27 +++++++++++++++++---------- 1 files changed, 17 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c index 247b9f2..f9c9cd1 100644 --- a/drivers/pinctrl/pinconf.c +++ b/drivers/pinctrl/pinconf.c @@ -282,21 +282,28 @@ int pinconf_map_to_setting(struct pinctrl_map const *map, struct pinctrl_setting *setting) { struct pinctrl_dev *pctldev = setting->pctldev; + int ret; switch (setting->type) { case PIN_MAP_TYPE_CONFIGS_PIN: - setting->data.configs.group_or_pin = - pin_get_from_name(pctldev, - map->data.configs.group_or_pin); - if (setting->data.configs.group_or_pin < 0) - return setting->data.configs.group_or_pin; + ret = pin_get_from_name(pctldev, + map->data.configs.group_or_pin); + if (ret < 0) { + dev_err(pctldev->dev, "could not map pin config for \"%s\"", + map->data.configs.group_or_pin); + return ret; + } + setting->data.configs.group_or_pin = ret; break; case PIN_MAP_TYPE_CONFIGS_GROUP: - setting->data.configs.group_or_pin = - pinctrl_get_group_selector(pctldev, - map->data.configs.group_or_pin); - if (setting->data.configs.group_or_pin < 0) - return setting->data.configs.group_or_pin; + ret = pinctrl_get_group_selector(pctldev, + map->data.configs.group_or_pin); + if (ret < 0) { + dev_err(pctldev->dev, "could not map group config for \"%s\"", + map->data.configs.group_or_pin); + return ret; + } + setting->data.configs.group_or_pin = ret; break; default: return -EINVAL;