Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
ca18d6f
Documentation
arch
block
certs
crypto
drivers
accessibility
acpi
amba
android
ata
atm
auxdisplay
base
bcma
block
bluetooth
bus
cdrom
char
clk
clocksource
connector
cpufreq
cpuidle
crypto
dax
dca
devfreq
dio
dma-buf
dma
edac
eisa
extcon
firewire
firmware
fmc
fpga
fsi
gpio
gpu
hid
hsi
hv
hwmon
hwspinlock
hwtracing
i2c
ide
Kconfig
Makefile
aec62xx.c
ali14xx.c
alim15x3.c
amd74xx.c
atiixp.c
au1xxx-ide.c
buddha.c
cmd640.c
cmd64x.c
cs5520.c
cs5530.c
cs5535.c
cs5536.c
cy82c693.c
delkin_cb.c
dtc2278.c
falconide.c
gayle.c
hpt366.c
ht6560b.c
icside.c
ide-4drives.c
ide-acpi.c
ide-atapi.c
ide-cd.c
ide-cd.h
ide-cd_ioctl.c
ide-cd_verbose.c
ide-cs.c
ide-devsets.c
ide-disk.c
ide-disk.h
ide-disk_ioctl.c
ide-disk_proc.c
ide-dma-sff.c
ide-dma.c
ide-eh.c
ide-floppy.c
ide-floppy.h
ide-floppy_ioctl.c
ide-floppy_proc.c
ide-gd.c
ide-gd.h
ide-generic.c
ide-io-std.c
ide-io.c
ide-ioctls.c
ide-iops.c
ide-legacy.c
ide-lib.c
ide-park.c
ide-pci-generic.c
ide-pio-blacklist.c
ide-pm.c
ide-pnp.c
ide-probe.c
ide-proc.c
ide-scan-pci.c
ide-sysfs.c
ide-tape.c
ide-taskfile.c
ide-timings.c
ide-xfer-mode.c
ide.c
ide_platform.c
it8172.c
it8213.c
it821x.c
jmicron.c
macide.c
ns87415.c
opti621.c
palm_bk3710.c
pdc202xx_new.c
pdc202xx_old.c
piix.c
pmac.c
q40ide.c
qd65xx.c
qd65xx.h
rapide.c
rz1000.c
sc1200.c
serverworks.c
setup-pci.c
sgiioc4.c
siimage.c
sis5513.c
sl82c105.c
slc90e66.c
tc86c001.c
triflex.c
trm290.c
tx4938ide.c
tx4939ide.c
umc8672.c
via82cxxx.c
idle
iio
infiniband
input
iommu
ipack
irqchip
isdn
leds
lguest
lightnvm
macintosh
mailbox
mcb
md
media
memory
memstick
message
mfd
misc
mmc
mtd
net
nfc
ntb
nubus
nvdimm
nvme
nvmem
of
oprofile
parisc
parport
pci
pcmcia
perf
phy
pinctrl
platform
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390
sbus
scsi
sfi
sh
sn
soc
spi
spmi
ssb
staging
target
tc
tee
thermal
thunderbolt
tty
uio
usb
uwb
vfio
vhost
video
virt
virtio
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile
firmware
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
drivers
/
ide
/
ide-devsets.c
Copy path
Blame
Blame
Latest commit
History
History
191 lines (148 loc) · 3.89 KB
Breadcrumbs
linux
/
drivers
/
ide
/
ide-devsets.c
Top
File metadata and controls
Code
Blame
191 lines (148 loc) · 3.89 KB
Raw
#include <linux/kernel.h> #include <linux/gfp.h> #include <linux/ide.h> DEFINE_MUTEX(ide_setting_mtx); ide_devset_get(io_32bit, io_32bit); static int set_io_32bit(ide_drive_t *drive, int arg) { if (drive->dev_flags & IDE_DFLAG_NO_IO_32BIT) return -EPERM; if (arg < 0 || arg > 1 + (SUPPORT_VLB_SYNC << 1)) return -EINVAL; drive->io_32bit = arg; return 0; } ide_devset_get_flag(ksettings, IDE_DFLAG_KEEP_SETTINGS); static int set_ksettings(ide_drive_t *drive, int arg) { if (arg < 0 || arg > 1) return -EINVAL; if (arg) drive->dev_flags |= IDE_DFLAG_KEEP_SETTINGS; else drive->dev_flags &= ~IDE_DFLAG_KEEP_SETTINGS; return 0; } ide_devset_get_flag(using_dma, IDE_DFLAG_USING_DMA); static int set_using_dma(ide_drive_t *drive, int arg) { #ifdef CONFIG_BLK_DEV_IDEDMA int err = -EPERM; if (arg < 0 || arg > 1) return -EINVAL; if (ata_id_has_dma(drive->id) == 0) goto out; if (drive->hwif->dma_ops == NULL) goto out; err = 0; if (arg) { if (ide_set_dma(drive)) err = -EIO; } else ide_dma_off(drive); out: return err; #else if (arg < 0 || arg > 1) return -EINVAL; return -EPERM; #endif } /* * handle HDIO_SET_PIO_MODE ioctl abusers here, eventually it will go away */ static int set_pio_mode_abuse(ide_hwif_t *hwif, u8 req_pio) { switch (req_pio) { case 202: case 201: case 200: case 102: case 101: case 100: return (hwif->host_flags & IDE_HFLAG_ABUSE_DMA_MODES) ? 1 : 0; case 9: case 8: return (hwif->host_flags & IDE_HFLAG_ABUSE_PREFETCH) ? 1 : 0; case 7: case 6: return (hwif->host_flags & IDE_HFLAG_ABUSE_FAST_DEVSEL) ? 1 : 0; default: return 0; } } static int set_pio_mode(ide_drive_t *drive, int arg) { ide_hwif_t *hwif = drive->hwif; const struct ide_port_ops *port_ops = hwif->port_ops; if (arg < 0 || arg > 255) return -EINVAL; if (port_ops == NULL || port_ops->set_pio_mode == NULL || (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) return -ENOSYS; if (set_pio_mode_abuse(drive->hwif, arg)) { drive->pio_mode = arg + XFER_PIO_0; if (arg == 8 || arg == 9) { unsigned long flags; /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */ spin_lock_irqsave(&hwif->lock, flags); port_ops->set_pio_mode(hwif, drive); spin_unlock_irqrestore(&hwif->lock, flags); } else port_ops->set_pio_mode(hwif, drive); } else { int keep_dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); ide_set_pio(drive, arg); if (hwif->host_flags & IDE_HFLAG_SET_PIO_MODE_KEEP_DMA) { if (keep_dma) ide_dma_on(drive); } } return 0; } ide_devset_get_flag(unmaskirq, IDE_DFLAG_UNMASK); static int set_unmaskirq(ide_drive_t *drive, int arg) { if (drive->dev_flags & IDE_DFLAG_NO_UNMASK) return -EPERM; if (arg < 0 || arg > 1) return -EINVAL; if (arg) drive->dev_flags |= IDE_DFLAG_UNMASK; else drive->dev_flags &= ~IDE_DFLAG_UNMASK; return 0; } ide_ext_devset_rw_sync(io_32bit, io_32bit); ide_ext_devset_rw_sync(keepsettings, ksettings); ide_ext_devset_rw_sync(unmaskirq, unmaskirq); ide_ext_devset_rw_sync(using_dma, using_dma); __IDE_DEVSET(pio_mode, DS_SYNC, NULL, set_pio_mode); int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting, int arg) { struct request_queue *q = drive->queue; struct request *rq; int ret = 0; if (!(setting->flags & DS_SYNC)) return setting->set(drive, arg); rq = blk_get_request(q, REQ_OP_DRV_IN, __GFP_RECLAIM); ide_req(rq)->type = ATA_PRIV_MISC; scsi_req(rq)->cmd_len = 5; scsi_req(rq)->cmd[0] = REQ_DEVSET_EXEC; *(int *)&scsi_req(rq)->cmd[1] = arg; rq->special = setting->set; blk_execute_rq(q, NULL, rq, 0); ret = scsi_req(rq)->result; blk_put_request(rq); return ret; } ide_startstop_t ide_do_devset(ide_drive_t *drive, struct request *rq) { int err, (*setfunc)(ide_drive_t *, int) = rq->special; err = setfunc(drive, *(int *)&scsi_req(rq)->cmd[1]); if (err) scsi_req(rq)->result = err; ide_complete_rq(drive, 0, blk_rq_bytes(rq)); return ide_stopped; }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
You can’t perform that action at this time.