Commit e45e8698 authored by Roland Vossen's avatar Roland Vossen Committed by Greg Kroah-Hartman

staging: brcm80211: replaced void pointers in otp functions

Code cleanup. Otp is 'One Time Programmable' functionality. Replaced void
pointers by less generic pointer types.
Reported-by: default avatarJulian Calaby <julian.calaby@gmail.com>
Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7b1cbc1d
...@@ -66,13 +66,13 @@ ...@@ -66,13 +66,13 @@
/* OTP function struct */ /* OTP function struct */
struct otp_fn_s { struct otp_fn_s {
int (*size)(void *oh); int (*size)(struct otpinfo *oi);
u16 (*read_bit)(void *oh, struct chipcregs *cc, uint off); u16 (*read_bit)(struct otpinfo *oi, struct chipcregs *cc, uint off);
void *(*init)(struct si_pub *sih); struct otpinfo *(*init)(struct si_pub *sih);
int (*read_region)(struct si_pub *sih, int region, u16 *data, int (*read_region)(struct otpinfo *oi, int region, u16 *data,
uint *wlen); uint *wlen);
int (*nvread)(void *oh, char *data, uint *len); int (*nvread)(struct otpinfo *oi, char *data, uint *len);
int (*status)(void *oh); int (*status)(struct otpinfo *oi);
}; };
struct otpinfo { struct otpinfo {
...@@ -148,31 +148,24 @@ static struct otpinfo otpinfo; ...@@ -148,31 +148,24 @@ static struct otpinfo otpinfo;
#define OTP4315_SWREG_SZ 178 /* 178 bytes */ #define OTP4315_SWREG_SZ 178 /* 178 bytes */
#define OTP_SZ_FU_144 (144/8) /* 144 bits */ #define OTP_SZ_FU_144 (144/8) /* 144 bits */
static int ipxotp_status(void *oh) static int ipxotp_status(struct otpinfo *oi)
{ {
struct otpinfo *oi = (struct otpinfo *) oh;
return (int)(oi->status); return (int)(oi->status);
} }
/* Return size in bytes */ /* Return size in bytes */
static int ipxotp_size(void *oh) static int ipxotp_size(struct otpinfo *oi)
{ {
struct otpinfo *oi = (struct otpinfo *) oh;
return (int)oi->wsize * 2; return (int)oi->wsize * 2;
} }
static u16 ipxotp_otpr(void *oh, struct chipcregs *cc, uint wn) static u16 ipxotp_otpr(struct otpinfo *oi, struct chipcregs *cc, uint wn)
{ {
struct otpinfo *oi;
oi = (struct otpinfo *) oh;
return R_REG(&cc->sromotp[wn]); return R_REG(&cc->sromotp[wn]);
} }
static u16 ipxotp_read_bit(void *oh, struct chipcregs *cc, uint off) static u16 ipxotp_read_bit(struct otpinfo *oi, struct chipcregs *cc, uint off)
{ {
struct otpinfo *oi = (struct otpinfo *) oh;
uint k, row, col; uint k, row, col;
u32 otpp, st; u32 otpp, st;
...@@ -300,7 +293,7 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs *cc) ...@@ -300,7 +293,7 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs *cc)
oi->flim = oi->wsize; oi->flim = oi->wsize;
} }
static void *ipxotp_init(struct si_pub *sih) static struct otpinfo *ipxotp_init(struct si_pub *sih)
{ {
uint idx; uint idx;
struct chipcregs *cc; struct chipcregs *cc;
...@@ -355,12 +348,12 @@ static void *ipxotp_init(struct si_pub *sih) ...@@ -355,12 +348,12 @@ static void *ipxotp_init(struct si_pub *sih)
ai_setcoreidx(sih, idx); ai_setcoreidx(sih, idx);
return (void *)oi; return oi;
} }
static int ipxotp_read_region(void *oh, int region, u16 *data, uint *wlen) static int
ipxotp_read_region(struct otpinfo *oi, int region, u16 *data, uint *wlen)
{ {
struct otpinfo *oi = (struct otpinfo *) oh;
uint idx; uint idx;
struct chipcregs *cc; struct chipcregs *cc;
uint base, i, sz; uint base, i, sz;
...@@ -436,27 +429,27 @@ static int ipxotp_read_region(void *oh, int region, u16 *data, uint *wlen) ...@@ -436,27 +429,27 @@ static int ipxotp_read_region(void *oh, int region, u16 *data, uint *wlen)
/* Read the data */ /* Read the data */
for (i = 0; i < sz; i++) for (i = 0; i < sz; i++)
data[i] = ipxotp_otpr(oh, cc, base + i); data[i] = ipxotp_otpr(oi, cc, base + i);
ai_setcoreidx(oi->sih, idx); ai_setcoreidx(oi->sih, idx);
*wlen = sz; *wlen = sz;
return 0; return 0;
} }
static int ipxotp_nvread(void *oh, char *data, uint *len) static int ipxotp_nvread(struct otpinfo *oi, char *data, uint *len)
{ {
return -ENOTSUPP; return -ENOTSUPP;
} }
static struct otp_fn_s ipxotp_fn = { static struct otp_fn_s ipxotp_fn = {
(int (*)(void *)) ipxotp_size, (int (*)(struct otpinfo *)) ipxotp_size,
(u16 (*)(void *, struct chipcregs *, uint)) ipxotp_read_bit, (u16 (*)(struct otpinfo *, struct chipcregs *, uint)) ipxotp_read_bit,
(void *(*)(struct si_pub *)) ipxotp_init, (struct otpinfo *(*)(struct si_pub *)) ipxotp_init,
(int (*)(struct si_pub *, int, u16 *, uint *)) ipxotp_read_region, (int (*)(struct otpinfo *, int, u16 *, uint *)) ipxotp_read_region,
(int (*)(void *, char *, uint *)) ipxotp_nvread, (int (*)(struct otpinfo *, char *, uint *)) ipxotp_nvread,
(int (*)(void *)) ipxotp_status (int (*)(struct otpinfo *)) ipxotp_status
}; };
/* /*
...@@ -468,34 +461,29 @@ static struct otp_fn_s ipxotp_fn = { ...@@ -468,34 +461,29 @@ static struct otp_fn_s ipxotp_fn = {
* otp_nvread() * otp_nvread()
*/ */
int otp_status(void *oh) int otp_status(struct otpinfo *oi)
{ {
struct otpinfo *oi = (struct otpinfo *) oh; return oi->fn->status(oi);
return oi->fn->status(oh);
} }
int otp_size(void *oh) int otp_size(struct otpinfo *oi)
{ {
struct otpinfo *oi = (struct otpinfo *) oh; return oi->fn->size(oi);
return oi->fn->size(oh);
} }
u16 otp_read_bit(void *oh, uint offset) u16 otp_read_bit(struct otpinfo *oi, uint offset)
{ {
struct otpinfo *oi = (struct otpinfo *) oh;
uint idx = ai_coreidx(oi->sih); uint idx = ai_coreidx(oi->sih);
struct chipcregs *cc = ai_setcoreidx(oi->sih, SI_CC_IDX); struct chipcregs *cc = ai_setcoreidx(oi->sih, SI_CC_IDX);
u16 readBit = (u16) oi->fn->read_bit(oh, cc, offset); u16 readBit = (u16) oi->fn->read_bit(oi, cc, offset);
ai_setcoreidx(oi->sih, idx); ai_setcoreidx(oi->sih, idx);
return readBit; return readBit;
} }
void *otp_init(struct si_pub *sih) struct otpinfo *otp_init(struct si_pub *sih)
{ {
struct otpinfo *oi; struct otpinfo *oi;
void *ret = NULL; struct otpinfo *ret = NULL;
oi = &otpinfo; oi = &otpinfo;
memset(oi, 0, sizeof(struct otpinfo)); memset(oi, 0, sizeof(struct otpinfo));
...@@ -516,9 +504,8 @@ void *otp_init(struct si_pub *sih) ...@@ -516,9 +504,8 @@ void *otp_init(struct si_pub *sih)
} }
int int
otp_read_region(struct si_pub *sih, int region, u16 *data, otp_read_region(struct si_pub *sih, int region, u16 *data, uint *wlen) {
uint *wlen) { struct otpinfo *oi;
void *oh;
int err = 0; int err = 0;
if (ai_is_otp_disabled(sih)) { if (ai_is_otp_disabled(sih)) {
...@@ -526,22 +513,19 @@ otp_read_region(struct si_pub *sih, int region, u16 *data, ...@@ -526,22 +513,19 @@ otp_read_region(struct si_pub *sih, int region, u16 *data,
goto out; goto out;
} }
oh = otp_init(sih); oi = otp_init(sih);
if (oh == NULL) { if (oi == NULL) {
err = -EBADE; err = -EBADE;
goto out; goto out;
} }
err = (((struct otpinfo *) oh)->fn->read_region) err = ((oi)->fn->read_region)(oi, region, data, wlen);
(oh, region, data, wlen);
out: out:
return err; return err;
} }
int otp_nvread(void *oh, char *data, uint *len) int otp_nvread(struct otpinfo *oi, char *data, uint *len)
{ {
struct otpinfo *oi = (struct otpinfo *) oh; return oi->fn->nvread(oi, data, len);
return oi->fn->nvread(oh, data, len);
} }
...@@ -36,13 +36,15 @@ ...@@ -36,13 +36,15 @@
/* OTP usage */ /* OTP usage */
#define OTP4325_FM_DISABLED_OFFSET 188 #define OTP4325_FM_DISABLED_OFFSET 188
struct otpinfo;
/* Exported functions */ /* Exported functions */
extern int otp_status(void *oh); extern int otp_status(struct otpinfo *oi);
extern int otp_size(void *oh); extern int otp_size(struct otpinfo *oi);
extern u16 otp_read_bit(void *oh, uint offset); extern u16 otp_read_bit(struct otpinfo *oi, uint offset);
extern void *otp_init(struct si_pub *sih); extern struct otpinfo *otp_init(struct si_pub *sih);
extern int otp_read_region(struct si_pub *sih, int region, u16 *data, extern int otp_read_region(struct si_pub *sih, int region, u16 *data,
uint *wlen); uint *wlen);
extern int otp_nvread(void *oh, char *data, uint *len); extern int otp_nvread(struct otpinfo *oi, char *data, uint *len);
#endif /* _BRCM_OTP_H_ */ #endif /* _BRCM_OTP_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment