forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/misc/eeprom/idt_89hpesx.c
....@@ -115,7 +115,6 @@
115115 * @client: i2c client used to perform IO operations
116116 *
117117 * @ee_file: EEPROM read/write sysfs-file
118
- * @csr_file: CSR read/write debugfs-node
119118 */
120119 struct idt_smb_seq;
121120 struct idt_89hpesx_dev {
....@@ -137,7 +136,6 @@
137136
138137 struct bin_attribute *ee_file;
139138 struct dentry *csr_dir;
140
- struct dentry *csr_file;
141139 };
142140
143141 /*
....@@ -942,14 +940,18 @@
942940 u32 csraddr, csrval;
943941 char *buf;
944942
943
+ if (*offp)
944
+ return 0;
945
+
945946 /* Copy data from User-space */
946947 buf = kmalloc(count + 1, GFP_KERNEL);
947948 if (!buf)
948949 return -ENOMEM;
949950
950
- ret = simple_write_to_buffer(buf, count, offp, ubuf, count);
951
- if (ret < 0)
951
+ if (copy_from_user(buf, ubuf, count)) {
952
+ ret = -EFAULT;
952953 goto free_buf;
954
+ }
953955 buf[count] = 0;
954956
955957 /* Find position of colon in the buffer */
....@@ -1378,8 +1380,8 @@
13781380 pdev->csr_dir = debugfs_create_dir(fname, csr_dbgdir);
13791381
13801382 /* Create Debugfs file for CSR read/write operations */
1381
- pdev->csr_file = debugfs_create_file(cli->name, 0600,
1382
- pdev->csr_dir, pdev, &csr_dbgfs_ops);
1383
+ debugfs_create_file(cli->name, 0600, pdev->csr_dir, pdev,
1384
+ &csr_dbgfs_ops);
13831385 }
13841386
13851387 /*