1 #include <linux/kernel.h>
2 #include <linux/module.h>
3 #include "modulbus_register.h"
6 #define PFX "VMOD args: "
8 /* module parameters */
9 static int lun
[VMOD_MAX_BOARDS
];
10 static unsigned int num_lun
;
11 module_param_array(lun
, int, &num_lun
, S_IRUGO
);
12 MODULE_PARM_DESC(lun
, "Logical Unit Number of the VMOD-XXX board");
14 static char *carrier
[VMOD_MAX_BOARDS
];
15 static unsigned int num_carrier
;
16 module_param_array(carrier
, charp
, &num_carrier
, S_IRUGO
);
17 MODULE_PARM_DESC(carrier
, "Name of the carrier in which the VMOD-XXX is plugged in.");
19 static int carrier_number
[VMOD_MAX_BOARDS
];
20 static unsigned int num_carrier_number
;
21 module_param_array(carrier_number
, int, &num_carrier_number
, S_IRUGO
);
22 MODULE_PARM_DESC(carrier_number
, "Logical Unit Number of the carrier");
24 static int slot
[VMOD_MAX_BOARDS
];
25 static unsigned int num_slot
;
26 module_param_array(slot
, int, &num_slot
, S_IRUGO
);
27 MODULE_PARM_DESC(slot
, "Slot of the carrier in which the VMOD-XXX board is placed.");
29 static int set_module_params(struct vmod_dev
*module
,
30 int lun
, char *cname
, int carrier_lun
, int slot
)
32 gas_t get_address_space
;
33 struct carrier_as as
, *asp
= &as
;
35 /* Sanity check parameters */
37 printk(KERN_ERR PFX
"invalid lun: %d\n", lun
);
40 get_address_space
= modulbus_carrier_as_entry(cname
);
41 if (get_address_space
== NULL
) {
42 printk(KERN_ERR PFX
"No carrier %s\n", cname
);
46 "Carrier %s get_address_space entry point at %p\n",
47 cname
, get_address_space
);
48 if (get_address_space(asp
, carrier_lun
, slot
, 1) < 0){
50 "Invalid carrier number: %d or slot: %d\n",
55 /* Parameters OK, go ahead */
57 module
->carrier_name
= cname
;
58 module
->carrier_lun
= carrier_lun
;
60 module
->address
= asp
->address
;
61 module
->is_big_endian
= asp
->is_big_endian
;
65 int read_params(char *driver_name
, struct vmod_devices
*devs
)
69 /* check that all insmod argument vectors are the same length */
70 if (num_lun
!= num_carrier
|| num_lun
!= num_carrier_number
||
71 num_lun
!= num_slot
|| num_lun
>= VMOD_MAX_BOARDS
) {
72 printk(KERN_ERR PFX
"the number of parameters doesn't match or is invalid\n");
77 for (i
=0; i
< num_lun
; i
++) {
79 struct vmod_dev
*module
= &devs
->module
[i
];
82 "configuring %s lun %d\n", driver_name
, lun
[i
]);
83 ret
= set_module_params(module
,
84 lun
[i
], carrier
[i
], carrier_number
[i
], slot
[i
]);
90 "module<%02d>: lun %d"
91 " carrier %s carrier_number = %d slot = %d"
92 " address 0x%08lx endian = %d\n",
93 i
, module
->lun
, module
->carrier_name
,
94 module
->carrier_lun
, module
->slot
,
95 module
->address
, module
->is_big_endian
);
97 devs
->num_modules
= device
;
102 int lun_to_index(struct vmod_devices
*devs
, int lun
)
106 for (i
= 0; i
< devs
->num_modules
; i
++)
107 if (lun
== devs
->module
[i
].lun
)