Skip to content

Commit ee959b0

Browse files
tonyj-susegregkh
authored andcommitted
SCSI: convert struct class_device to struct device
It's big, but there doesn't seem to be a way to split it up smaller... Signed-off-by: Tony Jones <[email protected]> Signed-off-by: Kay Sievers <[email protected]> Cc: Roland Dreier <[email protected]> Cc: Sean Hefty <[email protected]> Cc: Hal Rosenstock <[email protected]> Cc: James Bottomley <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 56d110e commit ee959b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1761
-1510
lines changed

block/bsg.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ static struct bsg_device *bsg_add_device(struct inode *inode,
758758
mutex_lock(&bsg_mutex);
759759
hlist_add_head(&bd->dev_list, bsg_dev_idx_hash(iminor(inode)));
760760

761-
strncpy(bd->name, rq->bsg_dev.class_dev->class_id, sizeof(bd->name) - 1);
761+
strncpy(bd->name, rq->bsg_dev.class_dev->bus_id, sizeof(bd->name) - 1);
762762
dprintk("bound to <%s>, max queue %d\n",
763763
format_dev_t(buf, inode->i_rdev), bd->max_queue);
764764

@@ -946,7 +946,7 @@ void bsg_unregister_queue(struct request_queue *q)
946946
mutex_lock(&bsg_mutex);
947947
idr_remove(&bsg_minor_idr, bcd->minor);
948948
sysfs_remove_link(&q->kobj, "bsg");
949-
class_device_unregister(bcd->class_dev);
949+
device_unregister(bcd->class_dev);
950950
put_device(bcd->dev);
951951
bcd->class_dev = NULL;
952952
mutex_unlock(&bsg_mutex);
@@ -959,7 +959,7 @@ int bsg_register_queue(struct request_queue *q, struct device *gdev,
959959
struct bsg_class_device *bcd;
960960
dev_t dev;
961961
int ret, minor;
962-
struct class_device *class_dev = NULL;
962+
struct device *class_dev = NULL;
963963
const char *devname;
964964

965965
if (name)
@@ -998,8 +998,7 @@ int bsg_register_queue(struct request_queue *q, struct device *gdev,
998998
bcd->queue = q;
999999
bcd->dev = get_device(gdev);
10001000
dev = MKDEV(bsg_major, bcd->minor);
1001-
class_dev = class_device_create(bsg_class, NULL, dev, gdev, "%s",
1002-
devname);
1001+
class_dev = device_create(bsg_class, gdev, dev, "%s", devname);
10031002
if (IS_ERR(class_dev)) {
10041003
ret = PTR_ERR(class_dev);
10051004
goto put_dev;
@@ -1016,7 +1015,7 @@ int bsg_register_queue(struct request_queue *q, struct device *gdev,
10161015
return 0;
10171016

10181017
unregister_class_dev:
1019-
class_device_unregister(class_dev);
1018+
device_unregister(class_dev);
10201019
put_dev:
10211020
put_device(gdev);
10221021
remove_idr:

drivers/ata/ahci.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg);
273273
static int ahci_pci_device_resume(struct pci_dev *pdev);
274274
#endif
275275

276-
static struct class_device_attribute *ahci_shost_attrs[] = {
277-
&class_device_attr_link_power_management_policy,
276+
static struct device_attribute *ahci_shost_attrs[] = {
277+
&dev_attr_link_power_management_policy,
278278
NULL
279279
};
280280

drivers/ata/libata-scsi.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ static const char *ata_scsi_lpm_get(enum link_pm policy)
131131
return NULL;
132132
}
133133

134-
static ssize_t ata_scsi_lpm_put(struct class_device *class_dev,
135-
const char *buf, size_t count)
134+
static ssize_t ata_scsi_lpm_put(struct device *dev,
135+
struct device_attribute *attr,
136+
const char *buf, size_t count)
136137
{
137-
struct Scsi_Host *shost = class_to_shost(class_dev);
138+
struct Scsi_Host *shost = class_to_shost(dev);
138139
struct ata_port *ap = ata_shost_to_port(shost);
139140
enum link_pm policy = 0;
140141
int i;
@@ -162,9 +163,9 @@ static ssize_t ata_scsi_lpm_put(struct class_device *class_dev,
162163
}
163164

164165
static ssize_t
165-
ata_scsi_lpm_show(struct class_device *class_dev, char *buf)
166+
ata_scsi_lpm_show(struct device *dev, struct device_attribute *attr, char *buf)
166167
{
167-
struct Scsi_Host *shost = class_to_shost(class_dev);
168+
struct Scsi_Host *shost = class_to_shost(dev);
168169
struct ata_port *ap = ata_shost_to_port(shost);
169170
const char *policy =
170171
ata_scsi_lpm_get(ap->pm_policy);
@@ -174,9 +175,9 @@ ata_scsi_lpm_show(struct class_device *class_dev, char *buf)
174175

175176
return snprintf(buf, 23, "%s\n", policy);
176177
}
177-
CLASS_DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR,
178+
DEVICE_ATTR(link_power_management_policy, S_IRUGO | S_IWUSR,
178179
ata_scsi_lpm_show, ata_scsi_lpm_put);
179-
EXPORT_SYMBOL_GPL(class_device_attr_link_power_management_policy);
180+
EXPORT_SYMBOL_GPL(dev_attr_link_power_management_policy);
180181

181182
static void ata_scsi_invalid_field(struct scsi_cmnd *cmd,
182183
void (*done)(struct scsi_cmnd *))

drivers/base/attribute_container.c

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@
2727
struct internal_container {
2828
struct klist_node node;
2929
struct attribute_container *cont;
30-
struct class_device classdev;
30+
struct device classdev;
3131
};
3232

3333
static void internal_container_klist_get(struct klist_node *n)
3434
{
3535
struct internal_container *ic =
3636
container_of(n, struct internal_container, node);
37-
class_device_get(&ic->classdev);
37+
get_device(&ic->classdev);
3838
}
3939

4040
static void internal_container_klist_put(struct klist_node *n)
4141
{
4242
struct internal_container *ic =
4343
container_of(n, struct internal_container, node);
44-
class_device_put(&ic->classdev);
44+
put_device(&ic->classdev);
4545
}
4646

4747

@@ -53,7 +53,7 @@ static void internal_container_klist_put(struct klist_node *n)
5353
* Returns the container associated with this classdev.
5454
*/
5555
struct attribute_container *
56-
attribute_container_classdev_to_container(struct class_device *classdev)
56+
attribute_container_classdev_to_container(struct device *classdev)
5757
{
5858
struct internal_container *ic =
5959
container_of(classdev, struct internal_container, classdev);
@@ -110,11 +110,11 @@ attribute_container_unregister(struct attribute_container *cont)
110110
EXPORT_SYMBOL_GPL(attribute_container_unregister);
111111

112112
/* private function used as class release */
113-
static void attribute_container_release(struct class_device *classdev)
113+
static void attribute_container_release(struct device *classdev)
114114
{
115115
struct internal_container *ic
116116
= container_of(classdev, struct internal_container, classdev);
117-
struct device *dev = classdev->dev;
117+
struct device *dev = classdev->parent;
118118

119119
kfree(ic);
120120
put_device(dev);
@@ -129,20 +129,20 @@ static void attribute_container_release(struct class_device *classdev)
129129
* This function allocates storage for the class device(s) to be
130130
* attached to dev (one for each matching attribute_container). If no
131131
* fn is provided, the code will simply register the class device via
132-
* class_device_add. If a function is provided, it is expected to add
132+
* device_add. If a function is provided, it is expected to add
133133
* the class device at the appropriate time. One of the things that
134134
* might be necessary is to allocate and initialise the classdev and
135135
* then add it a later time. To do this, call this routine for
136136
* allocation and initialisation and then use
137-
* attribute_container_device_trigger() to call class_device_add() on
137+
* attribute_container_device_trigger() to call device_add() on
138138
* it. Note: after this, the class device contains a reference to dev
139139
* which is not relinquished until the release of the classdev.
140140
*/
141141
void
142142
attribute_container_add_device(struct device *dev,
143143
int (*fn)(struct attribute_container *,
144144
struct device *,
145-
struct class_device *))
145+
struct device *))
146146
{
147147
struct attribute_container *cont;
148148

@@ -163,11 +163,11 @@ attribute_container_add_device(struct device *dev,
163163
}
164164

165165
ic->cont = cont;
166-
class_device_initialize(&ic->classdev);
167-
ic->classdev.dev = get_device(dev);
166+
device_initialize(&ic->classdev);
167+
ic->classdev.parent = get_device(dev);
168168
ic->classdev.class = cont->class;
169-
cont->class->release = attribute_container_release;
170-
strcpy(ic->classdev.class_id, dev->bus_id);
169+
cont->class->dev_release = attribute_container_release;
170+
strcpy(ic->classdev.bus_id, dev->bus_id);
171171
if (fn)
172172
fn(cont, dev, &ic->classdev);
173173
else
@@ -195,20 +195,19 @@ attribute_container_add_device(struct device *dev,
195195
* @fn: A function to call to remove the device
196196
*
197197
* This routine triggers device removal. If fn is NULL, then it is
198-
* simply done via class_device_unregister (note that if something
198+
* simply done via device_unregister (note that if something
199199
* still has a reference to the classdev, then the memory occupied
200200
* will not be freed until the classdev is released). If you want a
201201
* two phase release: remove from visibility and then delete the
202202
* device, then you should use this routine with a fn that calls
203-
* class_device_del() and then use
204-
* attribute_container_device_trigger() to do the final put on the
205-
* classdev.
203+
* device_del() and then use attribute_container_device_trigger()
204+
* to do the final put on the classdev.
206205
*/
207206
void
208207
attribute_container_remove_device(struct device *dev,
209208
void (*fn)(struct attribute_container *,
210209
struct device *,
211-
struct class_device *))
210+
struct device *))
212211
{
213212
struct attribute_container *cont;
214213

@@ -224,14 +223,14 @@ attribute_container_remove_device(struct device *dev,
224223
continue;
225224

226225
klist_for_each_entry(ic, &cont->containers, node, &iter) {
227-
if (dev != ic->classdev.dev)
226+
if (dev != ic->classdev.parent)
228227
continue;
229228
klist_del(&ic->node);
230229
if (fn)
231230
fn(cont, dev, &ic->classdev);
232231
else {
233232
attribute_container_remove_attrs(&ic->classdev);
234-
class_device_unregister(&ic->classdev);
233+
device_unregister(&ic->classdev);
235234
}
236235
}
237236
}
@@ -252,7 +251,7 @@ void
252251
attribute_container_device_trigger(struct device *dev,
253252
int (*fn)(struct attribute_container *,
254253
struct device *,
255-
struct class_device *))
254+
struct device *))
256255
{
257256
struct attribute_container *cont;
258257

@@ -270,7 +269,7 @@ attribute_container_device_trigger(struct device *dev,
270269
}
271270

272271
klist_for_each_entry(ic, &cont->containers, node, &iter) {
273-
if (dev == ic->classdev.dev)
272+
if (dev == ic->classdev.parent)
274273
fn(cont, dev, &ic->classdev);
275274
}
276275
}
@@ -313,11 +312,11 @@ attribute_container_trigger(struct device *dev,
313312
* attributes listed in the container
314313
*/
315314
int
316-
attribute_container_add_attrs(struct class_device *classdev)
315+
attribute_container_add_attrs(struct device *classdev)
317316
{
318317
struct attribute_container *cont =
319318
attribute_container_classdev_to_container(classdev);
320-
struct class_device_attribute **attrs = cont->attrs;
319+
struct device_attribute **attrs = cont->attrs;
321320
int i, error;
322321

323322
BUG_ON(attrs && cont->grp);
@@ -329,7 +328,7 @@ attribute_container_add_attrs(struct class_device *classdev)
329328
return sysfs_create_group(&classdev->kobj, cont->grp);
330329

331330
for (i = 0; attrs[i]; i++) {
332-
error = class_device_create_file(classdev, attrs[i]);
331+
error = device_create_file(classdev, attrs[i]);
333332
if (error)
334333
return error;
335334
}
@@ -338,18 +337,18 @@ attribute_container_add_attrs(struct class_device *classdev)
338337
}
339338

340339
/**
341-
* attribute_container_add_class_device - same function as class_device_add
340+
* attribute_container_add_class_device - same function as device_add
342341
*
343342
* @classdev: the class device to add
344343
*
345-
* This performs essentially the same function as class_device_add except for
344+
* This performs essentially the same function as device_add except for
346345
* attribute containers, namely add the classdev to the system and then
347346
* create the attribute files
348347
*/
349348
int
350-
attribute_container_add_class_device(struct class_device *classdev)
349+
attribute_container_add_class_device(struct device *classdev)
351350
{
352-
int error = class_device_add(classdev);
351+
int error = device_add(classdev);
353352
if (error)
354353
return error;
355354
return attribute_container_add_attrs(classdev);
@@ -364,7 +363,7 @@ attribute_container_add_class_device(struct class_device *classdev)
364363
int
365364
attribute_container_add_class_device_adapter(struct attribute_container *cont,
366365
struct device *dev,
367-
struct class_device *classdev)
366+
struct device *classdev)
368367
{
369368
return attribute_container_add_class_device(classdev);
370369
}
@@ -376,11 +375,11 @@ attribute_container_add_class_device_adapter(struct attribute_container *cont,
376375
*
377376
*/
378377
void
379-
attribute_container_remove_attrs(struct class_device *classdev)
378+
attribute_container_remove_attrs(struct device *classdev)
380379
{
381380
struct attribute_container *cont =
382381
attribute_container_classdev_to_container(classdev);
383-
struct class_device_attribute **attrs = cont->attrs;
382+
struct device_attribute **attrs = cont->attrs;
384383
int i;
385384

386385
if (!attrs && !cont->grp)
@@ -392,7 +391,7 @@ attribute_container_remove_attrs(struct class_device *classdev)
392391
}
393392

394393
for (i = 0; attrs[i]; i++)
395-
class_device_remove_file(classdev, attrs[i]);
394+
device_remove_file(classdev, attrs[i]);
396395
}
397396

398397
/**
@@ -401,13 +400,13 @@ attribute_container_remove_attrs(struct class_device *classdev)
401400
* @classdev: the class device
402401
*
403402
* This function simply removes all the attribute files and then calls
404-
* class_device_del.
403+
* device_del.
405404
*/
406405
void
407-
attribute_container_class_device_del(struct class_device *classdev)
406+
attribute_container_class_device_del(struct device *classdev)
408407
{
409408
attribute_container_remove_attrs(classdev);
410-
class_device_del(classdev);
409+
device_del(classdev);
411410
}
412411

413412
/**
@@ -419,16 +418,16 @@ attribute_container_class_device_del(struct class_device *classdev)
419418
* Looks up the device in the container's list of class devices and returns
420419
* the corresponding class_device.
421420
*/
422-
struct class_device *
421+
struct device *
423422
attribute_container_find_class_device(struct attribute_container *cont,
424423
struct device *dev)
425424
{
426-
struct class_device *cdev = NULL;
425+
struct device *cdev = NULL;
427426
struct internal_container *ic;
428427
struct klist_iter iter;
429428

430429
klist_for_each_entry(ic, &cont->containers, node, &iter) {
431-
if (ic->classdev.dev == dev) {
430+
if (ic->classdev.parent == dev) {
432431
cdev = &ic->classdev;
433432
/* FIXME: must exit iterator then break */
434433
klist_iter_exit(&iter);

0 commit comments

Comments
 (0)