提交 9132983a 编写于 作者: E Eric Sesterhenn 提交者: David S. Miller

[SPARC64]: kzalloc() conversion

this patch converts arch/sparc64 to kzalloc usage.
Crosscompile tested with allyesconfig.
Signed-off-by: NEric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 f7c00338
...@@ -277,10 +277,9 @@ static inline void *ebus_alloc(size_t size) ...@@ -277,10 +277,9 @@ static inline void *ebus_alloc(size_t size)
{ {
void *mem; void *mem;
mem = kmalloc(size, GFP_ATOMIC); mem = kzalloc(size, GFP_ATOMIC);
if (!mem) if (!mem)
panic("ebus_alloc: out of memory"); panic("ebus_alloc: out of memory");
memset((char *)mem, 0, size);
return mem; return mem;
} }
......
...@@ -316,12 +316,11 @@ unsigned int build_irq(int pil, int inofixup, unsigned long iclr, unsigned long ...@@ -316,12 +316,11 @@ unsigned int build_irq(int pil, int inofixup, unsigned long iclr, unsigned long
goto out; goto out;
} }
bucket->irq_info = kmalloc(sizeof(struct irq_desc), GFP_ATOMIC); bucket->irq_info = kzalloc(sizeof(struct irq_desc), GFP_ATOMIC);
if (!bucket->irq_info) { if (!bucket->irq_info) {
prom_printf("IRQ: Error, kmalloc(irq_desc) failed.\n"); prom_printf("IRQ: Error, kmalloc(irq_desc) failed.\n");
prom_halt(); prom_halt();
} }
memset(bucket->irq_info, 0, sizeof(struct irq_desc));
/* Ok, looks good, set it up. Don't touch the irq_chain or /* Ok, looks good, set it up. Don't touch the irq_chain or
* the pending flag. * the pending flag.
...@@ -357,12 +356,11 @@ unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino, int pil, unsign ...@@ -357,12 +356,11 @@ unsigned int sun4v_build_irq(u32 devhandle, unsigned int devino, int pil, unsign
bucket->pil = pil; bucket->pil = pil;
bucket->flags = flags; bucket->flags = flags;
bucket->irq_info = kmalloc(sizeof(struct irq_desc), GFP_ATOMIC); bucket->irq_info = kzalloc(sizeof(struct irq_desc), GFP_ATOMIC);
if (!bucket->irq_info) { if (!bucket->irq_info) {
prom_printf("IRQ: Error, kmalloc(irq_desc) failed.\n"); prom_printf("IRQ: Error, kmalloc(irq_desc) failed.\n");
prom_halt(); prom_halt();
} }
memset(bucket->irq_info, 0, sizeof(struct irq_desc));
return __irq(bucket); return __irq(bucket);
} }
......
...@@ -977,33 +977,30 @@ void pci_register_legacy_regions(struct resource *io_res, ...@@ -977,33 +977,30 @@ void pci_register_legacy_regions(struct resource *io_res,
struct resource *p; struct resource *p;
/* VGA Video RAM. */ /* VGA Video RAM. */
p = kmalloc(sizeof(*p), GFP_KERNEL); p = kzalloc(sizeof(*p), GFP_KERNEL);
if (!p) if (!p)
return; return;
memset(p, 0, sizeof(*p));
p->name = "Video RAM area"; p->name = "Video RAM area";
p->start = mem_res->start + 0xa0000UL; p->start = mem_res->start + 0xa0000UL;
p->end = p->start + 0x1ffffUL; p->end = p->start + 0x1ffffUL;
p->flags = IORESOURCE_BUSY; p->flags = IORESOURCE_BUSY;
request_resource(mem_res, p); request_resource(mem_res, p);
p = kmalloc(sizeof(*p), GFP_KERNEL); p = kzalloc(sizeof(*p), GFP_KERNEL);
if (!p) if (!p)
return; return;
memset(p, 0, sizeof(*p));
p->name = "System ROM"; p->name = "System ROM";
p->start = mem_res->start + 0xf0000UL; p->start = mem_res->start + 0xf0000UL;
p->end = p->start + 0xffffUL; p->end = p->start + 0xffffUL;
p->flags = IORESOURCE_BUSY; p->flags = IORESOURCE_BUSY;
request_resource(mem_res, p); request_resource(mem_res, p);
p = kmalloc(sizeof(*p), GFP_KERNEL); p = kzalloc(sizeof(*p), GFP_KERNEL);
if (!p) if (!p)
return; return;
memset(p, 0, sizeof(*p));
p->name = "Video ROM"; p->name = "Video ROM";
p->start = mem_res->start + 0xc0000UL; p->start = mem_res->start + 0xc0000UL;
p->end = p->start + 0x7fffUL; p->end = p->start + 0x7fffUL;
......
...@@ -139,12 +139,11 @@ void pci_iommu_table_init(struct pci_iommu *iommu, int tsbsize, u32 dma_offset, ...@@ -139,12 +139,11 @@ void pci_iommu_table_init(struct pci_iommu *iommu, int tsbsize, u32 dma_offset,
/* Allocate and initialize the free area map. */ /* Allocate and initialize the free area map. */
sz = num_tsb_entries / 8; sz = num_tsb_entries / 8;
sz = (sz + 7UL) & ~7UL; sz = (sz + 7UL) & ~7UL;
iommu->arena.map = kmalloc(sz, GFP_KERNEL); iommu->arena.map = kzalloc(sz, GFP_KERNEL);
if (!iommu->arena.map) { if (!iommu->arena.map) {
prom_printf("PCI_IOMMU: Error, kmalloc(arena.map) failed.\n"); prom_printf("PCI_IOMMU: Error, kmalloc(arena.map) failed.\n");
prom_halt(); prom_halt();
} }
memset(iommu->arena.map, 0, sz);
iommu->arena.limit = num_tsb_entries; iommu->arena.limit = num_tsb_entries;
/* Allocate and initialize the dummy page which we /* Allocate and initialize the dummy page which we
......
...@@ -1164,7 +1164,7 @@ static void pbm_config_busmastering(struct pci_pbm_info *pbm) ...@@ -1164,7 +1164,7 @@ static void pbm_config_busmastering(struct pci_pbm_info *pbm)
static void pbm_scan_bus(struct pci_controller_info *p, static void pbm_scan_bus(struct pci_controller_info *p,
struct pci_pbm_info *pbm) struct pci_pbm_info *pbm)
{ {
struct pcidev_cookie *cookie = kmalloc(sizeof(*cookie), GFP_KERNEL); struct pcidev_cookie *cookie = kzalloc(sizeof(*cookie), GFP_KERNEL);
if (!cookie) { if (!cookie) {
prom_printf("PSYCHO: Critical allocation failure.\n"); prom_printf("PSYCHO: Critical allocation failure.\n");
...@@ -1172,7 +1172,6 @@ static void pbm_scan_bus(struct pci_controller_info *p, ...@@ -1172,7 +1172,6 @@ static void pbm_scan_bus(struct pci_controller_info *p,
} }
/* All we care about is the PBM. */ /* All we care about is the PBM. */
memset(cookie, 0, sizeof(*cookie));
cookie->pbm = pbm; cookie->pbm = pbm;
pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno, pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno,
...@@ -1465,18 +1464,16 @@ void psycho_init(int node, char *model_name) ...@@ -1465,18 +1464,16 @@ void psycho_init(int node, char *model_name)
} }
} }
p = kmalloc(sizeof(struct pci_controller_info), GFP_ATOMIC); p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC);
if (!p) { if (!p) {
prom_printf("PSYCHO: Fatal memory allocation error.\n"); prom_printf("PSYCHO: Fatal memory allocation error.\n");
prom_halt(); prom_halt();
} }
memset(p, 0, sizeof(*p)); iommu = kzalloc(sizeof(struct pci_iommu), GFP_ATOMIC);
iommu = kmalloc(sizeof(struct pci_iommu), GFP_ATOMIC);
if (!iommu) { if (!iommu) {
prom_printf("PSYCHO: Fatal memory allocation error.\n"); prom_printf("PSYCHO: Fatal memory allocation error.\n");
prom_halt(); prom_halt();
} }
memset(iommu, 0, sizeof(*iommu));
p->pbm_A.iommu = p->pbm_B.iommu = iommu; p->pbm_A.iommu = p->pbm_B.iommu = iommu;
p->next = pci_controller_root; p->next = pci_controller_root;
......
...@@ -1167,7 +1167,7 @@ static void apb_init(struct pci_controller_info *p, struct pci_bus *sabre_bus) ...@@ -1167,7 +1167,7 @@ static void apb_init(struct pci_controller_info *p, struct pci_bus *sabre_bus)
static struct pcidev_cookie *alloc_bridge_cookie(struct pci_pbm_info *pbm) static struct pcidev_cookie *alloc_bridge_cookie(struct pci_pbm_info *pbm)
{ {
struct pcidev_cookie *cookie = kmalloc(sizeof(*cookie), GFP_KERNEL); struct pcidev_cookie *cookie = kzalloc(sizeof(*cookie), GFP_KERNEL);
if (!cookie) { if (!cookie) {
prom_printf("SABRE: Critical allocation failure.\n"); prom_printf("SABRE: Critical allocation failure.\n");
...@@ -1175,7 +1175,6 @@ static struct pcidev_cookie *alloc_bridge_cookie(struct pci_pbm_info *pbm) ...@@ -1175,7 +1175,6 @@ static struct pcidev_cookie *alloc_bridge_cookie(struct pci_pbm_info *pbm)
} }
/* All we care about is the PBM. */ /* All we care about is the PBM. */
memset(cookie, 0, sizeof(*cookie));
cookie->pbm = pbm; cookie->pbm = pbm;
return cookie; return cookie;
...@@ -1556,19 +1555,17 @@ void sabre_init(int pnode, char *model_name) ...@@ -1556,19 +1555,17 @@ void sabre_init(int pnode, char *model_name)
} }
} }
p = kmalloc(sizeof(*p), GFP_ATOMIC); p = kzalloc(sizeof(*p), GFP_ATOMIC);
if (!p) { if (!p) {
prom_printf("SABRE: Error, kmalloc(pci_controller_info) failed.\n"); prom_printf("SABRE: Error, kmalloc(pci_controller_info) failed.\n");
prom_halt(); prom_halt();
} }
memset(p, 0, sizeof(*p));
iommu = kmalloc(sizeof(*iommu), GFP_ATOMIC); iommu = kzalloc(sizeof(*iommu), GFP_ATOMIC);
if (!iommu) { if (!iommu) {
prom_printf("SABRE: Error, kmalloc(pci_iommu) failed.\n"); prom_printf("SABRE: Error, kmalloc(pci_iommu) failed.\n");
prom_halt(); prom_halt();
} }
memset(iommu, 0, sizeof(*iommu));
p->pbm_A.iommu = p->pbm_B.iommu = iommu; p->pbm_A.iommu = p->pbm_B.iommu = iommu;
upa_portid = prom_getintdefault(pnode, "upa-portid", 0xff); upa_portid = prom_getintdefault(pnode, "upa-portid", 0xff);
......
...@@ -1525,7 +1525,7 @@ static void pbm_config_busmastering(struct pci_pbm_info *pbm) ...@@ -1525,7 +1525,7 @@ static void pbm_config_busmastering(struct pci_pbm_info *pbm)
static void pbm_scan_bus(struct pci_controller_info *p, static void pbm_scan_bus(struct pci_controller_info *p,
struct pci_pbm_info *pbm) struct pci_pbm_info *pbm)
{ {
struct pcidev_cookie *cookie = kmalloc(sizeof(*cookie), GFP_KERNEL); struct pcidev_cookie *cookie = kzalloc(sizeof(*cookie), GFP_KERNEL);
if (!cookie) { if (!cookie) {
prom_printf("%s: Critical allocation failure.\n", pbm->name); prom_printf("%s: Critical allocation failure.\n", pbm->name);
...@@ -1533,7 +1533,6 @@ static void pbm_scan_bus(struct pci_controller_info *p, ...@@ -1533,7 +1533,6 @@ static void pbm_scan_bus(struct pci_controller_info *p,
} }
/* All we care about is the PBM. */ /* All we care about is the PBM. */
memset(cookie, 0, sizeof(*cookie));
cookie->pbm = pbm; cookie->pbm = pbm;
pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno, pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno,
...@@ -2120,27 +2119,24 @@ static void __schizo_init(int node, char *model_name, int chip_type) ...@@ -2120,27 +2119,24 @@ static void __schizo_init(int node, char *model_name, int chip_type)
} }
} }
p = kmalloc(sizeof(struct pci_controller_info), GFP_ATOMIC); p = kzalloc(sizeof(struct pci_controller_info), GFP_ATOMIC);
if (!p) { if (!p) {
prom_printf("SCHIZO: Fatal memory allocation error.\n"); prom_printf("SCHIZO: Fatal memory allocation error.\n");
prom_halt(); prom_halt();
} }
memset(p, 0, sizeof(*p));
iommu = kmalloc(sizeof(struct pci_iommu), GFP_ATOMIC); iommu = kzalloc(sizeof(struct pci_iommu), GFP_ATOMIC);
if (!iommu) { if (!iommu) {
prom_printf("SCHIZO: Fatal memory allocation error.\n"); prom_printf("SCHIZO: Fatal memory allocation error.\n");
prom_halt(); prom_halt();
} }
memset(iommu, 0, sizeof(*iommu));
p->pbm_A.iommu = iommu; p->pbm_A.iommu = iommu;
iommu = kmalloc(sizeof(struct pci_iommu), GFP_ATOMIC); iommu = kzalloc(sizeof(struct pci_iommu), GFP_ATOMIC);
if (!iommu) { if (!iommu) {
prom_printf("SCHIZO: Fatal memory allocation error.\n"); prom_printf("SCHIZO: Fatal memory allocation error.\n");
prom_halt(); prom_halt();
} }
memset(iommu, 0, sizeof(*iommu));
p->pbm_B.iommu = iommu; p->pbm_B.iommu = iommu;
p->next = pci_controller_root; p->next = pci_controller_root;
......
...@@ -536,15 +536,11 @@ static int __init topology_init(void) ...@@ -536,15 +536,11 @@ static int __init topology_init(void)
while (!cpu_find_by_instance(ncpus_probed, NULL, NULL)) while (!cpu_find_by_instance(ncpus_probed, NULL, NULL))
ncpus_probed++; ncpus_probed++;
for (i = 0; i < NR_CPUS; i++) { for_each_cpu(i) {
if (cpu_possible(i)) { struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
struct cpu *p = kmalloc(sizeof(*p), GFP_KERNEL); if (p) {
register_cpu(p, i, NULL);
if (p) { err = 0;
memset(p, 0, sizeof(*p));
register_cpu(p, i, NULL);
err = 0;
}
} }
} }
......
...@@ -600,12 +600,10 @@ asmlinkage long sys_utrap_install(utrap_entry_t type, ...@@ -600,12 +600,10 @@ asmlinkage long sys_utrap_install(utrap_entry_t type,
} }
if (!current_thread_info()->utraps) { if (!current_thread_info()->utraps) {
current_thread_info()->utraps = current_thread_info()->utraps =
kmalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long), GFP_KERNEL); kzalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long), GFP_KERNEL);
if (!current_thread_info()->utraps) if (!current_thread_info()->utraps)
return -ENOMEM; return -ENOMEM;
current_thread_info()->utraps[0] = 1; current_thread_info()->utraps[0] = 1;
memset(current_thread_info()->utraps+1, 0,
UT_TRAP_INSTRUCTION_31*sizeof(long));
} else { } else {
if ((utrap_handler_t)current_thread_info()->utraps[type] != new_p && if ((utrap_handler_t)current_thread_info()->utraps[type] != new_p &&
current_thread_info()->utraps[0] > 1) { current_thread_info()->utraps[0] > 1) {
......
...@@ -357,20 +357,16 @@ static int __init us2e_freq_init(void) ...@@ -357,20 +357,16 @@ static int __init us2e_freq_init(void)
struct cpufreq_driver *driver; struct cpufreq_driver *driver;
ret = -ENOMEM; ret = -ENOMEM;
driver = kmalloc(sizeof(struct cpufreq_driver), GFP_KERNEL); driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
if (!driver) if (!driver)
goto err_out; goto err_out;
memset(driver, 0, sizeof(*driver));
us2e_freq_table = kmalloc( us2e_freq_table = kzalloc(
(NR_CPUS * sizeof(struct us2e_freq_percpu_info)), (NR_CPUS * sizeof(struct us2e_freq_percpu_info)),
GFP_KERNEL); GFP_KERNEL);
if (!us2e_freq_table) if (!us2e_freq_table)
goto err_out; goto err_out;
memset(us2e_freq_table, 0,
(NR_CPUS * sizeof(struct us2e_freq_percpu_info)));
driver->init = us2e_freq_cpu_init; driver->init = us2e_freq_cpu_init;
driver->verify = us2e_freq_verify; driver->verify = us2e_freq_verify;
driver->target = us2e_freq_target; driver->target = us2e_freq_target;
......
...@@ -218,20 +218,16 @@ static int __init us3_freq_init(void) ...@@ -218,20 +218,16 @@ static int __init us3_freq_init(void)
struct cpufreq_driver *driver; struct cpufreq_driver *driver;
ret = -ENOMEM; ret = -ENOMEM;
driver = kmalloc(sizeof(struct cpufreq_driver), GFP_KERNEL); driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
if (!driver) if (!driver)
goto err_out; goto err_out;
memset(driver, 0, sizeof(*driver));
us3_freq_table = kmalloc( us3_freq_table = kzalloc(
(NR_CPUS * sizeof(struct us3_freq_percpu_info)), (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
GFP_KERNEL); GFP_KERNEL);
if (!us3_freq_table) if (!us3_freq_table)
goto err_out; goto err_out;
memset(us3_freq_table, 0,
(NR_CPUS * sizeof(struct us3_freq_percpu_info)));
driver->init = us3_freq_cpu_init; driver->init = us3_freq_cpu_init;
driver->verify = us3_freq_verify; driver->verify = us3_freq_verify;
driver->target = us3_freq_target; driver->target = us3_freq_target;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册