Re: controlling LED's on USB flash drives

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




----- Original Message ----
From: Mandeep Sandhu <mandeep.stinger@xxxxxxxxx>
To: Sharath <sharath_75@xxxxxxxxx>
Cc: kernelnewbies <kernelnewbies@xxxxxxxxxxxx>
Sent: Tuesday, April 18, 2006 7:55:50 PM
Subject: Re: controlling LED's on USB flash drives

On 4/18/06, Sharath <sharath_75@xxxxxxxxx> wrote:
>
>
> ----- Original Message ----
> From: Mandeep Sandhu <mandeep.stinger@xxxxxxxxx>
> To: Sharath <sharath_75@xxxxxxxxx>
> Cc: kernelnewbies <kernelnewbies@xxxxxxxxxxxx>
> Sent: Tuesday, April 18, 2006 5:20:51 PM
> Subject: Re: controlling LED's on USB flash drives
>
> On 4/18/06, Sharath <sharath_75@xxxxxxxxx> wrote:
> > Hi Mandeep,
> >
> > ----- Original Message ----
> > From: Mandeep Sandhu <mandeep.stinger@xxxxxxxxx>
> > To: kernelnewbies <kernelnewbies@xxxxxxxxxxxx>
> > Sent: Tuesday, April 18, 2006 3:52:50 PM
> > Subject: Re: controlling LED's on USB flash drives
> >
> > On 4/18/06, Greg KH <greg@xxxxxxxxx> wrote:
> > > On Tue, Apr 18, 2006 at 10:26:05AM +0530, Mandeep Sandhu wrote:
> > > > Hi all,
> > > >
> > > > How does one control the behavior of the LED's present on the various usb
> > > > flash drives. Is it controlled solely by software or is it like that
> > > > the usb host controller
> > > > controls the LED's operation. eg: when I write to my flash drive the
> > > > the LED blinks.
> > > > Is this done via some usb driver or does the usb host controller does
> > > > that for us
> > > > when we issue a write command to the drive? Is usbled.c under drivers/usb/misc
> > > > responsible for controlling this operation? Any pointers are welcome.
> > >
> > > No, there is no way to control it, it's up to the device itself.
> >
> > Well, Greg, the reason I was asking was because I wanted to know if the LED
> > of my drive could be switched off when I umount it. In windows I noticed that
> > the LED is switched off when the drive is ready to be unplugged. Is it that they
> > might be removing power to the drive? Could we acheive a similar result?
> >
> > This would depend on the electronics of the drive however, the LED status is set by the controller on the USB device. This status is commnunicated to it by the UBS protocol. Whena device is inserted, there are softwrae drivers that control the device and later it is mount onto a location in the filesystem.
> >
> >  The two drivers for the hardware are:
> >  ehci_hcd
> >  uhci_hcd
>
> You're correct. Removing ehci_hcd switched off the LED. I guess
> removing this module
> must be powering off the device. I'll look into the cleanup code to
> confirm this.
>
> Thanks.
>
> The only problem being that modules is used to control the other usb devices - mouse etc nd would cause them to cease functioning..
>

Does the host controller provide a way to switch off the LED? are it's
specs freely available?
I hope I'm not pestering you guys too much with this LED prob. ! :)
But I'd like to see
it go off when I umount my drive...as it gives a descent visual
indication that the drive
can be safely removed (of course all this only if there's a clean way
of doing it).

You want to windows way of doing things i.e. all lights go off and it is safe to remove the device.
 
 The way the device works is:
 plug it in
 - hardware informs the OS of a new device
 - OS loads up the driver for that device to initialize the device and estabilish a means of communication
 - OS then performs a task associated to that device
 
 in our case the task associated is to mount a filesystem and map it
 
 the mount command essentially says 'here use this device and make it mappapable as a filesystem a particular filesystem (in case of USB its vfat)'
 
 you could verify this by a dmesg to see the output of the driver when you insert the device
 
 when you perform an umount of the filesystem, the buffers are flushed and the device is no longer mapped as a filesystem
 
 however the device is still connected to the computer... and the driver is still active...
 
 when you perform the rmmod ehci_hcd, the driver is then unloaded and the device is no longer connected to the system.. this is when the LED goes off.. as the USB controller relays the command to the USB device.. however the safe time to remove the device is after a umount...
 
 On windows the same thing happens.. a device can be unloaded only by a priviledged user... if certain access right are not granted to the user, the driver cannot be removed... I've seen this happen on system configured that way..
 
 one alternative however is to provide the user the capability to unload the module... 
 
 essentially if you want to know when the safe time to remove the device is .. you can say its after the umount.. the umount does flush the buffer.. however if your objective is to make the LED turn off.. then you need to write a driver and or a mechanism that unloads the device after an unmount.. 
 
 -Sharath
 



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux