2007-05-03 21:34:56

by Anton Vorontsov

[permalink] [raw]
Subject: [PATCH 1/8] remove "#if 0" from find_bus function, export it.

This function were placed in "#if 0" because nobody was using it.
We using it now.

See http://lwn.net/Articles/210610/

Signed-off-by: Anton Vorontsov <[email protected]>
---
drivers/base/bus.c | 5 ++---
include/linux/device.h | 2 ++
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 253868e..971efa2 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -667,14 +667,13 @@ void put_bus(struct bus_type * bus)
*
* Note that kset_find_obj increments bus' reference count.
*/
-#if 0
+
struct bus_type * find_bus(char * name)
{
struct kobject * k = kset_find_obj(&bus_subsys.kset, name);
return k ? to_bus(k) : NULL;
}
-#endif /* 0 */
-
+EXPORT_SYMBOL_GPL(find_bus);

/**
* bus_add_attrs - Add default attributes for this bus.
diff --git a/include/linux/device.h b/include/linux/device.h
index 5cf30e9..4015b39 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -68,6 +68,8 @@ extern void bus_unregister(struct bus_type * bus);

extern int __must_check bus_rescan_devices(struct bus_type * bus);

+extern struct bus_type *find_bus(char *name);
+
/* iterator helpers for buses */

int bus_for_each_dev(struct bus_type * bus, struct device * start, void * data,
--
1.5.1.1-dirty


2007-05-03 23:17:43

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 1/8] remove "#if 0" from find_bus function, export it.

On Fri, May 04, 2007 at 01:31:21AM +0400, Anton Vorontsov wrote:
> This function were placed in "#if 0" because nobody was using it.
> We using it now.

Why? Shouldn't you just export the pointer you need instead?

> See http://lwn.net/Articles/210610/

I don't understand the need for this link, it talks about how the api
changes all the time, something we all know :)

And if you really want it, and you convince me you really need it, can
you change it to be "bus_find" to play nicer in the namespace?

thanks,

greg k-h

2007-05-04 00:25:13

by Anton Vorontsov

[permalink] [raw]
Subject: Re: [PATCH 1/8] remove "#if 0" from find_bus function, export it.

On Thu, May 03, 2007 at 04:14:59PM -0700, Greg KH wrote:
> On Fri, May 04, 2007 at 01:31:21AM +0400, Anton Vorontsov wrote:
> > This function were placed in "#if 0" because nobody was using it.
> > We using it now.
>
> Why? Shouldn't you just export the pointer you need instead?

We can do one way or another. We can ask W1 bus maintainer to
export bus type. Or we can un-"if 0" generic find_bus/bus_find
function.

> And if you really want it, and you convince me you really need it,

No, I don't want it at all. But ds2760_battery driver need to find
w1 bus type.

A long time ago in a Galaxy far far away we're used to find_bus
function, then it was removed, and somewhere in the thread I gave
link to, someone suggested to show real user of that function and
post that patch. I've just done that.

So, if you're unwilling to revert that function, please say it
explicitly, and I'll ping w1 folks to export bus type.

I really-really don't care how exactly we should find that
bus stuff.

> thanks,
>
> greg k-h

Good luck,

--
Anton Vorontsov
email: [email protected]
backup email: [email protected]
irc://irc.freenode.org/bd2

2007-05-04 11:19:01

by Paul Sokolovsky

[permalink] [raw]
Subject: Re: [Kernel-discuss] Re: [PATCH 1/8] remove "#if 0" from find_bus function, export it.

Hello Greg,

Friday, May 4, 2007, 2:14:59 AM, you wrote:

> On Fri, May 04, 2007 at 01:31:21AM +0400, Anton Vorontsov wrote:
>> This function were placed in "#if 0" because nobody was using it.
>> We using it now.

> Why? Shouldn't you just export the pointer you need instead?

>> See http://lwn.net/Articles/210610/

> I don't understand the need for this link, it talks about how the api
> changes all the time, something we all know :)

No, it talked about how complete APIs regress into random
set of functions, lacking complete coverage of target domain. The
response was that when users for the specific function in question
will be in mainline, it will be resurrected. So, here it comes ;-)

> And if you really want it, and you convince me you really need it, can
> you change it to be "bus_find" to play nicer in the namespace?

> thanks,

> greg k-h


--
Best regards,
Paul mailto:[email protected]