Skip to content

Commit 2fd3c5c

Browse files
Dan Carpenterdavem330
authored andcommitted
ide: make drive->dn read only
The IDE core always sets ->dn correctly so changing it is never required. Setting it to a different value than assigned by IDE core is very likely to result in data corruption (due to wrong transfer timings being set on the controller etc.) Signed-off-by: Dan Carpenter <[email protected]> Acked-by: Bartlomiej Zolnierkiewicz <[email protected]> Tested-by: Bartlomiej Zolnierkiewicz <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ce1f31b commit 2fd3c5c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

drivers/ide/ide-proc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static int set_xfer_rate (ide_drive_t *drive, int arg)
206206
ide_devset_rw(current_speed, xfer_rate);
207207
ide_devset_rw_field(init_speed, init_speed);
208208
ide_devset_rw_flag(nice1, IDE_DFLAG_NICE1);
209-
ide_devset_rw_field(number, dn);
209+
ide_devset_ro_field(number, dn);
210210

211211
static const struct ide_proc_devset ide_generic_settings[] = {
212212
IDE_PROC_DEVSET(current_speed, 0, 70),

include/linux/ide.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,10 @@ ide_devset_get(_name, _field); \
943943
ide_devset_set(_name, _field); \
944944
IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name)
945945

946+
#define ide_devset_ro_field(_name, _field) \
947+
ide_devset_get(_name, _field); \
948+
IDE_DEVSET(_name, 0, get_##_name, NULL)
949+
946950
#define ide_devset_rw_flag(_name, _field) \
947951
ide_devset_get_flag(_name, _field); \
948952
ide_devset_set_flag(_name, _field); \

0 commit comments

Comments
 (0)