From patchwork Mon Feb 4 17:52:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 218018 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3102F2C02B1 for ; Tue, 5 Feb 2013 05:00:29 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753907Ab3BDSAZ (ORCPT ); Mon, 4 Feb 2013 13:00:25 -0500 Received: from mail-vc0-f180.google.com ([209.85.220.180]:60144 "EHLO mail-vc0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753230Ab3BDSAZ (ORCPT ); Mon, 4 Feb 2013 13:00:25 -0500 Received: by mail-vc0-f180.google.com with SMTP id fo13so4007418vcb.25 for ; Mon, 04 Feb 2013 10:00:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=mpAxUBYqKYHqj1GayqfvQ8i+vGUanIvuvokJYS54/Kw=; b=y+IVqWZGxvD9tnHfC4uv2+jncY+7oYMklzMN8XL9cNnTAGabSdZYkVPMy7hjpEnI+U JyZ6/fYMwLfqHJYuiA5c6oXk4ZXLmtV7Y0HAxm0TcSIGPw8adZ1Yox4hHgDlx+eOL3d+ bISlJMstKG38XCNI0dRjYOm6TcxrmdEWBifcwANwnfxKy89JCF4bFvhiqy9CPOLprgAN EkYg0Q3HL8QsxIS4Y6cZvn8EkYKmuQREYuxrROmJuaEwAPGRp6SOxyWuhp6Kr6G+uVf8 /v4sPK1cgOnkCDWBE10IalLN6IcfENX2Kb7/vvk88pffk37H3tCO4s1IwLRL3vLThKXP 3y0g== X-Received: by 10.52.29.231 with SMTP id n7mr20679683vdh.103.1360000335984; Mon, 04 Feb 2013 09:52:15 -0800 (PST) Received: from mtj.dyndns.org (nat-pool-3-rdu.redhat.com. [66.187.233.203]) by mx.google.com with ESMTPS id yu12sm6407867vec.6.2013.02.04.09.52.13 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 04 Feb 2013 09:52:15 -0800 (PST) Date: Mon, 4 Feb 2013 09:52:10 -0800 From: Tejun Heo To: akpm@linux-foundation.org Cc: rusty@rustcorp.com.au, linux-kernel@vger.kernel.org, Chas Williams , netdev@vger.kernel.org Subject: [PATCH v2 02/14] atm/nicstar: don't use idr_remove_all() Message-ID: <20130204175210.GQ27963@mtj.dyndns.org> References: <1359163872-1949-1-git-send-email-tj@kernel.org> <1359163872-1949-3-git-send-email-tj@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1359163872-1949-3-git-send-email-tj@kernel.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Subject: atm/nicstar: convert to idr_alloc() Convert to the much saner new idr interface. The existing code looks buggy to me - ID 0 is treated as no-ID but allocation specifies 0 as lower limit and there's no error handling after partial success. This conversion keeps the bugs unchanged. Only compile tested. v2: id1 and id2 are now directly used for -errno return and thus should be signed. Make them int instead of u32. This was spotted by kbuild test robot. Signed-off-by: Tejun Heo Acked-by: Chas Williams Reported-by: kbuild test robot Cc: netdev@vger.kernel.org --- drivers/atm/nicstar.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/atm/nicstar.c +++ b/drivers/atm/nicstar.c @@ -949,7 +949,7 @@ static void free_scq(ns_dev *card, scq_i static void push_rxbufs(ns_dev * card, struct sk_buff *skb) { struct sk_buff *handle1, *handle2; - u32 id1 = 0, id2 = 0; + int id1 = 0, id2 = 0; u32 addr1, addr2; u32 stat; unsigned long flags; @@ -1026,24 +1026,21 @@ static void push_rxbufs(ns_dev * card, s card->lbfqc += 2; } - do { - if (!idr_pre_get(&card->idr, GFP_ATOMIC)) { - printk(KERN_ERR - "nicstar%d: no free memory for idr\n", - card->index); + if (id1 < 0) { + id1 = idr_alloc(&card->idr, handle1, 0, 0, GFP_ATOMIC); + if (id1 < 0) { + err = id1; goto out; } + } - if (!id1) - err = idr_get_new_above(&card->idr, handle1, 0, &id1); - - if (!id2 && err == 0) - err = idr_get_new_above(&card->idr, handle2, 0, &id2); - - } while (err == -EAGAIN); - - if (err) - goto out; + if (id2 < 0) { + id2 = idr_alloc(&card->idr, handle2, 0, 0, GFP_ATOMIC); + if (id2 < 0) { + err = id2; + goto out; + } + } spin_lock_irqsave(&card->res_lock, flags); while (CMD_BUSY(card)) ;