lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 4 May 2011 18:29:12 +0200
From:	Arnd Bergmann <arnd@...db.de>
To:	Vivien Didelot <vivien.didelot@...oirfairelinux.com>
Cc:	linux-kernel@...r.kernel.org,
	Jerome Oufella <jerome.oufella@...oirfairelinux.com>,
	platform-driver-x86@...r.kernel.org, linux-serial@...r.kernel.org,
	lm-sensors@...sensors.org
Subject: Re: [RFC 2/5] gpio: add support for Technologic Systems TS-5500 GPIOs

On Saturday 30 April 2011, Vivien Didelot wrote:
> +       ts5xxx_sbcinfo_set(&sbcinfo);
> +       if (5500 != sbcinfo.board_id) {
> +               printk(MODULE_NAME ": Incompatible TS Board.\n");
> +               return -ENODEV;
> +       }

The above should not be necessary:

> +static int __init ts5500_gpio_init(void)
> +{
> +       int ret;
> +
> +       ret = platform_driver_register(&ts5500_gpio_driver);
> +       if (ret)
> +               return ret;
> +
> +       ret = platform_device_register(&gpio_device);
> +       if (ret) {
> +               printk(MODULE_NAME ": Failed to register platform device\n");
> +               platform_driver_unregister(&ts5500_gpio_driver);
> +               return ret;
> +       }
> +
> +       printk(MODULE_NAME ": GPIO/DIO driver loaded.\n");
> +       return 0;
> +}
> +module_init(ts5500_gpio_init);

Doing it this way requires you know that you have to load the driver,
which is not good if you want to have the same kernel running on 
different machines.

Better move the device registration into your platform code, in the
place where you know what device you have. The add a MODULE_DEVICE_TABLE()
entry to the module so the driver gets automatically loaded (if it's
a module), and match the platform device to the driver you register
from the module_init function.

Same for the other devices where you follow the same pattern.

Another way to do the same in a more modern fashion would be
to provide a flattened device tree that describes all your devices
and pass that into the kernel. Take a look at the CE4100 and OLPC
platforms to see how that is done.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