Use kobject_set_name() for increased portability.

As of 2.6.25 kobj->k_name was replaced with kobj->name.  Some distros
such as RHEL5 (2.6.18) add a patch to prevent this from being a problem
but other older distros such as SLES10 (2.6.16) have not.  To avoid
the whole issue I'm updating the code to use kobject_set_name() which
does what I want and has existed all the way back to 2.6.11.
This commit is contained in:
Brian Behlendorf 2009-10-02 16:31:23 -07:00
parent e02d23d347
commit b5b5b23cbf
1 changed files with 3 additions and 5 deletions

View File

@ -1223,6 +1223,7 @@ static loff_t zpios_seek(struct file *file, loff_t offset, int origin)
return rc;
}
static struct cdev zpios_cdev;
static struct file_operations zpios_fops = {
.owner = THIS_MODULE,
.open = zpios_open,
@ -1236,11 +1237,6 @@ static struct file_operations zpios_fops = {
.llseek = zpios_seek,
};
static struct cdev zpios_cdev = {
.owner = THIS_MODULE,
.kobj = { .name = ZPIOS_NAME, },
};
static int
zpios_init(void)
{
@ -1253,6 +1249,8 @@ zpios_init(void)
/* Support for registering a character driver */
cdev_init(&zpios_cdev, &zpios_fops);
zpios_cdev.owner = THIS_MODULE;
kobject_set_name(&zpios_cdev.kobj, ZPIOS_NAME);
if ((rc = cdev_add(&zpios_cdev, dev, ZPIOS_MINORS))) {
printk(KERN_ERR "ZPIOS: Error adding cdev, %d\n", rc);
kobject_put(&zpios_cdev.kobj);