aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:28 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:28 -0400
commit8185d5aa93e0a5c111adc4952a5b87193a68ae5b (patch)
tree431aeb09a448b7b07a353e12f4fe931ebb8555cd /drivers/ide/ide.c
parent263138a0ad6e38de7f6526b7de037ed4511308ef (diff)
ide: /proc/ide/hd*/settings rework
* Add struct ide_devset, S_* flags, *DEVSET() & ide*_devset_*() macros. * Add 'const struct ide_devset **settings' to ide_driver_t. * Use 'const struct ide_devset **settings' in ide_drive_t instead of 'struct ide_settings_s *settings'. Then convert core code and device drivers to use struct ide_devset and co.: - device settings are no longer allocated dynamically for each device but instead there is an unique struct ide_devset instance per setting - device driver keeps the pointer to the table of pointers to its settings in ide_driver_t.settings - generic settings are kept in ide_generic_setting[] - ide_proc_[un]register_driver(), ide_find_setting_by_name(), ide_{read,write}_setting() and proc_ide_{read,write}_settings() are updated accordingly - ide*_add_settings() are removed * Remove no longer used __ide_add_setting(), ide_add_setting(), __ide_remove_setting() and auto_remove_settings(). * Remove no longer used TYPE_*, SETTING_*, ide_procset_t and ide_settings_t. * ->keep_settings, ->using_dma, ->unmask, ->noflush, ->dsc_overlap, ->nice1, ->addressing, ->wcache and ->nowerr ide_drive_t fields can now be bitfield flags. While at it: * Rename ide_find_setting_by_name() to ide_find_setting(). * Rename write_wcache() to set_wcache(). There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide.c')
-rw-r--r--drivers/ide/ide.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 8e0c9f27ae4a..eb64e942f58b 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -287,6 +287,8 @@ int ide_spin_wait_hwgroup (ide_drive_t *drive)
287 287
288EXPORT_SYMBOL(ide_spin_wait_hwgroup); 288EXPORT_SYMBOL(ide_spin_wait_hwgroup);
289 289
290ide_devset_get(io_32bit, io_32bit);
291
290int set_io_32bit(ide_drive_t *drive, int arg) 292int set_io_32bit(ide_drive_t *drive, int arg)
291{ 293{
292 if (drive->no_io_32bit) 294 if (drive->no_io_32bit)
@@ -305,6 +307,8 @@ int set_io_32bit(ide_drive_t *drive, int arg)
305 return 0; 307 return 0;
306} 308}
307 309
310ide_devset_get(ksettings, keep_settings);
311
308int set_ksettings(ide_drive_t *drive, int arg) 312int set_ksettings(ide_drive_t *drive, int arg)
309{ 313{
310 if (arg < 0 || arg > 1) 314 if (arg < 0 || arg > 1)
@@ -318,6 +322,8 @@ int set_ksettings(ide_drive_t *drive, int arg)
318 return 0; 322 return 0;
319} 323}
320 324
325ide_devset_get(using_dma, using_dma);
326
321int set_using_dma(ide_drive_t *drive, int arg) 327int set_using_dma(ide_drive_t *drive, int arg)
322{ 328{
323#ifdef CONFIG_BLK_DEV_IDEDMA 329#ifdef CONFIG_BLK_DEV_IDEDMA
@@ -394,6 +400,8 @@ int set_pio_mode(ide_drive_t *drive, int arg)
394 return 0; 400 return 0;
395} 401}
396 402
403ide_devset_get(unmaskirq, unmask);
404
397int set_unmaskirq(ide_drive_t *drive, int arg) 405int set_unmaskirq(ide_drive_t *drive, int arg)
398{ 406{
399 if (drive->no_unmask) 407 if (drive->no_unmask)
@@ -555,14 +563,13 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
555{ 563{
556 unsigned long flags; 564 unsigned long flags;
557 ide_driver_t *drv; 565 ide_driver_t *drv;
558 int err = 0, (*setfunc)(ide_drive_t *, int); 566 int err = 0, (*getfunc)(ide_drive_t *), (*setfunc)(ide_drive_t *, int);
559 u8 *val;
560 567
561 switch (cmd) { 568 switch (cmd) {
562 case HDIO_GET_32BIT: val = &drive->io_32bit; goto read_val; 569 case HDIO_GET_32BIT: getfunc = get_io_32bit; goto read_val;
563 case HDIO_GET_KEEPSETTINGS: val = &drive->keep_settings; goto read_val; 570 case HDIO_GET_KEEPSETTINGS: getfunc = get_ksettings; goto read_val;
564 case HDIO_GET_UNMASKINTR: val = &drive->unmask; goto read_val; 571 case HDIO_GET_UNMASKINTR: getfunc = get_unmaskirq; goto read_val;
565 case HDIO_GET_DMA: val = &drive->using_dma; goto read_val; 572 case HDIO_GET_DMA: getfunc = get_using_dma; goto read_val;
566 case HDIO_SET_32BIT: setfunc = set_io_32bit; goto set_val; 573 case HDIO_SET_32BIT: setfunc = set_io_32bit; goto set_val;
567 case HDIO_SET_KEEPSETTINGS: setfunc = set_ksettings; goto set_val; 574 case HDIO_SET_KEEPSETTINGS: setfunc = set_ksettings; goto set_val;
568 case HDIO_SET_PIO_MODE: setfunc = set_pio_mode; goto set_val; 575 case HDIO_SET_PIO_MODE: setfunc = set_pio_mode; goto set_val;
@@ -638,7 +645,7 @@ int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device
638read_val: 645read_val:
639 mutex_lock(&ide_setting_mtx); 646 mutex_lock(&ide_setting_mtx);
640 spin_lock_irqsave(&ide_lock, flags); 647 spin_lock_irqsave(&ide_lock, flags);
641 err = *val; 648 err = getfunc(drive);
642 spin_unlock_irqrestore(&ide_lock, flags); 649 spin_unlock_irqrestore(&ide_lock, flags);
643 mutex_unlock(&ide_setting_mtx); 650 mutex_unlock(&ide_setting_mtx);
644 return err >= 0 ? put_user(err, (long __user *)arg) : err; 651 return err >= 0 ? put_user(err, (long __user *)arg) : err;