From: Grant Likely <grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: "Li.Xiubo-KZfg59tc24xl57MIdRCFDg@public.gmane.org"
<Li.Xiubo-KZfg59tc24xl57MIdRCFDg@public.gmane.org>,
"robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org"
<robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
"devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: RE: [PATCH] of: fix of_update_property [v2]
Date: Thu, 03 Apr 2014 18:51:12 +0100 [thread overview]
Message-ID: <20140403175112.DF1FFC4200D@trevor.secretlab.ca> (raw)
In-Reply-To: <9622800c30f5412a9bbb9dfd95def751-+7O3WWA3DPshjIn37xzcLOO6mTEJWrR4XA4E9RH9d+qIuWR1G4zioA@public.gmane.org>
On Wed, 2 Apr 2014 05:29:53 +0000, "Li.Xiubo-KZfg59tc24xl57MIdRCFDg@public.gmane.org" <Li.Xiubo-KZfg59tc24xl57MIdRCFDg@public.gmane.org> wrote:
>
>
> > > @@ -1776,25 +1776,26 @@ int of_update_property(struct device_node *np,
> > struct property *newprop)
> > > if (!newprop->name)
> > > return -EINVAL;
> > >
> > > - oldprop = of_find_property(np, newprop->name, NULL);
> > > - if (!oldprop)
> > > - return of_add_property(np, newprop);
> > > -
> > > raw_spin_lock_irqsave(&devtree_lock, flags);
> > > - next = &np->properties;
> > > - while (*next) {
> > > + oldprop = __of_find_property(np, newprop->name, NULL);
> > > + if (!oldprop) {
> > > + /* add the node */
> > > + rc = __of_add_property(np, newprop);
> > > + } else {
> >
> > if you changed this line to:
> > } else while (*next) {
> > then most of the other changes go away. You don't need the separate
> > while loop
>
> Yes, I will fix this.
>
>
> > and the function remains largely identical aside from moving
> > the __of_find_property() into the spinlock.
> >
>
> But, from the following codes, we can see that, if oldprop != NULL
> Meaning that we have found it, and should just do the updatation later:
> +++++++++++++++
> oldprop = of_find_property(np, newprop->name, NULL);
> if (!oldprop)
> return of_add_property(np, newprop);
> ---------------
>
>
>
> > > /* found the node */
> > > newprop->next = oldprop->next;
> > > *next = newprop;
> > > oldprop->next = np->deadprops;
> > > np->deadprops = oldprop;
> > > - found = 1;
>
> And why the 'found' flag is here is that the oldprop maybe removed
> just before the spin_lock and after of_find_property().
>
> And so use and move __of_find_property() and __of_add_property() into
> the spinlock could avoid this...
Isn't that what I said?
g.
>
>
> Thanks,
> --
>
> BRs,
> Xiubo
>
>
> > > - break;
> > > }
> > > - next = &(*next)->next;
> > > }
> > > raw_spin_unlock_irqrestore(&devtree_lock, flags);
> > > +
> > > if (rc)
> > > return rc;
> > >
> > > @@ -1803,9 +1804,6 @@ int of_update_property(struct device_node *np, struct
> > property *newprop)
> > > sysfs_remove_bin_file(&np->kobj, &oldprop->attr);
> > > __of_add_property_sysfs(np, newprop);
> > >
> > > - if (!found)
> > > - return -ENODEV;
> > > -
> > > return 0;
> > > }
> > >
> > > --
> > > 1.8.4
> > >
> > >
> >
> >
>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-04-03 17:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-01 5:51 [PATCH] of: fix of_update_property [v2] Xiubo Li
[not found] ` <1396331486-29354-1-git-send-email-Li.Xiubo-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2014-04-01 9:19 ` Grant Likely
[not found] ` <20140401091920.E8E45C408A6-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2014-04-02 5:29 ` Li.Xiubo-KZfg59tc24xl57MIdRCFDg
[not found] ` < 20140401091920.E8E45C408A6@trevor.secretlab.ca>
[not found] ` < 9622800c30f5412a9bbb9dfd95def751@BY2PR03MB505.namprd03.prod.outlook.com>
[not found] ` <9622800c30f5412a9bbb9dfd95def751-+7O3WWA3DPshjIn37xzcLOO6mTEJWrR4XA4E9RH9d+qIuWR1G4zioA@public.gmane.org>
2014-04-03 17:51 ` Grant Likely [this message]
[not found] ` <20140403175112.DF1FFC4200D-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2014-04-04 8:00 ` Li.Xiubo-KZfg59tc24xl57MIdRCFDg
2014-04-04 8:30 ` Li.Xiubo-KZfg59tc24xl57MIdRCFDg
[not found] ` < 20140403175112.DF1FFC4200D@trevor.secretlab.ca>
[not found] ` < 179ad743feea49bb946a3b31a629e229@BY2PR03MB505.namprd03.prod.outlook.com>
[not found] ` <179ad743feea49bb946a3b31a629e229-+7O3WWA3DPshjIn37xzcLOO6mTEJWrR4XA4E9RH9d+qIuWR1G4zioA@public.gmane.org>
2014-04-04 14:28 ` Grant Likely
[not found] ` <20140404142855.D6C42C41E5F-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2014-04-08 1:57 ` Li.Xiubo-KZfg59tc24xl57MIdRCFDg
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=20140403175112.DF1FFC4200D@trevor.secretlab.ca \
--to=grant.likely-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=Li.Xiubo-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/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).