From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Kay Sievers <kay.sievers-tD+1rO4QERM@public.gmane.org>
Cc: Linux I2C <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Greg KH <greg-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH] i2c: Do not give adapters a default parent
Date: Thu, 23 Jul 2009 16:02:59 +0200 [thread overview]
Message-ID: <20090723160259.78a10e37@hyperion.delvare> (raw)
In-Reply-To: <1248296688.2065.4.camel-2/CBIq5w30c@public.gmane.org>
Hi Kay,
On Wed, 22 Jul 2009 23:04:48 +0200, Kay Sievers wrote:
> On Wed, 2009-07-22 at 21:07 +0200, Jean Delvare wrote:
> > Any progress on this? I have just committed the patches to
> > sensors-detect and libsensors, and the kernel patch is ready to go, but
> > without the compatibility links it doesn't make any sense to push it
> > upstream
>
> Something like this? Please change it as you need. I did only a very
> quick test.
>
> The only important part is that the kobject of the class directly is not
> exposed, so nobody else can do weird things with it.
> (...)
> --- a/drivers/base/class.c
> +++ b/drivers/base/class.c
> @@ -488,6 +488,45 @@ void class_interface_unregister(struct c
> class_put(parent);
> }
>
> +struct class_compat {
> + struct kobject *kobj;
> +};
> +
> +struct class_compat *class_compat_register(const char *name)
> +{
> + struct class_compat *cls;
> +
> + cls = kmalloc(sizeof(struct class_compat), GFP_KERNEL);
> + if (!cls)
> + return NULL;
> + cls->kobj = kobject_create_and_add(name, &class_kset->kobj);
> + if (!cls->kobj) {
> + kfree(cls);
> + return NULL;
> + }
> + return cls;
> +}
> +EXPORT_SYMBOL_GPL(class_compat_register);
> +
> +void class_compat_unregister(struct class_compat *cls)
> +{
> + kobject_put(cls->kobj);
> + kfree(cls);
> +}
> +EXPORT_SYMBOL_GPL(class_compat_unregister);
> +
> +int class_compat_create_link(struct class_compat *cls, struct device *dev)
> +{
> + return sysfs_create_link(cls->kobj, &dev->kobj, dev_name(dev));
> +}
> +EXPORT_SYMBOL_GPL(class_compat_create_link);
> +
> +void class_compat_remove_link(struct class_compat *cls, struct device *dev)
> +{
> + return sysfs_remove_link(cls->kobj, dev_name(dev));
I don't think you need the "return" here, as sysfs_remove_link returns
void.
> +}
> +EXPORT_SYMBOL_GPL(class_compat_remove_link);
> +
> int __init classes_init(void)
> {
> class_kset = kset_create_and_add("class", NULL, NULL);
>
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -223,6 +223,12 @@ extern void class_unregister(struct clas
> __class_register(class, &__key); \
> })
>
> +struct class_compat;
> +struct class_compat *class_compat_register(const char *name);
> +void class_compat_unregister(struct class_compat *cls);
> +int class_compat_create_link(struct class_compat *cls, struct device *dev);
> +void class_compat_remove_link(struct class_compat *cls, struct device *dev);
> +
> extern void class_dev_iter_init(struct class_dev_iter *iter,
> struct class *class,
> struct device *start,
Other than that (and in practice even with that) your patch works just
fine for me. Thanks! Unfortunately it doesn't provide perfect
compatibility, because sensors-detect likes to query attributes of the
i2c-adapter's parent device (when it is a PCI device) and the lack of
device link (now that i2c adapters are bus devices) prevent it from
doing so. I will have to check how bad it is for older versions of the
script (when I am done moving to my new place, that is.) For the
current version, it prevents sensors-detect from being smart on default
answers, but that's about it, so it isn't a blocker IMHO. And I'm
not really sure if/how this could be addressed anyway. Would it be OK
to add this device link (pointing to "..") temporarily or would that be
too confusing?
libsensors only needs the adapter's name so the compatibility layer
works perfectly there.
Another thing we have to discuss is the compatibility option. For now
I've made it i2c-specific and enabled by default:
config I2C_COMPAT
boolean "Enable compatibility bits for old user-space"
default y
help
Say Y here if you intend to run lm-sensors 3.1.1 or older.
But this means a lot of ifdefs in my code (6). With a system-wide
option, we could provide empty stubs I could get rid of them. OTOH, It
is easier to control the lifetime, and change the default value, of a
subsystem specific option. So I'm not too sure what do to. Maybe it
depends on how many subsystems will need the compatibility layer... Do
you have an opinion?
Thanks,
--
Jean Delvare
next prev parent reply other threads:[~2009-07-23 14:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-26 8:30 [PATCH] i2c: Warn when adapters have no parent Jean Delvare
[not found] ` <20090426103025.4525edd3-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-05-04 10:43 ` [PATCH] i2c: Do not give adapters a default parent Jean Delvare
[not found] ` <20090504124341.42405e79-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-05-04 12:40 ` Kay Sievers
[not found] ` <ac3eb2510905040540k65afe3f8k7e6c696d11bf7e1d-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-07-04 17:14 ` Jean Delvare
[not found] ` <20090704191431.3d352d0b-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-07-05 20:19 ` Kay Sievers
[not found] ` <ac3eb2510907051319i414a5e78r74d623ebb0508d0-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-07-05 20:56 ` Jean Delvare
[not found] ` <20090705225616.1d4817e7-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-07-05 21:34 ` Kay Sievers
[not found] ` <ac3eb2510907051434i4ee351cbk3db17b50c7e7618b-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-07-22 19:07 ` Jean Delvare
[not found] ` <20090722210753.35802816-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-07-22 21:04 ` Kay Sievers
[not found] ` <1248296688.2065.4.camel-2/CBIq5w30c@public.gmane.org>
2009-07-23 14:02 ` Jean Delvare [this message]
[not found] ` <20090723160259.78a10e37-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-07-23 15:19 ` Kay Sievers
[not found] ` <ac3eb2510907230819g1b8edf63g42ffc4c87dbc0cb5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-07-28 12:47 ` Jean Delvare
[not found] ` <20090728144755.69d328d4-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-07-30 15:12 ` Kay Sievers
[not found] ` <ac3eb2510907300812q2d848108ofe1d25801f7b990f-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-08-04 10:55 ` Jean Delvare
[not found] ` <20090804125534.6a555cc2-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-08-05 2:20 ` Kay Sievers
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=20090723160259.78a10e37@hyperion.delvare \
--to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
--cc=greg-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org \
--cc=kay.sievers-tD+1rO4QERM@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@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).