Message ID | 20220602160434.225417-6-dario.binacchi@amarulasolutions.com |
---|---|
State | New |
Headers | show
Return-Path: <linux-amarula+bncBCQ4XFG47UFRBH574OKAMGQECSTOOAA@amarulasolutions.com> X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id C2DDC3F06D for <linux-amarula@patchwork.amarulasolutions.com>; Thu, 2 Jun 2022 18:04:47 +0200 (CEST) Received: by mail-ed1-f70.google.com with SMTP id j4-20020aa7ca44000000b0042dd12a7bc5sf3733130edt.13 for <linux-amarula@patchwork.amarulasolutions.com>; Thu, 02 Jun 2022 09:04:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1654185887; cv=pass; d=google.com; s=arc-20160816; b=ilfJAcy9ChIxDWWl4HrnwlzOOPxV7qXY3zkvZWxyv386pcfq1OP7vwBbT107RGPnCD 6klvh/0B7/4rV9dl5M5zOpmN2ws486NcIucI0GeSxC0+MRvpDuf461MwisZ3p6IUTh6e kqOH+ui1ubob7yhKJW87rjfJiyrc+vnvEoHsKWE0KQb//XFyoDiLX2T3An4OpzLuucNe MV0yTrf5sqgUmx4XfTdJ5sGILIgiQxQyaTDK5tjSM2Vk0nHA4fIlXWhB+tAxRx4LTanU y/1gBuK+IUOJNjqfk809Vs2eUNpkud/9KJ3kwF/7zo0RXIHbaowNCvDJ5KlMxOzOyZoK hEJg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=UYlLUhNrcaon3PmjK0FP9xl1njqJlrMfqYJtLqA7J3c=; b=gUqB0QU183GI0p2DtVQhm2YHRrNpgBCubQ5hLRnFkgaaXZNbeVjG2Cg5NENLi8T7wV n/ywu8s4ptaKSbbo0fxLiVlTyNlnB9/6p802JS2cE9YkMHUELKdGLSQlYhajRJMjCNZl Oys9EOeT9X0k2/Q+NcHNxlXCPV9XuHbhHyndRtfoih4yiQoaCTD4VX5FD7z0GcAuI8Op 8BPMzd6y5u3PYYQ/4AyBNJQVX4Y6asQm5T0HkTSxTNKiZ0ukUGbN5aJB3aK18cpu6meQ +mhHfORZ5ULLOACu2kbq+6S/8uehg8Wy3D5/iMHFtUiaT7gqla42oaXx71SaDgGE78Z7 iDfw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Av1p1LCc; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=UYlLUhNrcaon3PmjK0FP9xl1njqJlrMfqYJtLqA7J3c=; b=bGjCwPeBVrAeSgww5LmyIFBAdItXLGhc7ntPlZj/yvupKWqciFcirEVi4U3tv07uJ4 C/cH2dd8/gNKuv7e2DcnOymzC63+coHOV9ChiOcJ+5U1fwZEkpd0jGyGfHFVba9gRzkl y6mbZQXXCTTFSTq6Hcb3a2iCoGt+Y9xp9BRqA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=UYlLUhNrcaon3PmjK0FP9xl1njqJlrMfqYJtLqA7J3c=; b=p4FwGgofCw4hBqlLzG3YH9tqVrJduZET2jIJdwZEBblo9VI6+gpbI11PPjR6Qn9+WP haYue1eGe2KsZ11ci/qM3gGuaCQEq2A3FirykEpt6yPe7rKEMbSdoKYZyJKN4Dyf3Stm PQD3ZZI8N0Ac6k9ryFE7+fCasR7b0Pabv+dLgs7/b4ERA1fmnY//MJMWHFH9EYNJzM4s +isvRioUtfaUOFcvcTo5UdCEuVmmNxCM/6fgzVAhqN1Q7HcuiXe9dF6kneLbdfSLrz/V 6y+QCbUIA7O0TjvwRNSJnq0CEcp66kJs2+wrCJbx8/GgDmbt4RrFndPNLvRMbpNFkWQw JYsA== X-Gm-Message-State: AOAM532eVE7Lu0K4TfUK7XFjX67bbJzbM8hs+cQrgrzy9kb/ZDxYrjFI dgqhzKKZ0nvLtVi0pVpg8ridX1NK X-Google-Smtp-Source: ABdhPJwnXaixUn8pUW8t9bC6CXa9ST5XY2Ac6B8xWFgkJXfnKXuA4oqksn1JwX5YG+u3XDG1ZkSlVw== X-Received: by 2002:a17:906:af71:b0:70b:cc0b:1f14 with SMTP id os17-20020a170906af7100b0070bcc0b1f14mr2374992ejb.669.1654185887610; Thu, 02 Jun 2022 09:04:47 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:906:86ce:b0:6fe:c3bd:7a48 with SMTP id j14-20020a17090686ce00b006fec3bd7a48ls2949609ejy.8.gmail; Thu, 02 Jun 2022 09:04:46 -0700 (PDT) X-Received: by 2002:a17:907:3c09:b0:70b:442e:7e80 with SMTP id gh9-20020a1709073c0900b0070b442e7e80mr3050662ejc.593.1654185883926; Thu, 02 Jun 2022 09:04:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654185883; cv=none; d=google.com; s=arc-20160816; b=Ebg4MijEF1IcXOv5j+YbDb+i+1uMrdUjWLjsYHIlVuJXkJ9ZerWxZdYPl6PYO4vaRh 8AWK/VUW8WfKvHfMt9FYN66FBHERyJvy4Ib4gI3K8LVHhBeKhVgSDUF3wPAv+Of864j/ cmetb3tL9YyR/F4/c/KTTlTRndaVzmRTeR2qf8EKg3ED729Wh1Au5mzQXOq77Ofu9vPE v7GxeIIpt70M3MLL+7nHSQCcMerVBfBItvQHjpBG23DgUe3tp6zSJC7ox/j5GMFzcRC1 DvwIO4AFcGXHerFKyub/LulTCe6IY0Ojlrveqllkv+A/b4WBXtDtxALZygrtsXtTKkd5 kRsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=Uy2KDmBJTDvOUfwfmXyB7sLHvziPAF7lM16G9Y6QNPI=; b=T+uLLz40nLRxpO8ATZqvTLTsq1NBetf/SqoW1GdNoymhu5/z9jNfxbBjYlOLBf1o3z zUEfdY4fjCfeEZu2/YXiyo1qr+aUeFYWaX7IHoAVt3DJKyUid33JcCBjTzbsBrZ6oMUS LSb2c8FhmLhQeObthbo9HvK1aw+CLD5k5Msh89PSZXJEOGZKTw6FsShkL0czh2mxVoZC KK2kVCFrZ21bhUyIX4mC15r7VJ79t3LCljzOdQBeWvZ8Bd/vsS4Tb956ZTpQaWjIttU3 oCQB6JB+cqYgK9TH6zkUCUykKauh8czQjmggqIThOuy+cQDY8EtN973CxsUNcuA9n0NM sSDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Av1p1LCc; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id y13-20020a056402358d00b0042dbf25b798sor3097909edc.66.2022.06.02.09.04.43 for <linux-amarula@amarulasolutions.com> (Google Transport Security); Thu, 02 Jun 2022 09:04:43 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6402:1941:b0:413:2b7e:676e with SMTP id f1-20020a056402194100b004132b7e676emr6379071edz.114.1654185883445; Thu, 02 Jun 2022 09:04:43 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.homenet.telecomitalia.it (host-80-116-90-174.pool80116.interbusiness.it. [80.116.90.174]) by smtp.gmail.com with ESMTPSA id f3-20020a056402150300b0042dd3bf1403sm2637095edw.54.2022.06.02.09.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jun 2022 09:04:43 -0700 (PDT) From: Dario Binacchi <dario.binacchi@amarulasolutions.com> To: linux-amarula@amarulasolutions.com Cc: dario.binacchi@amarulasolutions.com, michael@amarulasolutions.com, tommaso.merciai@amarulasolutions.com Subject: [RFC PATCH v2 05/13] can: slcan: simplify the device de-allocation Date: Thu, 2 Jun 2022 18:04:26 +0200 Message-Id: <20220602160434.225417-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> References: <20220602160434.225417-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Av1p1LCc; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: <linux-amarula.amarulasolutions.com> X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/post>, <mailto:linux-amarula@amarulasolutions.com> List-Help: <https://support.google.com/a/amarulasolutions.com/bin/topic.py?topic=25838>, <mailto:linux-amarula+help@amarulasolutions.com> List-Archive: <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/> List-Unsubscribe: <mailto:googlegroups-manage+476853432473+unsubscribe@googlegroups.com>, <https://groups.google.com/a/amarulasolutions.com/group/linux-amarula/subscribe> |
Series |
|
Related |
show
|
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index 956b47bd40a7..4df0455e11a2 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c @@ -428,11 +428,17 @@ static int slc_open(struct net_device *dev) static void slc_dealloc(struct slcan *sl) { - int i = sl->dev->base_addr; + unsigned int i; - free_candev(sl->dev); - if (slcan_devs) - slcan_devs[i] = NULL; + for (i = 0; i < maxdev; i++) { + if (sl->dev == slcan_devs[i]) { + free_candev(sl->dev); + slcan_devs[i] = NULL; + return; + } + } + + pr_err("slcan: can't free %s resources\n", sl->dev->name); } static int slcan_change_mtu(struct net_device *dev, int new_mtu) @@ -529,7 +535,6 @@ static struct slcan *slc_alloc(void) snprintf(dev->name, sizeof(dev->name), "slcan%d", i); dev->netdev_ops = &slc_netdev_ops; - dev->base_addr = i; sl = netdev_priv(dev); /* Initialize channel control data */
Since slcan_devs array contains the addresses of the created devices, I think it is more natural to use its address to remove it from the list. It is not necessary to store the index of the array that points to the device in the driver's private data. Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> --- (no changes since v1) drivers/net/can/slcan.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)