48 #include <linux/module.h>
49 #include <linux/device.h>
53 #include <linux/slab.h>
55 #include <scsi/scsi.h>
66 # define TYPE_OSD 0x11
69 #ifndef SCSI_OSD_MAJOR
70 # define SCSI_OSD_MAJOR 260
72 #define SCSI_OSD_MAX_MINOR MINORMASK
74 static const char osd_name[] =
"osd";
75 static const char *osd_version_string =
"open-osd 0.2.1";
100 static struct class osd_uld_class = {
163 static long osd_uld_ioctl(
struct file *
file,
unsigned int cmd,
170 do_test = _find_ioctl(cmd);
172 ret = do_test(&oud->
od, cmd, arg);
174 OSD_ERR(
"Unknown ioctl %d: osd_uld_device=%p\n", cmd, oud);
182 .open = osd_uld_open,
183 .release = osd_uld_release,
184 .unlocked_ioctl = osd_uld_ioctl,
195 if (!name || !*name) {
196 OSD_ERR(
"Mount with !path || !*path\n");
206 error = PTR_ERR(file);
210 if (file->
f_op != &osd_fops){
227 return ERR_PTR(error);
231 static inline bool _the_same_or_null(
const u8 *
a1,
unsigned a1_len,
232 const u8 *
a2,
unsigned a2_len)
237 if (a1_len != a2_len)
240 return 0 ==
memcmp(a1, a2, a1_len);
256 if (_the_same_or_null(oud->
odi.systemid, oud->
odi.systemid_len,
258 _the_same_or_null(oud->
odi.osdname, oud->
odi.osdname_len,
260 OSD_DEBUG(
"found device sysid_len=%d osdname=%d\n",
287 odh->
od = find.
oud->od;
299 if (od && !IS_ERR(od)) {
326 return &odh->
oud->odi;
337 _the_same_or_null(oud->
odi.systemid, oud->
odi.systemid_len,
340 _the_same_or_null(oud->
odi.osdname, oud->
odi.osdname_len,
358 OSD_DEBUG(
"start scsi_test_unit_ready %p %p %p\n",
362 OSD_ERR(
"warning: scsi_test_unit_ready failed\n");
375 struct scsi_device *scsi_device = oud->
od.scsi_device;
395 static int osd_probe(
struct device *dev)
398 struct gendisk *disk;
411 }
while (error == -
EAGAIN);
417 goto err_retract_minor;
423 goto err_retract_minor;
432 OSD_ERR(
"alloc_disk failed\n");
436 disk->first_minor = oud->
minor;
447 error = __detect_osd(oud);
449 OSD_ERR(
"osd detection failed, non-compatible OSD device\n");
470 OSD_ERR(
"dev_set_name failed => %d\n", error);
476 OSD_ERR(
"device_register failed => %d\n", error);
482 OSD_INFO(
"osd_probe %s\n", disk->disk_name);
498 static int osd_remove(
struct device *dev)
503 if (!oud || (oud->
od.scsi_device != scsi_device)) {
504 OSD_ERR(
"Half cooked osd-device %p,%p || %p!=%p",
505 dev, oud, oud ? oud->
od.scsi_device :
NULL,
524 .remove = osd_remove,
528 static int __init osd_uld_init(
void)
534 OSD_ERR(
"Unable to register sysfs class => %d\n", err);
541 OSD_ERR(
"Unable to register major %d for osd ULD => %d\n",
548 OSD_ERR(
"scsi_register_driver failed => %d\n", err);
552 OSD_INFO(
"LOADED %s\n", osd_version_string);
562 static void __exit osd_uld_exit(
void)
567 OSD_INFO(
"UNLOADED %s\n", osd_version_string);