aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-tape.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-tape.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-tape.c')
-rw-r--r--drivers/ide/ide-tape.c74
1 files changed, 51 insertions, 23 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index f41983e4a4e4..7037accb0589 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2410,28 +2410,56 @@ static void idetape_get_mode_sense_results(ide_drive_t *drive)
2410} 2410}
2411 2411
2412#ifdef CONFIG_IDE_PROC_FS 2412#ifdef CONFIG_IDE_PROC_FS
2413static void idetape_add_settings(ide_drive_t *drive) 2413#define ide_tape_devset_get(name, field) \
2414{ 2414static int get_##name(ide_drive_t *drive) \
2415 idetape_tape_t *tape = drive->driver_data; 2415{ \
2416 2416 idetape_tape_t *tape = drive->driver_data; \
2417 ide_add_setting(drive, "buffer", SETTING_READ, TYPE_SHORT, 0, 0xffff, 2417 return tape->field; \
2418 1, 2, (u16 *)&tape->caps[16], NULL); 2418}
2419 ide_add_setting(drive, "speed", SETTING_READ, TYPE_SHORT, 0, 0xffff, 2419
2420 1, 1, (u16 *)&tape->caps[14], NULL); 2420#define ide_tape_devset_set(name, field) \
2421 ide_add_setting(drive, "buffer_size", SETTING_READ, TYPE_INT, 0, 0xffff, 2421static int set_##name(ide_drive_t *drive, int arg) \
2422 1, 1024, &tape->buffer_size, NULL); 2422{ \
2423 ide_add_setting(drive, "tdsc", SETTING_RW, TYPE_INT, IDETAPE_DSC_RW_MIN, 2423 idetape_tape_t *tape = drive->driver_data; \
2424 IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_freq, 2424 tape->field = arg; \
2425 NULL); 2425 return 0; \
2426 ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 2426}
2427 1, &drive->dsc_overlap, NULL); 2427
2428 ide_add_setting(drive, "avg_speed", SETTING_READ, TYPE_INT, 0, 0xffff, 2428#define ide_tape_devset_rw(_name, _min, _max, _field, _mulf, _divf) \
2429 1, 1, &tape->avg_speed, NULL); 2429ide_tape_devset_get(_name, _field) \
2430 ide_add_setting(drive, "debug_mask", SETTING_RW, TYPE_INT, 0, 0xffff, 1, 2430ide_tape_devset_set(_name, _field) \
2431 1, &tape->debug_mask, NULL); 2431__IDE_DEVSET(_name, S_RW, _min, _max, get_##_name, set_##_name, _mulf, _divf)
2432} 2432
2433#else 2433#define ide_tape_devset_r(_name, _min, _max, _field, _mulf, _divf) \
2434static inline void idetape_add_settings(ide_drive_t *drive) { ; } 2434ide_tape_devset_get(_name, _field) \
2435__IDE_DEVSET(_name, S_READ, _min, _max, get_##_name, NULL, _mulf, _divf)
2436
2437static int mulf_tdsc(ide_drive_t *drive) { return 1000; }
2438static int divf_tdsc(ide_drive_t *drive) { return HZ; }
2439static int divf_buffer(ide_drive_t *drive) { return 2; }
2440static int divf_buffer_size(ide_drive_t *drive) { return 1024; }
2441
2442ide_devset_rw(dsc_overlap, 0, 1, dsc_overlap);
2443
2444ide_tape_devset_rw(debug_mask, 0, 0xffff, debug_mask, NULL, NULL);
2445ide_tape_devset_rw(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX,
2446 best_dsc_rw_freq, mulf_tdsc, divf_tdsc);
2447
2448ide_tape_devset_r(avg_speed, 0, 0xffff, avg_speed, NULL, NULL);
2449ide_tape_devset_r(speed, 0, 0xffff, caps[14], NULL, NULL);
2450ide_tape_devset_r(buffer, 0, 0xffff, caps[16], NULL, divf_buffer);
2451ide_tape_devset_r(buffer_size, 0, 0xffff, buffer_size, NULL, divf_buffer_size);
2452
2453static const struct ide_devset *idetape_settings[] = {
2454 &ide_devset_avg_speed,
2455 &ide_devset_buffer,
2456 &ide_devset_buffer_size,
2457 &ide_devset_debug_mask,
2458 &ide_devset_dsc_overlap,
2459 &ide_devset_speed,
2460 &ide_devset_tdsc,
2461 NULL
2462};
2435#endif 2463#endif
2436 2464
2437/* 2465/*
@@ -2515,7 +2543,6 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor)
2515 drive->using_dma ? ", DMA":""); 2543 drive->using_dma ? ", DMA":"");
2516 2544
2517 ide_proc_register_driver(drive, tape->driver); 2545 ide_proc_register_driver(drive, tape->driver);
2518 idetape_add_settings(drive);
2519} 2546}
2520 2547
2521static void ide_tape_remove(ide_drive_t *drive) 2548static void ide_tape_remove(ide_drive_t *drive)
@@ -2586,6 +2613,7 @@ static ide_driver_t idetape_driver = {
2586 .error = __ide_error, 2613 .error = __ide_error,
2587#ifdef CONFIG_IDE_PROC_FS 2614#ifdef CONFIG_IDE_PROC_FS
2588 .proc = idetape_proc, 2615 .proc = idetape_proc,
2616 .settings = idetape_settings,
2589#endif 2617#endif
2590}; 2618};
2591 2619