linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Pilcher <arequipeno@gmail.com>
To: linux-ide@vger.kernel.org
Subject: Monkey-patching libahci
Date: Mon, 14 Jul 2014 13:30:57 -0500	[thread overview]
Message-ID: <lq17mj$40p$1@ger.gmane.org> (raw)

I have a Thecus N5550 NAS with an ICH10R AHCI controller.  5 of the AHCI
ports are used for "data" drives, and each of these has an activity LED
which is driven by one of the ICH GPIOs.  (The other AHCI port is used
by the internal SATA DOM.)

In order to make the LEDs actually blink, I am wrapping libahci's
qc_issue function to blink the LED that corresponds to a given command's
port (if any):


https://github.com/ipilcher/n5550/blob/master/modules/n5550_ahci_leds.c#L177

I "hook in" the wrapper function by ensuring that my module is loaded
immediately after libahci (via modprobe configuration) and directly
modifying ahci_ops.qc_issue.  I do everything I can think of to make
sure that no other libahci users are loaded while I'm making the
changes.


https://github.com/ipilcher/n5550/blob/master/modules/n5550_ahci_leds.c#L207

I also prevent my module from being unloaded when any other libahci
users are loaded.  The module keeps an additional reference to itself,
which is released when the hook is successfully disabled via sysfs.


https://github.com/ipilcher/n5550/blob/master/modules/n5550_ahci_leds.c#L79

This definitely works, and it allows me to use pre-packaged kernels on
this system (ELRepo kernel-lt on CentOS 6 and hopefully the CentOSPlus
kernel on CentOS 7), but it sure does feel ugly and hackish.

Short of patching and rebuilding the libahci or ahci modules, is there a
better way to do this?  (Keeping in mind that I'm not worried about
supporting any other hardware configuration.)

Thanks!

-- 
========================================================================
Ian Pilcher                                         arequipeno@gmail.com
-------- "I grew up before Mark Zuckerberg invented friendship" --------
========================================================================


                 reply	other threads:[~2014-07-14 18:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='lq17mj$40p$1@ger.gmane.org' \
    --to=arequipeno@gmail.com \
    --cc=linux-ide@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).