diff options
Diffstat (limited to 'fs/sysfs/dir.c')
-rw-r--r-- | fs/sysfs/dir.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index b4074adbab01..eb9bc0a8717b 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -218,9 +218,9 @@ void release_sysfs_dirent(struct sysfs_dirent * sd) | |||
218 | repeat: | 218 | repeat: |
219 | parent_sd = sd->s_parent; | 219 | parent_sd = sd->s_parent; |
220 | 220 | ||
221 | if (sd->s_type & SYSFS_KOBJ_LINK) | 221 | if (sysfs_type(sd) == SYSFS_KOBJ_LINK) |
222 | sysfs_put(sd->s_elem.symlink.target_sd); | 222 | sysfs_put(sd->s_elem.symlink.target_sd); |
223 | if (sd->s_type & SYSFS_COPY_NAME) | 223 | if (sysfs_type(sd) & SYSFS_COPY_NAME) |
224 | kfree(sd->s_name); | 224 | kfree(sd->s_name); |
225 | kfree(sd->s_iattr); | 225 | kfree(sd->s_iattr); |
226 | sysfs_free_ino(sd->s_ino); | 226 | sysfs_free_ino(sd->s_ino); |
@@ -282,7 +282,7 @@ struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type) | |||
282 | 282 | ||
283 | sd->s_name = name; | 283 | sd->s_name = name; |
284 | sd->s_mode = mode; | 284 | sd->s_mode = mode; |
285 | sd->s_type = type; | 285 | sd->s_flags = type; |
286 | 286 | ||
287 | return sd; | 287 | return sd; |
288 | 288 | ||
@@ -330,7 +330,7 @@ int sysfs_dirent_exist(struct sysfs_dirent *parent_sd, | |||
330 | struct sysfs_dirent * sd; | 330 | struct sysfs_dirent * sd; |
331 | 331 | ||
332 | for (sd = parent_sd->s_children; sd; sd = sd->s_sibling) { | 332 | for (sd = parent_sd->s_children; sd; sd = sd->s_sibling) { |
333 | if (sd->s_type) { | 333 | if (sysfs_type(sd)) { |
334 | if (strcmp(sd->s_name, new)) | 334 | if (strcmp(sd->s_name, new)) |
335 | continue; | 335 | continue; |
336 | else | 336 | else |
@@ -446,11 +446,12 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry, | |||
446 | { | 446 | { |
447 | struct sysfs_dirent * parent_sd = dentry->d_parent->d_fsdata; | 447 | struct sysfs_dirent * parent_sd = dentry->d_parent->d_fsdata; |
448 | struct sysfs_dirent * sd; | 448 | struct sysfs_dirent * sd; |
449 | struct bin_attribute *bin_attr; | ||
449 | struct inode *inode; | 450 | struct inode *inode; |
450 | int found = 0; | 451 | int found = 0; |
451 | 452 | ||
452 | for (sd = parent_sd->s_children; sd; sd = sd->s_sibling) { | 453 | for (sd = parent_sd->s_children; sd; sd = sd->s_sibling) { |
453 | if ((sd->s_type & SYSFS_NOT_PINNED) && | 454 | if ((sysfs_type(sd) & SYSFS_NOT_PINNED) && |
454 | !strcmp(sd->s_name, dentry->d_name.name)) { | 455 | !strcmp(sd->s_name, dentry->d_name.name)) { |
455 | found = 1; | 456 | found = 1; |
456 | break; | 457 | break; |
@@ -468,16 +469,22 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry, | |||
468 | 469 | ||
469 | if (inode->i_state & I_NEW) { | 470 | if (inode->i_state & I_NEW) { |
470 | /* initialize inode according to type */ | 471 | /* initialize inode according to type */ |
471 | if (sd->s_type & SYSFS_KOBJ_ATTR) { | 472 | switch (sysfs_type(sd)) { |
473 | case SYSFS_KOBJ_ATTR: | ||
472 | inode->i_size = PAGE_SIZE; | 474 | inode->i_size = PAGE_SIZE; |
473 | inode->i_fop = &sysfs_file_operations; | 475 | inode->i_fop = &sysfs_file_operations; |
474 | } else if (sd->s_type & SYSFS_KOBJ_BIN_ATTR) { | 476 | break; |
475 | struct bin_attribute *bin_attr = | 477 | case SYSFS_KOBJ_BIN_ATTR: |
476 | sd->s_elem.bin_attr.bin_attr; | 478 | bin_attr = sd->s_elem.bin_attr.bin_attr; |
477 | inode->i_size = bin_attr->size; | 479 | inode->i_size = bin_attr->size; |
478 | inode->i_fop = &bin_fops; | 480 | inode->i_fop = &bin_fops; |
479 | } else if (sd->s_type & SYSFS_KOBJ_LINK) | 481 | break; |
482 | case SYSFS_KOBJ_LINK: | ||
480 | inode->i_op = &sysfs_symlink_inode_operations; | 483 | inode->i_op = &sysfs_symlink_inode_operations; |
484 | break; | ||
485 | default: | ||
486 | BUG(); | ||
487 | } | ||
481 | } | 488 | } |
482 | 489 | ||
483 | sysfs_instantiate(dentry, inode); | 490 | sysfs_instantiate(dentry, inode); |
@@ -532,7 +539,7 @@ static void __sysfs_remove_dir(struct dentry *dentry) | |||
532 | while (*pos) { | 539 | while (*pos) { |
533 | struct sysfs_dirent *sd = *pos; | 540 | struct sysfs_dirent *sd = *pos; |
534 | 541 | ||
535 | if (sd->s_type && (sd->s_type & SYSFS_NOT_PINNED)) { | 542 | if (sysfs_type(sd) && (sysfs_type(sd) & SYSFS_NOT_PINNED)) { |
536 | *pos = sd->s_sibling; | 543 | *pos = sd->s_sibling; |
537 | sd->s_sibling = removed; | 544 | sd->s_sibling = removed; |
538 | removed = sd; | 545 | removed = sd; |
@@ -775,7 +782,7 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir) | |||
775 | const char * name; | 782 | const char * name; |
776 | int len; | 783 | int len; |
777 | 784 | ||
778 | if (!next->s_type) | 785 | if (!sysfs_type(next)) |
779 | continue; | 786 | continue; |
780 | 787 | ||
781 | name = next->s_name; | 788 | name = next->s_name; |
@@ -824,7 +831,7 @@ static loff_t sysfs_dir_lseek(struct file * file, loff_t offset, int origin) | |||
824 | pos = &sd->s_children; | 831 | pos = &sd->s_children; |
825 | while (n && *pos) { | 832 | while (n && *pos) { |
826 | struct sysfs_dirent *next = *pos; | 833 | struct sysfs_dirent *next = *pos; |
827 | if (next->s_type) | 834 | if (sysfs_type(next)) |
828 | n--; | 835 | n--; |
829 | pos = &(*pos)->s_sibling; | 836 | pos = &(*pos)->s_sibling; |
830 | } | 837 | } |