From: Antony Pavlov <antonynpavlov@gmail.com>
To: barebox@lists.infradead.org
Cc: Trent Piepho <tpiepho@kymetacorp.com>
Subject: [RFC] at24: get devfs name from dt aliase
Date: Fri, 27 Nov 2015 10:29:46 +0300 [thread overview]
Message-ID: <1448609386-25753-1-git-send-email-antonynpavlov@gmail.com> (raw)
At the moment barebox can't work correctly with more
that one at24 eeprom because drivers/eeprom/at24.c
tries to register all eeproms as /dev/eeprom0.
I have tested this on a system with three at24 eeproms,
please see this dts-file fragment:
&i2c0 {
status = "okay";
i2c-switch@70 {
compatible = "nxp,pca9545";
#address-cells = <1>;
#size-cells = <0>;
i2c-parent = <&i2c0>;
reg = <0x70>;
i2c@1 { /* misc devices */
reg = <1>;
eeprom: at24@50 {
compatible = "at24,24c1024";
reg = <0x50>;
};
};
i2c@2 { /* SPD */
reg = <2>;
spd: at24@53 {
compatible = "at24,spd";
reg = <0x53>;
};
};
i2c@3 { /* DVI/HDMI */
reg = <3>;
ddc: at24@50 {
compatible = "at24,24c02";
reg = <0x50>;
};
};
};
};
A possible solution is using aliases for naming devices
under dev/, e.g.:
/ {
aliases {
eeprom = &eeprom;
spd = &spd;
ddc = &ddc;
};
}
So we'll get these files in the /dev directory:
crw------- 256 /dev/ddc
crw------- 131072 /dev/eeprom
cr-------- 256 /dev/spd
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
drivers/eeprom/at24.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/eeprom/at24.c b/drivers/eeprom/at24.c
index 3c0a7a9..85fb035 100644
--- a/drivers/eeprom/at24.c
+++ b/drivers/eeprom/at24.c
@@ -379,6 +379,7 @@ static int at24_probe(struct device_d *dev)
struct at24_data *at24;
int err;
unsigned i, num_addresses;
+ const char *eeprom_name = NULL;
if (dev->platform_data) {
chip = *(struct at24_platform_data *)dev->platform_data;
@@ -429,7 +430,17 @@ static int at24_probe(struct device_d *dev)
at24->chip = chip;
at24->num_addresses = num_addresses;
- at24->cdev.name = asprintf("eeprom%d", dev->id);
+
+ if (dev->device_node) {
+ eeprom_name = of_alias_get(dev->device_node);
+ }
+
+ if (!eeprom_name) {
+ at24->cdev.name = asprintf("eeprom%d", dev->id);
+ } else {
+ at24->cdev.name = eeprom_name;
+ }
+
at24->cdev.priv = at24;
at24->cdev.dev = dev;
at24->cdev.ops = &at24->fops;
--
2.6.2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next reply other threads:[~2015-11-27 7:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-27 7:29 Antony Pavlov [this message]
2015-11-27 8:37 ` Trent Piepho
2015-11-30 7:16 ` Sascha Hauer
2015-11-30 18:10 ` Trent Piepho
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1448609386-25753-1-git-send-email-antonynpavlov@gmail.com \
--to=antonynpavlov@gmail.com \
--cc=barebox@lists.infradead.org \
--cc=tpiepho@kymetacorp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox