aboutsummaryrefslogtreecommitdiff
path: root/drivers/scsi/iscsi_boot_sysfs.c
blob: 89700cbca16edf4b5d3d3ce0f2374fa33a390ef9 (plain)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
/*
 * Export the iSCSI boot info to userland via sysfs.
 *
 * Copyright (C) 2010 Red Hat, Inc.  All rights reserved.
 * Copyright (C) 2010 Mike Christie
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License v2.0 as published by
 * the Free Software Foundation
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#include <linux/module.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/sysfs.h>
#include <linux/capability.h>
#include <linux/iscsi_boot_sysfs.h>


MODULE_AUTHOR("Mike Christie <michaelc@cs.wisc.edu>");
MODULE_DESCRIPTION("sysfs interface and helpers to export iSCSI boot information");
MODULE_LICENSE("GPL");
/*
 * The kobject and attribute structures.
 */
struct iscsi_boot_attr {
	struct attribute attr;
	int type;
	ssize_t (*show) (void *data, int type, char *buf);
};

/*
 * The routine called for all sysfs attributes.
 */
static ssize_t iscsi_boot_show_attribute(struct kobject *kobj,
					 struct attribute *attr, char *buf)
{
	struct iscsi_boot_kobj *boot_kobj =
			container_of(kobj, struct iscsi_boot_kobj, kobj);
	struct iscsi_boot_attr *boot_attr =
			container_of(attr, struct iscsi_boot_attr, attr);
	ssize_t ret = -EIO;
	char *str = buf;

	if (!capable(CAP_SYS_ADMIN))
		return -EACCES;

	if (boot_kobj->show)
		ret = boot_kobj->show(boot_kobj->data, boot_attr->type, str);
	return ret;
}

static const struct sysfs_ops iscsi_boot_attr_ops = {
	.show = iscsi_boot_show_attribute,
};

static void iscsi_boot_kobj_release(struct kobject *kobj)
{
	struct iscsi_boot_kobj *boot_kobj =
			container_of(kobj, struct iscsi_boot_kobj, kobj);

	if (boot_kobj->release)
		boot_kobj->release(boot_kobj->data);
	kfree(boot_kobj);
}

static struct kobj_type iscsi_boot_ktype = {
	.release = iscsi_boot_kobj_release,
	.sysfs_ops = &iscsi_boot_attr_ops,
};

#define iscsi_boot_rd_attr(fnname, sysfs_name, attr_type)		\
static struct iscsi_boot_attr iscsi_boot_attr_##fnname = {	\
	.attr	= { .name = __stringify(sysfs_name), .mode = 0444 },	\
	.type	= attr_type,						\
}

/* Target attrs */
iscsi_boot_rd_attr(tgt_index, index, ISCSI_BOOT_TGT_INDEX);
iscsi_boot_rd_attr(tgt_flags, flags, ISCSI_BOOT_TGT_FLAGS);
iscsi_boot_rd_attr(tgt_ip, ip-addr, ISCSI_BOOT_TGT_IP_ADDR);
iscsi_boot_rd_attr(tgt_port, port, ISCSI_BOOT_TGT_PORT);
iscsi_boot_rd_attr(tgt_lun, lun, ISCSI_BOOT_TGT_LUN);
iscsi_boot_rd_attr(tgt_chap, chap-type, ISCSI_BOOT_TGT_CHAP_TYPE);
iscsi_boot_rd_attr(tgt_nic, nic-assoc, ISCSI_BOOT_TGT_NIC_ASSOC);
iscsi_boot_rd_attr(tgt_name, target-name, ISCSI_BOOT_TGT_NAME);
iscsi_boot_rd_attr(tgt_chap_name, chap-name, ISCSI_BOOT_TGT_CHAP_NAME);
iscsi_boot_rd_attr(tgt_chap_secret, chap-secret, ISCSI_BOOT_TGT_CHAP_SECRET);
iscsi_boot_rd_attr(tgt_chap_rev_name, rev-chap-name,
		   ISCSI_BOOT_TGT_REV_CHAP_NAME);
