2010-11-23 12:27:22

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 0/6] Add misc device handling.

Following patch series use misc device instead of character device
creation by kernel space (which is obvious obsolete and wrong).
We add limitation for maximum 3 devices to be connected simultaneously.
This interface is used only for testing and not influence basic device
functionality.

Marek Belisko (6):
staging: ft1000: Remove functions which create devices in kernel
space.
staging: ft1000: Use misc device instead self created device.
staging: ft1000: Remove unused variables.
staging: ft1000: Remove unused headers.
staging: ft1000: Remove dead code
staging: ft1000: Check return value of ft1000_CreateDevice().

drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 272 ++++++----------------
drivers/staging/ft1000/ft1000-usb/ft1000_hw.c | 11 +-
drivers/staging/ft1000/ft1000-usb/ft1000_usb.h | 3 -
3 files changed, 79 insertions(+), 207 deletions(-)


2010-11-23 12:27:25

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 1/6] staging: ft1000: Remove functions which create devices in kernel space.

Remove exec_mknod() and rm_mknod() helpers which was used for
device nodes creating/removing in kernel space.

Signed-off-by: Marek Belisko <[email protected]>
---
drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 93 ----------------------
1 files changed, 0 insertions(+), 93 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
index 76cee9e..1aec926 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
@@ -78,88 +78,6 @@ static struct file_operations ft1000fops =
.llseek = no_llseek,
};

-
-
-
-//---------------------------------------------------------------------------
-// Function: exec_mknod
-//
-// Parameters:
-//
-// Returns:
-//
-// Description:
-//
-// Notes:
-//
-//---------------------------------------------------------------------------
-static int exec_mknod (void *pdata)
-{
- struct ft1000_info *info;
- char mjnum[4];
- char minornum[4];
- char temp[32];
- int retcode;
-// int i; //aelias [-] reason : unused variable
- char *envp[] = { "HOME=/", "PATH=/usr/bin:/bin", NULL };
- char *argv[]={"-m 666",temp,"c",mjnum,minornum,NULL};
-
- info = pdata;
- DEBUG("ft1000_chdev:exec_mknod is called with major number = %d\n", info->DeviceMajor);
- sprintf(temp, "%s%s", "/dev/", info->DeviceName) ;
- sprintf(mjnum, "%d", info->DeviceMajor);
- sprintf(minornum, "%d", info->CardNumber);
-
- //char *argv[]={"mknod","-m 666",temp,"c",mjnum,minornum,NULL};
-// char *argv[]={"-m 666",temp,"c",mjnum,minornum,NULL};
-
- //for (i=0; i<7;i++)
- // DEBUG("argv[%d]=%s\n", i, argv[i]);
-
-
- retcode = call_usermodehelper ("/bin/mknod", argv, envp, 1);
- if (retcode) {
- DEBUG("ft1000_chdev:exec_mknod failed to make the node: retcode = %d\n", retcode);
- }
-
-
-
- return retcode;
-
-}
-
-//---------------------------------------------------------------------------
-// Function: rm_mknod
-//
-// Description: This module removes the FT1000 device file
-//
-//---------------------------------------------------------------------------
-static int rm_mknod (void *pdata)
-{
-
- struct ft1000_info *info;
- //char *argv[4]={"rm", "-f", "/dev/FT1000", NULL};
- int retcode;
- char temp[32];
- char *argv[]={"rm", "-f", temp, NULL};
-
- info = (struct ft1000_info *)pdata;
- DEBUG("ft1000_chdev:rm_mknod is called for device %s\n", info->DeviceName);
- sprintf(temp, "%s%s", "/dev/", info->DeviceName) ;
-
-// char *argv[]={"rm", "-f", temp, NULL};
-
- retcode = call_usermodehelper ("/bin/rm", argv, NULL, 1);
- if (retcode) {
- DEBUG("ft1000_chdev:rm_mknod failed to remove the node: retcode = %d\n", retcode);
- }
- else
- DEBUG("ft1000_chdev:rm_mknod done!\n");
-
-
- return retcode;
-
-}
//---------------------------------------------------------------------------
// Function: ft1000_get_buffer
//
@@ -238,15 +156,10 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
struct ft1000_info *info = netdev_priv(dev->net);
int result;
int i;
- pid_t pid;

// make a new device name
sprintf(info->DeviceName, "%s%d", "FT100", info->CardNumber);

- // Delete any existing FT1000 node
- pid = kernel_thread (rm_mknod,(void *)info, 0);
- msleep(1000);
-
DEBUG("ft1000_CreateDevice: number of instance = %d\n", ft1000_flarion_cnt);
DEBUG("DeviceCreated = %x\n", info->DeviceCreated);

@@ -282,9 +195,6 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
DEBUG("ft1000_PcdCreateDevice: device major = %d\n", info->DeviceMajor);
}

- // Create a thread to call user mode app to mknod
- pid = kernel_thread (exec_mknod, (void *)info, 0);
-
// initialize application information

// if (ft1000_flarion_cnt == 0) {
@@ -350,7 +260,6 @@ void ft1000_DestroyDevice(struct net_device *dev)
{
struct ft1000_info *info = netdev_priv(dev);
int result = 0;
- pid_t pid;
int i;
struct dpram_blk *pdpram_blk;
struct dpram_blk *ptr;
@@ -366,8 +275,6 @@ void ft1000_DestroyDevice(struct net_device *dev)
DEBUG("ft1000_DestroyDevice: unregistered device \"%s\", result = %d\n",
info->DeviceName, result);

- pid = kernel_thread (rm_mknod, (void *)info, 0);
-
// Make sure we free any memory reserve for slow Queue
for (i=0; i<MAX_NUM_APP; i++) {
while (list_empty(&info->app_info[i].app_sqlist) == 0) {
--
1.7.1

2010-11-23 12:27:30

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 6/6] staging: ft1000: Check return value of ft1000_CreateDevice().

Registering of misc device could fail so add checking
of return value.

Signed-off-by: Marek Belisko <[email protected]>
---
drivers/staging/ft1000/ft1000-usb/ft1000_hw.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
index 57a235f..fd1f071 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
@@ -948,9 +948,12 @@ int reg_ft1000_netdev(struct ft1000_device *ft1000dev, struct usb_interface *int
return rc;
}

-
- //Create character device, implemented by Jim
- ft1000_CreateDevice(ft1000dev);
+ rc = ft1000_CreateDevice(ft1000dev);
+ if (rc) {
+ DEBUG("Could not register misc device :%d\n", rc);
+ free_netdev(netdev);
+ return rc;
+ }

DEBUG ("reg_ft1000_netdev returned\n");

--
1.7.1

2010-11-23 12:27:27

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 2/6] staging: ft1000: Use misc device instead self created device.

Use simple misc device for ioctl driver funtionality testing.

Signed-off-by: Marek Belisko <[email protected]>
---
drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 90 ++++++++++++++++++---
1 files changed, 77 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
index 1aec926..d1784a3 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
@@ -32,6 +32,7 @@
#include <linux/poll.h>
#include <linux/netdevice.h>
#include <linux/delay.h>
+#include <linux/miscdevice.h>

#include <linux/fs.h>
#include <linux/kmod.h>
@@ -78,6 +79,47 @@ static struct file_operations ft1000fops =
.llseek = no_llseek,
};

+struct ft1000_misc_device {
+ struct miscdevice dev;
+ int inf_id;
+};
+
+#define FREE_ID (0xFF)
+
+/* we support just 3 devices */
+#define MAX_DEVICE 3
+
+static struct ft1000_misc_device ft1000dev[MAX_DEVICE] = {
+ [0] = {
+ .dev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "ft1000_1",
+ .nodename = "/net/ft1000_1",
+ .fops = &ft1000fops,
+ },
+ .inf_id = FREE_ID,
+ },
+ [1] = {
+ .dev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "ft1000_2",
+ .nodename = "/net/ft1000_2",
+ .fops = &ft1000fops,
+ },
+ .inf_id = FREE_ID,
+ },
+ [2] = {
+ .dev = {
+ .minor = MISC_DYNAMIC_MINOR,
+ .name = "ft1000_3",
+ .nodename = "/net/ft1000_3",
+ .fops = &ft1000fops,
+ },
+ .inf_id = FREE_ID,
+ },
+};
+
+
//---------------------------------------------------------------------------
// Function: ft1000_get_buffer
//
@@ -157,8 +199,17 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
int result;
int i;

- // make a new device name
- sprintf(info->DeviceName, "%s%d", "FT100", info->CardNumber);
+ for (i = 0; i < MAX_DEVICE; i++) {
+ if (ft1000dev[i].inf_id == FREE_ID)
+ break;
+ }
+
+ if (i == MAX_DEVICE) {
+ DEBUG("Max number of devices reached.\n");
+ return -ENODEV;
+ }
+
+ ft1000dev[i].inf_id = info->CardNumber;

DEBUG("ft1000_CreateDevice: number of instance = %d\n", ft1000_flarion_cnt);
DEBUG("DeviceCreated = %x\n", info->DeviceCreated);
@@ -176,17 +227,17 @@ int ft1000_CreateDevice(struct ft1000_device *dev)


// register the device
- DEBUG("ft1000_CreateDevice: \"%s\" device registration\n", info->DeviceName);
+ DEBUG("ft1000_CreateDevice: \"%s\" device registration\n",
+ ft1000dev[i].dev.nodename);
info->DeviceMajor = 0;
+ result = misc_register(&ft1000dev[i].dev);
+ if (result) {
+ DEBUG("%s: return: %d\n", __func__, result);
+ return result;
+ }

- result = register_chrdev(info->DeviceMajor, info->DeviceName, &ft1000fops);
- if (result < 0)
- {
- DEBUG("ft1000_CreateDevice: unable to get major %d\n", info->DeviceMajor);
- return result;
- }
-
- DEBUG("ft1000_CreateDevice: registered char device \"%s\"\n", info->DeviceName);
+ DEBUG("ft1000_CreateDevice: registered misc device \"%s\"\n",
+ ft1000dev[i].dev.nodename);

// save a dynamic device major number
if (info->DeviceMajor == 0)
@@ -271,9 +322,22 @@ void ft1000_DestroyDevice(struct net_device *dev)
if (info->DeviceCreated)
{
ft1000_flarion_cnt--;
- unregister_chrdev(info->DeviceMajor, info->DeviceName);
+ for (i = 0; i < MAX_DEVICE; i++) {
+ if (info->CardNumber == ft1000dev[i].inf_id)
+ break;
+ }
+
+ if (i == MAX_DEVICE) {
+ DEBUG("Device couldn't be found\n");
+ return;
+ }
+
DEBUG("ft1000_DestroyDevice: unregistered device \"%s\", result = %d\n",
- info->DeviceName, result);
+ ft1000dev[i].dev.nodename, result);
+
+ misc_deregister(&ft1000dev[i].dev);
+ ft1000dev[i].inf_id = FREE_ID;
+

// Make sure we free any memory reserve for slow Queue
for (i=0; i<MAX_NUM_APP; i++) {
--
1.7.1

2010-11-23 12:27:31

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 5/6] staging: ft1000: Remove dead code

Signed-off-by: Marek Belisko <[email protected]>
---
drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 68 +---------------------
1 files changed, 1 insertions(+), 67 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
index 3df4b4c..768cad0 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
@@ -35,8 +35,6 @@

static int ft1000_flarion_cnt = 0;

-//need to looking usage of ft1000Handle
-
static int ft1000_ChOpen (struct inode *Inode, struct file *File);
static unsigned int ft1000_ChPoll(struct file *file, poll_table *wait);
static long ft1000_ChIoctl(struct file *File, unsigned int Command,
@@ -45,7 +43,6 @@ static int ft1000_ChRelease (struct inode *Inode, struct file *File);

// Global pointer to device object
static struct ft1000_device *pdevobj[MAX_NUM_CARDS + 2];
-//static devfs_handle_t ft1000Handle[MAX_NUM_CARDS];

// List to free receive command buffer pool
struct list_head freercvpool;
@@ -55,12 +52,6 @@ spinlock_t free_buff_lock;

int numofmsgbuf = 0;

-// Global variable to indicate that all provisioning data is sent to DSP
-//bool fProvComplete;
-
-//
-// Table of entry-point routines for char device
-//
static struct file_operations ft1000fops =
{
.unlocked_ioctl = ft1000_ChIoctl,
@@ -207,9 +198,8 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
//save the device info to global array
pdevobj[info->CardNumber] = dev;

- DEBUG("ft1000_CreateDevice: ******SAVED pdevobj[%d]=%p\n", info->CardNumber, pdevobj[info->CardNumber]); //aelias [+] reason:up
+ DEBUG("ft1000_CreateDevice: ******SAVED pdevobj[%d]=%p\n", info->CardNumber, pdevobj[info->CardNumber]);

- // register the device
DEBUG("ft1000_CreateDevice: \"%s\" device registration\n",
ft1000dev[i].dev.nodename);
result = misc_register(&ft1000dev[i].dev);
@@ -221,30 +211,6 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
DEBUG("ft1000_CreateDevice: registered misc device \"%s\"\n",
ft1000dev[i].dev.nodename);

-
- // initialize application information
-
-// if (ft1000_flarion_cnt == 0) {
-//
-// DEBUG("Initialize free_buff_lock and freercvpool\n");
-// spin_lock_init(&free_buff_lock);
-//
-// // initialize a list of buffers to be use for queuing up receive command data
-// INIT_LIST_HEAD (&freercvpool);
-//
-// // create list of free buffers
-// for (i=0; i<NUM_OF_FREE_BUFFERS; i++) {
-// // Get memory for DPRAM_DATA link list
-// pdpram_blk = kmalloc ( sizeof(struct dpram_blk), GFP_KERNEL );
-// // Get a block of memory to store command data
-// pdpram_blk->pbuffer = kmalloc ( MAX_CMD_SQSIZE, GFP_KERNEL );
-// // link provisioning data
-// list_add_tail (&pdpram_blk->list, &freercvpool);
-// }
-// numofmsgbuf = NUM_OF_FREE_BUFFERS;
-// }
-
-
// initialize application information
info->appcnt = 0;
for (i=0; i<MAX_NUM_APP; i++) {
@@ -260,13 +226,6 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
INIT_LIST_HEAD (&info->app_info[i].app_sqlist);
}

-
-
-
-// ft1000Handle[info->CardNumber] = devfs_register(NULL, info->DeviceName, DEVFS_FL_AUTO_DEVNUM, 0, 0,
-// S_IFCHR | S_IRUGO | S_IWUGO, &ft1000fops, NULL);
-
-
ft1000_flarion_cnt++;

return result;
@@ -333,9 +292,6 @@ void ft1000_DestroyDevice(struct net_device *dev)
}
}

-// devfs_unregister(ft1000Handle[info->CardNumber]);
-
-
pdevobj[info->CardNumber] = NULL;
}

@@ -362,7 +318,6 @@ static int ft1000_ChOpen (struct inode *Inode, struct file *File)
DEBUG("pdevobj[%d]=%p\n", i, pdevobj[i]); //aelias [+] reason: down

if ( pdevobj[num] != NULL )
- //info = (struct ft1000_info *)(pdevobj[num]->net->priv);
info = netdev_priv(pdevobj[num]->net);
else
{
@@ -591,7 +546,6 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
case IOCTL_SET_DPRAM_CMD:
{
IOCTL_DPRAM_BLK *dpram_data = NULL;
- //IOCTL_DPRAM_COMMAND dpram_command;
u16 qtype;
u16 msgsz;
struct pseudo_hdr *ppseudo_hdr;
@@ -637,19 +591,11 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
if (!dpram_data)
break;

- //if ( copy_from_user(&(dpram_command.dpram_blk), (PIOCTL_DPRAM_BLK)Argument, msgsz+2) ) {
if ( copy_from_user(dpram_data, argp, msgsz+2) ) {
DEBUG("FT1000:ft1000_ChIoctl: copy fault occurred\n");
result = -EFAULT;
}
else {
-#if 0
- // whc - for debugging only
- ptr = (char *)&dpram_data;
- for (i=0; i<msgsz; i++) {
- DEBUG(1,"FT1000:ft1000_ChIoctl: data %d = 0x%x\n", i, *ptr++);
- }
-#endif
// Check if this message came from a registered application
for (i=0; i<MAX_NUM_APP; i++) {
if ( info->app_info[i].fileobject == &File->f_owner) {
@@ -665,7 +611,6 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
app_index = i;

// Check message qtype type which is the lower byte within qos_class
- //qtype = ntohs(dpram_command.dpram_blk.pseudohdr.qos_class) & 0xff;
qtype = ntohs(dpram_data->pseudohdr.qos_class) & 0xff;
//DEBUG("FT1000_ft1000_ChIoctl: qtype = %d\n", qtype);
if (qtype) {
@@ -705,7 +650,6 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
// Make sure we are within the limits of the slow queue memory limitation
if ( (msgsz < MAX_CMD_SQSIZE) && (msgsz > PSEUDOSZ) ) {
// Need to put sequence number plus new checksum for message
- //pmsg = (u16 *)&dpram_command.dpram_blk.pseudohdr;
pmsg = (u16 *)&dpram_data->pseudohdr;
ppseudo_hdr = (struct pseudo_hdr *)pmsg;
total_len = msgsz+2;
@@ -725,16 +669,6 @@ static long ft1000_ChIoctl (struct file *File, unsigned int Command,
}
pmsg++;
ppseudo_hdr = (struct pseudo_hdr *)pmsg;
-#if 0
- ptr = dpram_data;
- DEBUG("FT1000:ft1000_ChIoctl: Command Send\n");
- for (i=0; i<total_len; i++) {
- DEBUG("FT1000:ft1000_ChIoctl: data %d = 0x%x\n", i, *ptr++);
- }
-#endif
- //dpram_command.extra = 0;
-
- //CardSendCommand(ft1000dev,(unsigned char*)&dpram_command,total_len+2);
CardSendCommand(ft1000dev,(unsigned short*)dpram_data,total_len+2);


--
1.7.1

2010-11-23 12:27:58

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 4/6] staging: ft1000: Remove unused headers.

Signed-off-by: Marek Belisko <[email protected]>
---
drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 9 ---------
1 files changed, 0 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
index 8d2c059..3df4b4c 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
@@ -24,23 +24,14 @@
// 6/05/06 Whc Porting to Linux 2.6.9
//
//---------------------------------------------------------------------------
-#include <linux/module.h>
-#include <linux/kernel.h>
#include <linux/sched.h>
-#include <linux/signal.h>
-#include <linux/errno.h>
#include <linux/poll.h>
#include <linux/netdevice.h>
#include <linux/delay.h>
#include <linux/miscdevice.h>
-
-#include <linux/fs.h>
-#include <linux/kmod.h>
#include <linux/ioctl.h>
-#include <linux/unistd.h>

#include "ft1000_usb.h"
-//#include "ft1000_ioctl.h"

static int ft1000_flarion_cnt = 0;

--
1.7.1

2010-11-23 12:28:17

by Marek Belisko

[permalink] [raw]
Subject: [PATCH 3/6] staging: ft1000: Remove unused variables.

Remove various variables which was used in old character device
interface. When use misc device variables aren't necessary anymore
so remove them.

Signed-off-by: Marek Belisko <[email protected]>
---
drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 22 ----------------------
drivers/staging/ft1000/ft1000-usb/ft1000_hw.c | 2 --
drivers/staging/ft1000/ft1000-usb/ft1000_usb.h | 3 ---
3 files changed, 0 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
index d1784a3..8d2c059 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
@@ -212,24 +212,15 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
ft1000dev[i].inf_id = info->CardNumber;

DEBUG("ft1000_CreateDevice: number of instance = %d\n", ft1000_flarion_cnt);
- DEBUG("DeviceCreated = %x\n", info->DeviceCreated);

//save the device info to global array
pdevobj[info->CardNumber] = dev;

DEBUG("ft1000_CreateDevice: ******SAVED pdevobj[%d]=%p\n", info->CardNumber, pdevobj[info->CardNumber]); //aelias [+] reason:up

- if (info->DeviceCreated)
- {
- DEBUG("ft1000_CreateDevice: \"%s\" already registered\n", info->DeviceName);
- return -EIO;
- }
-
-
// register the device
DEBUG("ft1000_CreateDevice: \"%s\" device registration\n",
ft1000dev[i].dev.nodename);
- info->DeviceMajor = 0;
result = misc_register(&ft1000dev[i].dev);
if (result) {
DEBUG("%s: return: %d\n", __func__, result);
@@ -239,12 +230,6 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
DEBUG("ft1000_CreateDevice: registered misc device \"%s\"\n",
ft1000dev[i].dev.nodename);

- // save a dynamic device major number
- if (info->DeviceMajor == 0)
- {
- info->DeviceMajor = result;
- DEBUG("ft1000_PcdCreateDevice: device major = %d\n", info->DeviceMajor);
- }

// initialize application information

@@ -291,7 +276,6 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
// S_IFCHR | S_IRUGO | S_IWUGO, &ft1000fops, NULL);


- info->DeviceCreated = TRUE;
ft1000_flarion_cnt++;

return result;
@@ -319,8 +303,6 @@ void ft1000_DestroyDevice(struct net_device *dev)



- if (info->DeviceCreated)
- {
ft1000_flarion_cnt--;
for (i = 0; i < MAX_DEVICE; i++) {
if (info->CardNumber == ft1000dev[i].inf_id)
@@ -362,12 +344,8 @@ void ft1000_DestroyDevice(struct net_device *dev)

// devfs_unregister(ft1000Handle[info->CardNumber]);

- info->DeviceCreated = FALSE;

pdevobj[info->CardNumber] = NULL;
- }
-
-
}

//---------------------------------------------------------------------------
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
index 1ca01e2..57a235f 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_hw.c
@@ -834,8 +834,6 @@ u16 init_ft1000_netdev(struct ft1000_device *ft1000dev)
pInfo->ft1000_reset = ft1000_reset;
pInfo->mediastate = 0;
pInfo->fifo_cnt = 0;
- pInfo->DeviceCreated = FALSE;
- pInfo->DeviceMajor = 0;
pInfo->CurrentInterruptEnableMask = ISR_DEFAULT_MASK;
pInfo->InterruptsEnabled = FALSE;
pInfo->CardReady = 0;
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
index a07db26..1572985 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
@@ -502,12 +502,9 @@ struct ft1000_info {
int DSPResetNum;
int NumIOCTLBufs;
int IOCTLBufLvl;
- int DeviceCreated;
int CardReady;
int NetDevRegDone;
u8 CardNumber;
- u8 DeviceName[15];
- int DeviceMajor;
int registered;
int mediastate;
int dhcpflg;
--
1.7.1

2010-11-23 13:53:26

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH 2/6] staging: ft1000: Use misc device instead self created device.

On 11/23/2010 01:29 PM, Marek Belisko wrote:
> Use simple misc device for ioctl driver funtionality testing.
>
> Signed-off-by: Marek Belisko <[email protected]>
> ---
> drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 90 ++++++++++++++++++---
> 1 files changed, 77 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
> index 1aec926..d1784a3 100644
> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
> @@ -32,6 +32,7 @@
> #include <linux/poll.h>
> #include <linux/netdevice.h>
> #include <linux/delay.h>
> +#include <linux/miscdevice.h>
>
> #include <linux/fs.h>
> #include <linux/kmod.h>
> @@ -78,6 +79,47 @@ static struct file_operations ft1000fops =
> .llseek = no_llseek,
> };
>
> +struct ft1000_misc_device {
> + struct miscdevice dev;
> + int inf_id;
> +};
> +
> +#define FREE_ID (0xFF)
> +
> +/* we support just 3 devices */
> +#define MAX_DEVICE 3

No, why this should be converted to miscdevice? Leave it as chrdev.

regards,
--
js

2010-11-23 14:00:41

by Belisko Marek

[permalink] [raw]
Subject: Re: [PATCH 2/6] staging: ft1000: Use misc device instead self created device.

On Tue, Nov 23, 2010 at 2:53 PM, Jiri Slaby <[email protected]> wrote:
> On 11/23/2010 01:29 PM, Marek Belisko wrote:
>> Use simple misc device for ioctl driver funtionality testing.
>>
>> Signed-off-by: Marek Belisko <[email protected]>
>> ---
>>  drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c |   90 ++++++++++++++++++---
>>  1 files changed, 77 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
>> index 1aec926..d1784a3 100644
>> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
>> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
>> @@ -32,6 +32,7 @@
>>  #include <linux/poll.h>
>>  #include <linux/netdevice.h>
>>  #include <linux/delay.h>
>> +#include <linux/miscdevice.h>
>>
>>  #include <linux/fs.h>
>>  #include <linux/kmod.h>
>> @@ -78,6 +79,47 @@ static struct file_operations ft1000fops =
>>       .llseek         = no_llseek,
>>  };
>>
>> +struct ft1000_misc_device {
>> +     struct miscdevice dev;
>> +     int inf_id;
>> +};
>> +
>> +#define FREE_ID (0xFF)
>> +
>> +/* we support just 3 devices */
>> +#define MAX_DEVICE 3
>
> No, why this should be converted to miscdevice? Leave it as chrdev.
Is there any problem with using miscdev? Old interface create /dev nodes with
calling kernel thread and some usermode_helper or whatever. Just
convert to misc dev
where this is done automatically.
>
> regards,
> --
> js
>

thanks,

marek

--
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
icq: 290551086
web: http://open-nandra.com

2010-11-23 21:28:55

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH 2/6] staging: ft1000: Use misc device instead self created device.

On 11/23/2010 03:00 PM, Belisko Marek wrote:
> On Tue, Nov 23, 2010 at 2:53 PM, Jiri Slaby <[email protected]> wrote:
>> On 11/23/2010 01:29 PM, Marek Belisko wrote:
>>> Use simple misc device for ioctl driver funtionality testing.
>>>
>>> Signed-off-by: Marek Belisko <[email protected]>
>>> ---
>>> drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 90 ++++++++++++++++++---
>>> 1 files changed, 77 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
>>> index 1aec926..d1784a3 100644
>>> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
>>> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
>>> @@ -32,6 +32,7 @@
>>> #include <linux/poll.h>
>>> #include <linux/netdevice.h>
>>> #include <linux/delay.h>
>>> +#include <linux/miscdevice.h>
>>>
>>> #include <linux/fs.h>
>>> #include <linux/kmod.h>
>>> @@ -78,6 +79,47 @@ static struct file_operations ft1000fops =
>>> .llseek = no_llseek,
>>> };
>>>
>>> +struct ft1000_misc_device {
>>> + struct miscdevice dev;
>>> + int inf_id;
>>> +};
>>> +
>>> +#define FREE_ID (0xFF)
>>> +
>>> +/* we support just 3 devices */
>>> +#define MAX_DEVICE 3
>>
>> No, why this should be converted to miscdevice? Leave it as chrdev.
> Is there any problem with using miscdev?

Yes, if you want more than a single device per system.

> Old interface create /dev nodes with
> calling kernel thread and some usermode_helper or whatever.

Yes, that's crap indeed. But doesn't judge for miscdevice.

> Just convert to misc dev
> where this is done automatically.

So the only thing you need to do is to send a uevent to udev appropriately.

regards,
--
js

2010-11-24 09:16:42

by Belisko Marek

[permalink] [raw]
Subject: Re: [PATCH 2/6] staging: ft1000: Use misc device instead self created device.

On Tue, Nov 23, 2010 at 10:28 PM, Jiri Slaby <[email protected]> wrote:
> On 11/23/2010 03:00 PM, Belisko Marek wrote:
>> On Tue, Nov 23, 2010 at 2:53 PM, Jiri Slaby <[email protected]> wrote:
>>> On 11/23/2010 01:29 PM, Marek Belisko wrote:
>>>> Use simple misc device for ioctl driver funtionality testing.
>>>>
>>>> Signed-off-by: Marek Belisko <[email protected]>
>>>> ---
>>>>  drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c |   90 ++++++++++++++++++---
>>>>  1 files changed, 77 insertions(+), 13 deletions(-)
>>>>
>>>> diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
>>>> index 1aec926..d1784a3 100644
>>>> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
>>>> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
>>>> @@ -32,6 +32,7 @@
>>>>  #include <linux/poll.h>
>>>>  #include <linux/netdevice.h>
>>>>  #include <linux/delay.h>
>>>> +#include <linux/miscdevice.h>
>>>>
>>>>  #include <linux/fs.h>
>>>>  #include <linux/kmod.h>
>>>> @@ -78,6 +79,47 @@ static struct file_operations ft1000fops =
>>>>       .llseek         = no_llseek,
>>>>  };
>>>>
>>>> +struct ft1000_misc_device {
>>>> +     struct miscdevice dev;
>>>> +     int inf_id;
>>>> +};
>>>> +
>>>> +#define FREE_ID (0xFF)
>>>> +
>>>> +/* we support just 3 devices */
>>>> +#define MAX_DEVICE 3
>>>
>>> No, why this should be converted to miscdevice? Leave it as chrdev.
>> Is there any problem with using miscdev?
>
> Yes, if you want more than a single device per system.
>
>> Old interface create /dev nodes with
>> calling kernel thread and some usermode_helper or whatever.
>
> Yes, that's crap indeed. But doesn't judge for miscdevice.
>
>> Just convert to misc dev
>> where this is done automatically.
>
> So the only thing you need to do is to send a uevent to udev appropriately.
Could be used something like:
register_chrdev(0,"ft1000", &fops)
class = class_create(THIS_MODULE, "ft1000");
device_create(class, NULL, MKDEV(major, i), NULL, "ft1000%d", i);
Then will be created different devices for every plugged device.
This should have effect of automatic device node creation also suppose.

>
> regards,
> --
> js
>

thanks,

marek
,
--
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
icq: 290551086
web: http://open-nandra.com

2010-11-29 19:46:26

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 4/6] staging: ft1000: Remove unused headers.

On Tue, Nov 23, 2010 at 01:29:31PM +0100, Marek Belisko wrote:
> Signed-off-by: Marek Belisko <[email protected]>
> ---
> drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | 9 ---------
> 1 files changed, 0 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
> index 8d2c059..3df4b4c 100644
> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
> @@ -24,23 +24,14 @@
> // 6/05/06 Whc Porting to Linux 2.6.9
> //
> //---------------------------------------------------------------------------
> -#include <linux/module.h>
> -#include <linux/kernel.h>
> #include <linux/sched.h>

Odds are you do want module.h and kernel.h but not sched.h, right?

> -#include <linux/signal.h>
> -#include <linux/errno.h>

You have no error numbers in this driver? I doubt that.

> #include <linux/poll.h>
> #include <linux/netdevice.h>
> #include <linux/delay.h>
> #include <linux/miscdevice.h>
> -
> -#include <linux/fs.h>
> -#include <linux/kmod.h>

These can be removed.

> #include <linux/ioctl.h>
> -#include <linux/unistd.h>

As can this.

thanks,

greg k-h

2010-11-29 19:46:27

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 0/6] Add misc device handling.

On Tue, Nov 23, 2010 at 01:29:27PM +0100, Marek Belisko wrote:
> Following patch series use misc device instead of character device
> creation by kernel space (which is obvious obsolete and wrong).
> We add limitation for maximum 3 devices to be connected simultaneously.
> This interface is used only for testing and not influence basic device
> functionality.

I've only applied the first patch in this series, please remove the
miscdevice stuff as others have pointed out.

thanks,

greg k-h

2010-11-29 19:46:43

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 2/6] staging: ft1000: Use misc device instead self created device.

On Wed, Nov 24, 2010 at 10:16:36AM +0100, Belisko Marek wrote:
> On Tue, Nov 23, 2010 at 10:28 PM, Jiri Slaby <[email protected]> wrote:
> > On 11/23/2010 03:00 PM, Belisko Marek wrote:
> >> On Tue, Nov 23, 2010 at 2:53 PM, Jiri Slaby <[email protected]> wrote:
> >>> On 11/23/2010 01:29 PM, Marek Belisko wrote:
> >>>> Use simple misc device for ioctl driver funtionality testing.
> >>>>
> >>>> Signed-off-by: Marek Belisko <[email protected]>
> >>>> ---
> >>>> ?drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | ? 90 ++++++++++++++++++---
> >>>> ?1 files changed, 77 insertions(+), 13 deletions(-)
> >>>>
> >>>> diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
> >>>> index 1aec926..d1784a3 100644
> >>>> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
> >>>> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
> >>>> @@ -32,6 +32,7 @@
> >>>> ?#include <linux/poll.h>
> >>>> ?#include <linux/netdevice.h>
> >>>> ?#include <linux/delay.h>
> >>>> +#include <linux/miscdevice.h>
> >>>>
> >>>> ?#include <linux/fs.h>
> >>>> ?#include <linux/kmod.h>
> >>>> @@ -78,6 +79,47 @@ static struct file_operations ft1000fops =
> >>>> ? ? ? .llseek ? ? ? ? = no_llseek,
> >>>> ?};
> >>>>
> >>>> +struct ft1000_misc_device {
> >>>> + ? ? struct miscdevice dev;
> >>>> + ? ? int inf_id;
> >>>> +};
> >>>> +
> >>>> +#define FREE_ID (0xFF)
> >>>> +
> >>>> +/* we support just 3 devices */
> >>>> +#define MAX_DEVICE 3
> >>>
> >>> No, why this should be converted to miscdevice? Leave it as chrdev.
> >> Is there any problem with using miscdev?
> >
> > Yes, if you want more than a single device per system.
> >
> >> Old interface create /dev nodes with
> >> calling kernel thread and some usermode_helper or whatever.
> >
> > Yes, that's crap indeed. But doesn't judge for miscdevice.
> >
> >> Just convert to misc dev
> >> where this is done automatically.
> >
> > So the only thing you need to do is to send a uevent to udev appropriately.
> Could be used something like:
> register_chrdev(0,"ft1000", &fops)
> class = class_create(THIS_MODULE, "ft1000");
> device_create(class, NULL, MKDEV(major, i), NULL, "ft1000%d", i);
> Then will be created different devices for every plugged device.
> This should have effect of automatic device node creation also suppose.

Please don't create new classes.

Is this a USB device? If so, why not just use the USB major number?
Just ask me and I can reserve you a USB minor number for your driver.

thanks,

greg k-h

2010-11-29 20:08:10

by Belisko Marek

[permalink] [raw]
Subject: Re: [PATCH 2/6] staging: ft1000: Use misc device instead self created device.

On Mon, Nov 29, 2010 at 8:44 PM, Greg KH <[email protected]> wrote:
> On Wed, Nov 24, 2010 at 10:16:36AM +0100, Belisko Marek wrote:
>> On Tue, Nov 23, 2010 at 10:28 PM, Jiri Slaby <[email protected]> wrote:
>> > On 11/23/2010 03:00 PM, Belisko Marek wrote:
>> >> On Tue, Nov 23, 2010 at 2:53 PM, Jiri Slaby <[email protected]> wrote:
>> >>> On 11/23/2010 01:29 PM, Marek Belisko wrote:
>> >>>> Use simple misc device for ioctl driver funtionality testing.
>> >>>>
>> >>>> Signed-off-by: Marek Belisko <[email protected]>
>> >>>> ---
>> >>>>  drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c |   90 ++++++++++++++++++---
>> >>>>  1 files changed, 77 insertions(+), 13 deletions(-)
>> >>>>
>> >>>> diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
>> >>>> index 1aec926..d1784a3 100644
>> >>>> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
>> >>>> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
>> >>>> @@ -32,6 +32,7 @@
>> >>>>  #include <linux/poll.h>
>> >>>>  #include <linux/netdevice.h>
>> >>>>  #include <linux/delay.h>
>> >>>> +#include <linux/miscdevice.h>
>> >>>>
>> >>>>  #include <linux/fs.h>
>> >>>>  #include <linux/kmod.h>
>> >>>> @@ -78,6 +79,47 @@ static struct file_operations ft1000fops =
>> >>>>       .llseek         = no_llseek,
>> >>>>  };
>> >>>>
>> >>>> +struct ft1000_misc_device {
>> >>>> +     struct miscdevice dev;
>> >>>> +     int inf_id;
>> >>>> +};
>> >>>> +
>> >>>> +#define FREE_ID (0xFF)
>> >>>> +
>> >>>> +/* we support just 3 devices */
>> >>>> +#define MAX_DEVICE 3
>> >>>
>> >>> No, why this should be converted to miscdevice? Leave it as chrdev.
>> >> Is there any problem with using miscdev?
>> >
>> > Yes, if you want more than a single device per system.
>> >
>> >> Old interface create /dev nodes with
>> >> calling kernel thread and some usermode_helper or whatever.
>> >
>> > Yes, that's crap indeed. But doesn't judge for miscdevice.
>> >
>> >> Just convert to misc dev
>> >> where this is done automatically.
>> >
>> > So the only thing you need to do is to send a uevent to udev appropriately.
>> Could be used something like:
>> register_chrdev(0,"ft1000", &fops)
>> class = class_create(THIS_MODULE, "ft1000");
>> device_create(class, NULL, MKDEV(major, i), NULL, "ft1000%d", i);
>> Then will be created different devices for every plugged device.
>> This should have effect of automatic device node creation also suppose.
>
> Please don't create new classes.
>
> Is this a USB device?  If so, why not just use the USB major number?
Yes it is USB device.
> Just ask me and I can reserve you a USB minor number for your driver.
Idea behind existing code is that for every plugged device you will have created
/dev node. NUmber of devices was limited by number of plugged devices.
But who will plug more
then one device which just used for internet connection? So maybe I
should implement some
limit and would be nice if you could reserve me some USB minors (lest
say max. 3 devices?).

>
> thanks,
>
> greg k-h
>

thanks,

marek

--
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
icq: 290551086
web: http://open-nandra.com

2010-12-01 04:08:40

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH 2/6] staging: ft1000: Use misc device instead self created device.

On Mon, Nov 29, 2010 at 09:08:07PM +0100, Belisko Marek wrote:
> On Mon, Nov 29, 2010 at 8:44 PM, Greg KH <[email protected]> wrote:
> > On Wed, Nov 24, 2010 at 10:16:36AM +0100, Belisko Marek wrote:
> >> On Tue, Nov 23, 2010 at 10:28 PM, Jiri Slaby <[email protected]> wrote:
> >> > On 11/23/2010 03:00 PM, Belisko Marek wrote:
> >> >> On Tue, Nov 23, 2010 at 2:53 PM, Jiri Slaby <[email protected]> wrote:
> >> >>> On 11/23/2010 01:29 PM, Marek Belisko wrote:
> >> >>>> Use simple misc device for ioctl driver funtionality testing.
> >> >>>>
> >> >>>> Signed-off-by: Marek Belisko <[email protected]>
> >> >>>> ---
> >> >>>> ?drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c | ? 90 ++++++++++++++++++---
> >> >>>> ?1 files changed, 77 insertions(+), 13 deletions(-)
> >> >>>>
> >> >>>> diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
> >> >>>> index 1aec926..d1784a3 100644
> >> >>>> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
> >> >>>> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
> >> >>>> @@ -32,6 +32,7 @@
> >> >>>> ?#include <linux/poll.h>
> >> >>>> ?#include <linux/netdevice.h>
> >> >>>> ?#include <linux/delay.h>
> >> >>>> +#include <linux/miscdevice.h>
> >> >>>>
> >> >>>> ?#include <linux/fs.h>
> >> >>>> ?#include <linux/kmod.h>
> >> >>>> @@ -78,6 +79,47 @@ static struct file_operations ft1000fops =
> >> >>>> ? ? ? .llseek ? ? ? ? = no_llseek,
> >> >>>> ?};
> >> >>>>
> >> >>>> +struct ft1000_misc_device {
> >> >>>> + ? ? struct miscdevice dev;
> >> >>>> + ? ? int inf_id;
> >> >>>> +};
> >> >>>> +
> >> >>>> +#define FREE_ID (0xFF)
> >> >>>> +
> >> >>>> +/* we support just 3 devices */
> >> >>>> +#define MAX_DEVICE 3
> >> >>>
> >> >>> No, why this should be converted to miscdevice? Leave it as chrdev.
> >> >> Is there any problem with using miscdev?
> >> >
> >> > Yes, if you want more than a single device per system.
> >> >
> >> >> Old interface create /dev nodes with
> >> >> calling kernel thread and some usermode_helper or whatever.
> >> >
> >> > Yes, that's crap indeed. But doesn't judge for miscdevice.
> >> >
> >> >> Just convert to misc dev
> >> >> where this is done automatically.
> >> >
> >> > So the only thing you need to do is to send a uevent to udev appropriately.
> >> Could be used something like:
> >> register_chrdev(0,"ft1000", &fops)
> >> class = class_create(THIS_MODULE, "ft1000");
> >> device_create(class, NULL, MKDEV(major, i), NULL, "ft1000%d", i);
> >> Then will be created different devices for every plugged device.
> >> This should have effect of automatic device node creation also suppose.
> >
> > Please don't create new classes.
> >
> > Is this a USB device? ?If so, why not just use the USB major number?
> Yes it is USB device.
> > Just ask me and I can reserve you a USB minor number for your driver.
> Idea behind existing code is that for every plugged device you will have created
> /dev node. NUmber of devices was limited by number of plugged devices.
> But who will plug more
> then one device which just used for internet connection? So maybe I
> should implement some
> limit and would be nice if you could reserve me some USB minors (lest
> say max. 3 devices?).

Send me a patch using the USB major number, and I'll add an additional
one that reserves the proper minor number for your driver.

thanks,

greg k-h

2010-12-01 09:35:28

by Belisko Marek

[permalink] [raw]
Subject: Re: [PATCH 2/6] staging: ft1000: Use misc device instead self created device.

On Wed, Dec 1, 2010 at 5:06 AM, Greg KH <[email protected]> wrote:
> On Mon, Nov 29, 2010 at 09:08:07PM +0100, Belisko Marek wrote:
>> On Mon, Nov 29, 2010 at 8:44 PM, Greg KH <[email protected]> wrote:
>> > On Wed, Nov 24, 2010 at 10:16:36AM +0100, Belisko Marek wrote:
>> >> On Tue, Nov 23, 2010 at 10:28 PM, Jiri Slaby <[email protected]> wrote:
>> >> > On 11/23/2010 03:00 PM, Belisko Marek wrote:
>> >> >> On Tue, Nov 23, 2010 at 2:53 PM, Jiri Slaby <[email protected]> wrote:
>> >> >>> On 11/23/2010 01:29 PM, Marek Belisko wrote:
>> >> >>>> Use simple misc device for ioctl driver funtionality testing.
>> >> >>>>
>> >> >>>> Signed-off-by: Marek Belisko <[email protected]>
>> >> >>>> ---
>> >> >>>>  drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c |   90 ++++++++++++++++++---
>> >> >>>>  1 files changed, 77 insertions(+), 13 deletions(-)
>> >> >>>>
>> >> >>>> diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
>> >> >>>> index 1aec926..d1784a3 100644
>> >> >>>> --- a/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
>> >> >>>> +++ b/drivers/staging/ft1000/ft1000-usb/ft1000_chdev.c
>> >> >>>> @@ -32,6 +32,7 @@
>> >> >>>>  #include <linux/poll.h>
>> >> >>>>  #include <linux/netdevice.h>
>> >> >>>>  #include <linux/delay.h>
>> >> >>>> +#include <linux/miscdevice.h>
>> >> >>>>
>> >> >>>>  #include <linux/fs.h>
>> >> >>>>  #include <linux/kmod.h>
>> >> >>>> @@ -78,6 +79,47 @@ static struct file_operations ft1000fops =
>> >> >>>>       .llseek         = no_llseek,
>> >> >>>>  };
>> >> >>>>
>> >> >>>> +struct ft1000_misc_device {
>> >> >>>> +     struct miscdevice dev;
>> >> >>>> +     int inf_id;
>> >> >>>> +};
>> >> >>>> +
>> >> >>>> +#define FREE_ID (0xFF)
>> >> >>>> +
>> >> >>>> +/* we support just 3 devices */
>> >> >>>> +#define MAX_DEVICE 3
>> >> >>>
>> >> >>> No, why this should be converted to miscdevice? Leave it as chrdev.
>> >> >> Is there any problem with using miscdev?
>> >> >
>> >> > Yes, if you want more than a single device per system.
>> >> >
>> >> >> Old interface create /dev nodes with
>> >> >> calling kernel thread and some usermode_helper or whatever.
>> >> >
>> >> > Yes, that's crap indeed. But doesn't judge for miscdevice.
>> >> >
>> >> >> Just convert to misc dev
>> >> >> where this is done automatically.
>> >> >
>> >> > So the only thing you need to do is to send a uevent to udev appropriately.
>> >> Could be used something like:
>> >> register_chrdev(0,"ft1000", &fops)
>> >> class = class_create(THIS_MODULE, "ft1000");
>> >> device_create(class, NULL, MKDEV(major, i), NULL, "ft1000%d", i);
>> >> Then will be created different devices for every plugged device.
>> >> This should have effect of automatic device node creation also suppose.
>> >
>> > Please don't create new classes.
>> >
>> > Is this a USB device?  If so, why not just use the USB major number?
>> Yes it is USB device.
>> > Just ask me and I can reserve you a USB minor number for your driver.
>> Idea behind existing code is that for every plugged device you will have created
>> /dev node. NUmber of devices was limited by number of plugged devices.
>> But who will plug more
>> then one device which just used for internet connection? So maybe I
>> should implement some
>> limit and would be nice if you could reserve me some USB minors (lest
>> say max. 3 devices?).
>
> Send me a patch using the USB major number, and I'll add an additional
> one that reserves the proper minor number for your driver.
Patch sent (subject: [PATCH] staging: ft1000: Use usb device registration.)
>
> thanks,
>
> greg k-h
>

thanks,

marek

--
as simple and primitive as possible
-------------------------------------------------
Marek Belisko - OPEN-NANDRA
Freelance Developer

Ruska Nova Ves 219 | Presov, 08005 Slovak Republic
Tel: +421 915 052 184
skype: marekwhite
icq: 290551086
web: http://open-nandra.com