Skip to content

Commit

Permalink
ide: move IDE settings handling to ide-proc.c
Browse files Browse the repository at this point in the history
* move
	__ide_add_setting()
	ide_add_setting()
	__ide_remove_setting()
	auto_remove_settings()
	ide_find_setting_by_name()
	ide_read_setting()
	ide_write_setting()
	set_xfer_rate()
	ide_add_generic_settings()
	ide_register_subdriver()
	ide_unregister_subdriver()

  from ide.c to ide-proc.c

* set_{io_32bit,pio_mode,using_dma}() cannot be marked static now, fix it

* rename ide_[un]register_subdriver() to ide_proc_[un]register_driver(),
  update device drivers to use new names

* add CONFIG_IDE_PROC_FS=n versions of ide_proc_[un]register_driver()
  and ide_add_generic_settings()

* make ide_find_setting_by_name(), ide_{read,write}_setting()
  and ide_{add,remove}_proc_entries() static

* cover IDE settings code in device drivers with CONFIG_IDE_PROC_FS #ifdef,
  also while at it cover with CONFIG_IDE_PROC_FS #ifdef ide_driver_t.proc

* remove bogus comment from ide.h

* cover with CONFIG_IDE_PROC_FS #ifdef .proc and .settings in ide_drive_t

Besides saner code this patch results in the IDE core smaller by ~2 kB
(on x86-32) and IDE disk driver by ~1 kB (ditto) when CONFIG_IDE_PROC_FS=n.

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
  • Loading branch information
Bartlomiej Zolnierkiewicz committed May 9, 2007
1 parent 1497943 commit 7662d04
Show file tree
Hide file tree
Showing 8 changed files with 378 additions and 363 deletions.
14 changes: 9 additions & 5 deletions drivers/ide/ide-cd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3059,10 +3059,14 @@ int ide_cdrom_probe_capabilities (ide_drive_t *drive)
return nslots;
}

#ifdef CONFIG_IDE_PROC_FS
static void ide_cdrom_add_settings(ide_drive_t *drive)
{
ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL);
}
#else
static inline void ide_cdrom_add_settings(ide_drive_t *drive) { ; }
#endif

/*
* standard prep_rq_fn that builds 10 byte cmds
Expand Down Expand Up @@ -3291,7 +3295,7 @@ static void ide_cd_remove(ide_drive_t *drive)
{
struct cdrom_info *info = drive->driver_data;

ide_unregister_subdriver(drive, info->driver);
ide_proc_unregister_driver(drive, info->driver);

del_gendisk(info->disk);

Expand Down Expand Up @@ -3336,8 +3340,6 @@ 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 = {
Expand All @@ -3355,7 +3357,9 @@ static ide_driver_t ide_cdrom_driver = {
.end_request = ide_end_request,
.error = __ide_error,
.abort = __ide_abort,
#ifdef CONFIG_IDE_PROC_FS
.proc = idecd_proc,
#endif
};

static int idecd_open(struct inode * inode, struct file * file)
Expand Down Expand Up @@ -3517,7 +3521,7 @@ static int ide_cd_probe(ide_drive_t *drive)

ide_init_disk(g, drive);

ide_register_subdriver(drive, &ide_cdrom_driver);
ide_proc_register_driver(drive, &ide_cdrom_driver);

kref_init(&info->kref);

Expand All @@ -3534,7 +3538,7 @@ static int ide_cd_probe(ide_drive_t *drive)
g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE;
if (ide_cdrom_setup(drive)) {
struct cdrom_device_info *devinfo = &info->devinfo;
ide_unregister_subdriver(drive, &ide_cdrom_driver);
ide_proc_unregister_driver(drive, &ide_cdrom_driver);
kfree(info->buffer);
kfree(info->toc);
kfree(info->changer_info);
Expand Down
16 changes: 8 additions & 8 deletions drivers/ide/ide-disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,6 @@ static sector_t idedisk_capacity (ide_drive_t *drive)
}

#ifdef CONFIG_IDE_PROC_FS

static int smart_enable(ide_drive_t *drive)
{
ide_task_t args;
Expand Down Expand Up @@ -678,11 +677,6 @@ static ide_proc_entry_t idedisk_proc[] = {
{ "smart_thresholds", S_IFREG|S_IRUSR, proc_idedisk_read_smart_thresholds, NULL },
{ NULL, 0, NULL, NULL }
};

#else

#define idedisk_proc NULL

#endif /* CONFIG_IDE_PROC_FS */

