blob: 00a97e70f91425a57b1fc28628a5884ff93c285d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Pierre Ossmanaaac1b42007-02-28 15:33:10 +01002 * linux/drivers/mmc/core/sysfs.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
4 * Copyright (C) 2003 Russell King, All Rights Reserved.
Pierre Ossman4101c162007-05-19 13:39:01 +02005 * Copyright 2007 Pierre Ossman
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/device.h>
14
15#include <linux/mmc/card.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Pierre Ossmanda7fbe52006-12-24 22:46:55 +010017#include "sysfs.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
Pierre Ossman4101c162007-05-19 13:39:01 +020019int mmc_add_attrs(struct mmc_card *card, struct device_attribute *attrs)
Linus Torvalds1da177e2005-04-16 15:20:36 -070020{
Pierre Ossman4101c162007-05-19 13:39:01 +020021 int error = 0;
22 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Pierre Ossman4101c162007-05-19 13:39:01 +020024 for (i = 0; attr_name(attrs[i]); i++) {
25 error = device_create_file(&card->dev, &attrs[i]);
26 if (error) {
27 while (--i >= 0)
28 device_remove_file(&card->dev, &attrs[i]);
29 break;
Pierre Ossman4bc20a82005-09-06 15:18:58 -070030 }
31 }
Pierre Ossman4101c162007-05-19 13:39:01 +020032
33 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -070034}
35
Pierre Ossman4101c162007-05-19 13:39:01 +020036void mmc_remove_attrs(struct mmc_card *card, struct device_attribute *attrs)
Linus Torvalds1da177e2005-04-16 15:20:36 -070037{
Pierre Ossman4101c162007-05-19 13:39:01 +020038 int i;
Pierre Ossman4bc20a82005-09-06 15:18:58 -070039
Pierre Ossman4101c162007-05-19 13:39:01 +020040 for (i = 0; attr_name(attrs[i]); i++)
41 device_remove_file(&card->dev, &attrs[i]);
Linus Torvalds1da177e2005-04-16 15:20:36 -070042}
43