setup.c (94bd217e2d683719ab21a4ac117d8a1b91cbedc9) | setup.c (269a3eb1bf10a078ede74747a61603693a3f7853) |
---|---|
1/* 2 * Based on linux/arch/mips/txx9/rbtx4938/setup.c, 3 * and RBTX49xx patch from CELF patch archive. 4 * 5 * 2003-2005 (c) MontaVista Software, Inc. 6 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007 7 * 8 * This file is subject to the terms and conditions of the GNU General Public --- 8 unchanged lines hidden (view full) --- 17#include <linux/module.h> 18#include <linux/clk.h> 19#include <linux/err.h> 20#include <linux/gpio.h> 21#include <linux/platform_device.h> 22#include <linux/serial_core.h> 23#include <linux/mtd/physmap.h> 24#include <linux/leds.h> | 1/* 2 * Based on linux/arch/mips/txx9/rbtx4938/setup.c, 3 * and RBTX49xx patch from CELF patch archive. 4 * 5 * 2003-2005 (c) MontaVista Software, Inc. 6 * (C) Copyright TOSHIBA CORPORATION 2000-2001, 2004-2007 7 * 8 * This file is subject to the terms and conditions of the GNU General Public --- 8 unchanged lines hidden (view full) --- 17#include <linux/module.h> 18#include <linux/clk.h> 19#include <linux/err.h> 20#include <linux/gpio.h> 21#include <linux/platform_device.h> 22#include <linux/serial_core.h> 23#include <linux/mtd/physmap.h> 24#include <linux/leds.h> |
25#include <linux/sysdev.h> | 25#include <linux/device.h> |
26#include <linux/slab.h> 27#include <linux/irq.h> 28#include <asm/bootinfo.h> 29#include <asm/time.h> 30#include <asm/reboot.h> 31#include <asm/r4kcache.h> 32#include <asm/sections.h> 33#include <asm/txx9/generic.h> --- 858 unchanged lines hidden (view full) --- 892 893 if (!pdev || 894 platform_device_add_resources(pdev, res, ARRAY_SIZE(res)) || 895 platform_device_add(pdev)) 896 platform_device_put(pdev); 897#endif 898} 899 | 26#include <linux/slab.h> 27#include <linux/irq.h> 28#include <asm/bootinfo.h> 29#include <asm/time.h> 30#include <asm/reboot.h> 31#include <asm/r4kcache.h> 32#include <asm/sections.h> 33#include <asm/txx9/generic.h> --- 858 unchanged lines hidden (view full) --- 892 893 if (!pdev || 894 platform_device_add_resources(pdev, res, ARRAY_SIZE(res)) || 895 platform_device_add(pdev)) 896 platform_device_put(pdev); 897#endif 898} 899 |
900static struct sysdev_class txx9_sramc_sysdev_class; | 900static struct bus_type txx9_sramc_subsys = { 901 .name = "txx9_sram", 902 .dev_name = "txx9_sram", 903}; |
901 | 904 |
902struct txx9_sramc_sysdev { 903 struct sys_device dev; | 905struct txx9_sramc_dev { 906 struct device dev; |
904 struct bin_attribute bindata_attr; 905 void __iomem *base; 906}; 907 908static ssize_t txx9_sram_read(struct file *filp, struct kobject *kobj, 909 struct bin_attribute *bin_attr, 910 char *buf, loff_t pos, size_t size) 911{ | 907 struct bin_attribute bindata_attr; 908 void __iomem *base; 909}; 910 911static ssize_t txx9_sram_read(struct file *filp, struct kobject *kobj, 912 struct bin_attribute *bin_attr, 913 char *buf, loff_t pos, size_t size) 914{ |
912 struct txx9_sramc_sysdev *dev = bin_attr->private; | 915 struct txx9_sramc_dev *dev = bin_attr->private; |
913 size_t ramsize = bin_attr->size; 914 915 if (pos >= ramsize) 916 return 0; 917 if (pos + size > ramsize) 918 size = ramsize - pos; 919 memcpy_fromio(buf, dev->base + pos, size); 920 return size; 921} 922 923static ssize_t txx9_sram_write(struct file *filp, struct kobject *kobj, 924 struct bin_attribute *bin_attr, 925 char *buf, loff_t pos, size_t size) 926{ | 916 size_t ramsize = bin_attr->size; 917 918 if (pos >= ramsize) 919 return 0; 920 if (pos + size > ramsize) 921 size = ramsize - pos; 922 memcpy_fromio(buf, dev->base + pos, size); 923 return size; 924} 925 926static ssize_t txx9_sram_write(struct file *filp, struct kobject *kobj, 927 struct bin_attribute *bin_attr, 928 char *buf, loff_t pos, size_t size) 929{ |
927 struct txx9_sramc_sysdev *dev = bin_attr->private; | 930 struct txx9_sramc_dev *dev = bin_attr->private; |
928 size_t ramsize = bin_attr->size; 929 930 if (pos >= ramsize) 931 return 0; 932 if (pos + size > ramsize) 933 size = ramsize - pos; 934 memcpy_toio(dev->base + pos, buf, size); 935 return size; 936} 937 938void __init txx9_sramc_init(struct resource *r) 939{ | 931 size_t ramsize = bin_attr->size; 932 933 if (pos >= ramsize) 934 return 0; 935 if (pos + size > ramsize) 936 size = ramsize - pos; 937 memcpy_toio(dev->base + pos, buf, size); 938 return size; 939} 940 941void __init txx9_sramc_init(struct resource *r) 942{ |
940 struct txx9_sramc_sysdev *dev; | 943 struct txx9_sramc_dev *dev; |
941 size_t size; 942 int err; 943 | 944 size_t size; 945 int err; 946 |
944 if (!txx9_sramc_sysdev_class.name) { 945 txx9_sramc_sysdev_class.name = "txx9_sram"; 946 err = sysdev_class_register(&txx9_sramc_sysdev_class); 947 if (err) { 948 txx9_sramc_sysdev_class.name = NULL; 949 return; 950 } 951 } | 947 err = subsys_system_register(&txx9_sramc_subsys, NULL); 948 if (err) 949 return; |
952 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 953 if (!dev) 954 return; 955 size = resource_size(r); 956 dev->base = ioremap(r->start, size); 957 if (!dev->base) 958 goto exit; | 950 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 951 if (!dev) 952 return; 953 size = resource_size(r); 954 dev->base = ioremap(r->start, size); 955 if (!dev->base) 956 goto exit; |
959 dev->dev.cls = &txx9_sramc_sysdev_class; | 957 dev->dev.bus = &txx9_sramc_subsys; |
960 sysfs_bin_attr_init(&dev->bindata_attr); 961 dev->bindata_attr.attr.name = "bindata"; 962 dev->bindata_attr.attr.mode = S_IRUSR | S_IWUSR; 963 dev->bindata_attr.read = txx9_sram_read; 964 dev->bindata_attr.write = txx9_sram_write; 965 dev->bindata_attr.size = size; 966 dev->bindata_attr.private = dev; | 958 sysfs_bin_attr_init(&dev->bindata_attr); 959 dev->bindata_attr.attr.name = "bindata"; 960 dev->bindata_attr.attr.mode = S_IRUSR | S_IWUSR; 961 dev->bindata_attr.read = txx9_sram_read; 962 dev->bindata_attr.write = txx9_sram_write; 963 dev->bindata_attr.size = size; 964 dev->bindata_attr.private = dev; |
967 err = sysdev_register(&dev->dev); | 965 err = device_register(&dev->dev); |
968 if (err) 969 goto exit; 970 err = sysfs_create_bin_file(&dev->dev.kobj, &dev->bindata_attr); 971 if (err) { | 966 if (err) 967 goto exit; 968 err = sysfs_create_bin_file(&dev->dev.kobj, &dev->bindata_attr); 969 if (err) { |
972 sysdev_unregister(&dev->dev); | 970 device_unregister(&dev->dev); |
973 goto exit; 974 } 975 return; 976exit: 977 if (dev) { 978 if (dev->base) 979 iounmap(dev->base); 980 kfree(dev); 981 } 982} | 971 goto exit; 972 } 973 return; 974exit: 975 if (dev) { 976 if (dev->base) 977 iounmap(dev->base); 978 kfree(dev); 979 } 980} |