Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp760779pxb; Tue, 12 Apr 2022 12:44:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBD0qS/HRTReOx3NwAR5GwGVh0gP3u0VuXFrept6K52wzmu8QHqte5qUsAW7gm8NMYbF93 X-Received: by 2002:a17:903:2cb:b0:14f:4fb6:2fb0 with SMTP id s11-20020a17090302cb00b0014f4fb62fb0mr38146879plk.172.1649792692088; Tue, 12 Apr 2022 12:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649792692; cv=none; d=google.com; s=arc-20160816; b=Y/9j/s3FUBTGjF0Qh65jUYJOdpOaJgBAa/FSXziyTBT7UxkKTGxqc946j/HImdlKhw Vzx8mPiRh0854hr6/Pd7ngEaBjalOd46FFLvyQ1xJQoPWEAhmgJ2TFuDbcYDIrGhcAuW lPScprjIF6wMnUOO55yc9DY7/W8touoEAsF0F6fiqTcn+1DzrTSvrd7IMjU/HjRgDN08 g9zHs2MKBGGGyWDVUmeUtyyDr9QrE/W7w30y4zXYYOBKaOcONzw9CtQy5UW7xqd/IP6C U5fnqNlZG14j0DbAD8xmMOzO97Eyyv2o2Tcb2awRrctj+o9WZ1tv40WRdRFbJSknm5OB keZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=40nfkm7AJFhrLlgoTZd+KNaCMw5aAK6dNL2X6kEOaPU=; b=XGucDjQGUmiYV2/l9RWUXBfQhX0y7rsbuNNyl+jifBWgYKhLSKbY4astzkPduKNlcU /l9Bh3cs7nl+ycpVVwhhIVbXWheLCKhDALb13L9nJG28YoyUT3BUWUdUJgQxJfxFW+RM eUQK0rsoMnKhm3s62DP/i1mc2Z9zU3ceViWZnZ0rdHQuJUajIoG93nWrkXq24n8UrUFk N3LO8G5e4YmX4NosTbBOgsE+isCjt4+r6kuhQZAASCrh7PxI2eAxWr6vBaSLHFMRYKJh v3cIWuyBYoqz1hc5aHzhvUz1joi81HG0+QgYgUSbPiNCBTMm0Yfi9UsblOv155z3Mf/+ ikPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FLUUa7pA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 31-20020a63105f000000b003816043f09esi3408892pgq.659.2022.04.12.12.44.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 12:44:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FLUUa7pA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DE5A065D23; Tue, 12 Apr 2022 12:43:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233331AbiDLEAF (ORCPT + 99 others); Tue, 12 Apr 2022 00:00:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbiDLEAB (ORCPT ); Tue, 12 Apr 2022 00:00:01 -0400 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5388720F5D for ; Mon, 11 Apr 2022 20:57:44 -0700 (PDT) Received: by mail-qt1-x82f.google.com with SMTP id q6so7233429qtn.4 for ; Mon, 11 Apr 2022 20:57:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=40nfkm7AJFhrLlgoTZd+KNaCMw5aAK6dNL2X6kEOaPU=; b=FLUUa7pAkmcOG05Rc9OftUY87lGEUxCbrJQ7/SOliJA9Ykq6xkAcFgcbXkpMOg2kVZ L8QUyRyRAgoPCmg112qYV3BMMby5ETwND3amZT9RdeVkO5CZB3iAYByCa2WpaopAnV5l u/RqrlAbTp60+FI+Mi8AgP6xABq2Qd6QyD0UEa6dRNZkuTOQGHu372NpkRrMky/ah+vx TWLQSVYgPs6NdL5Zh/+8Iy32yZaZZFrANBj0q+PF/1tOC1X3zo8LqX+9WWWSHF4G3bii YOTtxFOLxjGtfTiH5q/dOqW+/g2MaN2q3ySZyvbnIXnp7eBkJbvxuoyweYtD1JYM+iYD MKLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=40nfkm7AJFhrLlgoTZd+KNaCMw5aAK6dNL2X6kEOaPU=; b=rI713mSpFCw4RakbLBE4uL+SCDLbJmhIcGAPcfeY4cHygT0D5n1UuQS7TwVAeYL7al /P//chpD3fXbwx8DmF4NfDr7laEkKXXiPAojnjf9h6kkvZgfYRgZCLbGwHMAHzWgW9mc 2MGOvVeyaSpznRu2DUjDQeauFXa4F8zB9b6xTJl34EJ5+vBt07dr/+Tf4ZhwnGW3ebOd 5+c+tGHRxtGpnJvnop+fAUuMLwCvy7C1f6iW7OiOFw1JyYsmMt/oTGyUOyhgNRrqdA6b hFXzLsxNVXoDLStGp7p/xIGt6dUZhv6IvLe/Da850UB0p5RmPb0EXE/L6tVoLcE0Iyv9 3ZNQ== X-Gm-Message-State: AOAM532+jo7UWxw1FNzeMT0tmsXfvypMHQEwE756tpS2drKzChhI5IlV /osgbi0QmF2ShaT7cGWk6z11k9cCNg4ko3OQ X-Received: by 2002:ac8:4f57:0:b0:2ed:d8f:d0bc with SMTP id i23-20020ac84f57000000b002ed0d8fd0bcmr1926261qtw.280.1649735863414; Mon, 11 Apr 2022 20:57:43 -0700 (PDT) Received: from jaehee-ThinkPad-X1-Extreme ([2607:fb90:50fb:900e:25ab:983d:ac30:58b5]) by smtp.gmail.com with ESMTPSA id 8-20020ac85948000000b002e1cd3fa142sm28152189qtz.92.2022.04.11.20.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 20:57:42 -0700 (PDT) Date: Mon, 11 Apr 2022 23:57:39 -0400 From: Jaehee Park To: Dan Carpenter Cc: =?iso-8859-1?B?Suly9G1l?= Pouiller , Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, outreachy@lists.linux.dev, Stefano Brivio Subject: Re: [PATCH v2] staging: wfx: use container_of() to get vif Message-ID: <20220412035739.GA2856917@jaehee-ThinkPad-X1-Extreme> References: <20220408032349.GA2132476@jaehee-ThinkPad-X1-Extreme> <20220408061936.GP3293@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220408061936.GP3293@kadam> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Fri, Apr 08, 2022 at 09:19:36AM +0300, Dan Carpenter wrote: > On Thu, Apr 07, 2022 at 11:23:49PM -0400, Jaehee Park wrote: > > diff --git a/drivers/staging/wfx/wfx.h b/drivers/staging/wfx/wfx.h > > index 6594cc647c2f..78f2a416fe4f 100644 > > --- a/drivers/staging/wfx/wfx.h > > +++ b/drivers/staging/wfx/wfx.h > > @@ -25,6 +25,8 @@ > > #define USEC_PER_TXOP 32 /* see struct ieee80211_tx_queue_params */ > > #define USEC_PER_TU 1024 > > > > +#define wvif_to_vif(ptr)(container_of((void *)ptr, struct ieee80211_vif, drv_priv)) > > + > > Better to make this a function. > Hi Dan, Thank you for your comments. To make sure I'm understanding your concerns correctly, do you mean I should define a function instead of using this macros here? > Stefano's comments are correct. It would have saved space with the 80 > limit to do a "struct ieee80211_vif *vif = wvif_to_vif();" at the start Got it. I implemented this on the next patch (v3) that I will be sending out soon. > of the function. Also dereferencing the results of a function call > like this, "frob(foo)->bar", without checking makes me itch. If it's > at the top of the function then that's kind of different. I normally > assume that the functions in the declaration block cannot fail. From > analysing static checker warnings, putting functions which can fail in > that the declaration block is risky. > The frob(foo)->bar in my case would be wvif_to_vif(wvif)->type? > It's always better to test things but this patch looks correct to me: > > The add interface does: > > struct wfx_vif *wvif = (struct wfx_vif *)vif->drv_priv > ... > wvif->vif = vif; > > The remove interface does: > wvif->vif = NULL; > > Those are the only places where ->vif is set container_of() will always > work. Yes this is true. The add and remove interface was the inspiration point for this patch. > > regards, > dan carpenter >