public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: kah.jing.lee@intel.com, linux-kernel@vger.kernel.org,
	arnd@arndb.de, rafael.j.wysocki@intel.com,
	tien.sung.ang@intel.com, dinh.nguyen@intel.com, Zhou@kroah.com,
	Furong <furong.zhou@intel.com>, Vinod Koul <vkoul@kernel.org>,
	Bard Liao <yung-chuan.liao@linux.intel.com>
Subject: Re: [PATCH v2 1/3] drivers: misc: intel_sysid: Add sysid from arch to drivers
Date: Fri, 29 Jul 2022 15:57:45 +0200	[thread overview]
Message-ID: <YuPnWcTNDEmkxfOo@kroah.com> (raw)
In-Reply-To: <YuPK6cvPJvL+L3/t@kroah.com>

On Fri, Jul 29, 2022 at 01:56:25PM +0200, Greg KH wrote:
> On Fri, Jul 29, 2022 at 01:43:55PM +0200, Greg KH wrote:
> > On Thu, Jul 28, 2022 at 11:53:33AM -0500, Pierre-Louis Bossart wrote:
> > > 
> > > 
> > > On 7/28/22 10:59, Greg KH wrote:
> > > > On Thu, Jul 28, 2022 at 10:37:37AM -0500, Pierre-Louis Bossart wrote:
> > > >> Thanks for the review Greg,
> > > >>
> > > >>>> +static int intel_sysid_probe(struct platform_device *pdev)
> > > >>>> +{
> > > >>>> +	struct intel_sysid *sysid;
> > > >>>> +	struct resource	*regs;
> > > >>>> +
> > > >>>> +	sysid = devm_kzalloc(&pdev->dev, sizeof(struct intel_sysid),
> > > >>>> +		GFP_KERNEL);
> > > >>>> +	if (!sysid)
> > > >>>> +		return -ENOMEM;
> > > >>>> +
> > > >>>> +	regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > > >>>> +	if (!regs)
> > > >>>> +		return -ENXIO;
> > > >>>> +
> > > >>>> +	sysid->regs = devm_ioremap_resource(&pdev->dev, regs);
> > > >>>> +	if (IS_ERR(sysid->regs))
> > > >>>> +		return PTR_ERR(sysid->regs);
> > > >>>> +
> > > >>>> +	platform_set_drvdata(pdev, sysid);
> > > >>>> +
> > > >>>> +	return devm_device_add_group(&pdev->dev, &intel_sysid_attr_group);
> > > >>>
> > > >>> You just raced with userspace and lost.  Please use the default group
> > > >>> for the platform device.
> > > >>>
> > > >>> I need to go remove this function, it should not be used at all as it is
> > > >>> broken.
> > > >>
> > > >> Can you elaborate on the issue and suggested replacement?
> > > >>
> > > >> We used this function for the SoundWire sysfs based on your review
> > > >> comments (2 years ago?) that we should not muck with kobj, and that
> > > >> function devm_device_add_group() is also used in a probe function.
> > > > 
> > > > Use the default_groups pointer in the driver structure.
> > > 
> > > did you mean dev_groups?
> > 
> > Yes, sorry, that's the correct name.
> > 
> > > I am not following the idea, for SoundWire all the attributes are really
> > > device-specific or described by ACPI and cannot be hard-coded in the
> > > driver structure.
> > 
> > That's what the is_visible() callback is for in the groups structure,
> > you determine if the attribute is visable or not at runtime, you don't
> > rely on the driver itself to add/remove attributes, that does not scale
> > and again, is racy.
> 
> In looking at your attribute code, ick, you dynamically create a ton of
> them.  But for the ones that you do not, you can just have the driver
> core add them.  Let me make up a patch that shows what I am thinking
> of...

Here's a series for this:
	https://lore.kernel.org/r/20220729135041.2285908-1-gregkh@linuxfoundation.org

I'll go fix up the other devm_device_add_groups() users, and then start
tackling devm_device_add_group() as well.

thanks,

greg k-h

  reply	other threads:[~2022-07-29 13:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-02 12:20 [PATCH 0/2] New driver for Intel(Altera) FPGA System ID softIP kah.jing.lee
2022-06-03  6:41 ` Greg KH
2022-06-03  7:35   ` kah.jing.lee
2022-07-21 12:30 ` [PATCH v2 0/3] " kah.jing.lee
2022-07-21 12:31   ` [PATCH v2 1/3] drivers: misc: intel_sysid: Add sysid from arch to drivers kah.jing.lee
2022-07-27 21:02     ` kernel test robot
2022-07-28  7:53     ` Greg KH
2022-07-28 15:37       ` Pierre-Louis Bossart
2022-07-28 15:59         ` Greg KH
2022-07-28 16:53           ` Pierre-Louis Bossart
2022-07-29 11:43             ` Greg KH
2022-07-29 11:56               ` Greg KH
2022-07-29 13:57                 ` Greg KH [this message]
2022-07-28  7:57     ` Greg KH
2022-08-14 12:07     ` kernel test robot
2022-07-21 12:32   ` [PATCH v2 2/3] dt-bindings: misc: intel_sysid: Add the system id binding for Altera(Intel) FPGA platform kah.jing.lee
2022-07-21 19:16     ` Greg KH
2022-07-25  3:47       ` kah.jing.lee
2022-07-25  3:56     ` [PATCH v3 " kah.jing.lee
2022-07-21 12:32   ` [PATCH v2 3/3] documentation: misc: intel_sysid: Add the system id sysfs documentation " kah.jing.lee
2022-07-21 19:16     ` Greg KH
2022-07-25  3:59     ` [PATCH v3 " kah.jing.lee
2022-07-28  7:51       ` Greg KH
2022-07-28  7:58   ` [PATCH v2 0/3] New driver for Intel(Altera) FPGA System ID softIP Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YuPnWcTNDEmkxfOo@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=Zhou@kroah.com \
    --cc=arnd@arndb.de \
    --cc=dinh.nguyen@intel.com \
    --cc=furong.zhou@intel.com \
    --cc=kah.jing.lee@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=tien.sung.ang@intel.com \
    --cc=vkoul@kernel.org \
    --cc=yung-chuan.liao@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox