Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp624395pxa; Thu, 27 Aug 2020 11:10:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgr9RETxZ7NIdxONh7VfUQjJ4+5/bGDQX1OeijfsYXwijJqMuhmPCKBmZmq4rMzv04ow9j X-Received: by 2002:a50:eb96:: with SMTP id y22mr14549848edr.371.1598551821815; Thu, 27 Aug 2020 11:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598551821; cv=none; d=google.com; s=arc-20160816; b=JsoqgsGUwfRWadFmn1ed4Mv2wmWEhYsfKtl+x7y4Fsvc4E0d7XnYeyW3rXhJTjgxnT rSGkwnPk1Cf5Pq1TX2KOOkIQznej7TI890NFKfu69UUkctE3it7xuK9AF2USKfQXDGjc HGXrhL5BIqy6QjnfI9OIk8ZnxOvfcGY5XkbAnxf0hsUGcGgKIMWwJFVQshfg3ghUcxyB Hv5UPyBjgExcRVpOm2yFn7Za8MMDoPJDVkcnq/DIrsxvKdJJzU782m8JABbLJsrAQjZl uSReau5cfiFwLqgNY3/mDSkbLG9puge6/Xyzc1/vH2YtmIv2yuQBq0WhMH+elkM/0UfZ Et1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=X3yZk4R92/MWzVrt+vnYcwH9WkmjTyPPJoHeGH+6ZfI=; b=Fn6qOlH9S0E+cIo4WAL3kzlRlGjrcVEkcI7JlI2YoSCNSE5mzDzTWNksexaNTUvgQG 5L8M8f1tUpRhDnNG3Gjf4Fh/7kF+7IUD9FuidyOGiygm/ov45h/YrANtrw/COsS63Imh sqnkbnwkX8cX0/3WwOwvl9BcrJ0bQ84yuR5m5maYXcu1AOwKYqBjJLB/2J66Zjfh4fVz uut3VK0m5MBSUIfDgJsrL4zMNeU7pnHAFLUgjIKWK1h2EuVi7qAZflJqt6TYPIUsmk8W RlGzL8H/GiRcgeLOQpM2NuNcmPaPBnDk0klTQbTOUZqAUdd/IGcXSSfaXQsBkzAls/G3 zQGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=gVsG4nbl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z66si1077655ede.394.2020.08.27.11.09.57; Thu, 27 Aug 2020 11:10:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=gVsG4nbl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727031AbgH0SIH (ORCPT + 99 others); Thu, 27 Aug 2020 14:08:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727048AbgH0SH7 (ORCPT ); Thu, 27 Aug 2020 14:07:59 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4455C06121B for ; Thu, 27 Aug 2020 11:07:58 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id j25so8894648ejk.9 for ; Thu, 27 Aug 2020 11:07:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=X3yZk4R92/MWzVrt+vnYcwH9WkmjTyPPJoHeGH+6ZfI=; b=gVsG4nblq60V5WQE20uNem0i8ZWEjFlXUgY1QEYqw0+8GrhUOSNTloxcWQky/H00yz SokChI0VSHdZVRL2uFUtsdQZb37+c4vwHyC4tKMzLrY2rtF0fdH9Ythr85tApJaSrTTu W1ADxHAjQTR/9o13N06/BJcK7O29NTPzgth0w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=X3yZk4R92/MWzVrt+vnYcwH9WkmjTyPPJoHeGH+6ZfI=; b=JUffPIto3la2Dab9Frg7KXfr2fo6iSgqOB9x5PYRTM+5VYN4u5PfuKIcAYycr3eOon 8cT7cc19CJ4xdcYQRo6545ntLsDkviwf4Qe8Im4pWooQkCCBr2szIrpdUSZQcea9P4AN XfehDBHyM5JpGpC6dlNqR08nh8095hhbaloZZzmGKguGzG+ShDQrarsnUlp9xqhBgZ8j Azbt9s3cPf8SMUpom0nRJ8UJuDzZDR56LOpr1rmYL+KKcGXDTXed8BEVOyYoYRp/zT2t jeSobEAe7X1ndnOZyNy283UjU9fh9pii7eNmfQCXJV1UD7yVHTb9GmWNDK2zlClMFYZv DjPg== X-Gm-Message-State: AOAM530ToxIBV/IOqDLrnzszL5ddXXA39Ke7BVYAgAp9b1ev4DHoc8c1 y5lhF8vlTMyyfnaSq0LbdeJBLA== X-Received: by 2002:a17:906:2e98:: with SMTP id o24mr21267780eji.229.1598551677360; Thu, 27 Aug 2020 11:07:57 -0700 (PDT) Received: from [192.168.1.149] (5.186.112.31.cgn.fibianet.dk. [5.186.112.31]) by smtp.gmail.com with ESMTPSA id u6sm2452164ejf.98.2020.08.27.11.07.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 27 Aug 2020 11:07:56 -0700 (PDT) Subject: Re: [PATCH] linux/kernel.h: add container_from() To: Allen Pais , torvalds@linux-foundation.org Cc: akpm@linux-foundation.org, keescook@chromium.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, "James E . J . Bottomley" , Greg Kroah-Hartman , Jens Axboe References: <20200827013636.149307-1-allen.lkml@gmail.com> From: Rasmus Villemoes Message-ID: <2176d7e4-2949-e922-1988-fa5eedfc2220@rasmusvillemoes.dk> Date: Thu, 27 Aug 2020 20:07:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200827013636.149307-1-allen.lkml@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/08/2020 03.36, Allen Pais wrote: > Introduce container_from() as a generic helper instead of > sub-systems defining a private from_* API > (Eg: from_tasklets recently introduced in > 12cc923f1ccc: Tasklet: Introduce new initialization API) > > The helper is similar to container_of() in argument order > with the difference of naming the containing structure instead ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > of having to specify its type. > > +/** > + * container_from - cast a member of a structure out to the containing structure > + * @ptr: the pointer to the member. > + * @container: the type of the container struct. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This seems to have been copy-pasted from container_of? Shouldn't @container be the (local) value we're storing into? As in foo = container_from(..., foo, ...)? Or am I misunderstanding the purpose of this? [And I think it would read nicer if the bikeshed was called to_container(), but don't care deeply.] Rasmus