本文主要介绍
在android系统的TP驱动中,生成device节点,,,
通过cat 节点来获取TP的FW版本
主要函数
device_create_file(dev,&ft5626_attrs[t]);
static struct device_attribute ft5626_attrs[] = {
__ATTR(touch_version, S_IRWXU| S_IRWXG| S_IRWXO, ft5626_version_show, ft5626_version_store),
static ssize_t ft5626_version_show(struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t ft5626_version_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t _count)
#define FACTORY_DEBUG 1
#ifdef FACTORY_DEBUG
unsigned char uc_reg_value;
unsigned char uc_reg_addr;
#ifdef FACTORY_DEBUG
static ssize_t ft5626_version_show(struct device *dev, struct device_attribute *attr, char *buf)
{
int err;
uc_reg_addr = FTS_REG_FW_VER;
err = fts_i2c_read(fts_i2c_client, &uc_reg_addr, 1, &uc_reg_value, 1);
if (err < 0) {
printk("[FTS] get FW version failed.\n");
uc_reg_value = 0;
}
return sprintf(buf, "%x\n", uc_reg_value);
}
static ssize_t ft5626_version_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t _count)
{
return _count;
}
static struct device_attribute ft5626_attrs[] = {
__ATTR(touch_version, S_IRWXU| S_IRWXG| S_IRWXO, ft5626_version_show, ft5626_version_store),
};
static int ft5626_create_sysfs(struct device *dev)
{
int r;
int t;
for (t = 0; t < ARRAY_SIZE(ft5626_attrs); t++)
{
r = device_create_file(dev,&ft5626_attrs[t]);
if (r)
{
dev_err(dev, "%s: failed to create sysfs file, error = %d\n", __func__, r);
return r;
}
}
return 0;
}#endif
//probe函数
#ifdef FACTORY_DEBUG
err = ft5626_create_sysfs(&client->dev);
if(err) {
dev_err(&client->dev, "failed to create FACTORY_DEBUG\n");
}
#endif
生成路径
/sys/devices/pci0000:00/808622C1:05/i2c-5/i2c-FTTH5506:00/touch_versio