Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2194388iof; Tue, 7 Jun 2022 22:49:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbSEfB0l2pMchV3dqNX9pUSpKrV7jnyaT9i3TsanI0WyhZFnnNZ0ZMRUiksfhD7SC8iygl X-Received: by 2002:a17:90b:17d0:b0:1e3:5324:c465 with SMTP id me16-20020a17090b17d000b001e35324c465mr35911816pjb.34.1654667360162; Tue, 07 Jun 2022 22:49:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667360; cv=none; d=google.com; s=arc-20160816; b=tqfnTiwVT8BJNN96/nTmETP/U+fy6GKuqkxEPRtXmMSgwrAMudeRMoTdBJX28eDcLM 4Ymw8nc0TNUQt/VAwpESx5F6sMLTmSscU3qaCJh9n+FATr1lQCWoPc5u+313X7fvEhY7 Q+TN3kgKW7Niy6H7Pv2yikKek6vX789rRufXOtAfuG87mc+ZhOf9SwvVUlDP9DvIhRGW KcZ9WKozxEsuzkc5b5y4Z5J+YXccGCUJtJQwHJo9Xhka2JvdUdfDu2e6AjB9LzDF/5iB 0WiF9WXcKmZ9z1QuWzbd9eEnprVIRC8Hk7vPFOA4G+brPo+CyJg2VK9ijsMq9AMQHo0D EFbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=5EXmhbBINWAX1iJ92pS7nRFv8qfOOWqr79b/Dpdp51E=; b=N0OVGj96Ybk1rO7mBKkkolk+s6g8ntF141qS/fzboeV9zwzYUnOAR3nukoC5r4Kbxa MIe3QXxVqCvrZGVM5xOVt9vwQjSy8/bVbs3Mn0qcHMFyCy54w+4q33zVwBIhRRCxIarP BXu3XjgAUMMhGCLAtZtE9QE6DyV/BANq0AVeSB65TVT87eaUzibV7z1crmEMtmaPplc/ XlTVqkrLDNr1JO83p906VmR6ZJ+rXCY7zQG0jJEtoZ0Fmae2ronumV67cREuY7fCXPuK ltODh+Tn2H8O+Qj1Gl/5vOzoqM1QSNZ/Biq/k1u8/dlgBppIOUo5/Dcp0ovWmtnhFc86 pdVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hartkopp.net header.s=strato-dkim-0002 header.b=RqreEK8D; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id i2-20020a6561a2000000b003fa7e315240si28115954pgv.249.2022.06.07.22.49.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:49:20 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@hartkopp.net header.s=strato-dkim-0002 header.b=RqreEK8D; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CAA704B586E; Tue, 7 Jun 2022 22:23:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390185AbiFHBGG (ORCPT + 99 others); Tue, 7 Jun 2022 21:06:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1449430AbiFGXJs (ORCPT ); Tue, 7 Jun 2022 19:09:48 -0400 Received: from mo4-p01-ob.smtp.rzone.de (mo4-p01-ob.smtp.rzone.de [85.215.255.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDD2D1F5C5B; Tue, 7 Jun 2022 13:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1654634754; s=strato-dkim-0002; d=hartkopp.net; h=In-Reply-To:Date:Message-ID:From:References:Cc:To:Subject:Cc:Date: From:Subject:Sender; bh=5EXmhbBINWAX1iJ92pS7nRFv8qfOOWqr79b/Dpdp51E=; b=RqreEK8DAmvUJvJ+ZocucZMHU5ApuzIv6BBlLrDYNCq2tol28Ufq+0FCXsxOi8hROq u2P9DJcs5VvkzDl484gXs708gmuPH9TOKrNAktktNEGSe4YMoBeFUetV3Uwh6cSpbkgS W6qOxhaiGU59jA7TaPCbzHolCR9YwrCjWR0CAo2SLEQjkk2FCvXD4+YC/SnvfafiR9NJ IBgxLOnC+giORLI2KzB9xqpyJCEhk52LUuMnfJKYI5lb9zkwv1uhpBaAv3isxjBmCBvl Bu7q171l+S59nA6AhvsoKSazrV1dsPrMD0R11wGZAKNDsilF/oFl282SDgevJogt3dBC sZxQ== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P2MHfkW8eP4Mre39l357AZT/I7AY/7nT2yrDxb8mjG14FZxedJy6qgO1q3DbdV+Ofo7wY7W6Qxgy" X-RZG-CLASS-ID: mo00 Received: from [172.20.10.8] by smtp.strato.de (RZmta 47.45.0 DYNA|AUTH) with ESMTPSA id R0691fy57Kjq8cw (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Tue, 7 Jun 2022 22:45:52 +0200 (CEST) Subject: Re: [RFC PATCH 05/13] can: slcan: simplify the device de-allocation To: Dario Binacchi , linux-kernel@vger.kernel.org Cc: Amarula patchwork , michael@amarulasolutions.com, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Marc Kleine-Budde , Paolo Abeni , Wolfgang Grandegger , linux-can@vger.kernel.org, netdev@vger.kernel.org References: <20220607094752.1029295-1-dario.binacchi@amarulasolutions.com> <20220607094752.1029295-6-dario.binacchi@amarulasolutions.com> From: Oliver Hartkopp Message-ID: Date: Tue, 7 Jun 2022 22:45:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20220607094752.1029295-6-dario.binacchi@amarulasolutions.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07.06.22 11:47, Dario Binacchi wrote: > 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. IMO this patch should not be part of the slcan enhancement series. I can see the "miss-use" of dev->base_addr but when we change this code we should also take care of a similar handling in drivers/net/slip/slip.c Therefore a change like this should be done in slcan.c and slip.c simultaneously with a single patch. Best regards, Oliver > > Signed-off-by: Dario Binacchi > --- > > drivers/net/can/slcan.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > 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 */ >