Commit 7bdc8e54 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jeff Garzik

[PATCH] devfs: cleanup devfs use in scsi

Store the path of it's devfs directory in struct scsi_device.  Use
it in the devfs_register calls instead of the devfs_handle_t
which will go away soon.
parent ee73954c
...@@ -47,6 +47,7 @@ const char * osst_version = "0.99.0"; ...@@ -47,6 +47,7 @@ const char * osst_version = "0.99.0";
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/version.h> #include <linux/version.h>
#include <linux/blk.h> #include <linux/blk.h>
#include <linux/devfs_fs_kernel.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/dma.h> #include <asm/dma.h>
#include <asm/system.h> #include <asm/system.h>
...@@ -99,6 +100,8 @@ static struct osst_dev_parm { ...@@ -99,6 +100,8 @@ static struct osst_dev_parm {
}; };
#endif #endif
static char *osst_formats[ST_NBR_MODES] ={"", "l", "m", "a"};
/* Some default definitions have been moved to osst_options.h */ /* Some default definitions have been moved to osst_options.h */
#define OSST_BUFFER_SIZE (OSST_BUFFER_BLOCKS * ST_KILOBYTE) #define OSST_BUFFER_SIZE (OSST_BUFFER_BLOCKS * ST_KILOBYTE)
#define OSST_WRITE_THRESHOLD (OSST_WRITE_THRESHOLD_BLOCKS * ST_KILOBYTE) #define OSST_WRITE_THRESHOLD (OSST_WRITE_THRESHOLD_BLOCKS * ST_KILOBYTE)
...@@ -5524,11 +5527,12 @@ static int osst_attach(Scsi_Device * SDp) ...@@ -5524,11 +5527,12 @@ static int osst_attach(Scsi_Device * SDp)
write_unlock(&os_scsi_tapes_lock); write_unlock(&os_scsi_tapes_lock);
for (mode = 0; mode < ST_NBR_MODES; ++mode) { for (mode = 0; mode < ST_NBR_MODES; ++mode) {
char name[8]; char name[8], devfs_name[64];
static char *formats[ST_NBR_MODES] ={"", "l", "m", "a"};
/* Rewind entry */ /* Rewind entry */
sprintf (name, "ot%s", formats[mode]); sprintf(name, "ot%s", osst_formats[mode]);
sprintf(devfs_name, "%s/ot%s", SDp->devfs_name, osst_formats[mode]);
sprintf(tpnt->driverfs_dev_r[mode].bus_id, "%s:%s", sprintf(tpnt->driverfs_dev_r[mode].bus_id, "%s:%s",
SDp->sdev_driverfs_dev.bus_id, name); SDp->sdev_driverfs_dev.bus_id, name);
sprintf(tpnt->driverfs_dev_r[mode].name, "%s%s", sprintf(tpnt->driverfs_dev_r[mode].name, "%s%s",
...@@ -5541,13 +5545,14 @@ static int osst_attach(Scsi_Device * SDp) ...@@ -5541,13 +5545,14 @@ static int osst_attach(Scsi_Device * SDp)
device_create_file(&tpnt->driverfs_dev_r[mode], device_create_file(&tpnt->driverfs_dev_r[mode],
&dev_attr_type); &dev_attr_type);
device_create_file(&tpnt->driverfs_dev_r[mode], &dev_attr_kdev); device_create_file(&tpnt->driverfs_dev_r[mode], &dev_attr_kdev);
tpnt->de_r[mode] = devfs_register(NULL, devfs_name, 0,
devfs_register (SDp->de, name, DEVFS_FL_DEFAULT,
OSST_MAJOR, dev_num + (mode << 5), OSST_MAJOR, dev_num + (mode << 5),
S_IFCHR | S_IRUGO | S_IWUGO, S_IFCHR | S_IRUGO | S_IWUGO,
&osst_fops, NULL); &osst_fops, NULL);
/* No-rewind entry */ /* No-rewind entry */
sprintf (name, "ot%sn", formats[mode]); sprintf (name, "ot%sn", osst_formats[mode]);
sprintf(devfs_name, "%s/ot%sn", SDp->devfs_name, osst_formats[mode]);
sprintf(tpnt->driverfs_dev_n[mode].bus_id, "%s:%s", sprintf(tpnt->driverfs_dev_n[mode].bus_id, "%s:%s",
SDp->sdev_driverfs_dev.bus_id, name); SDp->sdev_driverfs_dev.bus_id, name);
sprintf(tpnt->driverfs_dev_n[mode].name, "%s%s", sprintf(tpnt->driverfs_dev_n[mode].name, "%s%s",
...@@ -5561,8 +5566,7 @@ static int osst_attach(Scsi_Device * SDp) ...@@ -5561,8 +5566,7 @@ static int osst_attach(Scsi_Device * SDp)
&dev_attr_type); &dev_attr_type);
device_create_file(&tpnt->driverfs_dev_n[mode], device_create_file(&tpnt->driverfs_dev_n[mode],
&dev_attr_kdev); &dev_attr_kdev);
tpnt->de_n[mode] = devfs_register(NULL, devfs_name, 0,
devfs_register (SDp->de, name, DEVFS_FL_DEFAULT,
OSST_MAJOR, dev_num + (mode << 5) + 128, OSST_MAJOR, dev_num + (mode << 5) + 128,
S_IFCHR | S_IRUGO | S_IWUGO, S_IFCHR | S_IRUGO | S_IWUGO,
&osst_fops, NULL); &osst_fops, NULL);
...@@ -5595,10 +5599,8 @@ static void osst_detach(Scsi_Device * SDp) ...@@ -5595,10 +5599,8 @@ static void osst_detach(Scsi_Device * SDp)
if((tpnt = os_scsi_tapes[i]) && (tpnt->device == SDp)) { if((tpnt = os_scsi_tapes[i]) && (tpnt->device == SDp)) {
tpnt->device = NULL; tpnt->device = NULL;
for (mode = 0; mode < ST_NBR_MODES; ++mode) { for (mode = 0; mode < ST_NBR_MODES; ++mode) {
devfs_unregister (tpnt->de_r[mode]); devfs_remove("%s/ot%s", SDp->devfs_name, osst_formats[mode]);
tpnt->de_r[mode] = NULL; devfs_remove("%s/ot%sn", SDp->devfs_name, osst_formats[mode]);
devfs_unregister (tpnt->de_n[mode]);
tpnt->de_n[mode] = NULL;
} }
devfs_unregister_tape(tpnt->drive->number); devfs_unregister_tape(tpnt->drive->number);
put_disk(tpnt->drive); put_disk(tpnt->drive);
......
...@@ -5,9 +5,7 @@ ...@@ -5,9 +5,7 @@
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include <linux/config.h> #include <linux/config.h>
#include <linux/completion.h> #include <linux/completion.h>
#ifdef CONFIG_DEVFS_FS
#include <linux/devfs_fs_kernel.h>
#endif
/* FIXME - rename and use the following two types or delete them! /* FIXME - rename and use the following two types or delete them!
* and the types really should go to st.h anyway... * and the types really should go to st.h anyway...
...@@ -557,8 +555,6 @@ typedef struct { ...@@ -557,8 +555,6 @@ typedef struct {
/* Mode characteristics */ /* Mode characteristics */
ST_mode modes[ST_NBR_MODES]; ST_mode modes[ST_NBR_MODES];
int current_mode; int current_mode;
devfs_handle_t de_r[ST_NBR_MODES]; /* Rewind entries */
devfs_handle_t de_n[ST_NBR_MODES]; /* No-rewind entries */
struct device driverfs_dev_r[ST_NBR_MODES]; struct device driverfs_dev_r[ST_NBR_MODES];
struct device driverfs_dev_n[ST_NBR_MODES]; struct device driverfs_dev_n[ST_NBR_MODES];
......
...@@ -588,7 +588,8 @@ struct scsi_device { ...@@ -588,7 +588,8 @@ struct scsi_device {
int access_count; /* Count of open channels/mounts */ int access_count; /* Count of open channels/mounts */
void *hostdata; /* available to low-level driver */ void *hostdata; /* available to low-level driver */
devfs_handle_t de; /* directory for the device */ char devfs_name[256]; /* devfs junk */
devfs_handle_t de; /* will go away soon */
char type; char type;
char scsi_level; char scsi_level;
unsigned char inquiry_len; /* valid bytes in 'inquiry' */ unsigned char inquiry_len; /* valid bytes in 'inquiry' */
......
...@@ -1244,9 +1244,10 @@ static int scsi_add_lun(Scsi_Device *sdev, Scsi_Request *sreq, ...@@ -1244,9 +1244,10 @@ static int scsi_add_lun(Scsi_Device *sdev, Scsi_Request *sreq,
scsi_device_register(sdev); scsi_device_register(sdev);
sdev->de = devfs_mk_dir("scsi/host%d/bus%d/target%d/lun%d", sprintf(sdev->devfs_name, "scsi/host%d/bus%d/target%d/lun%d",
sdev->host->host_no, sdev->channel, sdev->host->host_no, sdev->channel,
sdev->id, sdev->lun); sdev->id, sdev->lun);
sdev->de = devfs_mk_dir(sdev->devfs_name);
/* /*
* End driverfs/devfs code. * End driverfs/devfs code.
...@@ -1733,7 +1734,7 @@ int scsi_remove_device(struct scsi_device *sdev) ...@@ -1733,7 +1734,7 @@ int scsi_remove_device(struct scsi_device *sdev)
if (sdev->attached) if (sdev->attached)
return -EINVAL; return -EINVAL;
devfs_unregister(sdev->de); devfs_remove(sdev->devfs_name);
scsi_device_unregister(sdev); scsi_device_unregister(sdev);
scsi_free_sdev(sdev); scsi_free_sdev(sdev);
......
...@@ -182,7 +182,6 @@ typedef struct sg_device { /* holds the state of each scsi generic device */ ...@@ -182,7 +182,6 @@ typedef struct sg_device { /* holds the state of each scsi generic device */
wait_queue_head_t o_excl_wait; /* queue open() when O_EXCL in use */ wait_queue_head_t o_excl_wait; /* queue open() when O_EXCL in use */
int sg_tablesize; /* adapter's max scatter-gather table size */ int sg_tablesize; /* adapter's max scatter-gather table size */
Sg_fd *headfp; /* first open fd belonging to this device */ Sg_fd *headfp; /* first open fd belonging to this device */
devfs_handle_t de;
volatile char detached; /* 0->attached, 1->detached pending removal */ volatile char detached; /* 0->attached, 1->detached pending removal */
volatile char exclude; /* opened for exclusive access */ volatile char exclude; /* opened for exclusive access */
char sgdebug; /* 0->off, 1->sense, 9->dump dev, 10-> all devs */ char sgdebug; /* 0->off, 1->sense, 9->dump dev, 10-> all devs */
...@@ -1350,6 +1349,7 @@ sg_attach(Scsi_Device * scsidp) ...@@ -1350,6 +1349,7 @@ sg_attach(Scsi_Device * scsidp)
struct gendisk *disk; struct gendisk *disk;
Sg_device *sdp = NULL; Sg_device *sdp = NULL;
unsigned long iflags; unsigned long iflags;
char devfs_name[64];
int k, error; int k, error;
disk = alloc_disk(1); disk = alloc_disk(1);
...@@ -1447,10 +1447,13 @@ sg_attach(Scsi_Device * scsidp) ...@@ -1447,10 +1447,13 @@ sg_attach(Scsi_Device * scsidp)
device_register(&sdp->sg_driverfs_dev); device_register(&sdp->sg_driverfs_dev);
device_create_file(&sdp->sg_driverfs_dev, &dev_attr_type); device_create_file(&sdp->sg_driverfs_dev, &dev_attr_type);
device_create_file(&sdp->sg_driverfs_dev, &dev_attr_kdev); device_create_file(&sdp->sg_driverfs_dev, &dev_attr_kdev);
sdp->de = devfs_register(scsidp->de, "generic", DEVFS_FL_DEFAULT,
sprintf(devfs_name, "%s/generic", scsidp->devfs_name);
devfs_register(NULL, devfs_name, 0,
SCSI_GENERIC_MAJOR, k, SCSI_GENERIC_MAJOR, k,
S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP,
&sg_fops, sdp); &sg_fops, sdp);
switch (scsidp->type) { switch (scsidp->type) {
case TYPE_DISK: case TYPE_DISK:
case TYPE_MOD: case TYPE_MOD:
...@@ -1527,8 +1530,7 @@ sg_detach(Scsi_Device * scsidp) ...@@ -1527,8 +1530,7 @@ sg_detach(Scsi_Device * scsidp)
write_unlock_irqrestore(&sg_dev_arr_lock, iflags); write_unlock_irqrestore(&sg_dev_arr_lock, iflags);
if (sdp) { if (sdp) {
devfs_unregister(sdp->de); devfs_remove("%s/generic", scsidp->devfs_name);
sdp->de = NULL;
device_remove_file(&sdp->sg_driverfs_dev, &dev_attr_type); device_remove_file(&sdp->sg_driverfs_dev, &dev_attr_type);
device_remove_file(&sdp->sg_driverfs_dev, &dev_attr_kdev); device_remove_file(&sdp->sg_driverfs_dev, &dev_attr_kdev);
device_unregister(&sdp->sg_driverfs_dev); device_unregister(&sdp->sg_driverfs_dev);
......
...@@ -35,6 +35,7 @@ static char *verstr = "20030413"; ...@@ -35,6 +35,7 @@ static char *verstr = "20030413";
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/blk.h> #include <linux/blk.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
#include <linux/devfs_fs_kernel.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/dma.h> #include <asm/dma.h>
#include <asm/system.h> #include <asm/system.h>
...@@ -116,6 +117,7 @@ static struct st_dev_parm { ...@@ -116,6 +117,7 @@ static struct st_dev_parm {
}; };
#endif #endif
static char *st_formats[ST_NBR_MODES] ={"", "l", "m", "a"};
/* The default definitions have been moved to st_options.h */ /* The default definitions have been moved to st_options.h */
...@@ -3863,11 +3865,12 @@ static int st_attach(Scsi_Device * SDp) ...@@ -3863,11 +3865,12 @@ static int st_attach(Scsi_Device * SDp)
write_unlock(&st_dev_arr_lock); write_unlock(&st_dev_arr_lock);
for (mode = 0; mode < ST_NBR_MODES; ++mode) { for (mode = 0; mode < ST_NBR_MODES; ++mode) {
char name[8]; char name[8], devfs_name[64];
static char *formats[ST_NBR_MODES] ={"", "l", "m", "a"};
/* Rewind entry */ /* Rewind entry */
sprintf (name, "mt%s", formats[mode]); sprintf(name, "mt%s", st_formats[mode]);
sprintf(devfs_name, "%s/mt%s", SDp->devfs_name, st_formats[mode]);
sprintf(tpnt->driverfs_dev_r[mode].bus_id, "%s:%s", sprintf(tpnt->driverfs_dev_r[mode].bus_id, "%s:%s",
SDp->sdev_driverfs_dev.bus_id, name); SDp->sdev_driverfs_dev.bus_id, name);
sprintf(tpnt->driverfs_dev_r[mode].name, "%s%s", sprintf(tpnt->driverfs_dev_r[mode].name, "%s%s",
...@@ -3880,13 +3883,14 @@ static int st_attach(Scsi_Device * SDp) ...@@ -3880,13 +3883,14 @@ static int st_attach(Scsi_Device * SDp)
device_create_file(&tpnt->driverfs_dev_r[mode], device_create_file(&tpnt->driverfs_dev_r[mode],
&dev_attr_type); &dev_attr_type);
device_create_file(&tpnt->driverfs_dev_r[mode], &dev_attr_kdev); device_create_file(&tpnt->driverfs_dev_r[mode], &dev_attr_kdev);
tpnt->de_r[mode] = devfs_register(NULL, devfs_name, 0,
devfs_register (SDp->de, name, DEVFS_FL_DEFAULT,
SCSI_TAPE_MAJOR, dev_num + (mode << 5), SCSI_TAPE_MAJOR, dev_num + (mode << 5),
S_IFCHR | S_IRUGO | S_IWUGO, S_IFCHR | S_IRUGO | S_IWUGO,
&st_fops, NULL); &st_fops, NULL);
/* No-rewind entry */ /* No-rewind entry */
sprintf (name, "mt%sn", formats[mode]); sprintf (name, "mt%sn", st_formats[mode]);
sprintf(devfs_name, "%s/mt%sn", SDp->devfs_name, st_formats[mode]);
sprintf(tpnt->driverfs_dev_n[mode].bus_id, "%s:%s", sprintf(tpnt->driverfs_dev_n[mode].bus_id, "%s:%s",
SDp->sdev_driverfs_dev.bus_id, name); SDp->sdev_driverfs_dev.bus_id, name);
sprintf(tpnt->driverfs_dev_n[mode].name, "%s%s", sprintf(tpnt->driverfs_dev_n[mode].name, "%s%s",
...@@ -3900,8 +3904,7 @@ static int st_attach(Scsi_Device * SDp) ...@@ -3900,8 +3904,7 @@ static int st_attach(Scsi_Device * SDp)
&dev_attr_type); &dev_attr_type);
device_create_file(&tpnt->driverfs_dev_n[mode], device_create_file(&tpnt->driverfs_dev_n[mode],
&dev_attr_kdev); &dev_attr_kdev);
tpnt->de_n[mode] = devfs_register(NULL, devfs_name, 0,
devfs_register (SDp->de, name, DEVFS_FL_DEFAULT,
SCSI_TAPE_MAJOR, dev_num + (mode << 5) + 128, SCSI_TAPE_MAJOR, dev_num + (mode << 5) + 128,
S_IFCHR | S_IRUGO | S_IWUGO, S_IFCHR | S_IRUGO | S_IWUGO,
&st_fops, NULL); &st_fops, NULL);
...@@ -3939,10 +3942,8 @@ static void st_detach(Scsi_Device * SDp) ...@@ -3939,10 +3942,8 @@ static void st_detach(Scsi_Device * SDp)
write_unlock(&st_dev_arr_lock); write_unlock(&st_dev_arr_lock);
devfs_unregister_tape(tpnt->disk->number); devfs_unregister_tape(tpnt->disk->number);
for (mode = 0; mode < ST_NBR_MODES; ++mode) { for (mode = 0; mode < ST_NBR_MODES; ++mode) {
devfs_unregister (tpnt->de_r[mode]); devfs_remove("%s/mt%s", SDp->devfs_name, st_formats[mode]);
tpnt->de_r[mode] = NULL; devfs_remove("%s/mt%sn", SDp->devfs_name, st_formats[mode]);
devfs_unregister (tpnt->de_n[mode]);
tpnt->de_n[mode] = NULL;
device_remove_file(&tpnt->driverfs_dev_r[mode], device_remove_file(&tpnt->driverfs_dev_r[mode],
&dev_attr_type); &dev_attr_type);
device_remove_file(&tpnt->driverfs_dev_r[mode], device_remove_file(&tpnt->driverfs_dev_r[mode],
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#ifndef _SCSI_H #ifndef _SCSI_H
#include "scsi.h" #include "scsi.h"
#endif #endif
#include <linux/devfs_fs_kernel.h>
#include <linux/completion.h> #include <linux/completion.h>
/* The tape buffer descriptor. */ /* The tape buffer descriptor. */
...@@ -104,8 +103,6 @@ typedef struct { ...@@ -104,8 +103,6 @@ typedef struct {
/* Mode characteristics */ /* Mode characteristics */
ST_mode modes[ST_NBR_MODES]; ST_mode modes[ST_NBR_MODES];
int current_mode; int current_mode;
devfs_handle_t de_r[ST_NBR_MODES]; /* Rewind entries */
devfs_handle_t de_n[ST_NBR_MODES]; /* No-rewind entries */
struct device driverfs_dev_r[ST_NBR_MODES]; struct device driverfs_dev_r[ST_NBR_MODES];
struct device driverfs_dev_n[ST_NBR_MODES]; struct device driverfs_dev_n[ST_NBR_MODES];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment