public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Curt Brune <curt@cumulusnetworks.com>
To: Laszlo Papp <lpapp@kde.org>
Cc: Wolfram Sang <wsa@the-dreams.de>,
	Thomas De Schampheleire <patrickdepinguin@gmail.com>,
	gregkh@linuxfoundation.org,
	Shrijeet Mukherjee <shm@cumulusnetworks.com>,
	linux-i2c@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] Create eeprom_dev hardware class for EEPROM devices
Date: Fri, 24 Jan 2014 11:27:42 -0800	[thread overview]
Message-ID: <20140124192742.GU29955@cumulusnetworks.com> (raw)
In-Reply-To: <CAOMwXhMfd8uw8n2Oa_BKW8UGzrUttD1L3=ATUGyDJMFy3kPUjQ@mail.gmail.com>

On Fri Jan 24 18:42, Laszlo Papp wrote:
> > Note: The class cannot be called 'eeprom' as that is the name of the
> > I/O file created by the driver.  The class name appears as a
> > sub-directory within the main device directory.  Hence the class name
> > 'eeprom_dev'.
> 
> I am not sure I follow the reasoning here, but it is possibly because
> I lack some knowledge. Could you please describe bad thing would
> happen if "/sys/class/eeprom/eeprom0/label" would be used as opposed
> to "/sys/class/eeprom_dev/eeprom0/label"?

By way of example -- let's say I have an at24 device on i2c bus 2,
with address 0x54.  In sysfs the device can be found by its bus
address as:

  $ cd /sys/bus/i2c/devices/2-0054
  $ ls -l

  total 0
  lrwxrwxrwx 1 root root    0 Jan 24 19:11 driver ->  ../../../../../../bus/i2c/drivers/at24
  -rw------- 1 root root  256 Jan 23 23:33 eeprom
  drwxr-xr-x 3 root root    0 Jan 23 23:33 eeprom_dev
  -r--r--r-- 1 root root 4096 Jan 24 19:11 modalias
  -r--r--r-- 1 root root 4096 Jan 24 19:11 name
  lrwxrwxrwx 1 root root    0 Jan 24 19:11 subsystem ->  ../../../../../../bus/i2c
  -rw-r--r-- 1 root root 4096 Jan 24 19:11 uevent

The file "/sys/bus/i2c/devices/2-0054/eeprom" comes from the at24
driver.  That is the file name the EEPROM driver exports for I/O to
the device.  User space applications read/write this file to
read/write the physical EEPROM via the at24 driver.

The directory "/sys/bus/i2c/devices/2-0054/eeprom_dev" comes from the
sysfs class name "eeprom_dev".  All sysfs class names appear as
directories with the corresponding device directory.

See the conflict?  If the class was also called "eeprom" it would
clash with the existing "eeprom" file.  There cannot be two things
named /sys/bus/i2c/devices/2-0054/eeprom.

The files under /sys/class/eeprom_dev are symlinks to the "eeprom_dev"
directories of the physical devices.  For this example:

  $ cd /sys/class/eeprom_dev
  $ ls -l eeprom0
  lrwxrwxrwx 1 root root 0 Jan 23 23:33 eeprom0 -> ../../devices/soc.0/ffe03000.i2c/i2c-0/i2c-2/2-0054/eeprom_dev/eeprom0

Believe me I wanted to use "eeprom" as the class name originally, as
it makes a lot of sense.  But the sysfs file creation failed due to
the duplicate name.

I was not about to change the at24 driver as user space expects the
"eeprom" name.

Hence the class name is eeprom_dev.

Hope that helps.

Cheers,
Curt

  reply	other threads:[~2014-01-24 19:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-23 19:16 [PATCH v2 1/2] Create eeprom_dev hardware class for EEPROM devices Curt Brune
2014-01-24 18:42 ` Laszlo Papp
2014-01-24 19:27   ` Curt Brune [this message]
2014-01-24 20:19     ` Laszlo Papp
2014-01-25  0:23 ` Andy Lutomirski
2014-02-11 13:03   ` Laszlo Papp
2014-04-07  9:09 ` Maxime Ripard

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=20140124192742.GU29955@cumulusnetworks.com \
    --to=curt@cumulusnetworks.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lpapp@kde.org \
    --cc=patrickdepinguin@gmail.com \
    --cc=shm@cumulusnetworks.com \
    --cc=wsa@the-dreams.de \
    /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