File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ void *pnp_alloc(long size);
33#define PNP_EISA_ID_MASK 0x7fffffff
44void pnp_eisa_id_to_string (u32 id , char * str );
55struct pnp_dev * pnp_alloc_dev (struct pnp_protocol * , int id , char * pnpid );
6+ struct pnp_card * pnp_alloc_card (struct pnp_protocol * , int id , char * pnpid );
67struct pnp_id * pnp_add_id (struct pnp_dev * dev , char * id );
78struct pnp_id * pnp_add_card_id (struct pnp_card * card , char * id );
89int pnp_interface_attach_device (struct pnp_dev * dev );
Original file line number Diff line number Diff line change @@ -151,6 +151,31 @@ static void pnp_release_card(struct device *dmdev)
151151 kfree (card );
152152}
153153
154+ struct 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+
154179static ssize_t pnp_show_card_name (struct device * dmdev ,
155180 struct device_attribute * attr , char * buf )
156181{
@@ -206,9 +231,6 @@ int pnp_add_card(struct pnp_card *card)
206231 int error ;
207232 struct list_head * pos , * temp ;
208233
209- sprintf (card -> dev .bus_id , "%02x:%02x" , card -> protocol -> number ,
210- card -> number );
211- card -> dev .parent = & card -> protocol -> dev ;
212234 card -> dev .bus = NULL ;
213235 card -> dev .release = & pnp_release_card ;
214236 error = device_register (& card -> dev );
Original file line number Diff line number Diff line change @@ -840,16 +840,14 @@ static int __init isapnp_build_device_list(void)
840840 header [5 ], header [6 ], header [7 ], header [8 ]);
841841 printk (KERN_DEBUG "checksum = 0x%x\n" , checksum );
842842#endif
843- if ((card =
844- kzalloc (sizeof (struct pnp_card ), GFP_KERNEL )) == NULL )
845- continue ;
846-
847- card -> number = csn ;
848- INIT_LIST_HEAD (& card -> devices );
849843 eisa_id = header [0 ] | header [1 ] << 8 |
850844 header [2 ] << 16 | header [3 ] << 24 ;
851845 pnp_eisa_id_to_string (eisa_id , id );
852- pnp_add_card_id (card , id );
846+ card = pnp_alloc_card (& isapnp_protocol , csn , id );
847+ if (!card )
848+ continue ;
849+
850+ INIT_LIST_HEAD (& card -> devices );
853851 card -> serial =
854852 (header [7 ] << 24 ) | (header [6 ] << 16 ) | (header [5 ] << 8 ) |
855853 header [4 ];
@@ -860,7 +858,6 @@ static int __init isapnp_build_device_list(void)
860858 "isapnp: checksum for device %i is not valid (0x%x)\n" ,
861859 csn , isapnp_checksum_value );
862860 card -> checksum = isapnp_checksum_value ;
863- card -> protocol = & isapnp_protocol ;
864861
865862 pnp_add_card (card );
866863 }
You can’t perform that action at this time.
0 commit comments