Skip to content

Commit cb6fc18

Browse files
Helge DellerKyle McMartin
authored andcommitted
[PARISC] Use kzalloc and other janitor-style cleanups
Helge, o Convert a bunch of kmalloc/memset uses to kzalloc. o pci.c: Add some __read_mostly annotations. o pci.c: Move constant pci_post_reset_delay to asm/pci.h o grfioctl.h: Add A4450A to comment of CRT_ID_VISUALIZE_EG. o Add some consts to perf.c/perf_images.h Matthew, o sticore.c: Add some consts to suppress compile warnings. Signed-off-by: Helge Deller <deller@parisc-linux.org> Signed-off-by: Matthew Wilcox <willy@parisc-linux.org> Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>
1 parent a1c7444 commit cb6fc18

17 files changed

Lines changed: 73 additions & 82 deletions

File tree

‎arch/parisc/kernel/drivers.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,10 @@ static void setup_bus_id(struct parisc_device *padev)
408408

409409
struct parisc_device * create_tree_node(char id, struct device *parent)
410410
{
411-
struct parisc_device *dev = kmalloc(sizeof(*dev), GFP_KERNEL);
411+
struct parisc_device *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
412412
if (!dev)
413413
return NULL;
414414

415-
memset(dev, 0, sizeof(*dev));
416415
dev->hw_path = id;
417416
dev->id.hw_type = HPHW_FAULTY;
418417

‎arch/parisc/kernel/pci.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,17 @@
4747
* this makes the boot time much longer than necessary.
4848
* 20ms seems to work for all the HP PCI implementations to date.
4949
*
50-
* XXX: turn into a #defined constant in <asm/pci.h> ?
50+
* #define pci_post_reset_delay 50
5151
*/
52-
int pci_post_reset_delay = 50;
5352

54-
struct pci_port_ops *pci_port;
55-
struct pci_bios_ops *pci_bios;
53+
struct pci_port_ops *pci_port __read_mostly;
54+
struct pci_bios_ops *pci_bios __read_mostly;
5655

57-
int pci_hba_count = 0;
56+
static int pci_hba_count __read_mostly;
5857

5958
/* parisc_pci_hba used by pci_port->in/out() ops to lookup bus data. */
6059
#define PCI_HBA_MAX 32
61-
struct pci_hba_data *parisc_pci_hba[PCI_HBA_MAX];
60+
struct pci_hba_data *parisc_pci_hba[PCI_HBA_MAX] __read_mostly;
6261

6362

6463
/********************************************************************

‎arch/parisc/kernel/perf.c‎

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,20 @@ struct rdr_tbl_ent {
6868
};
6969

7070
static int perf_processor_interface __read_mostly = UNKNOWN_INTF;
71-
static int perf_enabled __read_mostly = 0;
71+
static int perf_enabled __read_mostly;
7272
static spinlock_t perf_lock;
73-
struct parisc_device *cpu_device __read_mostly = NULL;
73+
struct parisc_device *cpu_device __read_mostly;
7474

7575
/* RDRs to write for PCX-W */
76-
static int perf_rdrs_W[] =
76+
static const int perf_rdrs_W[] =
7777
{ 0, 1, 4, 5, 6, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, -1 };
7878

7979
/* RDRs to write for PCX-U */
80-
static int perf_rdrs_U[] =
80+
static const int perf_rdrs_U[] =
8181
{ 0, 1, 4, 5, 6, 7, 16, 17, 18, 20, 21, 22, 23, 24, 25, -1 };
8282

8383
/* RDR register descriptions for PCX-W */
84-
static struct rdr_tbl_ent perf_rdr_tbl_W[] = {
84+
static const struct rdr_tbl_ent perf_rdr_tbl_W[] = {
8585
{ 19, 1, 8 }, /* RDR 0 */
8686
{ 16, 1, 16 }, /* RDR 1 */
8787
{ 72, 2, 0 }, /* RDR 2 */
@@ -117,7 +117,7 @@ static struct rdr_tbl_ent perf_rdr_tbl_W[] = {
117117
};
118118

119119
/* RDR register descriptions for PCX-U */
120-
static struct rdr_tbl_ent perf_rdr_tbl_U[] = {
120+
static const struct rdr_tbl_ent perf_rdr_tbl_U[] = {
121121
{ 19, 1, 8 }, /* RDR 0 */
122122
{ 32, 1, 16 }, /* RDR 1 */
123123
{ 20, 1, 0 }, /* RDR 2 */
@@ -156,7 +156,7 @@ static struct rdr_tbl_ent perf_rdr_tbl_U[] = {
156156
* A non-zero write_control in the above tables is a byte offset into
157157
* this array.
158158
*/
159-
static uint64_t perf_bitmasks[] = {
159+
static const uint64_t perf_bitmasks[] = {
160160
0x0000000000000000ul, /* first dbl word must be zero */
161161
0xfdffe00000000000ul, /* RDR0 bitmask */
162162
0x003f000000000000ul, /* RDR1 bitmask */
@@ -173,7 +173,7 @@ static uint64_t perf_bitmasks[] = {
173173
* Write control bitmasks for Pa-8700 processor given
174174
* somethings have changed slightly.
175175
*/
176-
static uint64_t perf_bitmasks_piranha[] = {
176+
static const uint64_t perf_bitmasks_piranha[] = {
177177
0x0000000000000000ul, /* first dbl word must be zero */
178178
0xfdffe00000000000ul, /* RDR0 bitmask */
179179
0x003f000000000000ul, /* RDR1 bitmask */
@@ -186,7 +186,7 @@ static uint64_t perf_bitmasks_piranha[] = {
186186
0xfffc000000000000ul
187187
};
188188

189-
static uint64_t *bitmask_array; /* array of bitmasks to use */
189+
static const uint64_t *bitmask_array; /* array of bitmasks to use */
190190

191191
/******************************************************************************
192192
* Function Prototypes
@@ -200,7 +200,7 @@ static ssize_t perf_write(struct file *file, const char __user *buf, size_t coun
200200
static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
201201
static void perf_start_counters(void);
202202
static int perf_stop_counters(uint32_t *raddr);
203-
static struct rdr_tbl_ent * perf_rdr_get_entry(uint32_t rdr_num);
203+
static const struct rdr_tbl_ent * perf_rdr_get_entry(uint32_t rdr_num);
204204
static int perf_rdr_read_ubuf(uint32_t rdr_num, uint64_t *buffer);
205205
static int perf_rdr_clear(uint32_t rdr_num);
206206
static int perf_write_image(uint64_t *memaddr);
@@ -655,7 +655,7 @@ static int perf_stop_counters(uint32_t *raddr)
655655
* Retrieve a pointer to the description of what this
656656
* RDR contains.
657657
*/
658-
static struct rdr_tbl_ent * perf_rdr_get_entry(uint32_t rdr_num)
658+
static const struct rdr_tbl_ent * perf_rdr_get_entry(uint32_t rdr_num)
659659
{
660660
if (perf_processor_interface == ONYX_INTF) {
661661
return &perf_rdr_tbl_U[rdr_num];
@@ -673,7 +673,7 @@ static int perf_rdr_read_ubuf(uint32_t rdr_num, uint64_t *buffer)
673673
{
674674
uint64_t data, data_mask = 0;
675675
uint32_t width, xbits, i;
676-
struct rdr_tbl_ent *tentry;
676+
const struct rdr_tbl_ent *tentry;
677677

678678
tentry = perf_rdr_get_entry(rdr_num);
679679
if ((width = tentry->width) == 0)
@@ -721,7 +721,7 @@ static int perf_rdr_read_ubuf(uint32_t rdr_num, uint64_t *buffer)
721721
*/
722722
static int perf_rdr_clear(uint32_t rdr_num)
723723
{
724-
struct rdr_tbl_ent *tentry;
724+
const struct rdr_tbl_ent *tentry;
725725
int32_t i;
726726

727727
tentry = perf_rdr_get_entry(rdr_num);
@@ -753,10 +753,11 @@ static int perf_write_image(uint64_t *memaddr)
753753
uint64_t buffer[MAX_RDR_WORDS];
754754
uint64_t *bptr;
755755
uint32_t dwords;
756-
uint32_t *intrigue_rdr;
757-
uint64_t *intrigue_bitmask, tmp64;
756+
const uint32_t *intrigue_rdr;
757+
const uint64_t *intrigue_bitmask;
758+
uint64_t tmp64;
758759
void __iomem *runway;
759-
struct rdr_tbl_ent *tentry;
760+
const struct rdr_tbl_ent *tentry;
760761
int i;
761762

762763
/* Clear out counters */
@@ -830,7 +831,7 @@ static int perf_write_image(uint64_t *memaddr)
830831
*/
831832
static void perf_rdr_write(uint32_t rdr_num, uint64_t *buffer)
832833
{
833-
struct rdr_tbl_ent *tentry;
834+
const struct rdr_tbl_ent *tentry;
834835
int32_t i;
835836

836837
printk("perf_rdr_write\n");

‎arch/parisc/kernel/perf_images.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#define PCXU_IMAGE_SIZE 584
2727

28-
static uint32_t onyx_images[][PCXU_IMAGE_SIZE/sizeof(uint32_t)] = {
28+
static uint32_t onyx_images[][PCXU_IMAGE_SIZE/sizeof(uint32_t)] __read_mostly = {
2929
/*
3030
* CPI:
3131
*
@@ -2093,7 +2093,7 @@ static uint32_t onyx_images[][PCXU_IMAGE_SIZE/sizeof(uint32_t)] = {
20932093
};
20942094
#define PCXW_IMAGE_SIZE 576
20952095

2096-
static uint32_t cuda_images[][PCXW_IMAGE_SIZE/sizeof(uint32_t)] = {
2096+
static uint32_t cuda_images[][PCXW_IMAGE_SIZE/sizeof(uint32_t)] __read_mostly = {
20972097
/*
20982098
* CPI: FROM CPI.IDF (Image 0)
20992099
*

‎arch/parisc/kernel/traps.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,9 @@ void show_stack(struct task_struct *task, unsigned long *s)
193193

194194
HERE:
195195
asm volatile ("copy %%r30, %0" : "=r"(sp));
196-
r = (struct pt_regs *)kmalloc(sizeof(struct pt_regs), GFP_KERNEL);
196+
r = kzalloc(sizeof(struct pt_regs), GFP_KERNEL);
197197
if (!r)
198198
return;
199-
memset(r, 0, sizeof(struct pt_regs));
200199
r->iaoq[0] = (unsigned long)&&HERE;
201200
r->gr[2] = (unsigned long)__builtin_return_address(0);
202201
r->gr[30] = sp;

‎drivers/parisc/ccio-dma.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ static void __init ccio_init_resources(struct ioc *ioc)
14231423
struct resource *res = ioc->mmio_region;
14241424
char *name = kmalloc(14, GFP_KERNEL);
14251425

1426-
sprintf(name, "GSC Bus [%d/]", ioc->hw_path);
1426+
snprintf(name, 14, "GSC Bus [%d/]", ioc->hw_path);
14271427

14281428
ccio_init_resource(res, name, &ioc->ioc_regs->io_io_low);
14291429
ccio_init_resource(res + 1, name, &ioc->ioc_regs->io_io_low_hv);
@@ -1557,12 +1557,11 @@ static int ccio_probe(struct parisc_device *dev)
15571557
int i;
15581558
struct ioc *ioc, **ioc_p = &ioc_list;
15591559

1560-
ioc = kmalloc(sizeof(struct ioc), GFP_KERNEL);
1560+
ioc = kzalloc(sizeof(struct ioc), GFP_KERNEL);
15611561
if (ioc == NULL) {
15621562
printk(KERN_ERR MODULE_NAME ": memory allocation failure\n");
15631563
return 1;
15641564
}
1565-
memset(ioc, 0, sizeof(struct ioc));
15661565

15671566
ioc->name = dev->id.hversion == U2_IOA_RUNWAY ? "U2" : "UTurn";
15681567

@@ -1578,7 +1577,7 @@ static int ccio_probe(struct parisc_device *dev)
15781577
ccio_ioc_init(ioc);
15791578
ccio_init_resources(ioc);
15801579
hppa_dma_ops = &ccio_ops;
1581-
dev->dev.platform_data = kmalloc(sizeof(struct pci_hba_data), GFP_KERNEL);
1580+
dev->dev.platform_data = kzalloc(sizeof(struct pci_hba_data), GFP_KERNEL);
15821581

15831582
/* if this fails, no I/O cards will work, so may as well bug */
15841583
BUG_ON(dev->dev.platform_data == NULL);

‎drivers/parisc/dino.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -989,14 +989,12 @@ static int __init dino_probe(struct parisc_device *dev)
989989
*/
990990
}
991991

992-
dino_dev = kmalloc(sizeof(struct dino_device), GFP_KERNEL);
992+
dino_dev = kzalloc(sizeof(struct dino_device), GFP_KERNEL);
993993
if (!dino_dev) {
994994
printk("dino_init_chip - couldn't alloc dino_device\n");
995995
return 1;
996996
}
997997

998-
memset(dino_dev, 0, sizeof(struct dino_device));
999-
1000998
dino_dev->hba.dev = dev;
1001999
dino_dev->hba.base_addr = ioremap(hpa, 4096);
10021000
dino_dev->hba.lmmio_space_offset = 0; /* CPU addrs == bus addrs */

‎drivers/parisc/hppb.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,11 @@ static int hppb_probe(struct parisc_device *dev)
6060
}
6161

6262
if(card->hpa) {
63-
card->next = kmalloc(sizeof(struct hppb_card), GFP_KERNEL);
63+
card->next = kzalloc(sizeof(struct hppb_card), GFP_KERNEL);
6464
if(!card->next) {
6565
printk(KERN_ERR "HP-PB: Unable to allocate memory.\n");
6666
return 1;
6767
}
68-
memset(card->next, '\0', sizeof(struct hppb_card));
6968
card = card->next;
7069
}
7170
printk(KERN_INFO "Found GeckoBoa at 0x%lx\n", dev->hpa.start);

‎drivers/parisc/iosapic.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -873,28 +873,24 @@ void *iosapic_register(unsigned long hpa)
873873
return NULL;
874874
}
875875

876-
isi = (struct iosapic_info *)kmalloc(sizeof(struct iosapic_info), GFP_KERNEL);
876+
isi = (struct iosapic_info *)kzalloc(sizeof(struct iosapic_info), GFP_KERNEL);
877877
if (!isi) {
878878
BUG();
879879
return NULL;
880880
}
881881

882-
memset(isi, 0, sizeof(struct iosapic_info));
883-
884882
isi->addr = ioremap(hpa, 4096);
885883
isi->isi_hpa = hpa;
886884
isi->isi_version = iosapic_rd_version(isi);
887885
isi->isi_num_vectors = IOSAPIC_IRDT_MAX_ENTRY(isi->isi_version) + 1;
888886

889887
vip = isi->isi_vector = (struct vector_info *)
890-
kmalloc(sizeof(struct vector_info) * isi->isi_num_vectors, GFP_KERNEL);
888+
kzalloc(sizeof(struct vector_info) * isi->isi_num_vectors, GFP_KERNEL);
891889
if (vip == NULL) {
892890
kfree(isi);
893891
return NULL;
894892
}
895893

896-
memset(vip, 0, sizeof(struct vector_info) * isi->isi_num_vectors);
897-
898894
for (cnt=0; cnt < isi->isi_num_vectors; cnt++, vip++) {
899895
vip->irqline = (unsigned char) cnt;
900896
vip->iosapic = isi;

‎drivers/parisc/lasi.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ lasi_init_chip(struct parisc_device *dev)
170170
struct gsc_irq gsc_irq;
171171
int ret;
172172

173-
lasi = kmalloc(sizeof(*lasi), GFP_KERNEL);
173+
lasi = kzalloc(sizeof(*lasi), GFP_KERNEL);
174174
if (!lasi)
175175
return -ENOMEM;
176176

0 commit comments

Comments
 (0)