Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1902362rwl; Thu, 6 Apr 2023 03:03:05 -0700 (PDT) X-Google-Smtp-Source: AKy350b1rmxwuX9RTxfnSJYSWOPGQ7fJ9SaEGKU7W+G8Q56gU6gO19aOnJUcS1kyrlgxj8CghybV X-Received: by 2002:a05:6a20:7a86:b0:db:9726:8e46 with SMTP id u6-20020a056a207a8600b000db97268e46mr2148497pzh.54.1680775385657; Thu, 06 Apr 2023 03:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680775385; cv=none; d=google.com; s=arc-20160816; b=ka0ZFyLGamlOpmPUVV5d1FNtQH3j83LDdLxRqlybV/iE40rw4LvB8J09z40lojNt0h aYnhzLR/BWZ3Qig8tvFk44l8CpNq36XiDzy46zJYluFFyssSgpsVB675DtmU/GLxQhR/ DsTit/Q+sI0w9/IqJ2SbgKRDeyTDlRec004zHsMRYnEz4px/OUD9Y1XsckdQGP8+LRIT wqDLryiwsK+ty6L3zj0h3e+Qz7ARPtSdDO7N6xjcqbNeOHYMfQEM4ltIGsYfdBo4liPi k0oFlQcxM1Eh8F9b9pKX1o1okfKZdFDmJ4u2QDU6FwoO781GQZl3DB5qpGVct6Sej742 c2Ig== 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=40Jd8m3DrCgqcHCewQ8GkhKssFC+kivgXN7oiXPPmlw=; b=dVfxUKoCyMx3P5c2cCugAsLkua3FR/GqXuq+yzFqUsYS4UCexl/7eOWQGmPmjAVALD EcXvZ6thyt1VFfdPSnb2o5QTAzil7auHXpiBlxnTa/9GMzi5vNArsf3IlVDuD2EhGcYC X3Rlx5qL9NYdvUxkplwEQDBcr5JktS+ZzSY4wAyAfF4zmHhal7aD+4D++76jdFfMefCb HJ0fCo6zTSMgrUFWWSrjFOHJt2+r8hFK0V6rVpEJkvE3sGe72433GVtin7+K9enw829P 8VxylVg35D7CF80QbbienafQIuwL9XqQR7M/uYTgDLyyZ/dXFksNpQSEAdrpn+6iqdri QFkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kKx34QXD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s8-20020a632c08000000b00513a4ba9ca0si876042pgs.722.2023.04.06.03.02.44; Thu, 06 Apr 2023 03:03:05 -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=@linuxfoundation.org header.s=korg header.b=kKx34QXD; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236884AbjDFKAw (ORCPT + 99 others); Thu, 6 Apr 2023 06:00:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236526AbjDFKA1 (ORCPT ); Thu, 6 Apr 2023 06:00:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5B2E86AB; Thu, 6 Apr 2023 03:00:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F07B96455C; Thu, 6 Apr 2023 10:00:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5A27C433EF; Thu, 6 Apr 2023 10:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1680775202; bh=WvH1QLnSC75c7SwSR4krkaAJCUF9p5g8TKLp+jWis7Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kKx34QXDiBpYMeOdyqG1cMkXCMSHVlSTIRiwCWuJuXOMOXlrex211Y6tZRGc5mlOO fRN/5A/7zX5zx5GFHEf7VFMATL90bpAqXa9WnIaFMuoISHzLy0/Hx5Kw3bc2ZYw7bj kloCJgm5v9nL3I8Ocv+IrclcbnDtuZphLhtewL64= Date: Thu, 6 Apr 2023 11:59:59 +0200 From: Greg KH To: Yangtao Li Cc: xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com, jefflexu@linux.alibaba.com, damien.lemoal@opensource.wdc.com, naohiro.aota@wdc.com, jth@kernel.org, rafael@kernel.org, linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 1/3] kobject: introduce kobject_is_added() Message-ID: <2023040628-cocoa-lizard-9941@gregkh> References: <20230406093056.33916-1-frank.li@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230406093056.33916-1-frank.li@vivo.com> X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_PASS 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 Thu, Apr 06, 2023 at 05:30:54PM +0800, Yangtao Li wrote: > Add kobject_is_added() to avoid consumers from directly accessing > the internal variables of kobject. > > Signed-off-by: Yangtao Li > --- > include/linux/kobject.h | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/include/linux/kobject.h b/include/linux/kobject.h > index bdab370a24f4..b5cdb0c58729 100644 > --- a/include/linux/kobject.h > +++ b/include/linux/kobject.h > @@ -203,6 +203,11 @@ static inline const struct kobj_type *get_ktype(const struct kobject *kobj) > return kobj->ktype; > } > > +static inline int kobject_is_added(struct kobject *kobj) > +{ > + return kobj->state_in_sysfs; > +} > + No, this implies that the caller is not doing something correctly as it should always know if it has added a kobject or not. Let me review the please where you used this to find the problems there... thanks, greg k-h