diff options
Diffstat (limited to 'drivers/pnp/core.c')
-rw-r--r-- | drivers/pnp/core.c | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c index 7d366ca672d3..20771b7d4482 100644 --- a/drivers/pnp/core.c +++ b/drivers/pnp/core.c | |||
@@ -106,18 +106,53 @@ static void pnp_release_device(struct device *dmdev) | |||
106 | pnp_free_option(dev->independent); | 106 | pnp_free_option(dev->independent); |
107 | pnp_free_option(dev->dependent); | 107 | pnp_free_option(dev->dependent); |
108 | pnp_free_ids(dev); | 108 | pnp_free_ids(dev); |
109 | kfree(dev->res); | ||
109 | kfree(dev); | 110 | kfree(dev); |
110 | } | 111 | } |
111 | 112 | ||
112 | int __pnp_add_device(struct pnp_dev *dev) | 113 | struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid) |
113 | { | 114 | { |
114 | int ret; | 115 | struct pnp_dev *dev; |
116 | struct pnp_id *dev_id; | ||
115 | 117 | ||
116 | pnp_fixup_device(dev); | 118 | dev = kzalloc(sizeof(struct pnp_dev), GFP_KERNEL); |
119 | if (!dev) | ||
120 | return NULL; | ||
121 | |||
122 | dev->res = kzalloc(sizeof(struct pnp_resource_table), GFP_KERNEL); | ||
123 | if (!dev->res) { | ||
124 | kfree(dev); | ||
125 | return NULL; | ||
126 | } | ||
127 | |||
128 | dev->protocol = protocol; | ||
129 | dev->number = id; | ||
130 | dev->dma_mask = DMA_24BIT_MASK; | ||
131 | |||
132 | dev->dev.parent = &dev->protocol->dev; | ||
117 | dev->dev.bus = &pnp_bus_type; | 133 | dev->dev.bus = &pnp_bus_type; |
118 | dev->dev.dma_mask = &dev->dma_mask; | 134 | dev->dev.dma_mask = &dev->dma_mask; |
119 | dev->dma_mask = dev->dev.coherent_dma_mask = DMA_24BIT_MASK; | 135 | dev->dev.coherent_dma_mask = dev->dma_mask; |
120 | dev->dev.release = &pnp_release_device; | 136 | dev->dev.release = &pnp_release_device; |
137 | |||
138 | sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number, | ||
139 | dev->number); | ||
140 | |||
141 | dev_id = pnp_add_id(dev, pnpid); | ||
142 | if (!dev_id) { | ||
143 | kfree(dev->res); | ||
144 | kfree(dev); | ||
145 | return NULL; | ||
146 | } | ||
147 | |||
148 | return dev; | ||
149 | } | ||
150 | |||
151 | int __pnp_add_device(struct pnp_dev *dev) | ||
152 | { | ||
153 | int ret; | ||
154 | |||
155 | pnp_fixup_device(dev); | ||
121 | dev->status = PNP_READY; | 156 | dev->status = PNP_READY; |
122 | spin_lock(&pnp_lock); | 157 | spin_lock(&pnp_lock); |
123 | list_add_tail(&dev->global_list, &pnp_global); | 158 | list_add_tail(&dev->global_list, &pnp_global); |
@@ -145,9 +180,6 @@ int pnp_add_device(struct pnp_dev *dev) | |||
145 | if (dev->card) | 180 | if (dev->card) |
146 | return -EINVAL; | 181 | return -EINVAL; |
147 | 182 | ||
148 | dev->dev.parent = &dev->protocol->dev; | ||
149 | sprintf(dev->dev.bus_id, "%02x:%02x", dev->protocol->number, | ||
150 | dev->number); | ||
151 | ret = __pnp_add_device(dev); | 183 | ret = __pnp_add_device(dev); |
152 | if (ret) | 184 | if (ret) |
153 | return ret; | 185 | return ret; |