hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/debugfs/file.c
....@@ -378,8 +378,8 @@
378378 }
379379 EXPORT_SYMBOL_GPL(debugfs_attr_read);
380380
381
-ssize_t debugfs_attr_write(struct file *file, const char __user *buf,
382
- size_t len, loff_t *ppos)
381
+static ssize_t debugfs_attr_write_xsigned(struct file *file, const char __user *buf,
382
+ size_t len, loff_t *ppos, bool is_signed)
383383 {
384384 struct dentry *dentry = F_DENTRY(file);
385385 ssize_t ret;
....@@ -387,11 +387,27 @@
387387 ret = debugfs_file_get(dentry);
388388 if (unlikely(ret))
389389 return ret;
390
- ret = simple_attr_write(file, buf, len, ppos);
390
+ if (is_signed)
391
+ ret = simple_attr_write_signed(file, buf, len, ppos);
392
+ else
393
+ ret = simple_attr_write(file, buf, len, ppos);
391394 debugfs_file_put(dentry);
392395 return ret;
393396 }
397
+
398
+ssize_t debugfs_attr_write(struct file *file, const char __user *buf,
399
+ size_t len, loff_t *ppos)
400
+{
401
+ return debugfs_attr_write_xsigned(file, buf, len, ppos, false);
402
+}
394403 EXPORT_SYMBOL_GPL(debugfs_attr_write);
404
+
405
+ssize_t debugfs_attr_write_signed(struct file *file, const char __user *buf,
406
+ size_t len, loff_t *ppos)
407
+{
408
+ return debugfs_attr_write_xsigned(file, buf, len, ppos, true);
409
+}
410
+EXPORT_SYMBOL_GPL(debugfs_attr_write_signed);
395411
396412 static struct dentry *debugfs_create_mode_unsafe(const char *name, umode_t mode,
397413 struct dentry *parent, void *value,
....@@ -748,11 +764,11 @@
748764 *val = atomic_read((atomic_t *)data);
749765 return 0;
750766 }
751
-DEFINE_DEBUGFS_ATTRIBUTE(fops_atomic_t, debugfs_atomic_t_get,
767
+DEFINE_DEBUGFS_ATTRIBUTE_SIGNED(fops_atomic_t, debugfs_atomic_t_get,
752768 debugfs_atomic_t_set, "%lld\n");
753
-DEFINE_DEBUGFS_ATTRIBUTE(fops_atomic_t_ro, debugfs_atomic_t_get, NULL,
769
+DEFINE_DEBUGFS_ATTRIBUTE_SIGNED(fops_atomic_t_ro, debugfs_atomic_t_get, NULL,
754770 "%lld\n");
755
-DEFINE_DEBUGFS_ATTRIBUTE(fops_atomic_t_wo, NULL, debugfs_atomic_t_set,
771
+DEFINE_DEBUGFS_ATTRIBUTE_SIGNED(fops_atomic_t_wo, NULL, debugfs_atomic_t_set,
756772 "%lld\n");
757773
758774 /**