From: Greg KH <greg@kroah.com>
To: Mike Turquette <mturquette@ti.com>
Cc: linux@arm.linux.org.uk, linux-kernel@vger.kernel.org,
linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
jeremy.kerr@canonical.com, broonie@opensource.wolfsonmicro.com,
tglx@linutronix.de, linus.walleij@stericsson.com,
amit.kucheria@linaro.org, dsaxena@linaro.org, patches@linaro.org,
linaro-dev@lists.linaro.org, aul@pwsan.com,
grant.likely@secretlab.ca, sboyd@quicinc.com,
shawn.guo@freescale.com, skannan@quicinc.com,
magnus.damm@gmail.com, arnd.bergmann@linaro.org,
eric.miao@linaro.org, richard.zhao@linaro.org,
Mike Turquette <mturquette@linaro.org>
Subject: Re: [PATCH v3 5/5] clk: export tree topology and clk data via sysfs
Date: Tue, 22 Nov 2011 07:49:00 -0800 [thread overview]
Message-ID: <20111122154900.GB18954@kroah.com> (raw)
In-Reply-To: <1321926047-14211-6-git-send-email-mturquette@linaro.org>
On Mon, Nov 21, 2011 at 05:40:47PM -0800, Mike Turquette wrote:
> Introduces kobject support for the common struct clk, exports per-clk
> data via read-only callbacks and models the clk tree topology in sysfs.
>
> Also adds support for generating the clk tree in clk_init and migrating
> nodes when input sources are switches in clk_set_parent.
>
> Signed-off-by: Mike Turquette <mturquette@linaro.org>
Thanks Arnd for pointing me at this.
> +#define MAX_STRING_LENGTH 32
Why?
> +static struct kobject *clk_kobj;
> +LIST_HEAD(kobj_list);
Um, no, please NEVER use raw kobjects, you should be using struct device
instead. Please change the code to do that.
> +static ssize_t clk_show(struct kobject *kobj, struct attribute *attr,
> + char *buf)
> +{
> + struct clk *clk;
> + struct clk_attribute *clk_attr;
> + ssize_t ret = -EINVAL;
> +
> + clk = container_of(kobj, struct clk, kobj);
> + clk_attr = container_of(attr, struct clk_attribute, attr);
> +
> + if (!clk || !clk_attr)
> + goto out;
> +
> + /* we don't do any locking for debug operations */
> +
> + /* refcount++ */
> + kobject_get(&clk->kobj);
> +
> + if (clk_attr->show)
> + ret = clk_attr->show(clk, buf);
> + else
> + ret = -EIO;
> +
> + /* refcount-- */
> + kobject_put(&clk->kobj);
Why in the world would you be incrementing and decrementing the
reference count of the kobject in the show function? What are you
trying to protect here that is not already protected by the core?
> +static void clk_release(struct kobject *kobj)
> +{
> + struct clk *clk;
> +
> + clk = container_of(kobj, struct clk, kobj);
> +
> + complete(&clk->kobj_unregister);
> +}
Look Ma, a memory leak!
> +static struct kobj_type clk_ktype = {
> + .sysfs_ops = &clk_ops,
> + .default_attrs = clk_default_attrs,
> + .release = clk_release,
> +};
> +
> +int clk_kobj_add(struct clk *clk)
> +{
> + if (IS_ERR(clk))
> + return -EINVAL;
> +
> + /*
> + * Some kobject trickery!
> + *
> + * We want to (ab)use the kobject infrastructure to track our
> + * tree topology for us, specifically the root clocks (which are
> + * otherwise not remembered in a global list).
> + * Unfortunately we might not be able to allocate memory yet
> + * when this path is hit. This pretty much rules out anything
> + * that looks or smells like kobject_add, since there are
> + * allocations for kobject->name and a dependency on sysfs being
> + * initialized.
> + *
> + * To get around this we initialize the kobjects and (ab)use
> + * struct kobject's list_head member, "entry". Later on we walk
> + * this list in clk_sysfs_tree_create() to make proper
> + * kobject_add calls once it is safe to do so.
> + *
> + * FIXME - this is starting to smell alot like clkdev (i.e.
> + * tracking the clocks in a list)
Ah, comments like this warm my heart.
Come on, no abusing the kobject code please, if have problems with how
the kernel core works, and it doesn't do things you want it to, then why
not change it to work properly for you, or at the least, ASK ME!!!
> + */
> +
> + kobject_init(&clk->kobj, &clk_ktype);
> + list_add_tail(&clk->kobj.entry, &kobj_list);
Yeah, no kobject lists for you, sorry, DO NOT DO THIS!
> +static int __init clk_sysfs_init(void)
> +{
> + struct list_head *tmp;
> +
> + clk_kobj = kobject_create_and_add("clk", NULL);
> +
> + WARN_ON(!clk_kobj);
Why? What is this helping with?
Please rewrite to use 'struct device'.
thanks,
greg k-h
next prev parent reply other threads:[~2011-11-22 15:49 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-22 1:40 [PATCH v3 0/5] common clk framework Mike Turquette
2011-11-22 1:40 ` [PATCH v3 1/5] clk: Kconfig: add entry for HAVE_CLK_PREPARE Mike Turquette
2011-11-26 0:51 ` Shawn Guo
2011-11-22 1:40 ` [PATCH v3 2/5] Documentation: common clk API Mike Turquette
2011-11-23 2:03 ` Saravana Kannan
2011-11-23 20:33 ` Turquette, Mike
2011-11-26 8:47 ` Shawn Guo
2011-11-27 1:43 ` Turquette, Mike
2011-11-22 1:40 ` [PATCH v3 3/5] clk: introduce the common clock framework Mike Turquette
2011-11-23 3:12 ` Saravana Kannan
2011-11-23 21:30 ` Turquette, Mike
2011-11-26 13:22 ` Shawn Guo
2011-11-27 6:00 ` Turquette, Mike
2011-12-01 1:20 ` Paul Walmsley
2011-12-01 5:53 ` Turquette, Mike
2011-12-01 6:39 ` Paul Walmsley
2011-12-01 14:42 ` Mark Brown
2011-12-01 18:25 ` Turquette, Mike
2011-12-01 18:30 ` Paul Walmsley
2011-12-01 18:32 ` Mark Brown
2011-12-01 22:03 ` Russell King - ARM Linux
2011-12-03 1:04 ` Paul Walmsley
2011-12-01 8:45 ` Russell King - ARM Linux
2011-12-02 17:13 ` Paul Walmsley
2011-12-02 20:23 ` Russell King - ARM Linux
2011-12-02 20:32 ` Uwe Kleine-König
2011-12-01 2:13 ` Paul Walmsley
2011-12-05 21:15 ` Paul Walmsley
2011-12-05 23:48 ` Russell King - ARM Linux
2011-12-06 1:37 ` Paul Walmsley
2011-12-06 6:28 ` Paul Walmsley
2011-12-05 23:40 ` Turquette, Mike
2011-11-22 1:40 ` [PATCH v3 4/5] clk: basic gateable and fixed-rate clks Mike Turquette
2011-11-22 13:11 ` Arnd Bergmann
2011-11-22 15:03 ` Mark Salter
2011-11-22 15:49 ` Arnd Bergmann
2011-11-26 13:48 ` Shawn Guo
2011-11-27 6:03 ` Turquette, Mike
2011-11-27 0:09 ` Shawn Guo
2011-11-22 1:40 ` [PATCH v3 5/5] clk: export tree topology and clk data via sysfs Mike Turquette
2011-11-22 13:07 ` Arnd Bergmann
2011-11-22 17:42 ` Mike Turquette
2011-11-22 15:49 ` Greg KH [this message]
2011-11-22 17:57 ` Mike Turquette
2011-11-22 19:13 ` Greg KH
2011-11-23 3:48 ` Saravana Kannan
2011-11-23 20:43 ` Turquette, Mike
2011-11-23 16:59 ` Tony Lindgren
2011-11-23 18:06 ` Russell King - ARM Linux
2011-11-23 18:55 ` Tony Lindgren
2011-11-23 19:09 ` Mark Brown
2011-11-23 19:19 ` Tony Lindgren
2011-11-23 22:42 ` Russell King - ARM Linux
2011-11-24 1:08 ` Tony Lindgren
[not found] ` <CACxGe6sOd6MiyYaok6BsihJtp-NNsm3WQf+aUPGMRFRpSLw2mQ@mail.gmail.com>
2011-11-22 18:01 ` Mike Turquette
2011-11-22 19:19 ` Grant Likely
2011-11-22 20:02 ` Arnd Bergmann
2011-11-22 20:19 ` Turquette, Mike
2011-11-22 15:42 ` [PATCH v3 0/5] common clk framework Greg KH
2011-11-22 17:45 ` Russell King - ARM Linux
2011-11-22 18:09 ` Mike Turquette
2011-11-22 19:12 ` Greg KH
2011-11-22 19:30 ` Mark Brown
2011-11-26 7:06 ` Shawn Guo
2011-11-27 1:12 ` Turquette, Mike
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=20111122154900.GB18954@kroah.com \
--to=greg@kroah.com \
--cc=amit.kucheria@linaro.org \
--cc=arnd.bergmann@linaro.org \
--cc=aul@pwsan.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=dsaxena@linaro.org \
--cc=eric.miao@linaro.org \
--cc=grant.likely@secretlab.ca \
--cc=jeremy.kerr@canonical.com \
--cc=linaro-dev@lists.linaro.org \
--cc=linus.walleij@stericsson.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=magnus.damm@gmail.com \
--cc=mturquette@linaro.org \
--cc=mturquette@ti.com \
--cc=patches@linaro.org \
--cc=richard.zhao@linaro.org \
--cc=sboyd@quicinc.com \
--cc=shawn.guo@freescale.com \
--cc=skannan@quicinc.com \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®