X-Git-Url: http://www.pilppa.org/gitweb/gitweb.cgi?p=linux-2.6-omap-h63xx.git;a=blobdiff_plain;f=drivers%2Fbluetooth%2Fhci_h4p%2Fsysfs.c;fp=drivers%2Fbluetooth%2Fhci_h4p%2Fsysfs.c;h=687df69324bf0273777a7be3066943d53dcdb8da;hp=0000000000000000000000000000000000000000;hb=0d5f2216edfeb9904e0d6512f803b0f93871baaf;hpb=14fc69723d3442ef46f8f82b3f481e82f06a346d diff --git a/drivers/bluetooth/hci_h4p/sysfs.c b/drivers/bluetooth/hci_h4p/sysfs.c new file mode 100644 index 00000000000..687df69324b --- /dev/null +++ b/drivers/bluetooth/hci_h4p/sysfs.c @@ -0,0 +1,74 @@ +/* + * This file is part of hci_h4p bluetooth driver + * + * Copyright (C) 2005, 2006 Nokia Corporation. + * + * Contact: Ville Tervo + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#include +#include +#include +#include + +#include "hci_h4p.h" + +#ifdef CONFIG_SYSFS + +static ssize_t hci_h4p_store_bdaddr(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + struct hci_h4p_info *info = (struct hci_h4p_info*)dev_get_drvdata(dev); + unsigned int bdaddr[6]; + int ret, i; + + ret = sscanf(buf, "%2x:%2x:%2x:%2x:%2x:%2x\n", + &bdaddr[0], &bdaddr[1], &bdaddr[2], + &bdaddr[3], &bdaddr[4], &bdaddr[5]); + + if (ret != 6) { + return -EINVAL; + } + + for (i = 0; i < 6; i++) + info->bdaddr[i] = bdaddr[i] & 0xff; + + return count; +} + +static ssize_t hci_h4p_show_bdaddr(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct hci_h4p_info *info = (struct hci_h4p_info*)dev_get_drvdata(dev); + + return sprintf(buf, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n", + info->bdaddr[0], + info->bdaddr[1], + info->bdaddr[2], + info->bdaddr[3], + info->bdaddr[4], + info->bdaddr[5]); +} + +static DEVICE_ATTR(bdaddr, S_IRUGO | S_IWUSR, hci_h4p_show_bdaddr, hci_h4p_store_bdaddr); +int hci_h4p_sysfs_create_files(struct device *dev) +{ + return device_create_file(dev, &dev_attr_bdaddr); +} + +#endif