From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Felipe Balbi <balbi@kernel.org>,
Mathias Nyman <mathias.nyman@intel.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"open list:ULTRA-WIDEBAND (UWB) SUBSYSTEM:"
<linux-usb@vger.kernel.org>
Subject: Re: [PATCH 1/6] software node: Provide replacement for device_add_properties()
Date: Tue, 2 Feb 2021 17:08:40 +0100 [thread overview]
Message-ID: <CAJZ5v0hVZBhqzLPGPHDZYPcYyJPfwgYwjzKGYaUMZOBw7Eh7CQ@mail.gmail.com> (raw)
In-Reply-To: <20210202150102.GA1687065@kuha.fi.intel.com>
On Tue, Feb 2, 2021 at 4:01 PM Heikki Krogerus
<heikki.krogerus@linux.intel.com> wrote:
>
> Hi Rafael,
>
> On Tue, Feb 02, 2021 at 03:44:05PM +0100, Rafael J. Wysocki wrote:
> > > +/**
> > > + * device_create_managed_software_node - Create a software node for a device
> > > + * @dev: The device the software node is assigned to.
> > > + * @properties: Device properties for the software node.
> > > + * @parent: Parent of the software node.
> > > + *
> > > + * Creates a software node as a managed resource for @dev, which means the
> > > + * lifetime of the newly created software node is tied to the lifetime of @dev.
> > > + * Software nodes created with this function should not be reused or shared
> > > + * because of that. The function takes a deep copy of @properties for the
> > > + * software node.
> > > + *
> > > + * Since the new software node is assigned directly to @dev, and since it should
> > > + * not be shared, it is not returned to the caller. The function returns 0 on
> > > + * success, and errno in case of an error.
> > > + */
> > > +int device_create_managed_software_node(struct device *dev,
> > > + const struct property_entry *properties,
> > > + const struct software_node *parent)
> > > +{
> > > + struct fwnode_handle *p = software_node_fwnode(parent);
> > > + struct fwnode_handle *fwnode;
> > > +
> > > + if (parent && !p)
> > > + return -EINVAL;
> > > +
> > > + fwnode = fwnode_create_software_node(properties, p);
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> To answer your question below: here.
>
> > > + if (IS_ERR(fwnode))
> > > + return PTR_ERR(fwnode);
> > > +
> > > + to_swnode(fwnode)->managed = true;
> > > + set_secondary_fwnode(dev, fwnode);
> > > +
> > > + return 0;
> > > +}
> > > +EXPORT_SYMBOL_GPL(device_create_managed_software_node);
> > > +
> > > int software_node_notify(struct device *dev, unsigned long action)
> > > {
> > > struct swnode *swnode;
> > > @@ -1073,6 +1111,11 @@ int software_node_notify(struct device *dev, unsigned long action)
> > > sysfs_remove_link(&swnode->kobj, dev_name(dev));
> > > sysfs_remove_link(&dev->kobj, "software_node");
> > > kobject_put(&swnode->kobj);
> > > +
> > > + if (swnode->managed) {
> > > + set_secondary_fwnode(dev, NULL);
> > > + kobject_put(&swnode->kobj);
> >
> > Where does the corresponding kobject_get() get called?
>
> So in function fwnode_create_software_node() we use
> kobject_init_and_add().
OK
It looks like there is a use case that cannot be addressed by using
device_add_properties() and that's why you need this new function.
Can you describe that use case, please, and explain what the problem
with using device_add_properties() in it is?
next prev parent reply other threads:[~2021-02-02 16:12 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-02 12:50 [PATCH 0/6] usb: Handle device properties with software node API Heikki Krogerus
2021-02-02 12:50 ` [PATCH 1/6] software node: Provide replacement for device_add_properties() Heikki Krogerus
2021-02-02 14:44 ` Rafael J. Wysocki
2021-02-02 15:01 ` Heikki Krogerus
2021-02-02 16:08 ` Rafael J. Wysocki [this message]
2021-02-03 9:45 ` Heikki Krogerus
2021-02-03 13:50 ` Rafael J. Wysocki
2021-02-03 14:26 ` Heikki Krogerus
2021-02-03 14:39 ` Rafael J. Wysocki
2021-02-03 14:51 ` Heikki Krogerus
2021-02-02 12:50 ` [PATCH 2/6] usb: dwc2: pci: Drop the empty quirk function Heikki Krogerus
2021-02-02 12:50 ` [PATCH 3/6] usb: dwc3: haps: Constify the software node Heikki Krogerus
2021-02-02 16:45 ` kernel test robot
2021-02-02 19:27 ` kernel test robot
2021-02-02 12:50 ` [PATCH 4/6] usb: dwc3: qcom: " Heikki Krogerus
2021-02-02 16:40 ` kernel test robot
2021-02-02 16:54 ` kernel test robot
2021-02-02 12:50 ` [PATCH 5/6] usb: dwc3: host: Use software node API with the properties Heikki Krogerus
2021-02-02 12:50 ` [PATCH 6/6] xhci: ext-caps: " Heikki Krogerus
2021-02-02 13:53 ` Hans de Goede
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=CAJZ5v0hVZBhqzLPGPHDZYPcYyJPfwgYwjzKGYaUMZOBw7Eh7CQ@mail.gmail.com \
--to=rafael@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@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;
as well as URLs for NNTP newsgroup(s).