|
Line 0
Link Here
|
|
|
1 |
--- ./hald/freebsd/hf-memcard.c.orig 2013-10-22 01:49:10.228430727 +0200 |
| 2 |
+++ ./hald/freebsd/hf-memcard.c 2013-10-22 01:48:06.869268391 +0200 |
| 3 |
@@ -0,0 +1,106 @@ |
| 4 |
+/*************************************************************************** |
| 5 |
+ * CVSID: $Id$ |
| 6 |
+ * |
| 7 |
+ * hf-memcard.c : memory card support |
| 8 |
+ * |
| 9 |
+ * Copyright (C) 2013 Alberto Villa <avilla@FreeBSD.org> |
| 10 |
+ * |
| 11 |
+ * This program is free software; you can redistribute it and/or modify |
| 12 |
+ * it under the terms of the GNU General Public License as published by |
| 13 |
+ * the Free Software Foundation; either version 2 of the License, or |
| 14 |
+ * (at your option) any later version. |
| 15 |
+ * |
| 16 |
+ * This program is distributed in the hope that it will be useful, |
| 17 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
+ * GNU General Public License for more details. |
| 20 |
+ * |
| 21 |
+ * You should have received a copy of the GNU General Public License |
| 22 |
+ * along with this program; if not, write to the Free Software |
| 23 |
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 24 |
+ * |
| 25 |
+ **************************************************************************/ |
| 26 |
+ |
| 27 |
+#ifdef HAVE_CONFIG_H |
| 28 |
+# include <config.h> |
| 29 |
+#endif |
| 30 |
+ |
| 31 |
+#include <string.h> |
| 32 |
+#include <errno.h> |
| 33 |
+#include <stdlib.h> |
| 34 |
+#include <unistd.h> |
| 35 |
+ |
| 36 |
+#include "../logger.h" |
| 37 |
+ |
| 38 |
+#include "hf-memcard.h" |
| 39 |
+#include "hf-block.h" |
| 40 |
+#include "hf-devtree.h" |
| 41 |
+#include "hf-storage.h" |
| 42 |
+#include "hf-util.h" |
| 43 |
+ |
| 44 |
+static HalDevice * |
| 45 |
+hf_memcard_block_device_new (HalDevice *parent, |
| 46 |
+ const char *driver, |
| 47 |
+ int unit, |
| 48 |
+ const char *drive_type) |
| 49 |
+{ |
| 50 |
+ HalDevice *device; |
| 51 |
+ char devname[16]; |
| 52 |
+ |
| 53 |
+ snprintf(devname, sizeof(devname), "%s%d", driver, unit); |
| 54 |
+ |
| 55 |
+ g_return_val_if_fail(HAL_IS_DEVICE(parent), NULL); |
| 56 |
+ g_return_val_if_fail(devname != NULL, NULL); |
| 57 |
+ |
| 58 |
+ device = hf_device_new(parent); |
| 59 |
+ |
| 60 |
+ hf_devtree_device_set_name(device, devname); |
| 61 |
+ hf_block_device_enable(device, devname); |
| 62 |
+ |
| 63 |
+ hf_storage_device_enable(device); |
| 64 |
+ |
| 65 |
+ hal_device_copy_property(parent, "info.subsystem", device, "storage.bus"); |
| 66 |
+ hal_device_property_set_string(device, "storage.originating_device", hal_device_get_udi(parent)); |
| 67 |
+ hal_device_property_set_bool(device, "storage.removable", TRUE); |
| 68 |
+ hal_device_property_set_bool(device, "storage.media_check_enabled", TRUE); |
| 69 |
+ hal_device_property_set_bool(device, "storage.removable.support_async_notification", FALSE); |
| 70 |
+ hal_device_property_set_bool(device, "storage.hotpluggable", TRUE); |
| 71 |
+ if (drive_type) |
| 72 |
+ { |
| 73 |
+ hal_device_property_set_string(device, "storage.drive_type", drive_type); |
| 74 |
+ } |
| 75 |
+ |
| 76 |
+ if (hf_device_preprobe(device)) |
| 77 |
+ { |
| 78 |
+ hf_block_device_complete(device, device, FALSE); |
| 79 |
+ hf_device_add(device); |
| 80 |
+ hf_storage_device_probe(device, FALSE); |
| 81 |
+ } |
| 82 |
+ |
| 83 |
+ return device; |
| 84 |
+} |
| 85 |
+ |
| 86 |
+void |
| 87 |
+hf_mmc_host_set_properties (HalDevice *device) |
| 88 |
+{ |
| 89 |
+ hal_device_property_set_string(device, "info.subsystem", "mmc_host"); |
| 90 |
+ hal_device_copy_property(device, "freebsd.unit", device, "mmc_host.host"); |
| 91 |
+} |
| 92 |
+ |
| 93 |
+void |
| 94 |
+hf_mmc_set_properties (HalDevice *device) |
| 95 |
+{ |
| 96 |
+ HalDevice *block_device; |
| 97 |
+ |
| 98 |
+ hal_device_property_set_string(device, "info.subsystem", "mmc"); |
| 99 |
+ |
| 100 |
+ hf_memcard_block_device_new(device, |
| 101 |
+ hal_device_property_get_string(device, "freebsd.driver"), |
| 102 |
+ hal_device_property_get_int(device, "freebsd.unit"), |
| 103 |
+ "sd_mmc"); |
| 104 |
+ |
| 105 |
+ /* This information belongs to the block device. */ |
| 106 |
+ hal_device_property_remove(device, "freebsd.device_file"); |
| 107 |
+ hal_device_property_remove(device, "freebsd.driver"); |
| 108 |
+ hal_device_property_remove(device, "freebsd.unit"); |
| 109 |
+} |