]> err.no Git - linux-2.6/blobdiff - drivers/media/dvb/siano/smscoreapi.c
V4L/DVB (8453): sms1xxx: dvb/siano/: cleanups
[linux-2.6] / drivers / media / dvb / siano / smscoreapi.c
index 32dbe246963948a81b7ae90538b51ba5fa444d8d..c5f45fed69dc41290a2300a5a90dfea701f87cdb 100644 (file)
 #include <linux/moduleparam.h>
 #include <linux/dma-mapping.h>
 #include <linux/delay.h>
-#include <asm/io.h>
+#include <linux/io.h>
 
 #include <linux/firmware.h>
 
 #include "smscoreapi.h"
+#include "sms-cards.h"
 
-#define PERROR(fmt, args...)\
-       printk(KERN_ERR "smscore error: line %d- %s(): " fmt, \
-               __LINE__,  __func__, ## args)
-
-#ifdef SMSCORE_DEBUG
-#undef PWARNING
-#  define PWARNING(fmt, args...) printk(KERN_INFO "smscore warning: " \
-                                       "line %d- %s(): " fmt, \
-                                       __LINE__, __func__, ## args)
-#undef PDEBUG                                  /* undef it, just in case */
-#  define PDEBUG(fmt, args...)   printk(KERN_INFO "smscore - %s(): " fmt, \
-                                       __func__, ## args)
-#else /*SMSCORE_DEBUG*/
-#define PDEBUG(fmt, args...)
-#define PWARNING(fmt, args...)
-#endif
+int sms_debug;
+module_param_named(debug, sms_debug, int, 0644);
+MODULE_PARM_DESC(debug, "set debug level (info=1, adv=2 (or-able))");
 
 struct smscore_device_notifyee_t {
        struct list_head entry;
@@ -101,8 +89,20 @@ struct smscore_device_t {
 
        struct completion version_ex_done, data_download_done, trigger_done;
        struct completion init_device_done, reload_start_done, resume_done;
+
+       int board_id;
 };
 
+void smscore_set_board_id(struct smscore_device_t *core, int id)
+{
+       core->board_id = id;
+}
+
+int smscore_get_board_id(struct smscore_device_t *core)
+{
+       return core->board_id;
+}
+
 struct smscore_registry_entry_t {
        struct list_head entry;
        char                    devpath[32];
@@ -110,12 +110,12 @@ struct smscore_registry_entry_t {
        enum sms_device_type_st type;
 };
 
-struct list_head g_smscore_notifyees;
-struct list_head g_smscore_devices;
-kmutex_t g_smscore_deviceslock;
+static struct list_head g_smscore_notifyees;
+static struct list_head g_smscore_devices;
+static struct mutex g_smscore_deviceslock;
 
-struct list_head g_smscore_registry;
-kmutex_t g_smscore_registrylock;
+static struct list_head g_smscore_registry;
+static struct mutex g_smscore_registrylock;
 
 static int default_mode = 4;
 
@@ -145,8 +145,7 @@ static struct smscore_registry_entry_t *smscore_find_registry(char *devpath)
                strcpy(entry->devpath, devpath);
                list_add(&entry->entry, &g_smscore_registry);
        } else
-               printk(KERN_ERR "%s failed to create smscore_registry.\n",
-                      __func__);
+               sms_err("failed to create smscore_registry.");
        kmutex_unlock(&g_smscore_registrylock);
        return entry;
 }
@@ -159,12 +158,12 @@ int smscore_registry_getmode(char *devpath)
        if (entry)
                return entry->mode;
        else
-               printk(KERN_ERR "%s No registry found.\n", __func__);
+               sms_err("No registry found.");
 
        return default_mode;
 }
 
-enum sms_device_type_st smscore_registry_gettype(char *devpath)
+static enum sms_device_type_st smscore_registry_gettype(char *devpath)
 {
        struct smscore_registry_entry_t *entry;
 
@@ -172,7 +171,7 @@ enum sms_device_type_st smscore_registry_gettype(char *devpath)
        if (entry)
                return entry->type;
        else
-               printk(KERN_ERR "%s No registry found.\n", __func__);
+               sms_err("No registry found.");
 
        return -1;
 }
@@ -185,10 +184,11 @@ void smscore_registry_setmode(char *devpath, int mode)
        if (entry)
                entry->mode = mode;
        else
