[PATCH 02/12] staging: dgnc: replaces generic struct from sizeof calls
Lidza Louina
lidza.louina at gmail.com
Sat Aug 31 22:19:10 UTC 2013
This patch replaces all instances of "sizeof(struct"
with actual instances of the struct. For example
"sizeof(struct tty_struct" is replaced with
"sizeof(brd->SerialDriver.ttys".
This patch affects driver.c, mgmt.c and tty.c.
Signed-off-by: Lidza Louina <lidza.louina at gmail.com>
---
drivers/staging/dgnc/dgnc_driver.c | 2 +-
drivers/staging/dgnc/dgnc_mgmt.c | 2 +-
drivers/staging/dgnc/dgnc_tty.c | 28 ++++++++++++++--------------
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index 1e76f0c..9dee64c 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -499,7 +499,7 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
/* get the board structure and prep it */
brd = dgnc_Board[dgnc_NumBoards] =
- kzalloc(sizeof(struct board_t), GFP_KERNEL);
+ kzalloc(sizeof(brd), GFP_KERNEL);
if (!brd) {
APR(("memory allocation for board structure failed\n"));
return(-ENOMEM);
diff --git a/drivers/staging/dgnc/dgnc_mgmt.c b/drivers/staging/dgnc/dgnc_mgmt.c
index c4629d7..dcab2a8 100644
--- a/drivers/staging/dgnc/dgnc_mgmt.c
+++ b/drivers/staging/dgnc/dgnc_mgmt.c
@@ -209,7 +209,7 @@ long dgnc_mgmt_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
uint board = 0;
uint channel = 0;
- if (copy_from_user(&ni, uarg, sizeof(struct ni_info))) {
+ if (copy_from_user(&ni, uarg, sizeof(ni))) {
return(-EFAULT);
}
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index a7bb6bc..e004ca8 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -208,8 +208,8 @@ int dgnc_tty_register(struct board_t *brd)
DPR_INIT(("tty_register start\n"));
- memset(&brd->SerialDriver, 0, sizeof(struct tty_driver));
- memset(&brd->PrintDriver, 0, sizeof(struct tty_driver));
+ memset(&brd->SerialDriver, 0, sizeof(brd->SerialDriver));
+ memset(&brd->PrintDriver, 0, sizeof(brd->PrintDriver));
brd->SerialDriver.magic = TTY_DRIVER_MAGIC;
@@ -230,7 +230,7 @@ int dgnc_tty_register(struct board_t *brd)
* The kernel wants space to store pointers to
* tty_struct's and termios's.
*/
- brd->SerialDriver.ttys = kzalloc(brd->maxports * sizeof(struct tty_struct *), GFP_KERNEL);
+ brd->SerialDriver.ttys = kzalloc(brd->maxports * sizeof(brd->SerialDriver.ttys), GFP_KERNEL);
if (!brd->SerialDriver.ttys)
return(-ENOMEM);
@@ -240,12 +240,12 @@ int dgnc_tty_register(struct board_t *brd)
kref_init(&brd->SerialDriver.kref);
#endif
- brd->SerialDriver.termios = kzalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL);
+ brd->SerialDriver.termios = kzalloc(brd->maxports * sizeof(brd->SerialDriver.termios), GFP_KERNEL);
if (!brd->SerialDriver.termios)
return(-ENOMEM);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
- brd->SerialDriver.termios_locked = kzalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL);
+ brd->SerialDriver.termios_locked = kzalloc(brd->maxports * sizeof(brd->SerialDriver.termios_locked), GFP_KERNEL);
if (!brd->SerialDriver.termios_locked)
return(-ENOMEM);
#endif
@@ -289,7 +289,7 @@ int dgnc_tty_register(struct board_t *brd)
* tty_struct's and termios's. Must be seperate from
* the Serial Driver so we don't get confused
*/
- brd->PrintDriver.ttys = kzalloc(brd->maxports * sizeof(struct tty_struct *), GFP_KERNEL);
+ brd->PrintDriver.ttys = kzalloc(brd->maxports * sizeof(brd->PrintDriver.ttys), GFP_KERNEL);
if (!brd->PrintDriver.ttys)
return(-ENOMEM);
@@ -299,12 +299,12 @@ int dgnc_tty_register(struct board_t *brd)
kref_init(&brd->PrintDriver.kref);
#endif
- brd->PrintDriver.termios = kzalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL);
+ brd->PrintDriver.termios = kzalloc(brd->maxports * sizeof(brd->PrintDriver.termios), GFP_KERNEL);
if (!brd->PrintDriver.termios)
return(-ENOMEM);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
- brd->PrintDriver.termios_locked = kzalloc(brd->maxports * sizeof(struct ktermios *), GFP_KERNEL);
+ brd->PrintDriver.termios_locked = kzalloc(brd->maxports * sizeof(brd->PrintDriver.termios_locked), GFP_KERNEL);
if (!brd->PrintDriver.termios_locked)
return(-ENOMEM);
#endif
@@ -371,7 +371,7 @@ int dgnc_tty_init(struct board_t *brd)
* Okay to malloc with GFP_KERNEL, we are not at
* interrupt context, and there are no locks held.
*/
- brd->channels[i] = kzalloc(sizeof(struct channel_t), GFP_KERNEL);
+ brd->channels[i] = kzalloc(sizeof(brd->channels[i]), GFP_KERNEL);
if (!brd->channels[i]) {
DPR_CORE(("%s:%d Unable to allocate memory for channel struct\n",
__FILE__, __LINE__));
@@ -2721,7 +2721,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_i
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return (-EFAULT);
- if (copy_from_user(&new_digi, new_info, sizeof(struct digi_t))) {
+ if (copy_from_user(&new_digi, new_info, sizeof(new_digi))) {
DPR_IOCTL(("DIGI_SETA failed copy_from_user\n"));
return(-EFAULT);
}
@@ -2744,7 +2744,7 @@ static int dgnc_tty_digiseta(struct tty_struct *tty, struct digi_t __user *new_i
if ((ch->ch_digi.digi_flags & DIGI_DTR_TOGGLE) && !(new_digi.digi_flags & DIGI_DTR_TOGGLE))
ch->ch_mostat |= (UART_MCR_DTR);
- memcpy(&ch->ch_digi, &new_digi, sizeof(struct digi_t));
+ memcpy(&ch->ch_digi, &new_digi, sizeof(ch->ch_digi));
if (ch->ch_digi.digi_maxcps < 1)
ch->ch_digi.digi_maxcps = 1;
@@ -3426,7 +3426,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
DGNC_UNLOCK(ch->ch_lock, lock_flags);
- if (copy_to_user(uarg, &buf, sizeof(struct digi_getcounter))) {
+ if (copy_to_user(uarg, &buf, sizeof(buf))) {
return (-EFAULT);
}
return(0);
@@ -3474,7 +3474,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
/*
* Get data from user first.
*/
- if (copy_from_user(&buf, uarg, sizeof(struct digi_getbuffer))) {
+ if (copy_from_user(&buf, uarg, sizeof(buf))) {
return (-EFAULT);
}
@@ -3520,7 +3520,7 @@ static int dgnc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
DGNC_UNLOCK(ch->ch_lock, lock_flags);
- if (copy_to_user(uarg, &buf, sizeof(struct digi_getbuffer))) {
+ if (copy_to_user(uarg, &buf, sizeof(buf))) {
return (-EFAULT);
}
return(0);
--
1.8.1.2
More information about the devel
mailing list