From patchwork Mon Aug 2 07:16:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Magnus Damm X-Patchwork-Id: 116409 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o727Fg0a011471 for ; Mon, 2 Aug 2010 07:15:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752803Ab0HBHPl (ORCPT ); Mon, 2 Aug 2010 03:15:41 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:35958 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752555Ab0HBHPl (ORCPT ); Mon, 2 Aug 2010 03:15:41 -0400 Received: by pzk26 with SMTP id 26so1243048pzk.19 for ; Mon, 02 Aug 2010 00:15:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:date:message-id :subject; bh=Dkz/35WInKk0kxayjpg8KuIjGdgGLfQJfaLx9xK77ik=; b=ShWrdjqrL6oQHTVKinSZ7vJ7VP4kGm949hJlEe5KreVifXITeEw5VfyH5psni/OgK/ tBjxA9sarqyqqqiAQf7vNXNo+KlZFgikTuRXvHUB+Ks40kqT943CTs8JI5dKxKgsLtQJ V4hdhP8rGG3FJnKGWmLzk8MkAv4J1GNEX+G9s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:date:message-id:subject; b=V1LdCVPb7+scrvJziILUj/RT2j62nVk6Tujj0I3XpAq0eR3VMejWk53zKkaLdqo+ad e4QzUENOIG/woP7UQ7AHZufJU9efanvl/RxgE9EpJkN7jfzynIEMJLD6te8ULoOZsRdr oJPBs+XKsfAjnYTDXf+p6M393IQDlySDvs3ms= Received: by 10.114.39.5 with SMTP id m5mr5050266wam.129.1280733340454; Mon, 02 Aug 2010 00:15:40 -0700 (PDT) Received: from [127.0.0.1] (49.14.32.202.bf.2iij.net [202.32.14.49]) by mx.google.com with ESMTPS id d38sm10836930wam.8.2010.08.02.00.15.38 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 02 Aug 2010 00:15:39 -0700 (PDT) From: Magnus Damm To: linux-i2c@vger.kernel.org Cc: khali@linux-fr.org, Magnus Damm , lethal@linux-sh.org, linux-sh@vger.kernel.org Date: Mon, 02 Aug 2010 16:16:37 +0900 Message-Id: <20100802071637.18054.76993.sendpatchset@t400s> Subject: [PATCH] i2c: i2c-sh_mobile irq rollback fix Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 02 Aug 2010 07:15:42 +0000 (UTC) --- 0001/drivers/i2c/busses/i2c-sh_mobile.c +++ work/drivers/i2c/busses/i2c-sh_mobile.c 2010-08-02 15:14:48.000000000 +0900 @@ -538,15 +538,17 @@ static int sh_mobile_i2c_hook_irqs(struc { struct resource *res; int ret = -ENXIO; - int q, m; - int k = 0; - int n = 0; + int n, k = 0; while ((res = platform_get_resource(dev, IORESOURCE_IRQ, k))) { for (n = res->start; hook && n <= res->end; n++) { if (request_irq(n, sh_mobile_i2c_isr, IRQF_DISABLED, - dev_name(&dev->dev), dev)) + dev_name(&dev->dev), dev)) { + for (n--; n >= res->start; n--) + free_irq(n, dev); + goto rollback; + } } k++; } @@ -554,16 +556,17 @@ static int sh_mobile_i2c_hook_irqs(struc if (hook) return k > 0 ? 0 : -ENOENT; - k--; ret = 0; rollback: - for (q = k; k >= 0; k--) { - for (m = n; m >= res->start; m--) - free_irq(m, dev); + k--; + + while (k >= 0) { + res = platform_get_resource(dev, IORESOURCE_IRQ, k); + for (n = res->start; n <= res->end; n++) + free_irq(n, dev); - res = platform_get_resource(dev, IORESOURCE_IRQ, k - 1); - m = res->end; + k--; } return ret;