aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/card.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2008-04-28 18:33:58 -0400
committerLen Brown <len.brown@intel.com>2008-04-29 03:22:17 -0400
commit6bf2aab24a5dc26bf8274c4b9dbbed8ca99ae82c (patch)
tree910e6795cf929481cecb00fc5ebad43121beba56 /drivers/pnp/card.c
parent068076d5517009654376ceda75ff44af0feb9b1d (diff)
PNP: add pnp_alloc_card()
Add pnp_alloc_card() to allocate a struct pnp_card and fill in the protocol, instance number, and initial PNP ID. Now it is always valid to use dev_printk() on any pnp_card pointer. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Acked-By: Rene Herman <rene.herman@gmail.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/pnp/card.c')
-rw-r--r--drivers/pnp/card.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/drivers/pnp/card.c b/drivers/pnp/card.c
index d606a163b1d7..a762a4176736 100644
--- a/drivers/pnp/card.c
+++ b/drivers/pnp/card.c
@@ -151,6 +151,31 @@ static void pnp_release_card(struct device *dmdev)
151 kfree(card); 151 kfree(card);
152} 152}
153 153
154struct pnp_card *pnp_alloc_card(struct pnp_protocol *protocol, int id, char *pnpid)
155{
156 struct pnp_card *card;
157 struct pnp_id *dev_id;
158
159 card = kzalloc(sizeof(struct pnp_card), GFP_KERNEL);
160 if (!card)
161 return NULL;
162
163 card->protocol = protocol;
164 card->number = id;
165
166 card->dev.parent = &card->protocol->dev;
167 sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number,
168 card->number);
169
170 dev_id = pnp_add_card_id(card, pnpid);
171 if (!dev_id) {
172 kfree(card);
173 return NULL;
174 }
175
176 return card;
177}
178
154static ssize_t pnp_show_card_name(struct device *dmdev, 179static ssize_t pnp_show_card_name(struct device *dmdev,
155 struct device_attribute *attr, char *buf) 180 struct device_attribute *attr, char *buf)
156{ 181{
@@ -206,9 +231,6 @@ int pnp_add_card(struct pnp_card *card)
206 int error; 231 int error;
207 struct list_head *pos, *temp; 232 struct list_head *pos, *temp;
208 233
209 sprintf(card->dev.bus_id, "%02x:%02x", card->protocol->number,
210 card->number);
211 card->dev.parent = &card->protocol->dev;
212 card->dev.bus = NULL; 234 card->dev.bus = NULL;
213 card->dev.release = &pnp_release_card; 235 card->dev.release = &pnp_release_card;
214 error = device_register(&card->dev); 236 error = device_register(&card->dev);