]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/bluetooth/hci_h4p/sysfs.c
Merge branch 'omap-fixes'
[linux-2.6-omap-h63xx.git] / drivers / bluetooth / hci_h4p / sysfs.c
1 /*
2  * This file is part of hci_h4p bluetooth driver
3  *
4  * Copyright (C) 2005, 2006 Nokia Corporation.
5  *
6  * Contact: Ville Tervo <ville.tervo@nokia.com>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * version 2 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  *
22  */
23
24 #include <linux/kernel.h>
25 #include <linux/init.h>
26 #include <linux/device.h>
27 #include <linux/platform_device.h>
28
29 #include "hci_h4p.h"
30
31 #ifdef CONFIG_SYSFS
32
33 static ssize_t hci_h4p_store_bdaddr(struct device *dev, struct device_attribute *attr,
34                                     const char *buf, size_t count)
35 {
36         struct hci_h4p_info *info = (struct hci_h4p_info*)dev_get_drvdata(dev);
37         unsigned int bdaddr[6];
38         int ret, i;
39
40         ret = sscanf(buf, "%2x:%2x:%2x:%2x:%2x:%2x\n",
41                         &bdaddr[0], &bdaddr[1], &bdaddr[2],
42                         &bdaddr[3], &bdaddr[4], &bdaddr[5]);
43
44         if (ret != 6) {
45                 return -EINVAL;
46         }
47
48         for (i = 0; i < 6; i++)
49                 info->bdaddr[i] = bdaddr[i] & 0xff;
50
51         return count;
52 }
53
54 static ssize_t hci_h4p_show_bdaddr(struct device *dev, struct device_attribute *attr,
55                                    char *buf)
56 {
57         struct hci_h4p_info *info = (struct hci_h4p_info*)dev_get_drvdata(dev);
58
59         return sprintf(buf, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",
60                        info->bdaddr[0],
61                        info->bdaddr[1],
62                        info->bdaddr[2],
63                        info->bdaddr[3],
64                        info->bdaddr[4],
65                        info->bdaddr[5]);
66 }
67
68 static DEVICE_ATTR(bdaddr, S_IRUGO | S_IWUSR, hci_h4p_show_bdaddr, hci_h4p_store_bdaddr);
69 int hci_h4p_sysfs_create_files(struct device *dev)
70 {
71         return device_create_file(dev, &dev_attr_bdaddr);
72 }
73
74 #endif