iscsi_boot_rd_attr(tgt_chap_rev_secret, rev-chap-name-secret,
		   ISCSI_BOOT_TGT_REV_CHAP_SECRET);

static struct attribute *target_attrs[] = {
	&iscsi_boot_attr_tgt_index.attr,
	&iscsi_boot_attr_tgt_flags.attr,
	&iscsi_boot_attr_tgt_ip.attr,
	&iscsi_boot_attr_tgt_port.attr,
	&iscsi_boot_attr_tgt_lun.attr,
	&iscsi_boot_attr_tgt_chap.attr,
	&iscsi_boot_attr_tgt_nic.attr,
	&iscsi_boot_attr_tgt_name.attr,
	&iscsi_boot_attr_tgt_chap_name.attr,
	&iscsi_boot_attr_tgt_chap_secret.attr,
	&iscsi_boot_attr_tgt_chap_rev_name.attr,
	&iscsi_boot_attr_tgt_chap_rev_secret.attr,
	NULL
};

static mode_t iscsi_boot_tgt_attr_is_visible(struct kobject *kobj,
					     struct attribute *attr, int i)
{
	struct iscsi_boot_kobj *boot_kobj =
			container_of(kobj, struct iscsi_boot_kobj, kobj);

	if (attr ==  &iscsi_boot_attr_tgt_index.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_TGT_INDEX);
	else if (attr == &iscsi_boot_attr_tgt_flags.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_TGT_FLAGS);
	else if (attr == &iscsi_boot_attr_tgt_ip.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					      ISCSI_BOOT_TGT_IP_ADDR);
	else if (attr == &iscsi_boot_attr_tgt_port.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					      ISCSI_BOOT_TGT_PORT);
	else if (attr == &iscsi_boot_attr_tgt_lun.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					      ISCSI_BOOT_TGT_LUN);
	else if (attr == &iscsi_boot_attr_tgt_chap.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_TGT_CHAP_TYPE);
	else if (attr == &iscsi_boot_attr_tgt_nic.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_TGT_NIC_ASSOC);
	else if (attr == &iscsi_boot_attr_tgt_name.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_TGT_NAME);
	else if (attr == &iscsi_boot_attr_tgt_chap_name.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_TGT_CHAP_NAME);
	else if (attr == &iscsi_boot_attr_tgt_chap_secret.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_TGT_CHAP_SECRET);
	else if (attr == &iscsi_boot_attr_tgt_chap_rev_name.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_TGT_REV_CHAP_NAME);
	else if (attr == &iscsi_boot_attr_tgt_chap_rev_secret.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_TGT_REV_CHAP_SECRET);
	return 0;
}

static struct attribute_group iscsi_boot_target_attr_group = {
	.attrs = target_attrs,
	.is_visible = iscsi_boot_tgt_attr_is_visible,
};

/* Ethernet attrs */
iscsi_boot_rd_attr(eth_index, index, ISCSI_BOOT_ETH_INDEX);
iscsi_boot_rd_attr(eth_flags, flags, ISCSI_BOOT_ETH_FLAGS);
iscsi_boot_rd_attr(eth_ip, ip-addr, ISCSI_BOOT_ETH_IP_ADDR);
iscsi_boot_rd_attr(eth_subnet, subnet-mask, ISCSI_BOOT_ETH_SUBNET_MASK);
iscsi_boot_rd_attr(eth_origin, origin, ISCSI_BOOT_ETH_ORIGIN);
iscsi_boot_rd_attr(eth_gateway, gateway, ISCSI_BOOT_ETH_GATEWAY);
iscsi_boot_rd_attr(eth_primary_dns, primary-dns, ISCSI_BOOT_ETH_PRIMARY_DNS);
iscsi_boot_rd_attr(eth_secondary_dns, secondary-dns,
		   ISCSI_BOOT_ETH_SECONDARY_DNS);
iscsi_boot_rd_attr(eth_dhcp, dhcp, ISCSI_BOOT_ETH_DHCP);
iscsi_boot_rd_attr(eth_vlan, vlan, ISCSI_BOOT_ETH_VLAN);
iscsi_boot_rd_attr(eth_mac, mac, ISCSI_BOOT_ETH_MAC);
iscsi_boot_rd_attr(eth_hostname, hostname, ISCSI_BOOT_ETH_HOSTNAME);

static struct attribute *ethernet_attrs[] = {
	&iscsi_boot_attr_eth_index.attr,
	&iscsi_boot_attr_eth_flags.attr,
	&iscsi_boot_attr_eth_ip.attr,
	&iscsi_boot_attr_eth_subnet.attr,
	&iscsi_boot_attr_eth_origin.attr,
	&iscsi_boot_attr_eth_gateway.attr,
	&iscsi_boot_attr_eth_primary_dns.attr,
	&iscsi_boot_attr_eth_secondary_dns.attr,
	&iscsi_boot_attr_eth_dhcp.attr,
	&iscsi_boot_attr_eth_vlan.attr,
	&iscsi_boot_attr_eth_mac.attr,
	&iscsi_boot_attr_eth_hostname.attr,
	NULL
};

static mode_t iscsi_boot_eth_attr_is_visible(struct kobject *kobj,
					     struct attribute *attr, int i)
{
	struct iscsi_boot_kobj *boot_kobj =
			container_of(kobj, struct iscsi_boot_kobj, kobj);

	if (attr ==  &iscsi_boot_attr_eth_index.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_ETH_INDEX);
	else if (attr ==  &iscsi_boot_attr_eth_flags.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_ETH_FLAGS);
	else if (attr ==  &iscsi_boot_attr_eth_ip.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_ETH_IP_ADDR);
	else if (attr ==  &iscsi_boot_attr_eth_subnet.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_ETH_SUBNET_MASK);
	else if (attr ==  &iscsi_boot_attr_eth_origin.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_ETH_ORIGIN);
	else if (attr ==  &iscsi_boot_attr_eth_gateway.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_ETH_GATEWAY);
	else if (attr ==  &iscsi_boot_attr_eth_primary_dns.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_ETH_PRIMARY_DNS);
	else if (attr ==  &iscsi_boot_attr_eth_secondary_dns.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_ETH_SECONDARY_DNS);
	else if (attr ==  &iscsi_boot_attr_eth_dhcp.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_ETH_DHCP);
	else if (attr ==  &iscsi_boot_attr_eth_vlan.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_ETH_VLAN);
	else if (attr ==  &iscsi_boot_attr_eth_mac.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_ETH_MAC);
	else if (attr ==  &iscsi_boot_attr_eth_hostname.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_ETH_HOSTNAME);
	return 0;
}

static struct attribute_group iscsi_boot_ethernet_attr_group = {
	.attrs = ethernet_attrs,
	.is_visible = iscsi_boot_eth_attr_is_visible,
};

/* Initiator attrs */
iscsi_boot_rd_attr(ini_index, index, ISCSI_BOOT_INI_INDEX);
iscsi_boot_rd_attr(ini_flags, flags, ISCSI_BOOT_INI_FLAGS);
iscsi_boot_rd_attr(ini_isns, isns-server, ISCSI_BOOT_INI_ISNS_SERVER);
iscsi_boot_rd_attr(ini_slp, slp-server, ISCSI_BOOT_INI_SLP_SERVER);
iscsi_boot_rd_attr(ini_primary_radius, pri-radius-server,
		   ISCSI_BOOT_INI_PRI_RADIUS_SERVER);
iscsi_boot_rd_attr(ini_secondary_radius, sec-radius-server,
		   ISCSI_BOOT_INI_SEC_RADIUS_SERVER);
iscsi_boot_rd_attr(ini_name, initiator-name, ISCSI_BOOT_INI_INITIATOR_NAME);

static struct attribute *initiator_attrs[] = {
	&iscsi_boot_attr_ini_index.attr,
	&iscsi_boot_attr_ini_flags.attr,
	&iscsi_boot_attr_ini_isns.attr,
	&iscsi_boot_attr_ini_slp.attr,
	&iscsi_boot_attr_ini_primary_radius.attr,
	&iscsi_boot_attr_ini_secondary_radius.attr,
	&iscsi_boot_attr_ini_name.attr,
	NULL
};

