diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2007-08-14 08:10:39 -0400 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-01-11 19:22:30 -0500 |
commit | 285e9670d91cdeb6b6693729950339cb45410fdc (patch) | |
tree | 5edd3f6d19ca92b408ed07daa85cc0361a7a9a72 /drivers/scsi/sr.c | |
parent | d0c4c9d4a2e46f052178806c4004d52cd3ae040f (diff) |
[SCSI] sr,sd: send media state change modification events
This will send for a card reader slot (remove/add media):
UEVENT[1187091572.155884] change /devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/host7/target7:0:0/7:0:0:0 (scsi)
UEVENT[1187091572.162314] remove /block/sdb/sdb1 (block)
UEVENT[1187091572.172464] add /block/sdb/sdb1 (block)
UEVENT[1187091572.175408] change /devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/host7/target7:0:0/7:0:0:0 (scsi)
and for a DVD drive (add/eject media):
UEVENT[1187091590.189159] change /devices/pci0000:00/0000:00:1f.1/host4/target4:0:0/4:0:0:0 (scsi)
UEVENT[1187091590.957124] add /module/isofs (module)
UEVENT[1187091604.468207] change /devices/pci0000:00/0000:00:1f.1/host4/target4:0:0/4:0:0:0 (scsi)
Userspace gets events, even for unpartitioned media. This unifies
the event handling for asynchronoous events (AN) and events caused by
perodical polling the device from userspace.
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
[jejb: modified for new event API]
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/sr.c')
-rw-r--r-- | drivers/scsi/sr.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index c61999031141..7702681d93f9 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -192,8 +192,9 @@ static int sr_media_change(struct cdrom_device_info *cdi, int slot) | |||
192 | * and we will figure it out later once the drive is | 192 | * and we will figure it out later once the drive is |
193 | * available again. */ | 193 | * available again. */ |
194 | cd->device->changed = 1; | 194 | cd->device->changed = 1; |
195 | return 1; /* This will force a flush, if called from | 195 | /* This will force a flush, if called from check_disk_change */ |
196 | * check_disk_change */ | 196 | retval = 1; |
197 | goto out; | ||
197 | }; | 198 | }; |
198 | 199 | ||
199 | retval = cd->device->changed; | 200 | retval = cd->device->changed; |
@@ -203,9 +204,16 @@ static int sr_media_change(struct cdrom_device_info *cdi, int slot) | |||
203 | if (retval) { | 204 | if (retval) { |
204 | /* check multisession offset etc */ | 205 | /* check multisession offset etc */ |
205 | sr_cd_check(cdi); | 206 | sr_cd_check(cdi); |
206 | |||
207 | get_sectorsize(cd); | 207 | get_sectorsize(cd); |
208 | } | 208 | } |
209 | |||
210 | out: | ||
211 | /* Notify userspace, that media has changed. */ | ||
212 | if (retval != cd->previous_state) | ||
213 | sdev_evt_send_simple(cd->device, SDEV_EVT_MEDIA_CHANGE, | ||
214 | GFP_KERNEL); | ||
215 | cd->previous_state = retval; | ||
216 | |||
209 | return retval; | 217 | return retval; |
210 | } | 218 | } |
211 | 219 | ||