mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Martin Schlemmer <azarah@gentoo.org>
To: Linux Kernel Mailing Lists <linux-kernel@vger.kernel.org>
Cc: Sam Ravnborg <sam@ravnborg.org>,
	"Prakash K. Cheemplavam" <PrakashKC@gmx.de>,
	linux-hotplug-devel@lists.sourceforge.net,
	Greg KH <greg@kroah.com>,
	zander@mail.minion.de
Subject: Re: [ANNOUNCE] udev 015 release
Date: Sun, 01 Feb 2004 17:24:07 +0200	[thread overview]
Message-ID: <1075649046.24826.8.camel@nosferatu.lan> (raw)
In-Reply-To: <20040130172310.GB5265@kroah.com>


[-- Attachment #1.1: Type: text/plain, Size: 1255 bytes --]

On Fri, 2004-01-30 at 19:23, Greg KH wrote:
> On Fri, Jan 30, 2004 at 05:45:41PM +0100, Prakash K. Cheemplavam wrote:
> > Hi Greg,
> > 
> > perhaps you remember me being a gentoo user wanting to switch to udev. 
> > Well I did so, but am having some problems:
> > 
> > 1.) Minor one: Nodes for Nvidia (I am using binary display modules 
> > 1.0.5328) ar not created. I have to do it by hand each start-up (written 
> > into loacal.start.):
> > mknod /dev/nvidia0 c 195 0
> > mknod /dev/nvidiactl c 195 255
> 
> Heh, and you expect me to be able to modify a binary driver to work with
> udev how?  :)
> 
> You're on your own here...
> 

No offense, but you guys sometimes really see things as too black and
white :)

Its only the high level api calls that are in binary object files, but
the main interface to the kernel is source that needs compiling.  I have
a patch attached here that adds basic sysfs support via the class_simple
functions.

It works as expected, only problem is kbuild seems to ignore
EXTRA_CFLAGS?  If I remove the 'defined(HAVE_CLASS_SIMPLE), or
use the attached non-kbuild Makefile, it works just fine.  Anybody
have an idea bout the EXTRA_CFLAGS issue?


Cheers,

-- 

Martin Schlemmer




[-- Attachment #1.2: NVIDIA-Linux-x86-1.0-5336-basic-sysfs-support.patch --]
[-- Type: text/x-patch, Size: 5871 bytes --]

diff -urpN NVIDIA-Linux-x86-1.0-5336/usr/src/nv/Makefile.kbuild NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/Makefile.kbuild
--- NVIDIA-Linux-x86-1.0-5336/usr/src/nv/Makefile.kbuild	2004-01-15 05:29:12.000000000 +0200
+++ NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/Makefile.kbuild	2004-02-01 16:15:55.529582488 +0200
@@ -146,6 +146,10 @@ ifeq ($(shell sh $(src)/conftest.sh rema
   EXTRA_CFLAGS += -DREMAP_PAGE_RANGE_4
 endif
 
+ifeq ($(shell sh $(src)/conftest.sh class_simple $(KERNEL_HEADERS)), yes)
+  EXTRA_CFLAGS += -DHAVE_CLASS_SIMPLE
+endif
+  
 #
 # NVIDIA binary object file includes .common section.
 #
diff -urpN NVIDIA-Linux-x86-1.0-5336/usr/src/nv/built-in.o NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/built-in.o
--- NVIDIA-Linux-x86-1.0-5336/usr/src/nv/built-in.o	1970-01-01 02:00:00.000000000 +0200
+++ NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/built-in.o	2004-02-01 16:11:27.428340072 +0200
@@ -0,0 +1 @@
+!<arch>
diff -urpN NVIDIA-Linux-x86-1.0-5336/usr/src/nv/conftest.sh NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/conftest.sh
--- NVIDIA-Linux-x86-1.0-5336/usr/src/nv/conftest.sh	2004-01-15 05:29:11.000000000 +0200
+++ NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/conftest.sh	2004-02-01 16:19:19.079638176 +0200
@@ -42,6 +42,29 @@ case "$1" in
         fi
     ;;
 
+    class_simple)
+        shift
+        #
+        # Determine if we have struct class_simple needed for limited sysfs
+        # support in 2.6
+        #
+        echo "#include <linux/device.h>
+        struct class_simple *test_class;
+        int add_test_class() {
+           test_class = class_simple_create(THIS_MODULE, \"test\");
+        }" > conftest.c
+
+        gcc -c conftest.c -o conftest.o $* -D__KERNEL__ > /dev/null 2>&1
+
+        if test -f conftest.o; then
+          echo "yes"
+        else
+          echo "no"
+        fi
+
+        rm -f conftest.{c,o}
+    ;;
+
     cc_sanity_check)
         shift
         #
diff -urpN NVIDIA-Linux-x86-1.0-5336/usr/src/nv/nv-linux.h NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/nv-linux.h
--- NVIDIA-Linux-x86-1.0-5336/usr/src/nv/nv-linux.h	2004-01-15 05:29:11.000000000 +0200
+++ NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/nv-linux.h	2004-02-01 16:54:14.850032648 +0200
@@ -448,6 +448,33 @@ typedef struct agp_memory agp_memory;
 #  endif // defined(KERNEL_2_4)
 #endif // defined(CONFIG_DEVFS_FS)
 
+#if defined(KERNEL_2_6) && defined(HAVE_CLASS_SIMPLE)
+#  define NV_SYSFS_REGISTER						\
+    nvidia_class = class_simple_create(THIS_MODULE, "nvidia");
+
+#  define NV_SYSFS_ADD_CONTROL						\
+     class_simple_device_add(nvidia_class,				\
+                             MKDEV(NV_MAJOR_DEVICE_NUMBER, 255),	\
+                             NULL, "nvidiactl");
+
+#  define NV_SYSFS_ADD_DEVICE(_name, _minor)				\
+     class_simple_device_add(nvidia_class,				\
+                             MKDEV(NV_MAJOR_DEVICE_NUMBER, _minor),	\
+                             &nv_linux_devices[_minor].dev->dev, _name);
+
+#  define NV_SYSFS_REMOVE_DEVICE(i)					\
+            class_simple_device_remove(MKDEV(NV_MAJOR_DEVICE_NUMBER, i));
+
+#  define NV_SYSFS_UNREGISTER						\
+    class_simple_destroy(nvidia_class);
+#else
+#  define NV_SYSFS_REGISTER
+#  define NV_SYSFS_ADD_CONTROL
+#  define NV_SYSFS_ADD_DEVICE(_name, _minor)
+#  define NV_SYSFS_REMOVE_DEVICE(i)
+#  define NV_SYSFS_UNREGISTER
+#endif
+
 
 /*
  * Linux 2.5 introduced the five argument version of remap_page_range, all
diff -urpN NVIDIA-Linux-x86-1.0-5336/usr/src/nv/nv.c NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/nv.c
--- NVIDIA-Linux-x86-1.0-5336/usr/src/nv/nv.c	2004-01-15 05:29:11.000000000 +0200
+++ NVIDIA-Linux-x86-1.0-5336.sysfs/usr/src/nv/nv.c	2004-02-01 16:58:03.429283320 +0200
@@ -47,6 +47,10 @@ struct proc_dir_entry *proc_nvidia;
 devfs_handle_t nv_devfs_handles[NV_MAX_DEVICES+1];
 #endif
 
+#if defined(KERNEL_2_6) && defined(HAVE_CLASS_SIMPLE)
+struct class_simple *nvidia_class;
+#endif
+
 // #define NV_DBG_MEM 1
 #undef NV_DBG_MEM
 
@@ -874,23 +878,31 @@ static int __init nvidia_init_module(voi
     rc = register_chrdev(nv_major, "nvidia", &nv_fops);
 #endif
 
+    NV_SYSFS_REGISTER;
+
     if (rc < 0)
     {
         nv_printf(NV_DBG_ERRORS, "nvidia_init_module: register failed\n");
         return rc;
     }
 
-#ifdef CONFIG_DEVFS_FS
+#if defined(CONFIG_DEVFS_FS) || defined(KERNEL_2_6)
     do
     {
         char name[10];
 
+# if defined(CONFIG_DEVFS_FS)
         nv_devfs_handles[0] = NV_DEVFS_REGISTER("nvidiactl", 255);
+# endif
+        NV_SYSFS_ADD_CONTROL;
 
         for (i = 0; i < num_nv_devices; i++)
         {
             sprintf(name, "nvidia%d", i);
+# if defined(CONFIG_DEVFS_FS)
             nv_devfs_handles[i+1] = NV_DEVFS_REGISTER(name, i);
+# endif
+            NV_SYSFS_ADD_DEVICE(name, i);
         }
     } while(0);
 #endif
@@ -951,6 +963,7 @@ static int __init nvidia_init_module(voi
 #else
     unregister_chrdev(nv_major, "nvidia");
 #endif
+    NV_SYSFS_UNREGISTER;
     return rc;
 }
 
@@ -1011,15 +1024,24 @@ static void __exit nvidia_exit_module(vo
         nv_printf(NV_DBG_ERRORS, "nvidia_exit_module: unregister nv failed\n");
     }
 
-#ifdef CONFIG_DEVFS_FS
+#if defined(CONFIG_DEVFS_FS) || defined(KERNEL_2_6)
     do {
         int i;
+# if defined(CONFIG_DEVFS_FS)
         NV_DEVFS_REMOVE_CONTROL();
-        for (i = 0; i < num_nv_devices; i++)
+# endif
+        NV_SYSFS_REMOVE_DEVICE(255);
+        for (i = 0; i < num_nv_devices; i++) {
+# if defined(CONFIG_DEVFS_FS)
             NV_DEVFS_REMOVE_DEVICE(i);
+# endif
+            NV_SYSFS_REMOVE_DEVICE(i);
+        }
     } while (0);
 #endif
 
+    NV_SYSFS_UNREGISTER;
+
 #if NV_ENABLE_MEM_TRACKING
     nv_list_mem(vm_list);
     nv_list_mem(km_list);

[-- Attachment #1.3: Makefile --]
[-- Type: text/x-makefile, Size: 4410 bytes --]

# This Makefile is automatically generated; do not edit
#   Generated on 'builder3.nvidia.com' on Thu Jun 19 04:05:35 PDT 2003

LINUX_MODULE=nv-linux.o
DEFINES=-D__KERNEL__ -DMODULE -D_LOOSE_KERNEL_NAMES -DKBUILD_MODNAME="nvidia" -DNTRM -D_GNU_SOURCE -D_LOOSE_KERNEL_NAMES -D__KERNEL__ -DMODULE  -DNV_MAJOR_VERSION=1 -DNV_MINOR_VERSION=0 -DNV_PATCHLEVEL=5328     -DNV_UNIX   -DNV_LINUX   -DNV_INT64_OK   -DNVCPU_X86
INCLUDES=-I.

OBJECTS=nv.o os-agp.o os-interface.o os-registry.o 
HEADERS=os-agp.h os-interface.h nv-linux.h nv-misc.h nv-memdbg.h nv.h  rmretval.h nvtypes.h  $(VERSION_HDR)

CFLAGS=-Wall -Wimplicit -Wreturn-type -Wswitch -Wformat -Wchar-subscripts -Wparentheses -Wcast-qual -Wno-multichar  -O -MD $(DEFINES) $(INCLUDES) -Wno-cast-qual

RESMAN_KERNEL_MODULE=nv-kernel.o

KERNDIR=/lib/modules/$(shell uname -r)

# check for newer paths. if found, use them, otherwise use old paths
# these wouldn't work with the gnu make included with rh6.2
# KERNINC=$(if -d $(KERNDIR)/build, $(KERNDIR)/build/include, /usr/src/linux/include)
# INSTALLDIR=$(if -d $(KERNDIR)/kernel, $(KERNDIR)/kernel/drivers/video, $(KERNDIR)/video)

# this is slightly more brain-dead, but works..
ifeq ($(shell if test -d $(KERNDIR)/build; then echo yes; fi),yes)
KERNINC=$(KERNDIR)/build/include
else
KERNINC=/usr/src/linux/include
endif

ifeq ($(shell if test -d $(KERNDIR)/kernel; then echo yes; fi),yes)
INSTALLDIR=$(KERNDIR)/kernel/drivers/video
else
INSTALLDIR=$(KERNDIR)/video
endif

ifeq ($(shell echo $(NVDEBUG)),1)
  ifeq ($(shell test -z $(RMDEBUG) && echo yes),yes)
    RMDEBUG=1
  endif
endif

ifeq ($(shell echo $(RMDEBUG)),1)
CFLAGS += -DDEBUG -g -fno-common
endif

# this is just plain wrong, get rid of it
BROKENDIR=$(KERNDIR)/kernel/video

INSTALL=$(shell which install)

# allow specification of alternate include file tree on command line and extra defines
ifdef SYSINCLUDE
INCLUDES += -I$(SYSINCLUDE)
INCLUDES += -I$(SYSINCLUDE)/asm/mach-default
else
INCLUDES += -I$(KERNINC)
INCLUDES += -I$(KERNINC)/asm/mach-default
endif

ifeq ($(shell sh conftest.sh remap_page_range $(INCLUDES)), 5)
  DEFINES += -DREMAP_PAGE_RANGE_5
endif

ifeq ($(shell sh conftest.sh remap_page_range $(INCLUDES)), 4)
  DEFINES += -DREMAP_PAGE_RANGE_4
endif

ifeq ($(shell sh conftest.sh class_simple $(INCLUDES)), yes)
  DEFINES += -DHAVE_CLASS_SIMPLE
endif

DEFINES+=$(EXTRA_DEFINES)

# allow build parameters to be passed in through the environment
ifdef BUILD_PARAMS
    DEFINES+=-D$(BUILD_PARAMS)
endif

VERSION_HDR=nv_compiler.h

all: install

install: package-install

suser-sanity-check:
	@if ! sh conftest.sh suser_sanity_check; then \
	  echo; \
	  echo "You have insufficient privileges for this operation. Please "; \
	  echo "run \"make install\" as root!                               "; \
	  echo; \
	  exit 1; \
	fi

rmmod-sanity-check:
	@if ! sh conftest.sh rmmod_sanity_check nvidia; then \
	  echo; \
	  echo "Unable to unload the currently loaded NVIDIA kernel module! "; \
	  echo "Please be certain that you have exited X before attempting  "; \
	  echo "to install this version.                                    "; \
	  echo; \
	  exit 1; \
	fi

cc-sanity-check:
	@if ! sh conftest.sh cc_sanity_check full_output $(CC); then exit 1; fi

package-install: suser-sanity-check nvidia.o rmmod-sanity-check
	if [ -d $(BROKENDIR) ]; then \
		rm -f $(BROKENDIR)/NVdriver; \
		rmdir --ignore-fail-on-non-empty $(BROKENDIR); \
	fi && \
	mkdir -p $(INSTALLDIR) && \
	rm -f $(INSTALLDIR)/NVdriver && \
	$(INSTALL) -m 0664 -o root -g root nvidia.o $(INSTALLDIR)/nvidia.o$(O) && \
	/sbin/depmod -a && \
	/sbin/modprobe nvidia && \
	sh makedevices.sh && \
	echo "nvidia.o installed successfully."; \

nvidia.o: cc-sanity-check $(LINUX_MODULE) $(RESMAN_KERNEL_MODULE) 
	ld -d -r -o $@ $(LINUX_MODULE) $(RESMAN_KERNEL_MODULE)

$(VERSION_HDR): 
	echo \#define NV_COMPILER \"`$(CC) -v 2>&1 | tail -n 1`\" > $@

$(LINUX_MODULE): $(OBJECTS)
	ld -r -o $@ $(OBJECTS)

%.o: %.c $(HEADERS)
	$(CC) -c $(CFLAGS) $<

# debug tool to preprocess the file and leave .i to make it easier to untangle #defines
%.i: %.c
	$(CC) $(CFLAGS) -E $< > $@

%.s: %.c
	$(CC) $(CFLAGS) -S $< > $@


clean:
	$(RM) $(OBJECTS) $(LINUX_MODULE) $(VERSION_HDR) *.d NVdriver nvidia.o


-include $(OBJECTS:%.o=%.d)

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2004-02-01 15:24 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-26 21:50 Greg KH
2004-01-26 22:15 ` Tomasz Torcz
2004-01-27  5:52 ` Chris Friesen
2004-01-27 22:22   ` Greg KH
2004-01-29  4:52 ` Martin Schlemmer
2004-01-29 21:54   ` Greg KH
2004-01-29 16:52 ` Martin Schlemmer
2004-01-29 21:55   ` Greg KH
2004-01-31  3:17     ` Kay Sievers
2004-01-31 17:54       ` Martin Schlemmer
2004-01-31 18:15         ` Kay Sievers
2004-01-31 18:27           ` Martin Schlemmer
2004-01-31 18:39             ` Kay Sievers
2004-01-31 18:47               ` Martin Schlemmer
2004-01-29 18:30 ` Martin Schlemmer
2004-01-30  4:41   ` Martin Schlemmer
2004-02-02 23:32   ` Greg KH
2004-02-03  4:12     ` Martin Schlemmer
2004-01-30 16:45 ` Prakash K. Cheemplavam
2004-01-30 17:23   ` Greg KH
2004-01-30 17:44     ` Prakash K. Cheemplavam
2004-01-30 17:49       ` Greg KH
2004-01-30 18:17         ` Prakash K. Cheemplavam
2004-02-01 15:24     ` Martin Schlemmer [this message]
2004-02-02  8:46       ` Prakash K. Cheemplavam
2004-01-30 17:33   ` Martin Schlemmer
2004-01-30 18:03   ` Andre Noll
2004-01-30 23:06     ` Tom Rini
2004-02-02 21:43       ` Greg KH
2004-02-05  0:31         ` [2.6 patch] remove USB_SCANNER Adrian Bunk
2004-02-05  1:14           ` Greg KH
2004-02-05 17:20             ` Azog
2004-02-05 17:30               ` Greg KH
2004-02-05 17:50                 ` Stian Jordet
2004-02-05 17:57                   ` Greg KH
2004-02-05 20:24                 ` Leopold Gouverneur
2004-02-05 21:15                   ` Stian Jordet
2004-02-05 21:36                     ` Leopold Gouverneur
2004-02-06  1:15               ` Gene Heskett
2004-02-06 20:59                 ` Bill Davidsen
2004-02-06 21:04                   ` Greg KH
2004-02-01 22:52 ` hal daemon and ide-floppy J.A. Magallon
2004-02-02  3:16   ` Greg KH
2004-02-02 22:32 ` udev depends on /usr J.A. Magallon
2004-02-02 22:44   ` Greg KH
2004-02-02 23:01     ` J.A. Magallon
2004-02-03  4:10     ` Martin Schlemmer
2004-02-02 23:08 ` [ANNOUNCE] udev 015 release Prakash K. Cheemplavam
2004-02-02 23:11   ` Greg KH

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=1075649046.24826.8.camel@nosferatu.lan \
    --to=azarah@gentoo.org \
    --cc=PrakashKC@gmx.de \
    --cc=greg@kroah.com \
    --cc=linux-hotplug-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sam@ravnborg.org \
    --cc=zander@mail.minion.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

Powered by JetHome