Commit 21b0838c authored by Ameya Palande's avatar Ameya Palande Committed by Greg Kroah-Hartman

Staging: crystalhd: Misc improvements for crystalhd_lnx.c

This patch does following improvements:

1. Follow kernel style for comments
2. Reorganize code for readability improvement
3. Use PCI helper macros
4. Use __devinit, __devexit, __devexit_p at necessary places
5. Mark functions and data as static when it is not exported
Signed-off-by: default avatarAmeya Palande <2ameya@gmail.com>
Cc: Naren Sankar <nsankar@broadcom.com>
Cc: Jarod Wilson <jarod@wilsonet.com>
Cc: Scott Davilla <davilla@4pi.com>
Cc: Manu Abraham <abraham.manu@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 09257969
...@@ -948,7 +948,7 @@ BC_STATUS crystalhd_user_close(struct crystalhd_cmd *ctx, struct crystalhd_user ...@@ -948,7 +948,7 @@ BC_STATUS crystalhd_user_close(struct crystalhd_cmd *ctx, struct crystalhd_user
* *
* Called at the time of driver load. * Called at the time of driver load.
*/ */
BC_STATUS crystalhd_setup_cmd_context(struct crystalhd_cmd *ctx, BC_STATUS __devinit crystalhd_setup_cmd_context(struct crystalhd_cmd *ctx,
struct crystalhd_adp *adp) struct crystalhd_adp *adp)
{ {
int i = 0; int i = 0;
...@@ -983,7 +983,7 @@ BC_STATUS crystalhd_setup_cmd_context(struct crystalhd_cmd *ctx, ...@@ -983,7 +983,7 @@ BC_STATUS crystalhd_setup_cmd_context(struct crystalhd_cmd *ctx,
* *
* Called at the time of driver un-load. * Called at the time of driver un-load.
*/ */
BC_STATUS crystalhd_delete_cmd_context(struct crystalhd_cmd *ctx) BC_STATUS __devexit crystalhd_delete_cmd_context(struct crystalhd_cmd *ctx)
{ {
BCMLOG(BCMLOG_DBG, "Deleting Command context..\n"); BCMLOG(BCMLOG_DBG, "Deleting Command context..\n");
......
/*************************************************************************** /***************************************************************************
* Copyright (c) 2005-2009, Broadcom Corporation. BCM70010 Linux driver
* Copyright (c) 2005-2009, Broadcom Corporation.
* Name: crystalhd_lnx . c
* This driver is free software; you can redistribute it and/or modify
* Description: it under the terms of the GNU General Public License as published by
* BCM70010 Linux driver the Free Software Foundation, version 2 of the License.
*
* HISTORY: This driver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
********************************************************************** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* This file is part of the crystalhd device driver. GNU General Public License for more details.
*
* This driver is free software; you can redistribute it and/or modify You should have received a copy of the GNU General Public License
* it under the terms of the GNU General Public License as published by along with this driver. If not, see <http://www.gnu.org/licenses/>.
* the Free Software Foundation, version 2 of the License. ***************************************************************************/
*
* This driver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this driver. If not, see <http://www.gnu.org/licenses/>.
**********************************************************************/
#include <linux/version.h> #include <linux/version.h>
...@@ -268,7 +259,7 @@ static int chd_dec_api_cmd(struct crystalhd_adp *adp, unsigned long ua, ...@@ -268,7 +259,7 @@ static int chd_dec_api_cmd(struct crystalhd_adp *adp, unsigned long ua,
return rc; return rc;
} }
/* ========================= API interfaces =================================*/ /* API interfaces */
static int chd_dec_ioctl(struct inode *in, struct file *fd, static int chd_dec_ioctl(struct inode *in, struct file *fd,
unsigned int cmd, unsigned long ua) unsigned int cmd, unsigned long ua)
{ {
...@@ -358,7 +349,7 @@ static const struct file_operations chd_dec_fops = { ...@@ -358,7 +349,7 @@ static const struct file_operations chd_dec_fops = {
.release = chd_dec_close, .release = chd_dec_close,
}; };
static int chd_dec_init_chdev(struct crystalhd_adp *adp) static int __devinit chd_dec_init_chdev(struct crystalhd_adp *adp)
{ {
crystalhd_ioctl_data *temp; crystalhd_ioctl_data *temp;
struct device *dev; struct device *dev;
...@@ -420,7 +411,7 @@ fail: ...@@ -420,7 +411,7 @@ fail:
return rc; return rc;
} }
static void chd_dec_release_chdev(struct crystalhd_adp *adp) static void __devexit chd_dec_release_chdev(struct crystalhd_adp *adp)
{ {
crystalhd_ioctl_data *temp = NULL; crystalhd_ioctl_data *temp = NULL;
if (!adp) if (!adp)
...@@ -446,7 +437,7 @@ static void chd_dec_release_chdev(struct crystalhd_adp *adp) ...@@ -446,7 +437,7 @@ static void chd_dec_release_chdev(struct crystalhd_adp *adp)
crystalhd_delete_elem_pool(adp); crystalhd_delete_elem_pool(adp);
} }
static int chd_pci_reserve_mem(struct crystalhd_adp *pinfo) static int __devinit chd_pci_reserve_mem(struct crystalhd_adp *pinfo)
{ {
int rc; int rc;
unsigned long bar2 = pci_resource_start(pinfo->pdev, 2); unsigned long bar2 = pci_resource_start(pinfo->pdev, 2);
...@@ -499,7 +490,7 @@ static int chd_pci_reserve_mem(struct crystalhd_adp *pinfo) ...@@ -499,7 +490,7 @@ static int chd_pci_reserve_mem(struct crystalhd_adp *pinfo)
return 0; return 0;
} }
static void chd_pci_release_mem(struct crystalhd_adp *pinfo) static void __devexit chd_pci_release_mem(struct crystalhd_adp *pinfo)
{ {
if (!pinfo) if (!pinfo)
return; return;
...@@ -514,7 +505,7 @@ static void chd_pci_release_mem(struct crystalhd_adp *pinfo) ...@@ -514,7 +505,7 @@ static void chd_pci_release_mem(struct crystalhd_adp *pinfo)
} }
static void chd_dec_pci_remove(struct pci_dev *pdev) static void __devexit chd_dec_pci_remove(struct pci_dev *pdev)
{ {
struct crystalhd_adp *pinfo; struct crystalhd_adp *pinfo;
BC_STATUS sts = BC_STS_SUCCESS; BC_STATUS sts = BC_STS_SUCCESS;
...@@ -542,7 +533,7 @@ static void chd_dec_pci_remove(struct pci_dev *pdev) ...@@ -542,7 +533,7 @@ static void chd_dec_pci_remove(struct pci_dev *pdev)
g_adp_info = NULL; g_adp_info = NULL;
} }
static int chd_dec_pci_probe(struct pci_dev *pdev, static int __devinit chd_dec_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *entry) const struct pci_device_id *entry)
{ {
struct crystalhd_adp *pinfo; struct crystalhd_adp *pinfo;
...@@ -621,7 +612,6 @@ static int chd_dec_pci_probe(struct pci_dev *pdev, ...@@ -621,7 +612,6 @@ static int chd_dec_pci_probe(struct pci_dev *pdev,
g_adp_info = pinfo; g_adp_info = pinfo;
return 0; return 0;
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
...@@ -700,24 +690,22 @@ int chd_dec_pci_resume(struct pci_dev *pdev) ...@@ -700,24 +690,22 @@ int chd_dec_pci_resume(struct pci_dev *pdev)
} }
#endif #endif
static struct pci_device_id chd_dec_pci_id_table[] = { static DEFINE_PCI_DEVICE_TABLE(chd_dec_pci_id_table) = {
/* vendor, device, subvendor, subdevice, class, classmask, driver_data */ { PCI_VDEVICE(BROADCOM, 0x1612), 8 },
{ 0x14e4, 0x1612, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8 },
{ 0, }, { 0, },
}; };
MODULE_DEVICE_TABLE(pci, chd_dec_pci_id_table);
struct pci_driver bc_chd_70012_driver = { static struct pci_driver bc_chd_70012_driver = {
.name = "Broadcom 70012 Decoder", .name = "Broadcom 70012 Decoder",
.probe = chd_dec_pci_probe, .probe = chd_dec_pci_probe,
.remove = chd_dec_pci_remove, .remove = __devexit_p(chd_dec_pci_remove),
.id_table = chd_dec_pci_id_table, .id_table = chd_dec_pci_id_table,
#ifdef CONFIG_PM #ifdef CONFIG_PM
.suspend = chd_dec_pci_suspend, .suspend = chd_dec_pci_suspend,
.resume = chd_dec_pci_resume .resume = chd_dec_pci_resume
#endif #endif
}; };
MODULE_DEVICE_TABLE(pci, chd_dec_pci_id_table);
void chd_set_log_level(struct crystalhd_adp *adp, char *arg) void chd_set_log_level(struct crystalhd_adp *adp, char *arg)
{ {
...@@ -744,7 +732,7 @@ struct crystalhd_adp *chd_get_adp(void) ...@@ -744,7 +732,7 @@ struct crystalhd_adp *chd_get_adp(void)
return g_adp_info; return g_adp_info;
} }
int __init chd_dec_module_init(void) static int __init chd_dec_module_init(void)
{ {
int rc; int rc;
...@@ -759,22 +747,19 @@ int __init chd_dec_module_init(void) ...@@ -759,22 +747,19 @@ int __init chd_dec_module_init(void)
return rc; return rc;
} }
module_init(chd_dec_module_init);
void __exit chd_dec_module_cleanup(void) static void __exit chd_dec_module_cleanup(void)
{ {
BCMLOG(BCMLOG_DATA, "unloading crystalhd %d.%d.%d \n", BCMLOG(BCMLOG_DATA, "unloading crystalhd %d.%d.%d \n",
crystalhd_kmod_major, crystalhd_kmod_minor, crystalhd_kmod_rev); crystalhd_kmod_major, crystalhd_kmod_minor, crystalhd_kmod_rev);
pci_unregister_driver(&bc_chd_70012_driver); pci_unregister_driver(&bc_chd_70012_driver);
} }
module_exit(chd_dec_module_cleanup);
MODULE_AUTHOR("Naren Sankar <nsankar@broadcom.com>"); MODULE_AUTHOR("Naren Sankar <nsankar@broadcom.com>");
MODULE_AUTHOR("Prasad Bolisetty <prasadb@broadcom.com>"); MODULE_AUTHOR("Prasad Bolisetty <prasadb@broadcom.com>");
MODULE_DESCRIPTION(CRYSTAL_HD_NAME); MODULE_DESCRIPTION(CRYSTAL_HD_NAME);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS("bcm70012"); MODULE_ALIAS("bcm70012");
module_init(chd_dec_module_init);
module_exit(chd_dec_module_cleanup);
...@@ -959,7 +959,8 @@ void crystalhd_destroy_dio_pool(struct crystalhd_adp *adp) ...@@ -959,7 +959,8 @@ void crystalhd_destroy_dio_pool(struct crystalhd_adp *adp)
* Create general purpose list element pool to hold pending, * Create general purpose list element pool to hold pending,
* and active requests. * and active requests.
*/ */
int crystalhd_create_elem_pool(struct crystalhd_adp *adp, uint32_t pool_size) int __devinit crystalhd_create_elem_pool(struct crystalhd_adp *adp,
uint32_t pool_size)
{ {
uint32_t i; uint32_t i;
crystalhd_elem_t *temp; crystalhd_elem_t *temp;
......
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