sysfs.c 928 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * linux/drivers/mmc/core/sysfs.c
  3. *
  4. * Copyright (C) 2003 Russell King, All Rights Reserved.
  5. * Copyright 2007 Pierre Ossman
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * MMC sysfs/driver model support.
  12. */
  13. #include <linux/device.h>
  14. #include <linux/mmc/card.h>
  15. #include "sysfs.h"
  16. int mmc_add_attrs(struct mmc_card *card, struct device_attribute *attrs)
  17. {
  18. int error = 0;
  19. int i;
  20. for (i = 0; attr_name(attrs[i]); i++) {
  21. error = device_create_file(&card->dev, &attrs[i]);
  22. if (error) {
  23. while (--i >= 0)
  24. device_remove_file(&card->dev, &attrs[i]);
  25. break;
  26. }
  27. }
  28. return error;
  29. }
  30. void mmc_remove_attrs(struct mmc_card *card, struct device_attribute *attrs)
  31. {
  32. int i;
  33. for (i = 0; attr_name(attrs[i]); i++)
  34. device_remove_file(&card->dev, &attrs[i]);
  35. }