I think I understand now.On 2019/8/28 äå11:22, Greg Kroah-Hartman wrote:
On Wed, Aug 28, 2019 at 09:27:56PM +0800, Zhangfei Gao wrote:
+struct uacce {At a quick glance, this problem really stood out to me. You CAN NOT
+ÂÂÂ const char *drv_name;
+ÂÂÂ const char *algs;
+ÂÂÂ const char *api_ver;
+ÂÂÂ unsigned int flags;
+ÂÂÂ unsigned long qf_pg_start[UACCE_QFRT_MAX];
+ÂÂÂ struct uacce_ops *ops;
+ÂÂÂ struct device *pdev;
+ÂÂÂ bool is_vf;
+ÂÂÂ u32 dev_id;
+ÂÂÂ struct cdev cdev;
+ÂÂÂ struct device dev;
+ÂÂÂ void *priv;
+ÂÂÂ atomic_t state;
+ÂÂÂ int prot;
+ÂÂÂ struct mutex q_lock;
+ÂÂÂ struct list_head qs;
+};
have two different objects within a structure that have different
lifetime rules and reference counts. You do that here with both a
'struct cdev' and a 'struct device'. Pick one or the other, but never
both.
I would recommend using a 'struct device' and then a 'struct cdev *'.
That way you get the advantage of using the driver model properly, and
then just adding your char device node pointer to "the side" which
interacts with this device.
Then you might want to call this "struct uacce_device" :)