[ide] kill ide_driver_t->capacity

* add private /proc/ide/hd?/capacity handlers to ide-{cd,disk,floppy}.c
* use generic proc_ide_read_capacity() for ide-{scsi,tape}.c
* kill ->capacity, default_capacity() and generic_subdriver_entries[]
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 7a44e2e8
...@@ -3251,6 +3251,25 @@ int ide_cdrom_cleanup(ide_drive_t *drive) ...@@ -3251,6 +3251,25 @@ int ide_cdrom_cleanup(ide_drive_t *drive)
static int ide_cdrom_attach (ide_drive_t *drive); static int ide_cdrom_attach (ide_drive_t *drive);
#ifdef CONFIG_PROC_FS
static int proc_idecd_read_capacity
(char *page, char **start, off_t off, int count, int *eof, void *data)
{
ide_drive_t*drive = (ide_drive_t *)data;
int len;
len = sprintf(page,"%llu\n", (long long)ide_cdrom_capacity(drive));
PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
}
static ide_proc_entry_t idecd_proc[] = {
{ "capacity", S_IFREG|S_IRUGO, proc_idecd_read_capacity, NULL },
{ NULL, 0, NULL, NULL }
};
#else
# define idecd_proc NULL
#endif
static ide_driver_t ide_cdrom_driver = { static ide_driver_t ide_cdrom_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "ide-cdrom", .name = "ide-cdrom",
...@@ -3260,7 +3279,7 @@ static ide_driver_t ide_cdrom_driver = { ...@@ -3260,7 +3279,7 @@ static ide_driver_t ide_cdrom_driver = {
.supports_dsc_overlap = 1, .supports_dsc_overlap = 1,
.cleanup = ide_cdrom_cleanup, .cleanup = ide_cdrom_cleanup,
.do_request = ide_do_rw_cdrom, .do_request = ide_do_rw_cdrom,
.capacity = ide_cdrom_capacity, .proc = idecd_proc,
.attach = ide_cdrom_attach, .attach = ide_cdrom_attach,
.drives = LIST_HEAD_INIT(ide_cdrom_driver.drives), .drives = LIST_HEAD_INIT(ide_cdrom_driver.drives),
}; };
......
...@@ -579,6 +579,16 @@ static int proc_idedisk_read_cache ...@@ -579,6 +579,16 @@ static int proc_idedisk_read_cache
PROC_IDE_READ_RETURN(page,start,off,count,eof,len); PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
} }
static int proc_idedisk_read_capacity
(char *page, char **start, off_t off, int count, int *eof, void *data)
{
ide_drive_t*drive = (ide_drive_t *)data;
int len;
len = sprintf(page,"%llu\n", (long long)idedisk_capacity(drive));
PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
}
static int proc_idedisk_read_smart_thresholds static int proc_idedisk_read_smart_thresholds
(char *page, char **start, off_t off, int count, int *eof, void *data) (char *page, char **start, off_t off, int count, int *eof, void *data)
{ {
...@@ -619,6 +629,7 @@ static int proc_idedisk_read_smart_values ...@@ -619,6 +629,7 @@ static int proc_idedisk_read_smart_values
static ide_proc_entry_t idedisk_proc[] = { static ide_proc_entry_t idedisk_proc[] = {
{ "cache", S_IFREG|S_IRUGO, proc_idedisk_read_cache, NULL }, { "cache", S_IFREG|S_IRUGO, proc_idedisk_read_cache, NULL },
{ "capacity", S_IFREG|S_IRUGO, proc_idedisk_read_capacity, NULL },
{ "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL },
{ "smart_values", S_IFREG|S_IRUSR, proc_idedisk_read_smart_values, NULL }, { "smart_values", S_IFREG|S_IRUSR, proc_idedisk_read_smart_values, NULL },
{ "smart_thresholds", S_IFREG|S_IRUSR, proc_idedisk_read_smart_thresholds, NULL }, { "smart_thresholds", S_IFREG|S_IRUSR, proc_idedisk_read_smart_thresholds, NULL },
...@@ -1035,7 +1046,6 @@ static ide_driver_t idedisk_driver = { ...@@ -1035,7 +1046,6 @@ static ide_driver_t idedisk_driver = {
.supports_dsc_overlap = 0, .supports_dsc_overlap = 0,
.cleanup = idedisk_cleanup, .cleanup = idedisk_cleanup,
.do_request = ide_do_rw_disk, .do_request = ide_do_rw_disk,
.capacity = idedisk_capacity,
.proc = idedisk_proc, .proc = idedisk_proc,
.attach = idedisk_attach, .attach = idedisk_attach,
.drives = LIST_HEAD_INIT(idedisk_driver.drives), .drives = LIST_HEAD_INIT(idedisk_driver.drives),
......
...@@ -1847,7 +1847,18 @@ static int idefloppy_cleanup (ide_drive_t *drive) ...@@ -1847,7 +1847,18 @@ static int idefloppy_cleanup (ide_drive_t *drive)
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static int proc_idefloppy_read_capacity
(char *page, char **start, off_t off, int count, int *eof, void *data)
{
ide_drive_t*drive = (ide_drive_t *)data;
int len;
len = sprintf(page,"%llu\n", (long long)idefloppy_capacity(drive));
PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
}
static ide_proc_entry_t idefloppy_proc[] = { static ide_proc_entry_t idefloppy_proc[] = {
{ "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL },
{ "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL },
{ NULL, 0, NULL, NULL } { NULL, 0, NULL, NULL }
}; };
...@@ -1873,7 +1884,6 @@ static ide_driver_t idefloppy_driver = { ...@@ -1873,7 +1884,6 @@ static ide_driver_t idefloppy_driver = {
.cleanup = idefloppy_cleanup, .cleanup = idefloppy_cleanup,
.do_request = idefloppy_do_request, .do_request = idefloppy_do_request,
.end_request = idefloppy_do_end_request, .end_request = idefloppy_do_end_request,
.capacity = idefloppy_capacity,
.proc = idefloppy_proc, .proc = idefloppy_proc,
.attach = idefloppy_attach, .attach = idefloppy_attach,
.drives = LIST_HEAD_INIT(idefloppy_driver.drives), .drives = LIST_HEAD_INIT(idefloppy_driver.drives),
......
...@@ -269,14 +269,12 @@ static int proc_ide_write_settings(struct file *file, const char __user *buffer, ...@@ -269,14 +269,12 @@ static int proc_ide_write_settings(struct file *file, const char __user *buffer,
int proc_ide_read_capacity int proc_ide_read_capacity
(char *page, char **start, off_t off, int count, int *eof, void *data) (char *page, char **start, off_t off, int count, int *eof, void *data)
{ {
ide_drive_t *drive = (ide_drive_t *) data; int len = sprintf(page,"%llu\n", (long long)0x7fffffff);
int len;
len = sprintf(page,"%llu\n",
(long long) (DRIVER(drive)->capacity(drive)));
PROC_IDE_READ_RETURN(page,start,off,count,eof,len); PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
} }
EXPORT_SYMBOL_GPL(proc_ide_read_capacity);
int proc_ide_read_geometry int proc_ide_read_geometry
(char *page, char **start, off_t off, int count, int *eof, void *data) (char *page, char **start, off_t off, int count, int *eof, void *data)
{ {
......
...@@ -4667,6 +4667,7 @@ static int proc_idetape_read_name ...@@ -4667,6 +4667,7 @@ static int proc_idetape_read_name
} }
static ide_proc_entry_t idetape_proc[] = { static ide_proc_entry_t idetape_proc[] = {
{ "capacity", S_IFREG|S_IRUGO, proc_ide_read_capacity, NULL },
{ "name", S_IFREG|S_IRUGO, proc_idetape_read_name, NULL }, { "name", S_IFREG|S_IRUGO, proc_idetape_read_name, NULL },
{ NULL, 0, NULL, NULL } { NULL, 0, NULL, NULL }
}; };
......
...@@ -417,11 +417,6 @@ struct seq_operations ide_drivers_op = { ...@@ -417,11 +417,6 @@ struct seq_operations ide_drivers_op = {
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
struct proc_dir_entry *proc_ide_root; struct proc_dir_entry *proc_ide_root;
static ide_proc_entry_t generic_subdriver_entries[] = {
{ "capacity", S_IFREG|S_IRUGO, proc_ide_read_capacity, NULL },
{ NULL, 0, NULL, NULL }
};
#endif #endif
static struct resource* hwif_request_region(ide_hwif_t *hwif, static struct resource* hwif_request_region(ide_hwif_t *hwif,
...@@ -2042,11 +2037,6 @@ default_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) ...@@ -2042,11 +2037,6 @@ default_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err)
return __ide_error(drive, rq, stat, err); return __ide_error(drive, rq, stat, err);
} }
static sector_t default_capacity (ide_drive_t *drive)
{
return 0x7fffffff;
}
static ide_startstop_t default_abort(ide_drive_t *drive, struct request *rq) static ide_startstop_t default_abort(ide_drive_t *drive, struct request *rq)
{ {
return __ide_abort(drive, rq); return __ide_abort(drive, rq);
...@@ -2060,7 +2050,6 @@ static void setup_driver_defaults (ide_driver_t *d) ...@@ -2060,7 +2050,6 @@ static void setup_driver_defaults (ide_driver_t *d)
if (d->end_request == NULL) d->end_request = default_end_request; if (d->end_request == NULL) d->end_request = default_end_request;
if (d->error == NULL) d->error = default_error; if (d->error == NULL) d->error = default_error;
if (d->abort == NULL) d->abort = default_abort; if (d->abort == NULL) d->abort = default_abort;
if (d->capacity == NULL) d->capacity = default_capacity;
} }
int ide_register_subdriver(ide_drive_t *drive, ide_driver_t *driver) int ide_register_subdriver(ide_drive_t *drive, ide_driver_t *driver)
...@@ -2088,10 +2077,8 @@ int ide_register_subdriver(ide_drive_t *drive, ide_driver_t *driver) ...@@ -2088,10 +2077,8 @@ int ide_register_subdriver(ide_drive_t *drive, ide_driver_t *driver)
drive->nice1 = 1; drive->nice1 = 1;
} }
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
if (drive->driver != &idedefault_driver) { if (drive->driver != &idedefault_driver)
ide_add_proc_entries(drive->proc, generic_subdriver_entries, drive);
ide_add_proc_entries(drive->proc, driver->proc, drive); ide_add_proc_entries(drive->proc, driver->proc, drive);
}
#endif #endif
return 0; return 0;
} }
...@@ -2125,7 +2112,6 @@ int ide_unregister_subdriver (ide_drive_t *drive) ...@@ -2125,7 +2112,6 @@ int ide_unregister_subdriver (ide_drive_t *drive)
} }
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
ide_remove_proc_entries(drive->proc, DRIVER(drive)->proc); ide_remove_proc_entries(drive->proc, DRIVER(drive)->proc);
ide_remove_proc_entries(drive->proc, generic_subdriver_entries);
#endif #endif
auto_remove_settings(drive); auto_remove_settings(drive);
drive->driver = &idedefault_driver; drive->driver = &idedefault_driver;
......
...@@ -708,6 +708,15 @@ static int idescsi_cleanup (ide_drive_t *drive) ...@@ -708,6 +708,15 @@ static int idescsi_cleanup (ide_drive_t *drive)
static int idescsi_attach(ide_drive_t *drive); static int idescsi_attach(ide_drive_t *drive);
#ifdef CONFIG_PROC_FS
static ide_proc_entry_t idescsi_proc[] = {
{ "capacity", S_IFREG|S_IRUGO, proc_ide_read_capacity, NULL },
{ NULL, 0, NULL, NULL }
};
#else
# define idescsi_proc NULL
#endif
/* /*
* IDE subdriver functions, registered with ide.c * IDE subdriver functions, registered with ide.c
*/ */
...@@ -718,6 +727,7 @@ static ide_driver_t idescsi_driver = { ...@@ -718,6 +727,7 @@ static ide_driver_t idescsi_driver = {
.media = ide_scsi, .media = ide_scsi,
.busy = 0, .busy = 0,
.supports_dsc_overlap = 0, .supports_dsc_overlap = 0,
.proc = idescsi_proc,
.attach = idescsi_attach, .attach = idescsi_attach,
.cleanup = idescsi_cleanup, .cleanup = idescsi_cleanup,
.do_request = idescsi_do_request, .do_request = idescsi_do_request,
......
...@@ -1098,7 +1098,6 @@ typedef struct ide_driver_s { ...@@ -1098,7 +1098,6 @@ typedef struct ide_driver_s {
ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8);
ide_startstop_t (*abort)(ide_drive_t *, struct request *rq); ide_startstop_t (*abort)(ide_drive_t *, struct request *rq);
int (*ioctl)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long); int (*ioctl)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);
sector_t (*capacity)(ide_drive_t *);
ide_proc_entry_t *proc; ide_proc_entry_t *proc;
int (*attach)(ide_drive_t *); int (*attach)(ide_drive_t *);
void (*ata_prebuilder)(ide_drive_t *); void (*ata_prebuilder)(ide_drive_t *);
......
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