static mode_t iscsi_boot_ini_attr_is_visible(struct kobject *kobj,
					     struct attribute *attr, int i)
{
	struct iscsi_boot_kobj *boot_kobj =
			container_of(kobj, struct iscsi_boot_kobj, kobj);

	if (attr ==  &iscsi_boot_attr_ini_index.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_INI_INDEX);
	if (attr ==  &iscsi_boot_attr_ini_flags.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_INI_FLAGS);
	if (attr ==  &iscsi_boot_attr_ini_isns.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_INI_ISNS_SERVER);
	if (attr ==  &iscsi_boot_attr_ini_slp.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_INI_SLP_SERVER);
	if (attr ==  &iscsi_boot_attr_ini_primary_radius.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_INI_PRI_RADIUS_SERVER);
	if (attr ==  &iscsi_boot_attr_ini_secondary_radius.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_INI_SEC_RADIUS_SERVER);
	if (attr ==  &iscsi_boot_attr_ini_name.attr)
		return boot_kobj->is_visible(boot_kobj->data,
					     ISCSI_BOOT_INI_INITIATOR_NAME);

	return 0;
}

static struct attribute_group iscsi_boot_initiator_attr_group = {
	.attrs = initiator_attrs,
	.is_visible = iscsi_boot_ini_attr_is_visible,
};

static struct iscsi_boot_kobj *
iscsi_boot_create_kobj(struct iscsi_boot_kset *boot_kset,
		       struct attribute_group *attr_group,
		       const char *name, int index, void *data,
		       ssize_t (*show) (void *data, int type, char *buf),
		       mode_t (*is_visible) (void *data, int type),
		       void (*release) (void *data))
{
	struct iscsi_boot_kobj *boot_kobj;

	boot_kobj = kzalloc(sizeof(*boot_kobj), GFP_KERNEL);
	if (!boot_kobj)
		return NULL;
	INIT_LIST_HEAD(&boot_kobj->list);

	boot_kobj->kobj.kset = boot_kset->kset;
	if (kobject_init_and_add(&boot_kobj->kobj, &iscsi_boot_ktype,
				 NULL, name, index)) {
		kfree(boot_kobj);
		return NULL;
	}
	boot_kobj->data = data;
	boot_kobj->show = show;
	boot_kobj->is_visible = is_visible;
	boot_kobj->release = release;

	if (sysfs_create_group(&boot_kobj->kobj, attr_group)) {
		/*
		 * We do not want to free this because the caller
		 * will assume that since the creation call failed
		 * the boot kobj was not setup and the normal release
		 * path is not being run.
		 */
		boot_kobj->release = NULL;
		kobject_put(&boot_kobj->kobj);
		return NULL;
	}
	boot_kobj->attr_group = attr_group;

	kobject_uevent(&boot_kobj->kobj, KOBJ_ADD);
	/* Nothing broke so lets add it to the list. */
	list_add_tail(&boot_kobj->list, &boot_kset->kobj_list);
	return boot_kobj;
}

static void iscsi_boot_remove_kobj(struct iscsi_boot_kobj *boot_kobj)
{
	list_del(&boot_kobj->list);
	sysfs_remove_group(&boot_kobj->kobj, boot_kobj->attr_group);
	kobject_put(&boot_kobj->kobj);
}

/**
 * iscsi_boot_create_target() - create boot target sysfs dir
 * @boot_kset: boot kset
 * @index: the target id
 * @data: driver specific data for target
 * @show: attr show function
 * @is_visible: attr visibility function
 * @release: release function
 *
 * Note: The boot sysfs lib will free the data passed in for the caller
 * when all refs to the target kobject have been released.
 */
struct iscsi_boot_kobj *
iscsi_boot_create_target(struct iscsi_boot_kset *boot_kset, int index,
			 void *data,
			 ssize_t (*show) (void *data, int type, char *buf),
			 mode_t (*is_visible) (void *data, int type),
			 void (*release) (void *data))
{
	return iscsi_boot_create_kobj(boot_kset, &iscsi_boot_target_attr_group,
				      "target%d", index, data, show, is_visible,
				      release);
}
EXPORT_SYMBOL_GPL(iscsi_boot_create_target);

/**
 * iscsi_boot_create_initiator() - create boot initiator sysfs dir
 * @boot_kset: boot kset
 * @index: the initiator id
 * @data: driver specific data
 * @show: attr show function
 * @is_visible: attr visibility function
 * @release: release function
 *
 * Note: The boot sysfs lib will free the data passed in for the caller
 * when all refs to the initiator kobject have been released.
 */
struct iscsi_boot_kobj *
iscsi_boot_create_initiator(struct iscsi_boot_kset *boot_kset, int index,
			    void *data,
			    ssize_t (*show) (void *data, int type, char *buf),
			    mode_t (*is_visible) (void *data, int type),
			    void (*release) (void *data))
{
	return iscsi_boot_create_kobj(boot_kset,
				      &iscsi_boot_initiator_attr_group,
				      "initiator", index, data, show,
				      is_visible, release);
}
EXPORT_SYMBOL_GPL(iscsi_boot_create_initiator);

/**
 * iscsi_boot_create_ethernet() - create boot ethernet sysfs dir
 * @boot_kset: boot kset
 * @index: the ethernet device id
 * @data: driver specific data
 * @show: attr show function
 * @is_visible: attr visibility function
 * @release: release function
 *
 * Note: The boot sysfs lib will free the data passed in for the caller
 * when all refs to the ethernet kobject have been released.
 */
struct iscsi_boot_kobj *
iscsi_boot_create_ethernet(struct iscsi_boot_kset *boot_kset, int index,
			   void *data,
			   ssize_t (*show) (void *data, int type, char *buf),
			   mode_t (*is_visible) (void *data, int type),
			   void (*release) (void *data))
{
	return iscsi_boot_create_kobj(boot_kset,
				      &iscsi_boot_ethernet_attr_group,
				      "ethernet%d", index, data, show,
				      is_visible, release);
}
EXPORT_SYMBOL_GPL(iscsi_boot_create_ethernet);

/**
 * iscsi_boot_create_kset() - creates root sysfs tree
 * @set_name: name of root dir
 */
struct iscsi_boot_kset *iscsi_boot_create_kset(const char *set_name)
{
	struct iscsi_boot_kset *boot_kset;

	boot_kset = kzalloc(sizeof(*boot_kset), GFP_KERNEL);
	if (!boot_kset)
		return NULL;

	boot_kset->kset = kset_create_and_add(set_name, NULL, firmware_kobj);
	if (!boot_kset->kset) {
		kfree(boot_kset);
		return NULL;
	}

	INIT_LIST_HEAD(&boot_kset->kobj_list);
	return boot_kset;
}
EXPORT_SYMBOL_GPL(iscsi_boot_create_kset);

/**
 * iscsi_boot_create_host_kset() - creates root sysfs tree for a scsi host
 * @hostno: host number of scsi host
 */
struct iscsi_boot_kset *iscsi_boot_create_host_kset(unsigned int hostno)
{
	struct iscsi_boot_kset *boot_kset;
	char *set_name;

	set_name = kasprintf(GFP_KERNEL, "iscsi_boot%u", hostno);
	if (!set_name)
		return NULL;

	boot_kset = iscsi_boot_create_kset(set_name);
	kfree(set_name);
	return boot_kset;
}
EXPORT_SYMBOL_GPL(iscsi_boot_create_host_kset);

/**
 * iscsi_boot_destroy_kset() - destroy kset and kobjects under it
 * @boot_kset: boot kset
 *
 * This will remove the kset and kobjects and attrs under it.
 */
void iscsi_boot_destroy_kset(struct iscsi_boot_kset *boot_kset)
{
	struct iscsi_boot_kobj *boot_kobj, *tmp_kobj;

	if (!boot_kset)
		return;

	list_for_each_entry_safe(boot_kobj, tmp_kobj,
				 &boot_kset->kobj_list, list)
		iscsi_boot_remove_kobj(boot_kobj);

	kset_unregister(boot_kset->kset);
}
EXPORT_SYMBOL_GPL(iscsi_boot_destroy_kset);