2005-12-09 15:23:49

by Martin Schwidefsky

[permalink] [raw]
Subject: [patch 3/17] s390: move s390_root_dev_* out of the cio layer.

From: Carsten Otte <[email protected]>

[patch 3/17] s390: move s390_root_dev_* out of the cio layer.

Extract the s390_root_dev_* functions from the common I/O layer as they
are also used by non-ccw device drivers.

Signed-off-by: Carsten Otte <[email protected]>
Signed-off-by: Martin Schwidefsky <[email protected]>
---

drivers/s390/Makefile | 2 -
drivers/s390/block/dcssblk.c | 2 -
drivers/s390/cio/css.c | 41 ---------------------------------
drivers/s390/net/cu3088.c | 3 +-
drivers/s390/net/iucv.c | 2 -
drivers/s390/net/qeth_main.c | 1
drivers/s390/s390_rdev.c | 53 +++++++++++++++++++++++++++++++++++++++++++
include/asm-s390/ccwdev.h | 3 --
include/asm-s390/s390_rdev.h | 15 ++++++++++++
9 files changed, 74 insertions(+), 48 deletions(-)

diff -urpN linux-2.6/drivers/s390/block/dcssblk.c linux-2.6-patched/drivers/s390/block/dcssblk.c
--- linux-2.6/drivers/s390/block/dcssblk.c 2005-10-28 02:02:08.000000000 +0200
+++ linux-2.6-patched/drivers/s390/block/dcssblk.c 2005-12-09 14:24:22.000000000 +0100
@@ -15,7 +15,7 @@
#include <asm/io.h>
#include <linux/completion.h>
#include <linux/interrupt.h>
-#include <asm/ccwdev.h> // for s390_root_dev_(un)register()
+#include <asm/s390_rdev.h>

//#define DCSSBLK_DEBUG /* Debug messages on/off */
#define DCSSBLK_NAME "dcssblk"
diff -urpN linux-2.6/drivers/s390/cio/css.c linux-2.6-patched/drivers/s390/cio/css.c
--- linux-2.6/drivers/s390/cio/css.c 2005-10-28 02:02:08.000000000 +0200
+++ linux-2.6-patched/drivers/s390/cio/css.c 2005-12-09 14:24:22.000000000 +0100
@@ -481,45 +481,6 @@ struct bus_type css_bus_type = {

subsys_initcall(init_channel_subsystem);

-/*
- * Register root devices for some drivers. The release function must not be
- * in the device drivers, so we do it here.
- */
-static void
-s390_root_dev_release(struct device *dev)
-{
- kfree(dev);
-}
-
-struct device *
-s390_root_dev_register(const char *name)
-{
- struct device *dev;
- int ret;
-
- if (!strlen(name))
- return ERR_PTR(-EINVAL);
- dev = kmalloc(sizeof(struct device), GFP_KERNEL);
- if (!dev)
- return ERR_PTR(-ENOMEM);
- memset(dev, 0, sizeof(struct device));
- strncpy(dev->bus_id, name, min(strlen(name), (size_t)BUS_ID_SIZE));
- dev->release = s390_root_dev_release;
- ret = device_register(dev);
- if (ret) {
- kfree(dev);
- return ERR_PTR(ret);
- }
- return dev;
-}
-
-void
-s390_root_dev_unregister(struct device *dev)
-{
- if (dev)
- device_unregister(dev);
-}
-
int
css_enqueue_subchannel_slow(unsigned long schid)
{
@@ -564,6 +525,4 @@ css_slow_subchannels_exist(void)

MODULE_LICENSE("GPL");
EXPORT_SYMBOL(css_bus_type);
-EXPORT_SYMBOL(s390_root_dev_register);
-EXPORT_SYMBOL(s390_root_dev_unregister);
EXPORT_SYMBOL_GPL(css_characteristics_avail);
diff -urpN linux-2.6/drivers/s390/Makefile linux-2.6-patched/drivers/s390/Makefile
--- linux-2.6/drivers/s390/Makefile 2005-10-28 02:02:08.000000000 +0200
+++ linux-2.6-patched/drivers/s390/Makefile 2005-12-09 14:24:22.000000000 +0100
@@ -2,7 +2,7 @@
# Makefile for the S/390 specific device drivers
#

-obj-y += s390mach.o sysinfo.o
+obj-y += s390mach.o sysinfo.o s390_rdev.o
obj-y += cio/ block/ char/ crypto/ net/ scsi/

drivers-y += drivers/s390/built-in.o
diff -urpN linux-2.6/drivers/s390/net/cu3088.c linux-2.6-patched/drivers/s390/net/cu3088.c
--- linux-2.6/drivers/s390/net/cu3088.c 2005-10-28 02:02:08.000000000 +0200
+++ linux-2.6-patched/drivers/s390/net/cu3088.c 2005-12-09 14:24:22.000000000 +0100
@@ -1,5 +1,5 @@
/*
- * $Id: cu3088.c,v 1.35 2005/03/30 19:28:52 richtera Exp $
+ * $Id: cu3088.c,v 1.36 2005/10/25 14:37:17 cohuck Exp $
*
* CTC / LCS ccw_device driver
*
@@ -27,6 +27,7 @@
#include <linux/module.h>
#include <linux/err.h>

+#include <asm/s390_rdev.h>
#include <asm/ccwdev.h>
#include <asm/ccwgroup.h>

diff -urpN linux-2.6/drivers/s390/net/iucv.c linux-2.6-patched/drivers/s390/net/iucv.c
--- linux-2.6/drivers/s390/net/iucv.c 2005-12-09 14:24:15.000000000 +0100
+++ linux-2.6-patched/drivers/s390/net/iucv.c 2005-12-09 14:24:22.000000000 +0100
@@ -54,7 +54,7 @@
#include <asm/s390_ext.h>
#include <asm/ebcdic.h>
#include <asm/smp.h>
-#include <asm/ccwdev.h> //for root device stuff
+#include <asm/s390_rdev.h>

/* FLAGS:
* All flags are defined in the field IPFLAGS1 of each function
diff -urpN linux-2.6/drivers/s390/net/qeth_main.c linux-2.6-patched/drivers/s390/net/qeth_main.c
--- linux-2.6/drivers/s390/net/qeth_main.c 2005-12-09 14:24:15.000000000 +0100
+++ linux-2.6-patched/drivers/s390/net/qeth_main.c 2005-12-09 14:24:22.000000000 +0100
@@ -65,6 +65,7 @@
#include <asm/timex.h>
#include <asm/semaphore.h>
#include <asm/uaccess.h>
+#include <asm/s390_rdev.h>

#include "qeth.h"
#include "qeth_mpc.h"
diff -urpN linux-2.6/drivers/s390/s390_rdev.c linux-2.6-patched/drivers/s390/s390_rdev.c
--- linux-2.6/drivers/s390/s390_rdev.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6-patched/drivers/s390/s390_rdev.c 2005-12-09 14:24:22.000000000 +0100
@@ -0,0 +1,53 @@
+/*
+ * drivers/s390/s390_rdev.c
+ * s390 root device
+ * $Revision: 1.2 $
+ *
+ * Copyright (C) 2002, 2005 IBM Deutschland Entwicklung GmbH,
+ * IBM Corporation
+ * Author(s): Cornelia Huck ([email protected])
+ * Carsten Otte ([email protected])
+ */
+
+#include <linux/slab.h>
+#include <linux/err.h>
+#include <linux/device.h>
+#include <asm/s390_rdev.h>
+
+static void
+s390_root_dev_release(struct device *dev)
+{
+ kfree(dev);
+}
+
+struct device *
+s390_root_dev_register(const char *name)
+{
+ struct device *dev;
+ int ret;
+
+ if (!strlen(name))
+ return ERR_PTR(-EINVAL);
+ dev = kmalloc(sizeof(struct device), GFP_KERNEL);
+ if (!dev)
+ return ERR_PTR(-ENOMEM);
+ memset(dev, 0, sizeof(struct device));
+ strncpy(dev->bus_id, name, min(strlen(name), (size_t)BUS_ID_SIZE));
+ dev->release = s390_root_dev_release;
+ ret = device_register(dev);
+ if (ret) {
+ kfree(dev);
+ return ERR_PTR(ret);
+ }
+ return dev;
+}
+
+void
+s390_root_dev_unregister(struct device *dev)
+{
+ if (dev)
+ device_unregister(dev);
+}
+
+EXPORT_SYMBOL(s390_root_dev_register);
+EXPORT_SYMBOL(s390_root_dev_unregister);
diff -urpN linux-2.6/include/asm-s390/ccwdev.h linux-2.6-patched/include/asm-s390/ccwdev.h
--- linux-2.6/include/asm-s390/ccwdev.h 2005-10-28 02:02:08.000000000 +0200
+++ linux-2.6-patched/include/asm-s390/ccwdev.h 2005-12-09 14:24:22.000000000 +0100
@@ -185,8 +185,5 @@ extern struct ccw_device *ccw_device_pro
extern int _ccw_device_get_device_number(struct ccw_device *);
extern int _ccw_device_get_subchannel_number(struct ccw_device *);

-extern struct device *s390_root_dev_register(const char *);
-extern void s390_root_dev_unregister(struct device *);
-
extern void *ccw_device_get_chp_desc(struct ccw_device *, int);
#endif /* _S390_CCWDEV_H_ */
diff -urpN linux-2.6/include/asm-s390/s390_rdev.h linux-2.6-patched/include/asm-s390/s390_rdev.h
--- linux-2.6/include/asm-s390/s390_rdev.h 1970-01-01 01:00:00.000000000 +0100
+++ linux-2.6-patched/include/asm-s390/s390_rdev.h 2005-12-09 14:24:22.000000000 +0100
@@ -0,0 +1,15 @@
+/*
+ * include/asm-s390/ccwdev.h
+ *
+ * Copyright (C) 2002,2005 IBM Deutschland Entwicklung GmbH, IBM Corporation
+ * Author(s): Cornelia Huck <[email protected]>
+ * Carsten Otte <[email protected]>
+ *
+ * Interface for s390 root device
+ */
+
+#ifndef _S390_RDEV_H_
+#define _S390_RDEV_H_
+extern struct device *s390_root_dev_register(const char *);
+extern void s390_root_dev_unregister(struct device *);
+#endif /* _S390_RDEV_H_ */


2005-12-09 16:51:53

by Adrian Bunk

[permalink] [raw]
Subject: Re: [patch 3/17] s390: move s390_root_dev_* out of the cio layer.

On Fri, Dec 09, 2005 at 04:23:45PM +0100, Martin Schwidefsky wrote:
>...
> --- linux-2.6/drivers/s390/s390_rdev.c 1970-01-01 01:00:00.000000000 +0100
> +++ linux-2.6-patched/drivers/s390/s390_rdev.c 2005-12-09 14:24:22.000000000 +0100
>...
> +static void
> +s390_root_dev_release(struct device *dev)
> +{
> + kfree(dev);
> +}
>...
> +void
> +s390_root_dev_unregister(struct device *dev)
> +{
> + if (dev)
> + device_unregister(dev);
> +}
>...
> --- linux-2.6/include/asm-s390/s390_rdev.h 1970-01-01 01:00:00.000000000 +0100
> +++ linux-2.6-patched/include/asm-s390/s390_rdev.h 2005-12-09 14:24:22.000000000 +0100
>...
> +extern struct device *s390_root_dev_register(const char *);
> +extern void s390_root_dev_unregister(struct device *);
>...

If you do _really_ need these wrappers, simply make them
"static inline"'s in the header file.

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

2005-12-09 16:54:46

by Martin Schwidefsky

[permalink] [raw]
Subject: Re: [patch 3/17] s390: move s390_root_dev_* out of the cio layer.

On Fri, 2005-12-09 at 17:51 +0100, Adrian Bunk wrote:
> On Fri, Dec 09, 2005 at 04:23:45PM +0100, Martin Schwidefsky wrote:
> > +extern struct device *s390_root_dev_register(const char *);
> > +extern void s390_root_dev_unregister(struct device *);
> >...
>
> If you do _really_ need these wrappers, simply make them
> "static inline"'s in the header file.

We can't. The point here is that we need an external release function
that is still available after the module has been unloaded that uses
these wrappers.

--
blue skies,
Martin

Martin Schwidefsky
Linux for zSeries Development & Services
IBM Deutschland Entwicklung GmbH


2005-12-10 07:55:25

by Greg KH

[permalink] [raw]
Subject: Re: [patch 3/17] s390: move s390_root_dev_* out of the cio layer.

On Fri, Dec 09, 2005 at 05:54:43PM +0100, Martin Schwidefsky wrote:
> On Fri, 2005-12-09 at 17:51 +0100, Adrian Bunk wrote:
> > On Fri, Dec 09, 2005 at 04:23:45PM +0100, Martin Schwidefsky wrote:
> > > +extern struct device *s390_root_dev_register(const char *);
> > > +extern void s390_root_dev_unregister(struct device *);
> > >...
> >
> > If you do _really_ need these wrappers, simply make them
> > "static inline"'s in the header file.
>
> We can't. The point here is that we need an external release function
> that is still available after the module has been unloaded that uses
> these wrappers.

release is find and understandable. But the unregister one is just
pretty foolish :)

thanks,

greg k-h

2005-12-12 09:36:16

by Martin Schwidefsky

[permalink] [raw]
Subject: Re: [patch 3/17] s390: move s390_root_dev_* out of the cio layer.

On Fri, 2005-12-09 at 23:50 -0800, Greg KH wrote:
> On Fri, Dec 09, 2005 at 05:54:43PM +0100, Martin Schwidefsky wrote:
> > On Fri, 2005-12-09 at 17:51 +0100, Adrian Bunk wrote:
> > > On Fri, Dec 09, 2005 at 04:23:45PM +0100, Martin Schwidefsky wrote:
> > > > +extern struct device *s390_root_dev_register(const char *);
> > > > +extern void s390_root_dev_unregister(struct device *);
> > > >...
> > >
> > > If you do _really_ need these wrappers, simply make them
> > > "static inline"'s in the header file.
> >
> > We can't. The point here is that we need an external release function
> > that is still available after the module has been unloaded that uses
> > these wrappers.
>
> release is find and understandable. But the unregister one is just
> pretty foolish :)

Well, the alternative is to only have a release function somewhere that
calls kfree. Which would be general-purpose "struct device"-kfree
wrapper and would be callable by any piece of code. Where is the
difference to calling kfree directly then? The additional indirection?

No, the release function should be related to a specific object and then
you need the register/unregister functions as well.

--
blue skies,
Martin

Martin Schwidefsky
Linux for zSeries Development & Services
IBM Deutschland Entwicklung GmbH