Skip to content

Commit 63e9cc5

Browse files
ecashinGreg KH
authored andcommitted
[PATCH] aoe 6/12: Alexey Dobriyan sparse cleanup
Alexey Dobriyan sparse cleanup Signed-off-by: Alexey Dobriyan <adobriyan@mail.ru> Signed-off-by: Ed L. Cashin <ecashin@coraid.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 0334793 commit 63e9cc5

3 files changed

Lines changed: 32 additions & 38 deletions

File tree

‎drivers/block/aoe/aoe.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ enum {
3939
struct aoe_hdr {
4040
unsigned char dst[6];
4141
unsigned char src[6];
42-
unsigned char type[2];
42+
__be16 type;
4343
unsigned char verfl;
4444
unsigned char err;
45-
unsigned char major[2];
45+
__be16 major;
4646
unsigned char minor;
4747
unsigned char cmd;
48-
unsigned char tag[4];
48+
__be32 tag;
4949
};
5050

5151
struct aoe_atahdr {
@@ -63,8 +63,8 @@ struct aoe_atahdr {
6363
};
6464

6565
struct aoe_cfghdr {
66-
unsigned char bufcnt[2];
67-
unsigned char fwver[2];
66+
__be16 bufcnt;
67+
__be16 fwver;
6868
unsigned char res;
6969
unsigned char aoeccmd;
7070
unsigned char cslen[2];

‎drivers/block/aoe/aoecmd.c‎

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,16 @@ newtag(struct aoedev *d)
9090
static int
9191
aoehdr_atainit(struct aoedev *d, struct aoe_hdr *h)
9292
{
93-
u16 type = __constant_cpu_to_be16(ETH_P_AOE);
94-
u16 aoemajor = __cpu_to_be16(d->aoemajor);
9593
u32 host_tag = newtag(d);
96-
u32 tag = __cpu_to_be32(host_tag);
9794

9895
memcpy(h->src, d->ifp->dev_addr, sizeof h->src);
9996
memcpy(h->dst, d->addr, sizeof h->dst);
100-
memcpy(h->type, &type, sizeof type);
97+
h->type = __constant_cpu_to_be16(ETH_P_AOE);
10198
h->verfl = AOE_HVER;
102-
memcpy(h->major, &aoemajor, sizeof aoemajor);
99+
h->major = cpu_to_be16(d->aoemajor);
103100
h->minor = d->aoeminor;
104101
h->cmd = AOECMD_ATA;
105-
memcpy(h->tag, &tag, sizeof tag);
102+
h->tag = cpu_to_be32(host_tag);
106103

107104
return host_tag;
108105
}
@@ -215,7 +212,6 @@ rexmit(struct aoedev *d, struct frame *f)
215212
struct aoe_hdr *h;
216213
char buf[128];
217214
u32 n;
218-
u32 net_tag;
219215

220216
n = newtag(d);
221217

@@ -227,8 +223,7 @@ rexmit(struct aoedev *d, struct frame *f)
227223

228224
h = (struct aoe_hdr *) f->data;
229225
f->tag = n;
230-
net_tag = __cpu_to_be32(n);
231-
memcpy(h->tag, &net_tag, sizeof net_tag);
226+
h->tag = cpu_to_be32(n);
232227

233228
skb = skb_prepare(d, f);
234229
if (skb) {
@@ -308,16 +303,16 @@ ataid_complete(struct aoedev *d, unsigned char *id)
308303
u16 n;
309304

310305
/* word 83: command set supported */
311-
n = __le16_to_cpu(*((u16 *) &id[83<<1]));
306+
n = le16_to_cpup((__le16 *) &id[83<<1]);
312307

313308
/* word 86: command set/feature enabled */
314-
n |= __le16_to_cpu(*((u16 *) &id[86<<1]));
309+
n |= le16_to_cpup((__le16 *) &id[86<<1]);
315310

316311
if (n & (1<<10)) { /* bit 10: LBA 48 */
317312
d->flags |= DEVFL_EXT;
318313

319314
/* word 100: number lba48 sectors */
320-
ssize = __le64_to_cpu(*((u64 *) &id[100<<1]));
315+
ssize = le64_to_cpup((__le64 *) &id[100<<1]);
321316

322317
/* set as in ide-disk.c:init_idedisk_capacity */
323318
d->geo.cylinders = ssize;
@@ -328,12 +323,12 @@ ataid_complete(struct aoedev *d, unsigned char *id)
328323
d->flags &= ~DEVFL_EXT;
329324

330325
/* number lba28 sectors */
331-
ssize = __le32_to_cpu(*((u32 *) &id[60<<1]));
326+
ssize = le32_to_cpup((__le32 *) &id[60<<1]);
332327

333328
/* NOTE: obsolete in ATA 6 */
334-
d->geo.cylinders = __le16_to_cpu(*((u16 *) &id[54<<1]));
335-
d->geo.heads = __le16_to_cpu(*((u16 *) &id[55<<1]));
336-
d->geo.sectors = __le16_to_cpu(*((u16 *) &id[56<<1]));
329+
d->geo.cylinders = le16_to_cpup((__le16 *) &id[54<<1]);
330+
d->geo.heads = le16_to_cpup((__le16 *) &id[55<<1]);
331+
d->geo.sectors = le16_to_cpup((__le16 *) &id[56<<1]);
337332
}
338333
d->ssize = ssize;
339334
d->geo.start = 0;
@@ -383,7 +378,7 @@ aoecmd_ata_rsp(struct sk_buff *skb)
383378
u16 aoemajor;
384379

385380
hin = (struct aoe_hdr *) skb->mac.raw;
386-
aoemajor = __be16_to_cpu(*((u16 *) hin->major));
381+
aoemajor = be16_to_cpu(hin->major);
387382
d = aoedev_by_aoeaddr(aoemajor, hin->minor);
388383
if (d == NULL) {
389384
snprintf(ebuf, sizeof ebuf, "aoecmd_ata_rsp: ata response "
@@ -395,15 +390,15 @@ aoecmd_ata_rsp(struct sk_buff *skb)
395390

396391
spin_lock_irqsave(&d->lock, flags);
397392

398-
f = getframe(d, __be32_to_cpu(*((u32 *) hin->tag)));
393+
f = getframe(d, be32_to_cpu(hin->tag));
399394
if (f == NULL) {
400395
spin_unlock_irqrestore(&d->lock, flags);
401396
snprintf(ebuf, sizeof ebuf,
402397
"%15s e%d.%d tag=%08x@%08lx\n",
403398
"unexpected rsp",
404-
__be16_to_cpu(*((u16 *) hin->major)),
399+
be16_to_cpu(hin->major),
405400
hin->minor,
406-
__be32_to_cpu(*((u32 *) hin->tag)),
401+
be32_to_cpu(hin->tag),
407402
jiffies);
408403
aoechr_error(ebuf);
409404
return;
@@ -453,7 +448,7 @@ aoecmd_ata_rsp(struct sk_buff *skb)
453448
printk(KERN_INFO "aoe: aoecmd_ata_rsp: unrecognized "
454449
"outbound ata command %2.2Xh for %d.%d\n",
455450
ahout->cmdstat,
456-
__be16_to_cpu(*((u16 *) hin->major)),
451+
be16_to_cpu(hin->major),
457452
hin->minor);
458453
}
459454
}
@@ -487,8 +482,6 @@ aoecmd_cfg(ushort aoemajor, unsigned char aoeminor)
487482
struct aoe_cfghdr *ch;
488483
struct sk_buff *skb, *sl;
489484
struct net_device *ifp;
490-
u16 aoe_type = __constant_cpu_to_be16(ETH_P_AOE);
491-
u16 net_aoemajor = __cpu_to_be16(aoemajor);
492485

493486
sl = NULL;
494487

@@ -508,9 +501,9 @@ aoecmd_cfg(ushort aoemajor, unsigned char aoeminor)
508501

509502
memset(h->dst, 0xff, sizeof h->dst);
510503
memcpy(h->src, ifp->dev_addr, sizeof h->src);
511-
memcpy(h->type, &aoe_type, sizeof aoe_type);
504+
h->type = __constant_cpu_to_be16(ETH_P_AOE);
512505
h->verfl = AOE_HVER;
513-
memcpy(h->major, &net_aoemajor, sizeof net_aoemajor);
506+
h->major = cpu_to_be16(aoemajor);
514507
h->minor = aoeminor;
515508
h->cmd = AOECMD_CFG;
516509

@@ -576,7 +569,8 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
576569
struct aoedev *d;
577570
struct aoe_hdr *h;
578571
struct aoe_cfghdr *ch;
579-
ulong flags, bufcnt, sysminor, aoemajor;
572+
ulong flags, sysminor, aoemajor;
573+
u16 bufcnt;
580574
struct sk_buff *sl;
581575
enum { MAXFRAMES = 8 };
582576

@@ -587,7 +581,7 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
587581
* Enough people have their dip switches set backwards to
588582
* warrant a loud message for this special case.
589583
*/
590-
aoemajor = __be16_to_cpu(*((u16 *) h->major));
584+
aoemajor = be16_to_cpu(h->major);
591585
if (aoemajor == 0xfff) {
592586
printk(KERN_CRIT "aoe: aoecmd_cfg_rsp: Warning: shelf "
593587
"address is all ones. Check shelf dip switches\n");
@@ -602,7 +596,7 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
602596
return;
603597
}
604598

605-
bufcnt = __be16_to_cpu(*((u16 *) ch->bufcnt));
599+
bufcnt = be16_to_cpu(ch->bufcnt);
606600
if (bufcnt > MAXFRAMES) /* keep it reasonable */
607601
bufcnt = MAXFRAMES;
608602

@@ -619,7 +613,7 @@ aoecmd_cfg_rsp(struct sk_buff *skb)
619613
return;
620614
}
621615

622-
d->fw_ver = __be16_to_cpu(*((u16 *) ch->fwver));
616+
d->fw_ver = be16_to_cpu(ch->fwver);
623617

624618
/* we get here only if the device is new */
625619
sl = aoecmd_ata_id(d);

‎drivers/block/aoe/aoenet.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ set_aoe_iflist(const char __user *user_str, size_t size)
6969
u64
7070
mac_addr(char addr[6])
7171
{
72-
u64 n = 0;
72+
__be64 n = 0;
7373
char *p = (char *) &n;
7474

7575
memcpy(p + 2, addr, 6); /* (sizeof addr != 6) */
@@ -108,7 +108,7 @@ static int
108108
aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt)
109109
{
110110
struct aoe_hdr *h;
111-
ulong n;
111+
u32 n;
112112

113113
skb = skb_check(skb);
114114
if (!skb)
@@ -121,7 +121,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt)
121121
skb_push(skb, ETH_HLEN); /* (1) */
122122

123123
h = (struct aoe_hdr *) skb->mac.raw;
124-
n = __be32_to_cpu(*((u32 *) h->tag));
124+
n = be32_to_cpu(h->tag);
125125
if ((h->verfl & AOEFL_RSP) == 0 || (n & 1<<31))
126126
goto exit;
127127

@@ -132,7 +132,7 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt)
132132
if (net_ratelimit())
133133
printk(KERN_ERR "aoe: aoenet_rcv: error packet from %d.%d; "
134134
"ecode=%d '%s'\n",
135-
__be16_to_cpu(*((u16 *) h->major)), h->minor,
135+
be16_to_cpu(h->major), h->minor,
136136
h->err, aoe_errlist[n]);
137137
goto exit;
138138
}

0 commit comments

Comments
 (0)