[systemd-devel] [PATCH] udev: Make builtin firmware to find in subdirectories

2013-06-17 Thread WaLyong Cho
From: WaLyong Cho walyong@samsung.com

We can specify firmware path using --with-firmware-path configure
option.
In some of system, firmware can be located in subdirectories of the
firmware path.
If there are many firmware directories in below specified path then we
have to define those to --with-firmware-path.
To avoid this, if builtin firmware could not find firmware in specified
directories then try to find firmware in subdirectories.

Signed-off-by: WaLyong Cho walyong@samsung.com
---
 src/udev/udev-builtin-firmware.c |   33 +
 1 file changed, 33 insertions(+)

diff --git a/src/udev/udev-builtin-firmware.c b/src/udev/udev-builtin-firmware.c
index b80940b..fb43a37 100644
--- a/src/udev/udev-builtin-firmware.c
+++ b/src/udev/udev-builtin-firmware.c
@@ -74,6 +74,34 @@ exit:
 return ret;
 }
 
+static FILE* find_firmware(const char *path, const char *fwpath, const char 
*firmware)
+{
+char searchpath[UTIL_PATH_SIZE];
+FILE *fwfile = NULL;
+DIR *srcdir;
+struct dirent *dent;
+struct stat statbuf;
+
+srcdir = opendir(path);
+while ((dent = readdir(srcdir)) != NULL) {
+if (strcmp(dent-d_name, .) == 0 || strcmp(dent-d_name, 
..) == 0)
+continue;
+if (fstatat(dirfd(srcdir), dent-d_name, statbuf, 0)  0)
+continue;
+if (S_ISDIR(statbuf.st_mode)) {
+strscpyl(fwpath, UTIL_PATH_SIZE, path, dent-d_name, 
/, firmware, NULL);
+fwfile = fopen(fwpath, re);
+if (fwfile == NULL) {
+strscpyl(searchpath, UTIL_PATH_SIZE, path, 
dent-d_name, /, NULL);
+fwfile = find_firmware(searchpath, fwpath, 
firmware);
+}
+if (fwfile != NULL)
+return fwfile;
+}
+}
+return NULL;
+}
+
 static int builtin_firmware(struct udev_device *dev, int argc, char *argv[], 
bool test)
 {
 struct udev *udev = udev_device_get_udev(dev);
@@ -107,6 +135,11 @@ static int builtin_firmware(struct udev_device *dev, int 
argc, char *argv[], boo
 fwfile = fopen(fwpath, re);
 if (fwfile != NULL)
 break;
+else {
+fwfile = find_firmware(searchpath[i], fwpath, 
firmware);
+if (fwfile != NULL)
+break;
+}
 }
 
 strscpyl(loadpath, sizeof(loadpath), udev_device_get_syspath(dev), 
/loading, NULL);
-- 
1.7.9.5

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] udev: Make builtin firmware to find in subdirectories

2013-06-17 Thread Kay Sievers
On Mon, Jun 17, 2013 at 8:17 AM, WaLyong Cho fyd0...@gmail.com wrote:
 We can specify firmware path using --with-firmware-path configure
 option.

This was configurable because some systems had no /lib directory, it
is not meant to carry device or driver specific directories.

 In some of system, firmware can be located in subdirectories of the
 firmware path.

Sure, but the request of the firware would carry the subdirectory. Why
would systems do that otherwise? It does not sound right.

 If there are many firmware directories in below specified path then we
 have to define those to --with-firmware-path.

I don't understand this. The non-kernel-version subdirectories should
be included in the kernel request, not added by the firmware loader.

 To avoid this, if builtin firmware could not find firmware in specified
 directories then try to find firmware in subdirectories.

This is incompatible with the current in-kernel loader which works
without any userspace helper. Things should really not work the way
the patch introduces. Leading directories should be added to the
kernel firmware request, not searched the firmware loader.

Btw, the entire userspace firmware loading is already disabled by
default in the udev sources, and will be entirely removed in the near
future. Firmware will not be loaded by userspace anymore.

Thanks,
Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] udev: Make builtin firmware to find in subdirectories

2013-06-17 Thread Greg KH
On Mon, Jun 17, 2013 at 03:17:12PM +0900, WaLyong Cho wrote:
 From: WaLyong Cho walyong@samsung.com
 
 We can specify firmware path using --with-firmware-path configure
 option.
 In some of system, firmware can be located in subdirectories of the
 firmware path.
 If there are many firmware directories in below specified path then we
 have to define those to --with-firmware-path.
 To avoid this, if builtin firmware could not find firmware in specified
 directories then try to find firmware in subdirectories.

Ick, how is the kernel handling all of this, now that it does this type
of thing instead of udev doing it?

We are thinking of adding multiple paths to find firmware to the kernel,
but for subdirectories?  No, the driver should be passing a sane name to
the firmware subsystem, no need to be digging through the disk like
this.

In fact, we should really just delete the firmware logic from udev
entirely now that the kernel doesn't even call it anymore, right?

thanks,

greg k-h
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] udev: Make builtin firmware to find in subdirectories

2013-06-17 Thread Tom Gundersen
On Mon, Jun 17, 2013 at 9:57 PM, Greg KH gre...@linuxfoundation.org wrote:
 In fact, we should really just delete the firmware logic from udev
 entirely now that the kernel doesn't even call it anymore, right?

This fimware logic is not compiled by default, but for people with old
kernels it can be enabled with a configure switch. Maybe rip it out
next time we bump the kernel version requirement?

-t
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] udev: Make builtin firmware to find in subdirectories

2013-06-17 Thread Greg KH
On Mon, Jun 17, 2013 at 10:23:53PM +0200, Tom Gundersen wrote:
 On Mon, Jun 17, 2013 at 9:57 PM, Greg KH gre...@linuxfoundation.org wrote:
  In fact, we should really just delete the firmware logic from udev
  entirely now that the kernel doesn't even call it anymore, right?
 
 This fimware logic is not compiled by default, but for people with old
 kernels it can be enabled with a configure switch. Maybe rip it out
 next time we bump the kernel version requirement?

Sounds good to me, given the upcoming cgroup changes, perhaps that would
be the good time to do it?

thanks,

greg k-h
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] udev: Make builtin firmware to find in subdirectories

2013-06-17 Thread Kay Sievers
On Mon, Jun 17, 2013 at 10:31 PM, Greg KH gre...@linuxfoundation.org wrote:
 On Mon, Jun 17, 2013 at 10:23:53PM +0200, Tom Gundersen wrote:
 On Mon, Jun 17, 2013 at 9:57 PM, Greg KH gre...@linuxfoundation.org wrote:
  In fact, we should really just delete the firmware logic from udev
  entirely now that the kernel doesn't even call it anymore, right?

 This fimware logic is not compiled by default, but for people with old
 kernels it can be enabled with a configure switch. Maybe rip it out
 next time we bump the kernel version requirement?

 Sounds good to me, given the upcoming cgroup changes, perhaps that would
 be the good time to do it?

Yeah, It will be deleted entirely as soon as any other thing requires
a newer kernel which also has the in-kernel firmware loader. Currently
it is 2.6.39.

Kay
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel