diff options
author | Matthew Bouyack <mbouyack@google.com> | 2020-11-24 14:29:03 -0800 |
---|---|---|
committer | Andrew Evans <andrewevans@google.com> | 2022-03-09 15:04:44 -0800 |
commit | 5c2f42f77e074afc703d26ba91712f26c642857c (patch) | |
tree | 0c6a0dff20b607d10bd69bc7bcb16c19c972f4df /ots_pat9126 | |
parent | 8e55f7af65a634b1bef7ce9af58e2714604b4c38 (diff) | |
download | rotary-encoders-5c2f42f77e074afc703d26ba91712f26c642857c.tar.gz |
Add crown ID to sysfs
Bug: 173175887
Change-Id: Id2d367f35a77df4f28e408aacb51a8e2cc53bbdd
Diffstat (limited to 'ots_pat9126')
-rw-r--r-- | ots_pat9126/pat9126.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ots_pat9126/pat9126.c b/ots_pat9126/pat9126.c index 307647a..153f22d 100644 --- a/ots_pat9126/pat9126.c +++ b/ots_pat9126/pat9126.c @@ -416,11 +416,32 @@ static ssize_t pat9126_sensitivity_show(struct device *dev, return count; } +static ssize_t pat9126_id_show(struct device *dev, + struct device_attribute *attr, + char *buf) { + int count = 0; + uint8_t maj, min; + + struct pixart_pat9126_data *data = + (struct pixart_pat9126_data *) dev_get_drvdata(dev); + struct i2c_client *client = data->client; + + pat9126_read(client, PIXART_PAT9126_PRODUCT_ID1_REG, &maj); + pat9126_read(client, PIXART_PAT9126_PRODUCT_ID2_REG, &min); + count += sprintf(buf, "0x%2x 0x%2x\n", maj, min); + + return count; +} + static DEVICE_ATTR (crown_sensitivity, S_IRUGO | S_IWUSR | S_IWGRP, pat9126_sensitivity_show, pat9126_sensitivity_store); +static DEVICE_ATTR + (id, S_IRUGO, pat9126_id_show, NULL); + static struct attribute *pat9126_attr_list[] = { &dev_attr_crown_sensitivity.attr, + &dev_attr_id.attr, NULL, }; |