kern_conf.c (66cdbc28d05df05a546dec9df3b2e4166e5fa4c4) | kern_conf.c (ca916247cdab4aa84a7f00de7c39b9e8c933e581) |
---|---|
1/*- 2 * Copyright (c) 1999-2002 Poul-Henning Kamp 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 42 unchanged lines hidden (view full) --- 51 * udev_t's show that a prime halfway between two powers of two works 52 * best. 53 */ 54#define DEVT_HASH 83 55 56/* The number of dev_t's we can create before malloc(9) kick in. */ 57#define DEVT_STASH 50 58 | 1/*- 2 * Copyright (c) 1999-2002 Poul-Henning Kamp 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 42 unchanged lines hidden (view full) --- 51 * udev_t's show that a prime halfway between two powers of two works 52 * best. 53 */ 54#define DEVT_HASH 83 55 56/* The number of dev_t's we can create before malloc(9) kick in. */ 57#define DEVT_STASH 50 58 |
59static struct specinfo devt_stash[DEVT_STASH]; | 59static struct cdev devt_stash[DEVT_STASH]; |
60 | 60 |
61static LIST_HEAD(, specinfo) dev_hash[DEVT_HASH]; | 61static LIST_HEAD(, cdev) dev_hash[DEVT_HASH]; |
62 | 62 |
63static LIST_HEAD(, specinfo) dev_free; | 63static LIST_HEAD(, cdev) dev_free; |
64 65devfs_create_t *devfs_create_hook; 66devfs_destroy_t *devfs_destroy_hook; 67int devfs_present; 68 69static int ready_for_devs; 70 71static int free_devt; --- 96 unchanged lines hidden (view full) --- 168 KASSERT(unit <= 0xffffff, ("Invalid unit (%d) in unit2minor", unit)); 169 return ((unit & 0xff) | ((unit << 8) & ~0xffff)); 170} 171 172static dev_t 173allocdev(void) 174{ 175 static int stashed; | 64 65devfs_create_t *devfs_create_hook; 66devfs_destroy_t *devfs_destroy_hook; 67int devfs_present; 68 69static int ready_for_devs; 70 71static int free_devt; --- 96 unchanged lines hidden (view full) --- 168 KASSERT(unit <= 0xffffff, ("Invalid unit (%d) in unit2minor", unit)); 169 return ((unit & 0xff) | ((unit << 8) & ~0xffff)); 170} 171 172static dev_t 173allocdev(void) 174{ 175 static int stashed; |
176 struct specinfo *si; | 176 struct cdev *si; |
177 178 if (LIST_FIRST(&dev_free)) { 179 si = LIST_FIRST(&dev_free); 180 LIST_REMOVE(si, si_hash); 181 } else if (stashed >= DEVT_STASH) { | 177 178 if (LIST_FIRST(&dev_free)) { 179 si = LIST_FIRST(&dev_free); 180 LIST_REMOVE(si, si_hash); 181 } else if (stashed >= DEVT_STASH) { |
182 MALLOC(si, struct specinfo *, sizeof(*si), M_DEVT, | 182 MALLOC(si, struct cdev *, sizeof(*si), M_DEVT, |
183 M_USE_RESERVE | M_ZERO); 184 } else { 185 si = devt_stash + stashed++; 186 bzero(si, sizeof *si); 187 si->si_flags |= SI_STASHED; 188 } 189 LIST_INIT(&si->si_children); 190 TAILQ_INIT(&si->si_snapshots); 191 return (si); 192} 193 194dev_t 195makedev(int x, int y) 196{ | 183 M_USE_RESERVE | M_ZERO); 184 } else { 185 si = devt_stash + stashed++; 186 bzero(si, sizeof *si); 187 si->si_flags |= SI_STASHED; 188 } 189 LIST_INIT(&si->si_children); 190 TAILQ_INIT(&si->si_snapshots); 191 return (si); 192} 193 194dev_t 195makedev(int x, int y) 196{ |
197 struct specinfo *si; | 197 struct cdev *si; |
198 udev_t udev; 199 int hash; 200 201 if (x == umajor(NOUDEV) && y == uminor(NOUDEV)) 202 panic("makedev of NOUDEV"); 203 udev = (x << 8) | y; 204 hash = udev % DEVT_HASH; 205 LIST_FOREACH(si, &dev_hash[hash], si_hash) { --- 279 unchanged lines hidden --- | 198 udev_t udev; 199 int hash; 200 201 if (x == umajor(NOUDEV) && y == uminor(NOUDEV)) 202 panic("makedev of NOUDEV"); 203 udev = (x << 8) | y; 204 hash = udev % DEVT_HASH; 205 LIST_FOREACH(si, &dev_hash[hash], si_hash) { --- 279 unchanged lines hidden --- |