-               printk(KERN_ERR "%s No registry found.\n", __func__);
+               sms_err("No registry found.");
 }
 
-void smscore_registry_settype(char *devpath, enum sms_device_type_st type)
+static void smscore_registry_settype(char *devpath,
+                                    enum sms_device_type_st type)
 {
        struct smscore_registry_entry_t *entry;
 
@@ -196,12 +196,12 @@ void smscore_registry_settype(char *devpath, enum sms_device_type_st type)
        if (entry)
                entry->type = type;
        else
-               printk(KERN_ERR "%s No registry found.\n", __func__);
+               sms_err("No registry found.");
 }
 
 
-void list_add_locked(struct list_head *new, struct list_head *head,
-                    spinlock_t *lock)
+static void list_add_locked(struct list_head *new, struct list_head *head,
+                           spinlock_t *lock)
 {
        unsigned long flags;
 
@@ -282,7 +282,7 @@ void smscore_unregister_hotplug(hotplug_t hotplug)
        kmutex_unlock(&g_smscore_deviceslock);
 }
 
-void smscore_notify_clients(struct smscore_device_t *coredev)
+static void smscore_notify_clients(struct smscore_device_t *coredev)
 {
        struct smscore_client_t *client;
 
@@ -293,8 +293,8 @@ void smscore_notify_clients(struct smscore_device_t *coredev)
        }
 }
 
-int smscore_notify_callbacks(struct smscore_device_t *coredev,
-                            struct device *device, int arrival)
+static int smscore_notify_callbacks(struct smscore_device_t *coredev,
+                                   struct device *device, int arrival)
 {
        struct list_head *next, *first;
        int rc = 0;
@@ -313,13 +313,14 @@ int smscore_notify_callbacks(struct smscore_device_t *coredev,
        return rc;
 }
 
-struct smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer,
+static struct
+smscore_buffer_t *smscore_createbuffer(u8 *buffer, void *common_buffer,
                                       dma_addr_t common_buffer_phys)
 {
        struct smscore_buffer_t *cb =
                kmalloc(sizeof(struct smscore_buffer_t), GFP_KERNEL);
        if (!cb) {
-               printk(KERN_INFO "%s kmalloc(...) failed\n", __func__);
+               sms_info("kmalloc(...) failed");
                return NULL;
        }
 
@@ -348,7 +349,7 @@ int smscore_register_device(struct smsdevice_params_t *params,
 
        dev = kzalloc(sizeof(struct smscore_device_t), GFP_KERNEL);
        if (!dev) {
-               printk(KERN_INFO "%s kzalloc(...) failed\n", __func__);
+               sms_info("kzalloc(...) failed");
                return -ENOMEM;
        }
 
@@ -396,8 +397,7 @@ int smscore_register_device(struct smsdevice_params_t *params,
                smscore_putbuffer(dev, cb);
        }
 
-       printk(KERN_INFO "%s allocated %d buffers\n",
-              __func__, dev->num_buffers);
+       sms_info("allocated %d buffers", dev->num_buffers);
 
        dev->mode = DEVICE_MODE_NONE;
        dev->context = params->context;
@@ -420,7 +420,7 @@ int smscore_register_device(struct smsdevice_params_t *params,
 
        *coredev = dev;
 
-       printk(KERN_INFO "%s device %p created\n", __func__, dev);
+       sms_info("device %p created", dev);
 
        return 0;
 }
@@ -438,8 +438,7 @@ int smscore_start_device(struct smscore_device_t *coredev)
        int rc = smscore_set_device_mode(
                        coredev, smscore_registry_getmode(coredev->devpath));
        if (rc < 0) {
-               printk(KERN_INFO "%s set device mode faile , rc %d\n",
-                      __func__, rc);
+               sms_info("set device mode faile , rc %d", rc);
                return rc;
        }
 
@@ -447,21 +446,20 @@ int smscore_start_device(struct smscore_device_t *coredev)
 
        rc = smscore_notify_callbacks(coredev, coredev->device, 1);
 
-       printk(KERN_INFO "%s device %p started, rc %d\n",
-              __func__, coredev, rc);
+       sms_info("device %p started, rc %d", coredev, rc);
 
        kmutex_unlock(&g_smscore_deviceslock);
 
        return rc;
 }
 
-int smscore_sendrequest_and_wait(struct smscore_device_t *coredev, void *buffer,
-                                size_t size, struct completion *completion)
+static int smscore_sendrequest_and_wait(struct smscore_device_t *coredev,
+                                       void *buffer, size_t size,
+                                       struct completion *completion)
 {
        int rc = coredev->sendrequest_handler(coredev->context, buffer, size);
        if (rc < 0) {
-               printk(KERN_INFO "%s sendrequest returned error %d\n",
-                      __func__, rc);
+               sms_info("sendrequest returned error %d", rc);
                return rc;
        }
 
@@ -470,8 +468,8 @@ int smscore_sendrequest_and_wait(struct smscore_device_t *coredev, void *buffer,
                                                0 : -ETIME;
 }
 
-int smscore_load_firmware_family2(struct smscore_device_t *coredev,
-                                 void *buffer, size_t size)
+static int smscore_load_firmware_family2(struct smscore_device_t *coredev,
+                                        void *buffer, size_t size)
 {
        struct SmsFirmware_ST *firmware = (struct SmsFirmware_ST *) buffer;
        struct SmsMsgHdr_ST *msg;
@@ -479,8 +477,8 @@ int smscore_load_firmware_family2(struct smscore_device_t *coredev,
        u8 *payload = firmware->Payload;
        int rc = 0;
 
-       printk(KERN_INFO "%s loading FW to addr 0x%x size %d\n",
-              __func__, mem_address, firmware->Length);
+       sms_info("loading FW to addr 0x%x size %d",
+                mem_address, firmware->Length);
        if (coredev->preload_handler) {
                rc = coredev->preload_handler(coredev->context);
                if (rc < 0)
@@ -493,7 +491,7 @@ int smscore_load_firmware_family2(struct smscore_device_t *coredev,
                return -ENOMEM;
 
        if (coredev->mode != DEVICE_MODE_NONE) {
-               PDEBUG("Sending reload command\n");
+               sms_debug("sending reload command.");
                SMS_INIT_MSG(msg, MSG_SW_RELOAD_START_REQ,
                             sizeof(struct SmsMsgHdr_ST));
                rc = smscore_sendrequest_and_wait(coredev, msg,
@@ -566,8 +564,8 @@ int smscore_load_firmware_family2(struct smscore_device_t *coredev,
                msleep(500);
        }
 
-       printk(KERN_DEBUG "%s rc=%d, postload=%p \n", __func__, rc,
-              coredev->postload_handler);
+       sms_debug("rc=%d, postload=%p ", rc,
+                 coredev->postload_handler);
 
        kfree(msg);
 
@@ -586,9 +584,9 @@ int smscore_load_firmware_family2(struct smscore_device_t *coredev,
  *
  * @return 0 on success, <0 on error.
  */
-int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
-                                   char *filename,
-                                   loadfirmware_t loadfirmware_handler)
+static int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
+                                          char *filename,
+                                          loadfirmware_t loadfirmware_handler)
 {
        int rc = -ENOENT;
        const struct firmware *fw;
@@ -600,12 +598,10 @@ int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
 
        rc = request_firmware(&fw, filename, coredev->device);
        if (rc < 0) {
-               printk(KERN_INFO "%s failed to open \"%s\"\n",
-                      __func__, filename);
+               sms_info("failed to open \"%s\"", filename);
                return rc;
        }
-       printk(KERN_INFO "%s read FW %s, size=%d\"\n", __func__,
-              filename, fw->size);
+       sms_info("read FW %s, size=%zd", filename, fw->size);
        fw_buffer = kmalloc(ALIGN(fw->size, SMS_ALLOC_ALIGNMENT),
                            GFP_KERNEL | GFP_DMA);
        if (fw_buffer) {
@@ -620,8 +616,7 @@ int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
 
                kfree(fw_buffer);
        } else {
-               printk(KERN_INFO "%s failed to allocate firmware buffer\n",
-                      __func__);
+               sms_info("failed to allocate firmware buffer");
                rc = -ENOMEM;
        }
 
@@ -630,13 +625,6 @@ int smscore_load_firmware_from_file(struct smscore_device_t *coredev,
        return rc;
 }
 
-int smscore_load_firmware_from_buffer(struct smscore_device_t *coredev,
-                                     u8 *buffer, int size, int new_mode)
-{
-       PERROR("Feature not implemented yet\n");
-       return -EFAULT;
-}
-
 /**
  * notifies all clients registered with the device, notifies hotplugs,
  * frees all buffers and coredev object
@@ -668,17 +656,17 @@ void smscore_unregister_device(struct smscore_device_t *coredev)
                if (num_buffers == coredev->num_buffers)
                        break;
                if (++retry > 10) {
-                       printk(KERN_INFO "%s exiting although "
-                              "not all buffers released.\n", __func__);
+                       sms_info("exiting although "
+                                "not all buffers released.");
                        break;
                }
 
-               printk(KERN_INFO "%s waiting for %d buffer(s)\n", __func__,
-                      coredev->num_buffers - num_buffers);
+               sms_info("waiting for %d buffer(s)",
+                        coredev->num_buffers - num_buffers);
                msleep(100);
        }
 
-       printk(KERN_INFO "%s freed %d buffers\n", __func__, num_buffers);
+       sms_info("freed %d buffers", num_buffers);
 
        if (coredev->common_buffer)
                dma_free_coherent(NULL, coredev->common_buffer_size,
@@ -690,10 +678,10 @@ void smscore_unregister_device(struct smscore_device_t *coredev)
 
        kmutex_unlock(&g_smscore_deviceslock);
 
-       printk(KERN_INFO "%s device %p destroyed\n", __func__, coredev);
+       sms_info("device %p destroyed", coredev);
 }
 
-int smscore_detect_mode(struct smscore_device_t *coredev)
+static int smscore_detect_mode(struct smscore_device_t *coredev)
 {
        void *buffer = kmalloc(sizeof(struct SmsMsgHdr_ST) + SMS_DMA_ALIGNMENT,
                               GFP_KERNEL | GFP_DMA);
@@ -710,8 +698,7 @@ int smscore_detect_mode(struct smscore_device_t *coredev)
        rc = smscore_sendrequest_and_wait(coredev, msg, msg->msgLength,
                                          &coredev->version_ex_done);
        if (rc == -ETIME) {
-               printk(KERN_ERR "%s: MSG_SMS_GET_VERSION_EX_REQ "
-                      "failed first try\n", __func__);
+               sms_err("MSG_SMS_GET_VERSION_EX_REQ failed first try");
 
                if (wait_for_completion_timeout(&coredev->resume_done,
                                                msecs_to_jiffies(5000))) {
@@ -719,9 +706,8 @@ int smscore_detect_mode(struct smscore_device_t *coredev)
                                coredev, msg, msg->msgLength,
                                &coredev->version_ex_done);
                        if (rc < 0)
-                               printk(KERN_ERR "%s: "
-                                      "MSG_SMS_GET_VERSION_EX_REQ failed "
-                                      "second try, rc %d\n", __func__, rc);
+                               sms_err("MSG_SMS_GET_VERSION_EX_REQ failed "
+                                       "second try, rc %d", rc);
                } else
                        rc = -ETIME;
        }
@@ -731,7 +717,7 @@ int smscore_detect_mode(struct smscore_device_t *coredev)
        return rc;
 }
 
-char *smscore_fw_lkup[][SMS_NUM_OF_DEVICE_TYPES] = {
+static char *smscore_fw_lkup[][SMS_NUM_OF_DEVICE_TYPES] = {
        /*Stellar               NOVA A0         Nova B0         VEGA*/
        /*DVBT*/
        {"none", "dvb_nova_12mhz.inp", "dvb_nova_12mhz_b0.inp", "none"},
@@ -751,6 +737,12 @@ char *smscore_fw_lkup[][SMS_NUM_OF_DEVICE_TYPES] = {
        {"none", "none", "none", "cmmb_vega_12mhz.inp"}
 };
 
+static inline char *sms_get_fw_name(struct smscore_device_t *coredev,
+                                   int mode, enum sms_device_type_st type)
+{
+       char **fw = sms_get_board(smscore_get_board_id(coredev))->fw;
+       return (fw && fw[mode]) ? fw[mode] : smscore_fw_lkup[mode][type];
+}
 
 /**
  * calls device handler to change mode of operation
@@ -768,11 +760,10 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
        int rc = 0;
        enum sms_device_type_st type;
 
-       PDEBUG("set device mode to %d\n", mode);
+       sms_debug("set device mode to %d", mode);
        if (coredev->device_flags & SMS_DEVICE_FAMILY2) {
                if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_RAW_TUNER) {
-                       printk(KERN_INFO "%s invalid mode specified %d\n",
-                              __func__, mode);
+                       sms_err("invalid mode specified %d", mode);
                        return -EINVAL;
                }
 
@@ -781,30 +772,45 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
                if (!(coredev->device_flags & SMS_DEVICE_NOT_READY)) {
                        rc = smscore_detect_mode(coredev);
                        if (rc < 0) {
-                               printk(KERN_INFO "%s mode detect failed %d\n",
-                                      __func__, rc);
+                               sms_err("mode detect failed %d", rc);
                                return rc;
                        }
                }
 
                if (coredev->mode == mode) {
-                       printk(KERN_INFO "%s device mode %d already set\n",
-                              __func__, mode);
+                       sms_info("device mode %d already set", mode);
                        return 0;
                }
 
                if (!(coredev->modes_supported & (1 << mode))) {
+                       char *fw_filename;
+
                        type = smscore_registry_gettype(coredev->devpath);
-                       rc = smscore_load_firmware_from_file(
-                               coredev, smscore_fw_lkup[mode][type], NULL);
+                       fw_filename = sms_get_fw_name(coredev, mode, type);
+
+                       rc = smscore_load_firmware_from_file(coredev,
+                                                            fw_filename, NULL);
                        if (rc < 0) {
-                               printk(KERN_INFO "%s load firmware "
-                                      "failed %d\n", __func__, rc);
-                               return rc;
+                               sms_warn("error %d loading firmware: %s, "
+                                        "trying again with default firmware",
+                                        rc, fw_filename);
+
+                               /* try again with the default firmware */
+                               fw_filename = smscore_fw_lkup[mode][type];
+                               rc = smscore_load_firmware_from_file(coredev,
+                                                            fw_filename, NULL);
+
+                               if (rc < 0) {
+                                       sms_warn("error %d loading "
+                                                "firmware: %s", rc,
+                                                fw_filename);
+                                       return rc;
+                               }
                        }
+                       sms_log("firmware download success: %s", fw_filename);
                } else
-                       printk(KERN_INFO "%s mode %d supported by running "
-                              "firmware\n", __func__, mode);
+                       sms_info("mode %d supported by running "
+                                "firmware", mode);
 
                buffer = kmalloc(sizeof(struct SmsMsgData_ST) +
                                 SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA);
@@ -823,14 +829,13 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
 
                        kfree(buffer);
                } else {
-                       printk(KERN_INFO "%s Could not allocate buffer for "
-                              "init device message.\n", __func__);
+                       sms_err("Could not allocate buffer for "
+                               "init device message.");
                        rc = -ENOMEM;
                }
        } else {
                if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_DVBT_BDA) {
-                       printk(KERN_INFO "%s invalid mode specified %d\n",
-                              __func__, mode);
+                       sms_err("invalid mode specified %d", mode);
                        return -EINVAL;
                }
 
@@ -850,7 +855,7 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
        }
 
        if (rc != 0)
-               printk(KERN_INFO "%s return error code %d.\n", __func__, rc);
+               sms_err("return error code %d.", rc);
        return rc;
 }
 
@@ -877,7 +882,8 @@ int smscore_get_device_mode(struct smscore_device_t *coredev)
  * @param id client id (SMS_DONT_CARE for all id)
  *
  */
-struct smscore_client_t *smscore_find_client(struct smscore_device_t *coredev,
+static struct
+smscore_client_t *smscore_find_client(struct smscore_device_t *coredev,
                                      int data_type, int id)
 {
        struct smscore_client_t *client = NULL;
@@ -933,9 +939,9 @@ void smscore_onresponse(struct smscore_device_t *coredev,
                last_sample_time = time_now;
 
        if (time_now - last_sample_time > 10000) {
-               printk(KERN_DEBUG "\n%s data rate %d bytes/secs\n", __func__,
-                      (int)((data_total * 1000) /
-                            (time_now - last_sample_time)));
+               sms_debug("\ndata rate %d bytes/secs",
+                         (int)((data_total * 1000) /
+                               (time_now - last_sample_time)));
 
                last_sample_time = time_now;
                data_total = 0;
@@ -953,10 +959,10 @@ void smscore_onresponse(struct smscore_device_t *coredev,
                {
                        struct SmsVersionRes_ST *ver =
                                (struct SmsVersionRes_ST *) phdr;
-                       printk(KERN_DEBUG "%s: MSG_SMS_GET_VERSION_EX_RES "
-                              "id %d prots 0x%x ver %d.%d\n", __func__,
-                              ver->FirmwareId, ver->SupportedProtocols,
-                              ver->RomVersionMajor, ver->RomVersionMinor);
+                       sms_debug("MSG_SMS_GET_VERSION_EX_RES "
+                                 "id %d prots 0x%x ver %d.%d",
+                                 ver->FirmwareId, ver->SupportedProtocols,
+                                 ver->RomVersionMajor, ver->RomVersionMinor);
 
                        coredev->mode = ver->FirmwareId == 255 ?
                                DEVICE_MODE_NONE : ver->FirmwareId;
@@ -966,26 +972,21 @@ void smscore_onresponse(struct smscore_device_t *coredev,
                        break;
                }
                case MSG_SMS_INIT_DEVICE_RES:
-                       printk(KERN_DEBUG "%s: MSG_SMS_INIT_DEVICE_RES\n",
-                              __func__);
+                       sms_debug("MSG_SMS_INIT_DEVICE_RES");
                        complete(&coredev->init_device_done);
                        break;
                case MSG_SW_RELOAD_START_RES:
-                       printk(KERN_DEBUG "%s: MSG_SW_RELOAD_START_RES\n",
-                              __func__);
+                       sms_debug("MSG_SW_RELOAD_START_RES");
                        complete(&coredev->reload_start_done);
                        break;
                case MSG_SMS_DATA_DOWNLOAD_RES:
                        complete(&coredev->data_download_done);
                        break;
                case MSG_SW_RELOAD_EXEC_RES:
-                       printk(KERN_DEBUG "%s: MSG_SW_RELOAD_EXEC_RES\n",
-                              __func__);
+                       sms_debug("MSG_SW_RELOAD_EXEC_RES");
                        break;
                case MSG_SMS_SWDOWNLOAD_TRIGGER_RES:
-                       printk(KERN_DEBUG
-                              "%s: MSG_SMS_SWDOWNLOAD_TRIGGER_RES\n",
-                              __func__);
+                       sms_debug("MSG_SMS_SWDOWNLOAD_TRIGGER_RES");
                        complete(&coredev->trigger_done);
                        break;
                case MSG_SMS_SLEEP_RESUME_COMP_IND:
@@ -1037,15 +1038,15 @@ void smscore_putbuffer(struct smscore_device_t *coredev,
        list_add_locked(&cb->entry, &coredev->buffers, &coredev->bufferslock);
 }
 
-int smscore_validate_client(struct smscore_device_t *coredev,
-                           struct smscore_client_t *client,
-                           int data_type, int id)
+static int smscore_validate_client(struct smscore_device_t *coredev,
+                                  struct smscore_client_t *client,
+                                  int data_type, int id)
 {
        struct smscore_idlist_t *listentry;
        struct smscore_client_t *registered_client;
 
        if (!client) {
-               PERROR("bad parameter.\n");
+               sms_err("bad parameter.");
                return -EFAULT;
        }
        registered_client = smscore_find_client(coredev, data_type, id);
@@ -1053,12 +1054,12 @@ int smscore_validate_client(struct smscore_device_t *coredev,
                return 0;
 
        if (registered_client) {
-               PERROR("The msg ID already registered to another client.\n");
+               sms_err("The msg ID already registered to another client.");
                return -EEXIST;
        }
        listentry = kzalloc(sizeof(struct smscore_idlist_t), GFP_KERNEL);
        if (!listentry) {
-               PERROR("Can't allocate memory for client id.\n");
+               sms_err("Can't allocate memory for client id.");
                return -ENOMEM;
        }
        listentry->id = id;
@@ -1090,13 +1091,13 @@ int smscore_register_client(struct smscore_device_t *coredev,
        /* check that no other channel with same parameters exists */
        if (smscore_find_client(coredev, params->data_type,
                                params->initial_id)) {
-               PERROR("Client already exist.\n");
+               sms_err("Client already exist.");
                return -EEXIST;
        }
 
        newclient = kzalloc(sizeof(struct smscore_client_t), GFP_KERNEL);
        if (!newclient) {
-               PERROR("Failed to allocate memory for client.\n");
+               sms_err("Failed to allocate memory for client.");
                return -ENOMEM;
        }
 
@@ -1110,8 +1111,8 @@ int smscore_register_client(struct smscore_device_t *coredev,
        smscore_validate_client(coredev, newclient, params->data_type,
                                params->initial_id);
        *client = newclient;
-       PDEBUG("%p %d %d\n", params->context, params->data_type,
-              params->initial_id);
+       sms_debug("%p %d %d", params->context, params->data_type,
+                 params->initial_id);
 
        return 0;
 }
@@ -1138,7 +1139,7 @@ void smscore_unregister_client(struct smscore_client_t *client)
                kfree(identry);
        }
 
-       printk(KERN_INFO "%s %p\n", __func__, client->context);
+       sms_info("%p", client->context);
 
        list_del(&client->entry);
        kfree(client);
@@ -1165,7 +1166,7 @@ int smsclient_sendrequest(struct smscore_client_t *client,
        int rc;
 
        if (client == NULL) {
-               printk(KERN_ERR "%s Got NULL client\n", __func__);
+               sms_err("Got NULL client");
                return -EINVAL;
        }
 
@@ -1173,7 +1174,7 @@ int smsclient_sendrequest(struct smscore_client_t *client,
 
        /* check that no other channel with same id exists */
        if (coredev == NULL) {
-               printk(KERN_ERR "%s Got NULL coredev\n", __func__);
+               sms_err("Got NULL coredev");
                return -EINVAL;
        }
 
@@ -1185,56 +1186,8 @@ int smsclient_sendrequest(struct smscore_client_t *client,
        return coredev->sendrequest_handler(coredev->context, buffer, size);
 }
 
-/**
- * return the size of large (common) buffer
- *
- * @param coredev pointer to a coredev object from clients hotplug
- *
- * @return size (in bytes) of the buffer
- */
-int smscore_get_common_buffer_size(struct smscore_device_t *coredev)
-{
-       return coredev->common_buffer_size;
-}
-
-/**
- * maps common buffer (if supported by platform)
- *
- * @param coredev pointer to a coredev object from clients hotplug
- * @param vma pointer to vma struct from mmap handler
- *
- * @return 0 on success, <0 on error.
- */
-int smscore_map_common_buffer(struct smscore_device_t *coredev,
-                              struct vm_area_struct *vma)
-{
-       unsigned long end = vma->vm_end,
-                     start = vma->vm_start,
-                     size = PAGE_ALIGN(coredev->common_buffer_size);
-
-       if (!(vma->vm_flags & (VM_READ | VM_SHARED)) ||
-            (vma->vm_flags & VM_WRITE)) {
-               printk(KERN_INFO "%s invalid vm flags\n", __func__);
-               return -EINVAL;
-       }
-
-       if ((end - start) != size) {
-               printk(KERN_INFO "%s invalid size %d expected %d\n",
-                      __func__, (int)(end - start), (int) size);
-               return -EINVAL;
-       }
-
-       if (remap_pfn_range(vma, start,
-                           coredev->common_buffer_phys >> PAGE_SHIFT,
-                           size, pgprot_noncached(vma->vm_page_prot))) {
-               printk(KERN_INFO "%s remap_page_range failed\n", __func__);
-               return -EAGAIN;
-       }
-
-       return 0;
-}
 
-int smscore_module_init(void)
+static int __init smscore_module_init(void)
 {
        int rc = 0;
 
@@ -1251,12 +1204,12 @@ int smscore_module_init(void)
        /* DVB Register */
        rc = smsdvb_register();
 
-       printk(KERN_INFO "%s, rc %d\n", __func__, rc);
+       sms_debug("rc %d", rc);
 
        return rc;
 }
 
-void smscore_module_exit(void)
+static void __exit smscore_module_exit(void)
 {
 
        kmutex_lock(&g_smscore_deviceslock);
@@ -1287,12 +1240,12 @@ void smscore_module_exit(void)
        /* Unregister USB */
        smsusb_unregister();
 
-       printk(KERN_INFO "%s\n", __func__);
+       sms_debug("");
 }
 
 module_init(smscore_module_init);
 module_exit(smscore_module_exit);
 
-MODULE_DESCRIPTION("smscore");
+MODULE_DESCRIPTION("Driver for the Siano SMS1XXX USB dongle");
 MODULE_AUTHOR("Siano Mobile Silicon,,, (doronc@siano-ms.com)");
 MODULE_LICENSE("GPL");