Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp43614iof; Wed, 8 Jun 2022 14:48:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVcJOPT6S4xOTci3tO2a/RAp/bT2Xrth9HVw6bjo72nS64mLEQW8OG5BiG7ohECTI2X4B9 X-Received: by 2002:aa7:c846:0:b0:431:6c7b:26af with SMTP id g6-20020aa7c846000000b004316c7b26afmr17559685edt.123.1654724937377; Wed, 08 Jun 2022 14:48:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654724937; cv=none; d=google.com; s=arc-20160816; b=lqzoo1Uww/NIydkA4FS41ZFaZQ8Bgd5h9xzfqKTZ8CP6Pxy/k1VNwe8XGYpnCJFHnU TWS8189x4IXjdu5JtuMx00xk85oqydSynzHTl1dTkiorn18s7zvlDn6UgRaDSTwuV6r5 qUPX9ivC8rMU79xUgrvj0A+PewEryrrEO7pJWElDkjaSKX99Etc7TxgnNVOANtWR61RZ tee2aq3zjDgHexMRxTxFLIK9AhXTZetcbI0jPAAz4j3y1PAZitmGI+UnbQDGc2CENsRs ZC+Aa1bc4e5k5tlG9ZxgwCd8eYAt0RrE3hlvYcOeRbN5Mj50zBcnc3FtPhGLEgD82Ib6 2+ag== 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=vPC4nYdjhDqJ8lKsGfPtKW79duI66lmrks2vdSL6r3Y=; b=NibkL6H2OOizrJKSr5odDMGKsx2TXfP4BxSml7PtridsmESpgxEWxw0eIbwWgHCew5 EuW6JAsTdH3borknoBIKPVbmjFpF3XtDupMVv5WQOV24CNCyIVOppuimx7UU0aXsJc9d RcGIpVKx1JPAIf2Jdb9Mxf6bjWh8tSLWU7JJtJ450gwYMkXH7gWItChtQZkpcr7xT7lD L1+Bel2oKvaVP7apOUK9YAV/TphinvK2rdSDqhmT+N8qaet4UotQjnMEez7KM+n5+HY4 bWoFnUj3HH2xt/8am/Nrhvtud/OUygqFovytCfnre4hkQCb6ZlFYiJICdJW5XJGwfkrU 3U/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hartkopp.net header.s=strato-dkim-0002 header.b=UW3vqTqc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l13-20020a056402230d00b0042ddac6eb39si21672489eda.239.2022.06.08.14.48.32; Wed, 08 Jun 2022 14:48:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@hartkopp.net header.s=strato-dkim-0002 header.b=UW3vqTqc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232482AbiFHUjP (ORCPT + 99 others); Wed, 8 Jun 2022 16:39:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232316AbiFHUjN (ORCPT ); Wed, 8 Jun 2022 16:39:13 -0400 Received: from mo4-p01-ob.smtp.rzone.de (mo4-p01-ob.smtp.rzone.de [85.215.255.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23695B0A79; Wed, 8 Jun 2022 13:39:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1654720732; 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=vPC4nYdjhDqJ8lKsGfPtKW79duI66lmrks2vdSL6r3Y=; b=UW3vqTqcFxaeo7mDo6EzjHifIGYUVVMlaRhMzwfOKmAR22mqvvTs/vkEECsc9GSe6R kzZTguFrFj16iTBnNCIaz5dKaU3pJj8AbIIHLdMTTJbKUtOY9MLSWWNjMwx7ps8HY+Bi M3vCH0obg++w/lTcwf2p8gw2JyXhLje3aDbTbTFDwfDUuWnzctG8+MkdiFrvo5hsDPp/ 6fxze/6FNVL9RAgp7IOQyEGwcMeM19HxkXaGB3XzgO7gn6h/f5yPB3exUhTG2Pmb+lTo zCa0Cjo++o60RmAgixyl+Wp/CTXnbQsQP3MM9rECobLugpmGxzBe85V0h4whUfRLVFyR ZFYw== Authentication-Results: strato.com; dkim=none X-RZG-AUTH: ":P2MHfkW8eP4Mre39l357AZT/I7AY/7nT2yrDxb8mjG14FZxedJy6qgO1q3DbdV+Ofov4eKO8Kg==" X-RZG-CLASS-ID: mo00 Received: from [172.20.10.8] by smtp.strato.de (RZmta 47.45.0 DYNA|AUTH) with ESMTPSA id R0691fy58KcoC46 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Wed, 8 Jun 2022 22:38:50 +0200 (CEST) Subject: Re: [PATCH v2 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: <20220608165116.1575390-1-dario.binacchi@amarulasolutions.com> <20220608165116.1575390-6-dario.binacchi@amarulasolutions.com> From: Oliver Hartkopp Message-ID: Date: Wed, 8 Jun 2022 22:38:50 +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: <20220608165116.1575390-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.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 This patch (at least) needs some rework. The patch cf124db566e6b036 ("net: Fix inconsistent teardown and release of private netdev state.") from DaveM added some priv_destructor dev->priv_destructor = sl_free_netdev; which is not taken into account in this patch. As written before I would like to discuss this change out of your patch series "can: slcan: extend supported features" as it is no slcan feature extension AND has to be synchronized with the drivers/net/slip/slip.c implementation. When it has not real benefit and introduces more code and may create side effects, this beautification should probably be omitted at all. Thanks, Oliver On 08.06.22 18:51, 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. > > Signed-off-by: Dario Binacchi > --- > > (no changes since v1) > > 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 929cb55e08af..cf05c30b8da5 100644 > --- a/drivers/net/can/slcan.c > +++ b/drivers/net/can/slcan.c > @@ -432,11 +432,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) > @@ -533,7 +539,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 */ >