From: Pete Zaitcev <zaitcev@redhat.com>
To: greg@kroah.com
Cc: linux-kernel@vger.kernel.org, zaitcev@redhat.com,
jglauber@redhat.com, xenia@us.ibm.com, wein@de.ibm.com
Subject: dev->release = (void (*)(struct device *))kfree;
Date: Mon, 24 Oct 2005 20:10:18 -0700 [thread overview]
Message-ID: <20051024201018.153550d6.zaitcev@redhat.com> (raw)
I seem to recall the discussion about this, but very dimly. Would someone
be so kind to remind me, why the attached patch cannot be used?
-- Pete
diff -urp -X dontdiff linux-2.6.14-rc5/drivers/s390/char/vmlogrdr.c linux-2.6.14-rc5-lem/drivers/s390/char/vmlogrdr.c
--- linux-2.6.14-rc5/drivers/s390/char/vmlogrdr.c 2005-09-13 01:06:11.000000000 -0700
+++ linux-2.6.14-rc5-lem/drivers/s390/char/vmlogrdr.c 2005-10-24 20:05:26.000000000 -0700
@@ -74,7 +74,7 @@ struct vmlogrdr_priv_t {
int buffer_free;
int dev_in_use; /* 1: already opened, 0: not opened*/
spinlock_t priv_lock;
- struct device *device;
+ struct device device;
struct class_device *class_device;
int autorecording;
int autopurge;
@@ -756,27 +756,14 @@ vmlogrdr_unregister_driver(void) {
static int
vmlogrdr_register_device(struct vmlogrdr_priv_t *priv) {
- struct device *dev;
+ struct device *dev = &priv->device;
int ret;
- dev = kmalloc(sizeof(struct device), GFP_KERNEL);
- if (dev) {
- memset(dev, 0, sizeof(struct device));
- snprintf(dev->bus_id, BUS_ID_SIZE, "%s",
- priv->internal_name);
- dev->bus = &iucv_bus;
- dev->parent = iucv_root;
- dev->driver = &vmlogrdr_driver;
- /*
- * The release function could be called after the
- * module has been unloaded. It's _only_ task is to
- * free the struct. Therefore, we specify kfree()
- * directly here. (Probably a little bit obfuscating
- * but legitime ...).
- */
- dev->release = (void (*)(struct device *))kfree;
- } else
- return -ENOMEM;
+ memset(dev, 0, sizeof(struct device));
+ snprintf(dev->bus_id, BUS_ID_SIZE, "%s", priv->internal_name);
+ dev->bus = &iucv_bus;
+ dev->parent = iucv_root;
+ dev->driver = &vmlogrdr_driver;
ret = device_register(dev);
if (ret)
return ret;
@@ -799,7 +786,6 @@ vmlogrdr_register_device(struct vmlogrdr
return ret;
}
dev->driver_data = priv;
- priv->device = dev;
return 0;
}
@@ -807,11 +793,8 @@ vmlogrdr_register_device(struct vmlogrdr
static int
vmlogrdr_unregister_device(struct vmlogrdr_priv_t *priv ) {
class_device_destroy(vmlogrdr_class, MKDEV(vmlogrdr_major, priv->minor_num));
- if (priv->device != NULL) {
- sysfs_remove_group(&priv->device->kobj, &vmlogrdr_attr_group);
- device_unregister(priv->device);
- priv->device=NULL;
- }
+ sysfs_remove_group(&priv->device.kobj, &vmlogrdr_attr_group);
+ device_unregister(&priv->device);
return 0;
}
next reply other threads:[~2005-10-25 3:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-25 3:10 Pete Zaitcev [this message]
2005-10-25 4:36 ` Benjamin Herrenschmidt
2005-10-25 6:44 ` Heiko Carstens
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=20051024201018.153550d6.zaitcev@redhat.com \
--to=zaitcev@redhat.com \
--cc=greg@kroah.com \
--cc=jglauber@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=wein@de.ibm.com \
--cc=xenia@us.ibm.com \
/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®