/* under kernel */
#ifndef AML_NAND_UBOOT
-ssize_t dtb_show(struct class *class, struct class_attribute *attr,
- char *buf)
-{
- pr_info("dtb_show : #####\n");
- /* fixme, read back and show in log! */
- return 0;
-}
-
-ssize_t dtb_store(struct class *class, struct class_attribute *attr,
- const char *buf, size_t count)
-{
- int ret = 0;
- u8 *dtb_ptr = NULL;
-
- pr_info("dtb_store : #####\n");
- dtb_ptr = kzalloc(aml_chip_dtb->dtbsize, GFP_KERNEL);
- if (dtb_ptr == NULL) {
- pr_info("%s: malloc buf failed\n ", __func__);
- return -ENOMEM;
- }
- /* fixme, why read back then write? */
- ret = amlnf_dtb_read(dtb_ptr, aml_chip_dtb->dtbsize);
- if (ret) {
- pr_info("%s: read failed\n", __func__);
- kfree(dtb_ptr);
- return -EFAULT;
- }
-
- ret = amlnf_dtb_save(dtb_ptr, aml_chip_dtb->dtbsize);
- if (ret) {
- pr_info("%s: save failed\n", __func__);
- kfree(dtb_ptr);
- return -EFAULT;
- }
-
- pr_info("dtb_store : OK #####\n");
- return count;
-}
-
-static CLASS_ATTR(nfdtb, 0644, dtb_show, dtb_store);
int dtb_open(struct inode *node, struct file *file)
{
goto exit_err2;
}
- ret = class_create_file(amlnf_dtb_class, &class_attr_nfdtb);
- if (ret) {
- pr_info("%s dev add failed\n", __func__);
- ret = -1;
- goto exit_err2;
- }
-
dtb_dev_nand = device_create(amlnf_dtb_class,
NULL,
amlnf_dtb_no,
return ret;
exit_err3:
- class_remove_file(amlnf_dtb_class, &class_attr_nfdtb);
class_destroy(amlnf_dtb_class);
exit_err2:
cdev_del(&amlnf_dtb);
#ifndef CONFIG_MTD_ENV_IN_NAND
#ifndef AML_NAND_UBOOT
-ssize_t env_show(struct class *class, struct class_attribute *attr,
- char *buf)
-{
- pr_info("env_show : #####\n");
- return 0;
-}
-
-ssize_t env_store(struct class *class, struct class_attribute *attr,
- const char *buf, size_t count)
-{
- int ret = 0;
- u8 *env_ptr = NULL;
-
-
- env_ptr = kzalloc(CONFIG_ENV_SIZE, GFP_KERNEL);
- if (env_ptr == NULL)
- return -ENOMEM;
-
- mutex_lock(&env_mutex);
- pr_info("env_store : #####\n");
- ret = amlnf_env_read(env_ptr, CONFIG_ENV_SIZE);
- if (ret) {
- pr_info("nand_env_read: nand env read failed\n");
- kfree(env_ptr);
- return -EFAULT;
- }
-
- ret = amlnf_env_save(env_ptr, CONFIG_ENV_SIZE);
- if (ret) {
- pr_info("nand_env_read: nand env read failed\n");
- kfree(env_ptr);
- return -EFAULT;
- }
-
- pr_info("env_store : OK #####\n");
- mutex_unlock(&env_mutex);
- return count;
-}
-
-static CLASS_ATTR(env, 0644, env_show, env_store);
-
int uboot_env_open(struct inode *node, struct file *file)
{
return 0;
goto exit_err2;
}
- ret = class_create_file(uboot_env_class, &class_attr_env);
- if (ret) {
- pr_info("uboot env dev add failed\n");
- ret = -1;
- goto exit_err2;
- }
-
uboot_dev = device_create(uboot_env_class,
NULL,
uboot_env_no,
return ret;
exit_err3:
- class_remove_file(uboot_env_class, &class_attr_env);
class_destroy(uboot_env_class);
exit_err2:
cdev_del(&uboot_env);