static void idedisk_prepare_flush(request_queue_t *q, struct request *rq)
Expand Down Expand Up @@ -881,6 +875,7 @@ static int set_lba_addressing(ide_drive_t *drive, int arg)
return 0;
}

#ifdef CONFIG_IDE_PROC_FS
static void idedisk_add_settings(ide_drive_t *drive)
{
struct hd_driveid *id = drive->id;
Expand All @@ -898,6 +893,9 @@ static void idedisk_add_settings(ide_drive_t *drive)
ide_add_setting(drive, "failures", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, &drive->failures, NULL);
ide_add_setting(drive, "max_failures", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, &drive->max_failures, NULL);
}
#else
static inline void idedisk_add_settings(ide_drive_t *drive) { ; }
#endif

static void idedisk_setup (ide_drive_t *drive)
{
Expand Down Expand Up @@ -1016,7 +1014,7 @@ static void ide_disk_remove(ide_drive_t *drive)
struct ide_disk_obj *idkp = drive->driver_data;
struct gendisk *g = idkp->disk;

ide_unregister_subdriver(drive, idkp->driver);
ide_proc_unregister_driver(drive, idkp->driver);

del_gendisk(g);

Expand Down Expand Up @@ -1081,7 +1079,9 @@ static ide_driver_t idedisk_driver = {
.end_request = ide_end_request,
.error = __ide_error,
.abort = __ide_abort,
#ifdef CONFIG_IDE_PROC_FS
.proc = idedisk_proc,
#endif
};

static int idedisk_open(struct inode *inode, struct file *filp)
Expand Down Expand Up @@ -1257,7 +1257,7 @@ static int ide_disk_probe(ide_drive_t *drive)

ide_init_disk(g, drive);

ide_register_subdriver(drive, &idedisk_driver);
ide_proc_register_driver(drive, &idedisk_driver);

kref_init(&idkp->kref);

Expand Down
16 changes: 8 additions & 8 deletions drivers/ide/ide-floppy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,7 @@ static int idefloppy_identify_device (ide_drive_t *drive,struct hd_driveid *id)
return 0;
}

#ifdef CONFIG_IDE_PROC_FS
static void idefloppy_add_settings(ide_drive_t *drive)
{
idefloppy_floppy_t *floppy = drive->driver_data;
Expand All @@ -1823,6 +1824,9 @@ static void idefloppy_add_settings(ide_drive_t *drive)
ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, &drive->bios_sect, NULL);
ide_add_setting(drive, "ticks", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &floppy->ticks, NULL);
}
#else
static inline void idefloppy_add_settings(ide_drive_t *drive) { ; }
#endif

/*
* Driver initialization.
Expand Down Expand Up @@ -1873,7 +1877,7 @@ static void ide_floppy_remove(ide_drive_t *drive)
idefloppy_floppy_t *floppy = drive->driver_data;
struct gendisk *g = floppy->disk;

ide_unregister_subdriver(drive, floppy->driver);
ide_proc_unregister_driver(drive, floppy->driver);

del_gendisk(g);

Expand All @@ -1893,7 +1897,6 @@ static void ide_floppy_release(struct kref *kref)
}

#ifdef CONFIG_IDE_PROC_FS

static int proc_idefloppy_read_capacity
(char *page, char **start, off_t off, int count, int *eof, void *data)
{
Expand All @@ -1909,11 +1912,6 @@ static ide_proc_entry_t idefloppy_proc[] = {
{ "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL },
{ NULL, 0, NULL, NULL }
};

#else

#define idefloppy_proc NULL

#endif /* CONFIG_IDE_PROC_FS */

static int ide_floppy_probe(ide_drive_t *);
Expand All @@ -1933,7 +1931,9 @@ static ide_driver_t idefloppy_driver = {
.end_request = idefloppy_do_end_request,
.error = __ide_error,
.abort = __ide_abort,
#ifdef CONFIG_IDE_PROC_FS
.proc = idefloppy_proc,
#endif
};

static int idefloppy_open(struct inode *inode, struct file *filp)
Expand Down Expand Up @@ -2159,7 +2159,7 @@ static int ide_floppy_probe(ide_drive_t *drive)

ide_init_disk(g, drive);

ide_register_subdriver(drive, &idefloppy_driver);
ide_proc_register_driver(drive, &idefloppy_driver);

kref_init(&floppy->kref);

Expand Down
Loading

0 comments on commit 7662d04

Please sign in to comment.