backports: pending patches for Luis
cover backports: pending patches for Luis
From: "Luis R. Rodriguez" <[email protected]>
Here's my dump as I worked towards the merge of our trees.
Tested with ckmake alone. I'll test ckmake --allyesconfig in a bit with some two other new subsystem. We just might make it in time to use this for the next release :) I'm running i915 right now through this new tree.
1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ]
Luis R. Rodriguez (18):
backports: enable DRM_NOUVEAU for 3.2
compat: backport dev_level_ratelimited()
compat: backport __i2c_transfer()
compat: backport devm_regmap_init()
compat: backport GPIOF_OPEN_DRAIN definition
compat: backport ASYNC_DOMAIN_EXCLUSIVE()
compat: backport devres_release()
compat: backport dev_get_regmap()
compat: backport devm_ioremap_resource()
compat: backport module_platform_driver_probe()
compat: add helpers to aid backport of generic DMA changes for v4l
compat: backport dma_get_sgtable()
backports: add blacklist module support
backports: add support for module compression
backports: add check_depmod to look for module search path
backports: add udev rules if required for backported firmware_class
backports: use depmod -a
backports: add update-initramfs support
backport/.blacklist.map | 10 ++ backport/Makefile.real | 20 +-- backport/compat/compat-3.4.c | 232 ++++++++++++++++++++++++++++ backport/compat/compat-3.5.c | 34 ++++ backport/compat/compat-3.6.c | 52 +++++++ backport/compat/compat-3.9.c | 55 +++++++ backport/include/linux/compat-3.4.h | 42 +++++ backport/include/linux/compat-3.5.h | 51 ++++++ backport/include/linux/compat-3.6.h | 28 ++++ backport/include/linux/compat-3.9.h | 31 ++++ backport/scripts/are_mods_compressed | 8 + backport/scripts/backport_firmware_install | 21 +++ backport/scripts/blacklist.sh | 35 +++++ backport/scripts/check_depmod | 78 ++++++++++ backport/scripts/mod_path | 8 + backport/scripts/update-initramfs | 62 ++++++++ backport/udev/50-compat_firmware.rules | 4 + backport/udev/compat_firmware.sh | 35 +++++ backport/udev/ubuntu/compat_firmware.sh | 29 ++++ dependencies | 1 - gentree.py | 1 + 21 files changed, 827 insertions(+), 10 deletions(-) create mode 100644 backport/.blacklist.map create mode 100755 backport/scripts/are_mods_compressed create mode 100755 backport/scripts/backport_firmware_install create mode 100755 backport/scripts/blacklist.sh create mode 100755 backport/scripts/check_depmod create mode 100755 backport/scripts/mod_path create mode 100755 backport/scripts/update-initramfs create mode 100644 backport/udev/50-compat_firmware.rules create mode 100755 backport/udev/compat_firmware.sh create mode 100755 backport/udev/ubuntu/compat_firmware.sh
Signature · 1 line
1.7.10.4
PATCH 1/18 backports: enable DRM_NOUVEAU for 3.2
From: "Luis R. Rodriguez" <[email protected]>
--- dependencies | 1 - 1 file changed, 1 deletion(-)
dependencies +0 -1
@@ -45,7 +45,6 @@ MWIFIEX 2.6.27 HDMI 3.2 DRM 3.2 DRM_TTM 3.2 -DRM_NOUVEAU 3.3 # This requires proc_create(), and that doesn't exist before 2.6.24 LIBIPW_DEBUG 2.6.25
Signature · 1 line
1.7.10.4
Johannes Berg
AppliedRe: [PATCH 01/18] backports: enable DRM_NOUVEAU for 3.2
Applied.
johannes
PATCH 2/18 compat: backport dev_level_ratelimited()
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains 6ca04593 v3.5-rc1~147^2~7
This is only enabled for kernels where ratelimit.h was added.
commit 6ca045930338485a8cdef117e74372aa1678009d
Author: Hiroshi DOYU <[email protected]> Date: Mon May 14 10:47:57 2012 +0300
driver core: Add dev_*_ratelimited() family
Add dev_*_ratelimited() family, dev_* version of pr_*_ratelimited().
Using Joe Perches's proposal/implementation.
--- backport/include/linux/compat-3.5.h | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
backport/include/linux/compat-3.5.h +36 -0
@@ -10,6 +10,42 @@#include <net/netlink.h> +#if (LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,27 )) +#include <linux/ratelimit.h> +#define dev_level_ratelimited (dev_level, dev, fmt, ...) \ +do { \ + static DEFINE_RATELIMIT_STATE(_rs, \ + DEFAULT_RATELIMIT_INTERVAL, \ + DEFAULT_RATELIMIT_BURST); \ + if (__ratelimit(&_rs)) \ + dev_level(dev, fmt, ##__VA_ARGS__); \ +} while (0) + +#define dev_emerg_ratelimited (dev, fmt, ...) \ + dev_level_ratelimited(dev_emerg, dev, fmt, ##__VA_ARGS__) +#define dev_alert_ratelimited (dev, fmt, ...) \ + dev_level_ratelimited(dev_alert, dev, fmt, ##__VA_ARGS__) + + +#if defined(CONFIG_DYNAMIC_DEBUG ) || defined(DEBUG ) +#define dev_dbg_ratelimited (dev, fmt, ...) \ +do { \ + static DEFINE_RATELIMIT_STATE(_rs, \ + DEFAULT_RATELIMIT_INTERVAL, \ + DEFAULT_RATELIMIT_BURST); \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \ + if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \ + __ratelimit(&_rs)) \ + __dynamic_pr_debug(&descriptor, pr_fmt(fmt), \ + ##__VA_ARGS__); \ +} while (0) +#else +#define dev_dbg_ratelimited (dev, fmt, ...) \ + no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) +#endif + +#endif +/* * This backports: * commit 569a8fc38367dfafd87454f27ac646c8e6b54bca
Signature · 1 line
1.7.10.4
Johannes Berg
AppliedRe: [PATCH 02/18] compat: backport dev_level_ratelimited()
On Wed, 2013-04-10 at 04:35 -0700, Luis R. Rodriguez wrote:
Applied.
backport/include/linux/compat-3.5.h line 14
Quoted 7 lines
+++
b/backport/include/linux/compat-3.5.hbackport/include/linux/compat-3.5.h +2
-0@@ -10,6 +10,42 @@#include <net/netlink.h> +#if (LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,27 )) +#include <linux/ratelimit.h>
I think, however, that it would be easier to understand if we started putting less stuff into compat-xyz.h and more into linux/feature.h? Needs more discussion though I guess.
johannes
Re: [PATCH 02/18] compat: backport dev_level_ratelimited()
Quoted 7 lines · Johannes Berg
On Wed, 2013-04-10 at 04:35 -0700, Luis R. Rodriguez wrote:
Applied.
Quoted 3 lines
+++
b/backport/include/linux/compat-3.5.h(quoted diff) +0
-0@@ -10,6 +10,42 @@
Quoted 8 lines
backport/include/linux/compat-3.5.h line 14
Quoted 4 lines
backport/include/linux/compat-3.5.h +2
-0#include <net/netlink.h> +#if (LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,27 )) +#include <linux/ratelimit.h> I think, however, that it would be easier to understand if we started putting less stuff into
compat-xyz.hand more intolinux/feature.h? Needs more discussion though I guess.
Sure, lets what's the idea or do you want to do that on another thread?
Luis
Re: [PATCH 02/18] compat: backport dev_level_ratelimited()
Quoted 5 lines · Luis R. Rodriguez
Quoted 3 lines
I think, however, that it would be easier to understand if we started putting less stuff into
compat-xyz.hand more intolinux/feature.h? Needs more discussion though I guess.Sure, lets what's the idea or do you want to do that on another thread?
It's kinda half-baked and I'm not completely sure it's a good idea (because we may have to follow header file renames, though they happen rarely), but I was basically thinking this:
Say there's
void my_foo_function(struct foo *f);
that we want to backport. Let's also say it's defined in <linux/foo.h>, and that it was usually present starting from kernel 3.0, but for now let's assume the "foo" subsystem always existed (i.e. <linux/foo.h>)
Typically, we'd therefore add it to <linux/compat-3.0.h> and declare it there, maybe with the LINUX_BACKPORT() wrapper, and then define it in compat/compat-3.0.c.
What I'm thinking is that we should maybe declare it in compat in include/linux/foo.h instead, maybe like this:
#ifndef __BACKPORT_FOO
#define __BACKPORT_FOO
#include_next <linux/foo.h>
#if LINUX_VERSION < 3.0
#define my_foo_function LINUX_BACKPORT(my_foo_function)
void my_foo_function(struct foo *f);
#endif
#endif /* __BACKPORT_FOO */
I'm a bit undecided. On the one hand I think it's nice that we can spot in one place what's backported where in all the include/linux/compat-xyz.h files, but on the other hand it's kinda becoming a messy jumble of features across different subsystems, and hard to determine what you have already and might need for a given header file?
Anyway it's probably not even half-baked yet :)
johannes
taking backports out of compat-*.h (was: [PATCH 02/18] compat: backport dev_level_ratelimited())
Quoted 1 line · Johannes Berg
Quoted 1 line
Sure, lets what's the idea or do you want to do that on another thread?
Let me give it a different subject :-)
Quoted 33 lines
It's kinda half-baked and I'm not completely sure it's a good idea (because we may have to follow header file renames, though they happen rarely), but I was basically thinking this:
Say there's
void
my_foo_function(struct foo *f);that we want to backport. Let's also say it's defined in <
linux/foo.h>, and that it was usually present starting from kernel 3.0, but for now let's assume the "foo" subsystem always existed (i.e. <linux/foo.h>)Typically, we'd therefore add it to <
linux/compat-3.0.h> and declare it there, maybe with theLINUX_BACKPORT()wrapper, and then define it incompat/compat-3.0.c.What I'm thinking is that we should maybe declare it in compat in
include/linux/foo.hinstead, maybe like this:#ifndef
__BACKPORT_FOO
#define__BACKPORT_FOO
#include_next <linux/foo.h>#if
LINUX_VERSION< 3.0
#definemy_foo_functionLINUX_BACKPORT(my_foo_function)void
my_foo_function(struct foo *f);
#endif#endif /*
__BACKPORT_FOO*/
Quoted 6 lines
I'm a bit undecided. On the one hand I think it's nice that we can spot in one place what's backported where in all the
include/linux/compat-xyz.hfiles, but on the other hand it's kinda becoming a messy jumble of features across different subsystems, and hard to determine what you have already and might need for a given header file?
In addition to what I said, I just realized that we should probably do this, and do it consistently even for old things. That way, we can get rid of all the pr_fmt patches.
The reason for the pr_fmt patches is that typically, a source file would have
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <whatever, including somehow getting printk.h>
Now that we force them to include compat-2.6.h at the very beginning of the file, printk.h already gets included in some way through compat-2.6.h (there are of course MANY MANY paths to it.)
To avoid redefine warnings, we thus patch everything to be
#undef pr_fmt
#define pr_fmt
...
which of course works, but it's pretty ugly (we have >1000 patchlines for this!)
If we were able to get rid of compat-2.6.h and put all the backports into their appropriate headers (linux/foo.h) we could only force an include of compat_autoconf.h (which doesn't include printk.h of course) and then we'd be able to get rid of all these patches.
johannes
Re: taking backports out of compat-*.h
Quoted 66 lines · Johannes Berg
Quoted 1 line · Johannes Berg
Quoted 1 line
Sure, lets what's the idea or do you want to do that on another thread?
Let me give it a different subject :-)
Quoted 33 lines
It's kinda half-baked and I'm not completely sure it's a good idea (because we may have to follow header file renames, though they happen rarely), but I was basically thinking this:
Say there's
void
my_foo_function(struct foo *f);that we want to backport. Let's also say it's defined in <
linux/foo.h>, and that it was usually present starting from kernel 3.0, but for now let's assume the "foo" subsystem always existed (i.e. <linux/foo.h>)Typically, we'd therefore add it to <
linux/compat-3.0.h> and declare it there, maybe with theLINUX_BACKPORT()wrapper, and then define it incompat/compat-3.0.c.What I'm thinking is that we should maybe declare it in compat in
include/linux/foo.hinstead, maybe like this:#ifndef
__BACKPORT_FOO
#define__BACKPORT_FOO
#include_next <linux/foo.h>#if
LINUX_VERSION< 3.0
#definemy_foo_functionLINUX_BACKPORT(my_foo_function)void
my_foo_function(struct foo *f);
#endif#endif /*
__BACKPORT_FOO*/Quoted 6 lines
I'm a bit undecided. On the one hand I think it's nice that we can spot in one place what's backported where in all the
include/linux/compat-xyz.hfiles, but on the other hand it's kinda becoming a messy jumble of features across different subsystems, and hard to determine what you have already and might need for a given header file?In addition to what I said, I just realized that we should probably do this, and do it consistently even for old things. That way, we can get rid of all the
pr_fmtpatches.The reason for the
pr_fmtpatches is that typically, a source file would have#define
pr_fmt(fmt)KBUILD_MODNAME": " fmt
#include <whatever, including somehow gettingprintk.h>Now that we force them to include
compat-2.6.hat the very beginning of the file,printk.halready gets included in some way throughcompat-2.6.h(there are of course MANY MANY paths to it.)To avoid redefine warnings, we thus patch everything to be
#undef
pr_fmt
#definepr_fmt
...
Quoted 8 lines
which of course works, but it's pretty ugly (we have >1000 patchlines for this!)
If we were able to get rid of
compat-2.6.hand put all the backports into their appropriate headers (linux/foo.h) we could only force an include ofcompat_autoconf.h(which doesn't includeprintk.hof course) and then we'd be able to get rid of all these patches.
I had a similar same idea a year ago, but haven't found the time to complete it, see [0]. I am still for this solution.
If linux/foo.h does not exist in recent kernel versions we have to add it anyway, because the new code references it, so this is not a problem.
With this solution we would clean up the includes used when compiling and we do not need the pr_fmt patch any more and hopefully some more.
Hauke
[0]:
https://lists.linuxfoundation.org/pipermail/lf_driver_backport/2012-April/000972.html
PATCH 3/18 compat: backport __i2c_transfer()
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains b37d2a3a v3.6-rc1~28^2~265
commit b37d2a3a75cb0e72e18c29336cb2095b63dabfc8
Author: Jean Delvare <[email protected]> Date: Fri Jun 29 07:47:19 2012 -0300
[media] i2c: Export an unlocked flavor of i2c_transfer
Some drivers (in particular for TV cards) need exclusive access to their I2C buses for specific operations. Export an unlocked flavor of i2c_transfer to give them full control.
The unlocked flavor has the following limitations:
* Obviously, caller must hold the i2c adapter lock.
* No debug messages are logged. We don't want to log messages while holding a rt_mutex.
* No check is done on the existence of adap->algo->master_xfer. It is thus the caller's responsibility to ensure that the function is OK to call.
--- backport/compat/compat-3.6.c | 34 ++++++++++++++++++++++++++++++++++ backport/include/linux/compat-3.6.h | 9 +++++++++ 2 files changed, 43 insertions(+)
backport/compat/compat-3.6.c +34 -0
@@ -13,6 +13,40 @@#include <linux/export.h> #include <linux/bug.h> #include <linux/bitmap.h> +#include <linux/i2c.h> + +#if (LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,2 ,0 )) +/** +* __i2c_transfer - unlocked flavor of i2c_transfer +* @adap: Handle to I2C bus +* @msgs: One or more messages to execute before STOP is issued to +* terminate the operation; each message begins with a START. +* @num: Number of messages to be executed. +* +* Returns negative errno, else the number of messages executed. +* +* Adapter lock must be held when calling this function. No debug logging +* takes place. adap->algo->master_xfer existence isn't checked. +*/ +int __i2c_transfer (struct i2c_adapter *adap,struct i2c_msg *msgs,int num) +{ +unsigned long orig_jiffies; +int ret, try; + +/* Retry automatically on arbitration loss */ + orig_jiffies = jiffies; +for (ret =0 , try =0 ; try <= adap->retries; try++) { + ret = adap->algo->master_xfer (adap, msgs, num); +if (ret != -EAGAIN ) +break ; +if (time_after (jiffies, orig_jiffies + adap->timeout)) +break ; + } + +return ret; +} +EXPORT_SYMBOL (__i2c_transfer); +#endif /** * memweight - count the total number of bits set in memory area
backport/include/linux/compat-3.6.h +9 -0
@@ -7,6 +7,15 @@#include <linux/scatterlist.h> +#if (LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,2 ,0 )) +#include <linux/i2c.h> +/* Unlocked flavor */ +#define __i2c_transfer LINUX_BACKPORT(__i2c_transfer) +extern int __i2c_transfer (struct i2c_adapter *adap,struct i2c_msg *msgs, +int num); +#endif + +#define memweight LINUX_BACKPORT(memweight)extern size_t memweight (const void *ptr,size_t bytes);
Signature · 1 line
1.7.10.4
Johannes Berg
AppliedRe: [PATCH 03/18] compat: backport __i2c_transfer()
Applied.
johannes
PATCH 4/18 compat: backport devm_regmap_init()
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
Backport devm_regmap_init() for I2C and SPI. Asynchronous I/O support was added as of 3.9 and since the regmap is part the core we don't want to deal with trying a full backport replacement yet. Given that no one as of next-20130328 uses regmap asynchronous we simply warn if its ever used for now. The regmap callbacks were made bus agnostic as of commit 0135bbcc added on on 3.5 and becuase of this we we just remove all that from our port given that we do this port for kernels < 3.4.
This works with the old core regmap implementation added as of 3.1 given that static inlines were used as wrapper for calls and the bus context was only used by the internal code.
mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains c0eb4676 v3.4-rc1~126^2~4^2
mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains 0d509f2b v3.9-rc2~19^2~6^2~5
mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains 0135bbcc v3.5-rc1~117^2~7^3~6
commit c0eb46766d395da8d62148bda2e59bad5e6ee2f2
Author: Mark Brown <[email protected]> Date: Mon Jan 30 19:56:52 2012 +0000
regmap: Implement managed regmap_init()
Save error handling and unwinding code in drivers by providing managed versions of the regmap init functions, simplifying usage.
commit 0d509f2b112b21411712f0bf789b372987967e49
Author: Mark Brown <[email protected]> Date: Sun Jan 27 22:07:38 2013 +0800
regmap: Add asynchronous I/O support
Some use cases like firmware download can transfer a lot of data in quick succession. With high speed buses these use cases can benefit from having multiple transfers scheduled at once since this allows the bus to minimise the delay between transfers.
Support this by adding regmap_raw_write_async(), allowing raw transfers to be scheduled, and regmap_async_complete() to wait for them to finish.
commit 0135bbcc7a0cc056f0203ff839466236b8e3dc19
Author: Stephen Warren <[email protected]> Date: Wed Apr 4 15:48:30 2012 -0600
regmap: introduce explicit bus_context for bus callbacks
The only context needed by I2C and SPI bus definitions is the device itself; this can be converted to an i2c_client or spi_device in order to perform IO on the device. However, other bus types may need more context in order to perform IO. Enable this by having regmap_init accept a bus_context parameter, and pass this to all bus callbacks. The existing callbacks simply pass the struct device here. Future bus types may pass something else.
--- backport/compat/compat-3.4.c | 232 +++++++++++++++++++++++++++++++++++ backport/include/linux/compat-3.4.h | 40 ++++++ 2 files changed, 272 insertions(+)
backport/compat/compat-3.4.c +232 -0
@@ -12,6 +12,238 @@#include <linux/module.h> #include <linux/wait.h> +#if (LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,2 ,0 )) +#include <linux/regmap.h> +#include <linux/i2c.h> +#include <linux/spi/spi.h> +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */ + +#if (LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,2 ,0 )) +#if defined(CONFIG_REGMAP ) +static void devm_regmap_release (struct device *dev,void *res) +{ +regmap_exit (*(struct regmap **)res); +} + +#if defined(CONFIG_REGMAP_I2C ) +static int regmap_i2c_write ( +struct device *dev, +const void *data, +size_t count) +{ +struct i2c_client *i2c =to_i2c_client (dev); +int ret; + + ret =i2c_master_send (i2c, data, count); +if (ret == count) +return 0 ; +else if (ret <0 ) +return ret; +else +return -EIO ; +} + +static int regmap_i2c_gather_write ( +struct device *dev, +const void *reg,size_t reg_size, +const void *val,size_t val_size) +{ +struct i2c_client *i2c =to_i2c_client (dev); +struct i2c_msg xfer[2 ]; +int ret; + +/* If the I2C controller can't do a gather tell the core, it +* will substitute in a linear write for us. +*/ +if (!i2c_check_functionality (i2c->adapter,I2C_FUNC_NOSTART )) +return -ENOTSUPP ; + + xfer[0 ].addr = i2c->addr; + xfer[0 ].flags =0 ; + xfer[0 ].len = reg_size; + xfer[0 ].buf = (void *)reg; + + xfer[1 ].addr = i2c->addr; + xfer[1 ].flags =I2C_M_NOSTART ; + xfer[1 ].len = val_size; + xfer[1 ].buf = (void *)val; + + ret =i2c_transfer (i2c->adapter, xfer,2 ); +if (ret ==2 ) +return 0 ; +if (ret <0 ) +return ret; +else +return -EIO ; +} + +static int regmap_i2c_read ( +struct device *dev, +const void *reg,size_t reg_size, +void *val,size_t val_size) +{ +struct i2c_client *i2c =to_i2c_client (dev); +struct i2c_msg xfer[2 ]; +int ret; + + xfer[0 ].addr = i2c->addr; + xfer[0 ].flags =0 ; + xfer[0 ].len = reg_size; + xfer[0 ].buf = (void *)reg; + + xfer[1 ].addr = i2c->addr; + xfer[1 ].flags =I2C_M_RD ; + xfer[1 ].len = val_size; + xfer[1 ].buf = val; + + ret =i2c_transfer (i2c->adapter, xfer,2 ); +if (ret ==2 ) +return 0 ; +else if (ret <0 ) +return ret; +else +return -EIO ; +} + +static struct regmap_bus regmap_i2c = { + .write = regmap_i2c_write, + .gather_write = regmap_i2c_gather_write, + .read = regmap_i2c_read, +}; +#endif /* defined(CONFIG_REGMAP_I2C) */ + +/** +* devm_regmap_init(): Initialise managed register map +* +* @dev: Device that will be interacted with +* @bus: Bus-specific callbacks to use with device +* @bus_context: Data passed to bus-specific callbacks +* @config: Configuration for register map +* +* The return value will be an ERR_PTR() on error or a valid pointer +* to a struct regmap. This function should generally not be called +* directly, it should be called by bus-specific init functions. The +* map will be automatically freed by the device management code. +*/ +struct regmap *devm_regmap_init (struct device *dev, +const struct regmap_bus *bus, +const struct regmap_config *config) +{ +struct regmap **ptr, *regmap; + + ptr =devres_alloc (devm_regmap_release,sizeof (*ptr),GFP_KERNEL ); +if (!ptr) +return ERR_PTR (-ENOMEM ); + + regmap =regmap_init (dev, + bus, + config); +if (!IS_ERR (regmap)) { + *ptr = regmap; +devres_add (dev, ptr); + }else { +devres_free (ptr); + } + +return regmap; +} +EXPORT_SYMBOL_GPL (devm_regmap_init); + +#if defined(CONFIG_REGMAP_I2C ) +/** +* devm_regmap_init_i2c(): Initialise managed register map +* +* @i2c: Device that will be interacted with +* @config: Configuration for register map +* +* The return value will be an ERR_PTR() on error or a valid pointer +* to a struct regmap. The regmap will be automatically freed by the +* device management code. +*/ +struct regmap *devm_regmap_init_i2c (struct i2c_client *i2c, +const struct regmap_config *config) +{ +return devm_regmap_init (&i2c->dev, ®map_i2c, config); +} +EXPORT_SYMBOL_GPL (devm_regmap_init_i2c); +#endif /* defined(CONFIG_REGMAP_I2C) */ + +#if defined(CONFIG_REGMAP_SPI ) +static int regmap_spi_write ( +struct device *dev, +const void *data,size_t count) +{ +struct spi_device *spi =to_spi_device (dev); + +return spi_write (spi, data, count); +} + +static int regmap_spi_gather_write ( +struct device *dev, +const void *reg,size_t reg_len, +const void *val,size_t val_len) +{ +struct spi_device *spi =to_spi_device (dev); +struct spi_message m; +struct spi_transfer t[2 ] = { { .tx_buf = reg, .len = reg_len, }, + { .tx_buf = val, .len = val_len, }, }; + +spi_message_init (&m); +spi_message_add_tail (&t[0 ], &m); +spi_message_add_tail (&t[1 ], &m); + +return spi_sync (spi, &m); +} + +static int regmap_spi_read ( +struct device *dev, +const void *reg,size_t reg_size, +void *val,size_t val_size) +{ +struct spi_device *spi =to_spi_device (dev); + +return spi_write_then_read (spi, reg, reg_size, val, val_size); +} + +static struct regmap_bus regmap_spi = { + .write = regmap_spi_write, + .gather_write = regmap_spi_gather_write, +/* +* See commit 0d509f2b112b +* only 3.9 kernels have this we'll ignore it +* given I have not seen drivers use these we +* are backporting. We'll -EINVAL these. +*/ +#if 0 + .async_write = regmap_spi_async_write, + .async_alloc = regmap_spi_async_alloc, +#endif + .read = regmap_spi_read, + .read_flag_mask =0x80 , + +}; + +/** +* devm_regmap_init_spi(): Initialise register map +* +* @spi: Device that will be interacted with +* @config: Configuration for register map +* +* The return value will be an ERR_PTR() on error or a valid pointer +* to a struct regmap. The map will be automatically freed by the +* device management code. +*/ +struct regmap *devm_regmap_init_spi (struct spi_device *spi, +const struct regmap_config *config) +{ +return devm_regmap_init (&spi->dev, ®map_spi, config); +} +EXPORT_SYMBOL_GPL (devm_regmap_init_spi); +#endif /* defined(CONFIG_REGMAP_SPI) */ + +#endif /* defined(CONFIG_REGMAP) */ +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */ +/* __wake_up_common was declared as part of the wait.h until * 2.6.31 in which they made it private to the scheduler. Prefix it with * compat to avoid double declaration issues.
backport/include/linux/compat-3.4.h +40 -0
@@ -11,6 +11,46 @@#include <linux/kconfig.h> #endif +#if (LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,2 ,0 )) +#if defined(CONFIG_REGMAP ) +#include <linux/regmap.h> +#define devm_regmap_init LINUX_BACKPORT(devm_regmap_init) +struct regmap *devm_regmap_init (struct device *dev, +const struct regmap_bus *bus, +const struct regmap_config *config); +#if defined(CONFIG_REGMAP_I2C ) +#define devm_regmap_init_i2c LINUX_BACKPORT(devm_regmap_init_i2c) +struct regmap *devm_regmap_init_i2c (struct i2c_client *i2c, +const struct regmap_config *config); +#endif /* defined(CONFIG_REGMAP_I2C) */ +#if defined(CONFIG_REGMAP_SPI ) +#define devm_regmap_init_spi LINUX_BACKPORT(devm_regmap_init_spi) +struct regmap *devm_regmap_init_spi (struct spi_device *dev, +const struct regmap_config *config); +#endif /* defined(CONFIG_REGMAP_SPI) */ + +/* +* We can't backport these unless we try to backport +* the full regmap into core so warn if used. +* No drivers are using this yet anyway. +*/ +#define regmap_raw_write_async LINUX_BACKPORT(regmap_raw_write_async) +static inline int regmap_raw_write_async (struct regmap *map,unsigned int reg, +const void *val,size_t val_len) +{ +WARN_ONCE (1 ,"regmap API is disabled" ); +return -EINVAL ; +} + +#define regmap_async_complete LINUX_BACKPORT(regmap_async_complete) +static inline void regmap_async_complete (struct regmap *map) +{ +WARN_ONCE (1 ,"regmap API is disabled" ); +} + +#endif /* defined(CONFIG_REGMAP) */ +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */ +/* * defined here to allow things to compile but technically * using this for memory regions will yield in a no-op on newer
Signature · 1 line
1.7.10.4
Johannes Berg
AppliedRe: [PATCH 04/18] compat: backport devm_regmap_init()
On Wed, 2013-04-10 at 04:35 -0700, Luis R. Rodriguez wrote:
[...]
Applied.
johannes
PATCH 5/18 compat: backport GPIOF_OPEN_DRAIN definition
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
This functionality will just be ignored, later we'll just port the full gpiolib.
mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains aca5ce14 v3.4-rc1~65^2~20
commit aca5ce14eb773a75e5d935968b2e390dc5bd29c3
Author: Laxman Dewangan <[email protected]> Date: Fri Feb 17 20:26:21 2012 +0530
gpio: gpiolib: Support for open drain/collector gpios
Adding support for the open drain gpio on which client can specify the open drain property through GPIO flag GPIOF_OPEN_DRAIN at the time of gpio request.
The open drain pins are normally pulled high and it cannot be driven to output with value of 1 and so when client request for setting the pin to HIGH, the gpio will be set to input direction to make pin in tristate and hence PULL-UP on pins will make the state to HIGH. The open drain pin can be driven to LOW by setting output with value of 0.
--- backport/include/linux/compat-3.4.h | 2 ++ 1 file changed, 2 insertions(+)
backport/include/linux/compat-3.4.h +2 -0
@@ -11,6 +11,8 @@#include <linux/kconfig.h> #endif +#define GPIOF_OPEN_DRAIN (1 << 2) +#if (LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,2 ,0 ))#if defined(CONFIG_REGMAP )#include <linux/regmap.h>
Signature · 1 line
1.7.10.4
Re: [PATCH 05/18] compat: backport GPIOF_OPEN_DRAIN definition
Quoted 4 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
This functionality will just be ignored, later we'll just port the full gpiolib.
That seems a bit dangerous? If the driver expects to be able to set the pin this way, do we really want to stop it?
johannes
Re: [PATCH 05/18] compat: backport GPIOF_OPEN_DRAIN definition
Quoted 8 lines · Johannes Berg
Quoted 4 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
This functionality will just be ignored, later we'll just port the full gpiolib.
That seems a bit dangerous? If the driver expects to be able to set the pin this way, do we really want to stop it?
Yes, thanks I forgot to drop this. Thanks for the review.
Luis
PATCH 6/18 compat: backport ASYNC_DOMAIN_EXCLUSIVE()
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
For older kernels this is simply a matter of using LIST_HEAD.
mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains 2955b47d v3.6-rc1~103^2~4
commit 2955b47d2c1983998a8c5915cb96884e67f7cb53
Author: Dan Williams <[email protected]> Date: Mon Jul 9 19:33:25 2012 -0700
[SCSI] async: introduce 'async_domain' type
This is in preparation for teaching async_synchronize_full() to sync all pending async work, and not just on the async_running domain. This conversion is functionally equivalent, just embedding the existing list in a new async_domain type.
The .registered attribute is used in a later patch to distinguish between domains that want to be flushed by async_synchronize_full() versus those that only expect async_synchronize_{full|cookie}_domain to be used for flushing.
--- backport/include/linux/compat-3.6.h | 3 +++ 1 file changed, 3 insertions(+)
backport/include/linux/compat-3.6.h +3 -0
@@ -9,6 +9,9 @@#if (LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,2 ,0 ))#include <linux/i2c.h> + +#define ASYNC_DOMAIN_EXCLUSIVE (_domain) LIST_HEAD(_domain) +/* Unlocked flavor */ #define __i2c_transfer LINUX_BACKPORT(__i2c_transfer) extern int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
Signature · 1 line
1.7.10.4
Re: [PATCH 06/18] compat: backport ASYNC_DOMAIN_EXCLUSIVE()
Quoted 4 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
For older kernels this is simply a matter of using
LIST_HEAD.
Hmm, how is that useful if it will not have any effect?
johannes
Re: [PATCH 06/18] compat: backport ASYNC_DOMAIN_EXCLUSIVE()
Quoted 7 lines · Johannes Berg
Quoted 4 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
For older kernels this is simply a matter of using
LIST_HEAD.Hmm, how is that useful if it will not have any effect?
The core of the handling is done in the internal asynch code and that's kept hidden from the users of this -- so far.
Luis
Re: [PATCH 06/18] compat: backport ASYNC_DOMAIN_EXCLUSIVE()
Quoted 5 lines · Luis R. Rodriguez
Quoted 3 lines · Johannes Berg
Quoted 2 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
For older kernels this is simply a matter of using
LIST_HEAD.Hmm, how is that useful if it will not have any effect?
The core of the handling is done in the internal asynch code and that's kept hidden from the users of this -- so far.
I guess I'd have to review the async API, but now this wouldn't do anything? What's the use of just this when you don't have things like async_schedule_domain() and async_synchronize_full_domain(), regulator stuff wouldn't compile I think?
I guess I'm a bit confused what kind of effect this has.
johannes
Re: [PATCH 06/18] compat: backport ASYNC_DOMAIN_EXCLUSIVE()
Quoted 9 lines · Johannes Berg
Quoted 8 lines · Luis R. Rodriguez
Quoted 6 lines · Johannes Berg
Quoted 4 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
For older kernels this is simply a matter of using
LIST_HEAD.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Hmm, how is that useful if it will not have any effect?
The core of the handling is done in the internal asynch code and that's kept hidden from the users of this -- so far.
I guess I'd have to review the async API,
Yeap, reviewing the commit noted would help too.
Quoted 2 lines
but now this wouldn't do
anything?
Nope.
Quoted 3 lines
What's the use of just this when you don't have things like
async_schedule_domain()andasync_synchronize_full_domain(), regulator stuff wouldn't compile I think?
You mean is not having the full asynch that deals with all registered domains likely to have an issue on the useres of async_synchronize_full_domain() ? Lets better ask Dan.
Quoted 1 line
I guess I'm a bit confused what kind of effect this has.
Nothing, really. If we had a user of it in other ways we'd fail compiling anyway but right now its a simple direct replacement.
Luis
Re: [PATCH 06/18] compat: backport ASYNC_DOMAIN_EXCLUSIVE()
Quoted 3 lines · Luis R. Rodriguez
Quoted 1 line
I guess I'd have to review the async API,
Yeap, reviewing the commit noted would help too.
Yeah ... :)
Quoted 7 lines
Quoted 3 lines
What's the use of just this when you don't have things like
async_schedule_domain()andasync_synchronize_full_domain(), regulator stuff wouldn't compile I think?You mean is not having the full asynch that deals with all registered domains likely to have an issue on the useres of
async_synchronize_full_domain()? Lets better ask Dan.
I don't know. However it seems that in order to have an ASYNC_DOMAIN() or ASYNC_DOMAIN_EXCLUSIVE() you always need to *do* something with it, so for that you'd also need the functions async_schedule_domain() and async_synchronize_full_domain() or similar, at least, no?
The point here seems to be making boot faster by starting a bunch of async probing inside a domain, and then you wait for the entire domain, so everything that's in that domain can be done in parallel.
Say for example you have 20 SCSI drives. If you look at them serially then you'd waste much time waiting for the drives. The point here appears to be that you create a domain (using this macro), then add all the drives to the domain and then wait for the domain to finish.
However, it seems entirely pointless to backport just a small part of the API?
johannes
Re: [PATCH 06/18] compat: backport ASYNC_DOMAIN_EXCLUSIVE()
Quoted 25 lines · Johannes Berg
Quoted 3 lines · Luis R. Rodriguez
Quoted 1 line
I guess I'd have to review the async API,
Yeap, reviewing the commit noted would help too.
Yeah ... :)
Quoted 7 lines
Quoted 3 lines
What's the use of just this when you don't have things like
async_schedule_domain()andasync_synchronize_full_domain(), regulator stuff wouldn't compile I think?You mean is not having the full asynch that deals with all registered domains likely to have an issue on the useres of
async_synchronize_full_domain()? Lets better ask Dan.I don't know. However it seems that in order to have an
ASYNC_DOMAIN()orASYNC_DOMAIN_EXCLUSIVE()you always need to *do* something with it, so for that you'd also need the functionsasync_schedule_domain()andasync_synchronize_full_domain()or similar, at least, no?The point here seems to be making boot faster by starting a bunch of async probing inside a domain, and then you wait for the entire domain, so everything that's in that domain can be done in parallel.
Quoted 7 lines
Say for example you have 20 SCSI drives. If you look at them serially then you'd waste much time waiting for the drives. The point here appears to be that you create a domain (using this macro), then add all the drives to the domain and then wait for the domain to finish.
However, it seems entirely pointless to backport just a small part of the API?
Oh I agree don't get me wrong, however porting kernel/async.c seems like a rather separate effort worth considering. As-is though I have not seen any negative impact though to keep older subsystems from compiling, ie its a no-op for older kernels as I see it.
Luis
Re: [PATCH 06/18] compat: backport ASYNC_DOMAIN_EXCLUSIVE()
Quoted 7 lines · Luis R. Rodriguez
Quoted 2 lines
However, it seems entirely pointless to backport just a small part of the API?
Oh I agree don't get me wrong, however porting
kernel/async.cseems like a rather separate effort worth considering. As-is though I have not seen any negative impact though to keep older subsystems from compiling, ie its a no-op for older kernels as I see it.
I guess that's what I don't understand -- I don't see usages of ASYNC_DOMAIN_EXCLUSIVE in any header files, and in e.g. regulator/core.c you'd also need the functions async_schedule_domain() etc. So where does this help even compiling?
johannes
Re: [PATCH 06/18] compat: backport ASYNC_DOMAIN_EXCLUSIVE()
Quoted 10 lines · Johannes Berg
Quoted 7 lines · Luis R. Rodriguez
Quoted 2 lines
However, it seems entirely pointless to backport just a small part of the API?
Oh I agree don't get me wrong, however porting
kernel/async.cseems like a rather separate effort worth considering. As-is though I have not seen any negative impact though to keep older subsystems from compiling, ie its a no-op for older kernels as I see it.
Quoted 4 lines
I guess that's what I don't understand -- I don't see usages of
ASYNC_DOMAIN_EXCLUSIVEin any header files, and in e.g.regulator/core.cyou'd also need the functionsasync_schedule_domain()etc. So where does this help even compiling?
You know what, sorry this was left over from when I tried to backport the regulatory to the core of compat, and since I decided to not even go there given that it relies on init sections on the vmlinux we can safely discard this patch (although what I said still hold, just not needed).
Luis
Re: [PATCH 06/18] compat: backport ASYNC_DOMAIN_EXCLUSIVE()
Quoted 10 lines · Luis R. Rodriguez
Quoted 9 lines
Quoted 4 lines
Oh I agree don't get me wrong, however porting
kernel/async.cseems like a rather separate effort worth considering. As-is though I have not seen any negative impact though to keep older subsystems from compiling, ie its a no-op for older kernels as I see it.I guess that's what I don't understand -- I don't see usages of
ASYNC_DOMAIN_EXCLUSIVEin any header files, and in e.g.regulator/core.cyou'd also need the functionsasync_schedule_domain()etc. So where does this help even compiling?
Quoted 5 lines
You know what, sorry this was left over from when I tried to backport the regulatory to the core of compat, and since I decided to not even go there given that it relies on init sections on the vmlinux we can safely discard this patch (although what I said still hold, just not needed).
Ok. Yeah after looking at the users I actually do agree this won't really hurt, but it seemed it doesn't help anything at all hence my confusion... :)
johannes
Re: [PATCH 06/18] compat: backport ASYNC_DOMAIN_EXCLUSIVE()
Quoted 18 lines · Johannes Berg
Quoted 10 lines · Luis R. Rodriguez
Quoted 9 lines
Quoted 4 lines
Oh I agree don't get me wrong, however porting
kernel/async.cseems like a rather separate effort worth considering. As-is though I have not seen any negative impact though to keep older subsystems from compiling, ie its a no-op for older kernels as I see it.I guess that's what I don't understand -- I don't see usages of
ASYNC_DOMAIN_EXCLUSIVEin any header files, and in e.g.regulator/core.cyou'd also need the functionsasync_schedule_domain()etc. So where does this help even compiling?Quoted 5 lines
You know what, sorry this was left over from when I tried to backport the regulatory to the core of compat, and since I decided to not even go there given that it relies on init sections on the vmlinux we can safely discard this patch (although what I said still hold, just not needed).
Quoted 3 lines
Ok. Yeah after looking at the users I actually do agree this won't really hurt, but it seemed it doesn't help anything at all hence my confusion... :)
Yea its fine to drop for now.
Luis
PATCH 7/18 compat: backport devres_release()
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
commit d926d0e4c74cfcb42a05e91d1cdf698b41e1e118
Author: Mark Brown <[email protected]> Date: Thu May 3 18:15:13 2012 +0100
devres: Add devres_release()
APIs using devres frequently want to implement a "remove and free the resource" operation so it seems sensible that they should be able to just have devres do the freeing for them since that's a big part of what devres is all about.
--- backport/compat/compat-3.5.c | 34 ++++++++++++++++++++++++++++++++++ backport/include/linux/compat-3.5.h | 6 ++++++ 2 files changed, 40 insertions(+)
backport/compat/compat-3.5.c +34 -0
@@ -12,6 +12,40 @@#include <linux/highuid.h> #include <linux/ktime.h> +#if (LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,2 ,0 )) +#include <linux/device.h> + +/** +* devres_release - Find a device resource and destroy it, calling release +* @dev: Device to find resource from +* @release: Look for resources associated with this release function +* @match: Match function (optional) +* @match_data: Data for the match function +* +* Find the latest devres of @dev associated with @release and for +* which @match returns 1. If @match is NULL, it's considered to +* match all. If found, the resource is removed atomically, the +* release function called and the resource freed. +* +* RETURNS: +* 0 if devres is found and freed, -ENOENT if not found. +*/ +int devres_release (struct device *dev,dr_release_t release, +dr_match_t match,void *match_data) +{ +void *res; + + res =devres_remove (dev, release, match, match_data); +if (unlikely (!res)) +return -ENOENT ; + + (*release)(dev, res); +devres_free (res); +return 0 ; +} +EXPORT_SYMBOL_GPL (devres_release); +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */ +/* * Commit 7a4e7408c5cadb240e068a662251754a562355e3 * exported overflowuid and overflowgid for all
backport/include/linux/compat-3.5.h +6 -0
@@ -10,6 +10,12 @@#include <net/netlink.h> +#if (LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,2 ,0 )) +#define devres_release LINUX_BACKPORT(devres_release) +extern int devres_release (struct device *dev,dr_release_t release, +dr_match_t match,void *match_data); +#endif +#if (LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,27 ))#include <linux/ratelimit.h> #define dev_level_ratelimited (dev_level, dev, fmt, ...) \
Signature · 1 line
1.7.10.4
PATCH 8/18 compat: backport dev_get_regmap()
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
We can't backport dev_get_regmap() unless we backport regmap fully onto compat, but users typically try to get the regmap in other ways first:
if (config->regmap)
rdev->regmap = config->regmap;
else if (dev_get_regmap(dev, NULL))
rdev->regmap = dev_get_regmap(dev, NULL);
else if (dev->parent)
rdev->regmap = dev_get_regmap(dev->parent, NULL);So this would option would just not be available for.
mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains 72b39f6f v3.5-rc1~117^2~7^3
commit 72b39f6f2b5a6b0beff14b80bed9756f151218a9
Author: Mark Brown <[email protected]> Date: Tue May 8 17:44:40 2012 +0100
regmap: Implement dev_get_regmap()
Use devres to implement dev_get_regmap(). This should mean that in almost all cases devices wishing to take advantage of framework features based on regmap shouldn't need to explicitly pass the regmap into the framework. This simplifies device setup a bit.
--- backport/include/linux/compat-3.5.h | 9 +++++++++ 1 file changed, 9 insertions(+)
backport/include/linux/compat-3.5.h +9 -0
@@ -11,6 +11,15 @@#include <net/netlink.h> #if (LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,2 ,0 )) +#include <linux/regmap.h> + +#define dev_get_regmap LINUX_BACKPORT(dev_get_regmap) +static inline +struct regmap *dev_get_regmap (struct device *dev,const char *name) +{ +return NULL ; +} +#define devres_release LINUX_BACKPORT(devres_release)extern int devres_release (struct device *dev,dr_release_t release,dr_match_t match,void *match_data);
Signature · 1 line
1.7.10.4
PATCH 9/18 compat: backport devm_ioremap_resource()
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
The new API gives more information to driver users but the older kernels do not have any of these mechanisms in place so just throw out ERR_PTR(-ENOMEM) in case of failure.
mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains 75096579 v3.9-rc1~128^2~63
commit 75096579c3ac39ddc2f8b0d9a8924eba31f4d920
Author: Thierry Reding <[email protected]> Date: Mon Jan 21 11:08:54 2013 +0100
lib: devres: Introduce devm_ioremap_resource()
The devm_request_and_ioremap() function is very useful and helps avoid a whole lot of boilerplate. However, one issue that keeps popping up is its lack of a specific error code to determine which of the steps that it performs failed. Furthermore, while the function gives an example and suggests what error code to return on failure, a wide variety of error codes are used throughout the tree.
In an attempt to fix these problems, this patch adds a new function that drivers can transition to. The devm_ioremap_resource() returns a pointer to the remapped I/O memory on success or an ERR_PTR() encoded error code on failure. Callers can check for failure using IS_ERR() and determine its cause by extracting the error code using PTR_ERR().
devm_request_and_ioremap() is implemented as a wrapper around the new API and return NULL on failure as before. This ensures that backwards compatibility is maintained until all users have been converted to the new API, at which point the old devm_request_and_ioremap() function should be removed.
A semantic patch is included which can be used to convert from the old devm_request_and_ioremap() API to the new devm_ioremap_resource() API. Some non-trivial cases may require manual intervention, though.
--- backport/compat/compat-3.9.c | 12 ++++++++++++ backport/include/linux/compat-3.9.h | 4 ++++ 2 files changed, 16 insertions(+)
backport/compat/compat-3.9.c +12 -0
@@ -10,6 +10,7 @@#include <linux/module.h> #include <linux/scatterlist.h> +#include <linux/device.h> #ifdef __sg_page_iter_next
@@ -51,4 +52,15 @@ bool __sg_page_iter_next(struct sg_page_iter *piter) }EXPORT_SYMBOL_GPL (__sg_page_iter_next); +void __iomem *devm_ioremap_resource (struct device *dev,struct resource *res) +{ +void __iomem *dest_ptr; + + dest_ptr =devm_ioremap_resource (dev, res); +if (!dest_ptr) +return ERR_PTR (-ENOMEM ); +return dest_ptr; +} +EXPORT_SYMBOL_GPL (devm_ioremap_resource); +#endif /* __sg_page_iter_next */
backport/include/linux/compat-3.9.h +4 -0
@@ -15,6 +15,7 @@#include <linux/tty_flip.h> #include <linux/printk.h> #include <linux/scatterlist.h> +#include <linux/device.h> /* include this before changing hlist_for_each_* to use the old versions. */ #include <net/sch_generic.h>
@@ -207,6 +208,9 @@ static inline struct inode *file_inode(struct file *f)return f->f_path.dentry->d_inode; } +#define devm_ioremap_resource LINUX_BACKPORT(devm_ioremap_resource) +void __iomem *devm_ioremap_resource (struct device *dev,struct resource *res); +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) */ #endif /* LINUX_3_9_COMPAT_H */
Signature · 1 line
1.7.10.4
PATCH 10/18 compat: backport module_platform_driver_probe()
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
This is just a helper.
commit bab734fcdf2c690371e6749ce484b17653b3cb0e
Author: Fabio Porcedda <[email protected]> Date: Wed Jan 9 12:15:26 2013 +0100
driver core: add helper macro for platform_driver_probe() boilerplate
For simple modules that contain a single platform_driver without any additional setup code then ends up being a block of duplicated boilerplate. This patch adds a new macro, module_platform_driver_probe(), which replaces the module_init()/module_exit() registrations with template functions.
This macro use the same idea of module_platform_driver().
This macro is useful to stop the misuse of module_platform_driver() for removing the platform_driver_probe() boilerplate.
mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains bab734fc v3.9-rc1~128^2~123
--- backport/include/linux/compat-3.9.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
backport/include/linux/compat-3.9.h +20 -0
@@ -16,6 +16,26 @@#include <linux/printk.h> #include <linux/scatterlist.h> #include <linux/device.h> +#include <linux/platform_device.h> + +/* module_platform_driver_probe() - Helper macro for drivers that don't do +* anything special in module init/exit. This eliminates a lot of +* boilerplate. Each module may only use this macro once, and +* calling it replaces module_init() and module_exit() +*/ +#define module_platform_driver_probe (__platform_driver, __platform_probe) \ +static int __init __platform_driver##_init(void) \ +{ \ + return platform_driver_probe(&(__platform_driver), \ + __platform_probe); \ +} \ +module_init(__platform_driver##_init); \ +static void __exit __platform_driver##_exit(void) \ +{ \ + platform_driver_unregister(&(__platform_driver)); \ +} \ +module_exit(__platform_driver##_exit); +/* include this before changing hlist_for_each_* to use the old versions. */ #include <net/sch_generic.h>
Signature · 1 line
1.7.10.4
PATCH 11/18 compat: add helpers to aid backport of generic DMA changes for v4l
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
Commit c60520fa needs to be reverted for older kernels because although we can backport some large changes to DMA that ended up extending some core dma data structures, for details see bca0fa5f as an example. To *aid* with the driver changes required add a helper that lets us call what we used to do, thus requiring a smaller delta on the upstream code.
We're only adding this for >= 3.2 as this is required only for media which are also only supporting on >= 3.2.
commit c60520fa50cd86d64bc8ebb34300ddc4ca91393d
Author: Marek Szyprowski <[email protected]> Date: Thu Jun 14 11:32:21 2012 -0300
[media] v4l: vb2-dma-contig: let mmap method to use dma_mmap_coherent call
Let mmap method to use dma_mmap_coherent call. Moreover, this patch removes vb2_mmap_pfn_range from videobuf2 helpers as it was suggested by Laurent Pinchart. The function is no longer used in vb2 code.
--- backport/compat/compat-3.9.c | 43 +++++++++++++++++++++++++++++++++++ backport/include/linux/compat-3.9.h | 7 ++++++ 2 files changed, 50 insertions(+)
backport/compat/compat-3.9.c +43 -0
@@ -12,6 +12,49 @@#include <linux/scatterlist.h> #include <linux/device.h> +#if (LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,2 ,0 )) +/** +* vb2_mmap_pfn_range() - map physical pages to userspace +* @vma: virtual memory region for the mapping +* @paddr: starting physical address of the memory to be mapped +* @size: size of the memory to be mapped +* @vm_ops: vm operations to be assigned to the created area +* @priv: private data to be associated with the area +* +* Returns 0 on success. +*/ +int vb2_mmap_pfn_range (struct vm_area_struct *vma,unsigned long paddr, +unsigned long size, +const struct vm_operations_struct *vm_ops, +void *priv) +{ +int ret; + + size = min_t(unsigned long, vma->vm_end - vma->vm_start, size); + + vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); + ret =remap_pfn_range (vma, vma->vm_start, paddr >>PAGE_SHIFT , + size, vma->vm_page_prot); +if (ret) { +printk (KERN_ERR "Remapping memory failed, error: %d\n" , ret); +return ret; + } + + vma->vm_flags |=VM_DONTEXPAND |VM_DONTDUMP ; + vma->vm_private_data = priv; + vma->vm_ops = vm_ops; + + vma->vm_ops->open (vma); + +pr_debug ("%s: mapped paddr 0x%08lx at 0x%08lx, size %ld\n" , + __func__, paddr, vma->vm_start, size); + +return 0 ; +} +EXPORT_SYMBOL_GPL (vb2_mmap_pfn_range); +#endif + +#ifdef __sg_page_iter_next void __sg_page_iter_start(struct sg_page_iter *piter,
backport/include/linux/compat-3.9.h +7 -0
@@ -18,6 +18,13 @@#include <linux/device.h> #include <linux/platform_device.h> +#if (LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,2 ,0 )) +int vb2_mmap_pfn_range (struct vm_area_struct *vma,unsigned long paddr, +unsigned long size, +const struct vm_operations_struct *vm_ops, +void *priv); +#endif +/* module_platform_driver_probe() - Helper macro for drivers that don't do * anything special in module init/exit. This eliminates a lot of * boilerplate. Each module may only use this macro once, and
Signature · 1 line
1.7.10.4
PATCH 12/18 compat: backport dma_get_sgtable()
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
No architectures yet have their own dma_map_sg ops so we just use the commonly developed one for all archs in this implementation. We enable this only for 3.2 given that this is only needed for dma-buf ops implementations and we only port that down to 3.2 so far as well.
mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains d2b7428e v3.6-rc1~57^2~3
commit d2b7428eb0caa7c66e34b6ac869a43915b294123
Author: Marek Szyprowski <[email protected]> Date: Wed Jun 13 10:05:52 2012 +0200
common: dma-mapping: introduce dma_get_sgtable() function
This patch adds dma_get_sgtable() function which is required to let drivers to share the buffers allocated by DMA-mapping subsystem. Right now the driver gets a dma address of the allocated buffer and the kernel virtual mapping for it. If it wants to share it with other device (= map into its dma address space) it usually hacks around kernel virtual addresses to get pointers to pages or assumes that both devices share the DMA address space. Both solutions are just hacks for the special cases, which should be avoided in the final version of buffer sharing.
To solve this issue in a generic way, a new call to DMA mapping has been introduced - dma_get_sgtable(). It allocates a scatter-list which describes the allocated buffer and lets the driver(s) to use it with other device(s) by calling dma_map_sg() on it.
This patch provides a generic implementation based on virt_to_page() call. Architectures which require more sophisticated translation might provide their own get_sgtable() methods.
ckmake (only for compat)
1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ]
real 2m39.638s user 24m55.205s sys 12m59.349s
--- backport/compat/compat-3.6.c | 18 ++++++++++++++++++ backport/include/linux/compat-3.6.h | 16 ++++++++++++++++ 2 files changed, 34 insertions(+)
backport/compat/compat-3.6.c +18 -0
@@ -16,6 +16,24 @@#include <linux/i2c.h> #if (LINUX_VERSION_CODE >=KERNEL_VERSION (3 ,2 ,0 )) +/* +* Create scatter-list for the already allocated DMA buffer. +*/ +int dma_common_get_sgtable (struct device *dev,struct sg_table *sgt, +void *cpu_addr,dma_addr_t handle,size_t size) +{ +struct page *page =virt_to_page (cpu_addr); +int ret; + + ret =sg_alloc_table (sgt,1 ,GFP_KERNEL ); +if (unlikely (ret)) +return ret; + +sg_set_page (sgt->sgl, page,PAGE_ALIGN (size),0 ); +return 0 ; +} +EXPORT_SYMBOL_GPL (dma_common_get_sgtable); +/** * __i2c_transfer - unlocked flavor of i2c_transfer * @adap: Handle to I2C bus
backport/include/linux/compat-3.6.h +16 -0
@@ -29,6 +29,22 @@ int sg_alloc_table_from_pages(struct sg_table *sgt, unsigned long offset, unsigned long size, gfp_t gfp_mask); +#define dma_common_get_sgtable LINUX_BACKPORT(dma_common_get_sgtable) +int +dma_common_get_sgtable (struct device *dev,struct sg_table *sgt, +void *cpu_addr,dma_addr_t dma_addr,size_t size); + +#define dma_get_sgtable_attrs LINUX_BACKPORT(dma_get_sgtable_attrs) +static inline int +dma_get_sgtable_attrs (struct device *dev,struct sg_table *sgt,void *cpu_addr, +dma_addr_t dma_addr,size_t size,struct dma_attrs *attrs) +{ +return dma_common_get_sgtable (dev, sgt, cpu_addr, dma_addr, size); +} + +#define dma_get_sgtable (d, t, v, h, s) dma_get_sgtable_attrs(d, t, v, h, s, NULL) + +/** * Backports *
Signature · 1 line
1.7.10.4
Re: [PATCH 12/18] compat: backport dma_get_sgtable()
Applied 7-12.
johannes
PATCH 13/18 backports: add blacklist module support
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
This lets us provide a simple map of new drivers and old drivers that it replaces at install time. This generates a blacklist via the file:
/etc/modprobe.d/backports.conf
--- backport/.blacklist.map | 10 ++++++++++ backport/Makefile.real | 3 +-- backport/scripts/blacklist.sh | 35 +++++++++++++++++++++++++++++++++++ gentree.py | 1 + 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 backport/.blacklist.map create mode 100755 backport/scripts/blacklist.sh
backport/.blacklist.map new file +10 -0
@@ -0,0 +1,10 @@ +# Update this map when a driver gets renamed or +# symbols from old drivers get moved to a newer +# driver. If you have the driver on the right +# hand side it will be blacklisted upon installation +# only if you actually installed the driver on the +# left. + +# new-driver old-driver +iwlagn iwlwifi +iwlagn iwl4965
backport/Makefile.real +1 -2
@@ -87,6 +87,7 @@ install: modules @$(MAKE) -C $(KLIB_BUILD) M=$(BACKPORT_PWD) \ INSTALL_MOD_DIR=$(KMODDIR) $(KMODPATH_ARG) \ modules_install + @./scripts/blacklist.sh $(KLIB)/ $(KLIB)/$(KMODDIR) @/sbin/depmod -ae @echo @echo Your backported driver modules should be installed now.
@@ -95,7 +96,5 @@ install: modules # FIXME: # compress modules # check depmod -# iwlwifi vs. iwlagn -# iwl4965 vs. iwlagn # install/load/unload/... scripts? # compat firmware class udev stuff
backport/scripts/blacklist.sh new file +35 -0
@@ -0,0 +1,35 @@ +#!/bin/bash + +BLACKLIST_CONF="/etc/modprobe.d/backports.conf" +BLACKLIST_MAP=".blacklist.map" + +MODULE_DIR=$1 +MODULE_UPDATES=$2 + +if [[ ! -d $MODULE_DIR ]]; then + exit +fi + +if [[ ! -d $MODULE_UPDATES ]]; then + exit +fi + +mkdir -p $(dirname $BLACKLIST_CONF) +rm -f $BLACKLIST_CONF + +echo "# To be used when using backported drivers" >> $BLACKLIST_CONF + +for i in $(grep -v ^# $BLACKLIST_MAP | cut -f 2); do + MODULE="${i}.ko" + MODULE_UPDATE="$(grep -v ^# $BLACKLIST_MAP | grep $i | cut -f 1 | head -1).ko" + + COUNT=$(find $MODULE_DIR -type f -name ${MODULE} -or -name ${MODULE}.gz | wc -l) + COUNT_REPLACE=$(find $MODULE_UPDATES -type f -name ${MODULE_UPDATE} -or -name ${MODULE_UPDATE}.gz | wc -l) + + if [ $COUNT -ne 0 ]; then + if [ $COUNT_REPLACE -ne 0 ]; then + echo "Blacklisting $MODULE ..." + echo blacklist $i >> $BLACKLIST_CONF + fi + fi +done
gentree.py +1 -0
@@ -324,6 +324,7 @@ def process(kerneldir, outdir, copy_list_file, git_revision=None, backport_files = [(x, x) for x in [ 'Kconfig', 'Makefile', 'Makefile.build', 'Makefile.kernel', '.gitignore', 'Makefile.real', 'compat/', 'include/', 'kconfig/', 'defconfigs/', + 'scripts/', '.blacklist.map', ]] if not args.git_revision: logwrite('Copy original source files ...')
Signature · 1 line
1.7.10.4
Re: [PATCH 13/18] backports: add blacklist module support
backport/.blacklist.map line 10
Quoted 13 lines · Luis R. Rodriguez
backport/.blacklist.map new file +10
-0@@ -0,0 +1,10 @@ +# Update this map when a driver gets renamed or +# symbols from old drivers get moved to a newer +# driver. If you have the driver on the right +# hand side it will be blacklisted upon installation +# only if you actually installed the driver on the +# left. + +# new-driver old-driver +iwlagn iwlwifi +iwlagn iwl4965
Seems that's really
# old-driver new-driver
no?
backport/.blacklist.map
Quoted 3 lines
backport/.blacklist.map new file +3
-0+rm -f $BLACKLIST_CONF + +echo "# To be used when using backported drivers" >> $BLACKLIST_CONF
Or you could just use > instead of >> on this first line ;-)
Quoted 1 line
+for i in $(grep -v ^# $BLACKLIST_MAP | cut -f 2); do
What happens if the blacklist map contains empty lines? Might want to allow that.
backport/.blacklist.map
Quoted 11 lines
backport/.blacklist.map new file +11
-0+ MODULE="${i}.ko" + MODULE_UPDATE="$(grep -v ^# $BLACKLIST_MAP | grep $i | cut -f 1 | head -1).ko" + + COUNT=$(find $MODULE_DIR -type f -name ${MODULE} -or -name ${MODULE}.gz | wc -l) + COUNT_REPLACE=$(find $MODULE_UPDATES -type f -name ${MODULE_UPDATE} -or -name ${MODULE_UPDATE}.gz | wc -l) + + if [ $COUNT -ne 0 ]; then + if [ $COUNT_REPLACE -ne 0 ]; then + echo "Blacklisting $MODULE ..." + echo blacklist $i >> $BLACKLIST_CONF + fi
So you do mean "# new-driver old-driver", but then shouldn't the iwlwifi lines be reversed?
johannes
Re: [PATCH 13/18] backports: add blacklist module support
Quoted 6 lines · Johannes Berg
backport/scripts/blacklist.sh line 20
Quoted 3 lines · Luis R. Rodriguez
backport/scripts/blacklist.sh new file +3
-0+rm -f $BLACKLIST_CONF + +echo "# To be used when using backported drivers" >> $BLACKLIST_CONFOr you could just use > instead of >> on this first line ;-)
Doh, yes.
Quoted 4 lines
Quoted 1 line
+for i in $(grep -v ^# $BLACKLIST_MAP | cut -f 2); do
What happens if the blacklist map contains empty lines? Might want to allow that.
That's magically taken care of, I tested even with a line with just just empty lines but also spaces. For some reason awk works more reliably for the field cutting so I'll switch it.
Quoted 6 lines
Quoted 6 lines
backport/scripts/blacklist.sh new file +6
-0+ MODULE="${i}.ko" + MODULE_UPDATE="$(grep -v ^# $BLACKLIST_MAP | grep $i | cut -f 1 | head -1).ko" + + COUNT=$(find $MODULE_DIR -type f -name ${MODULE} -or -name ${MODULE}.gz | wc -l) + COUNT_REPLACE=$(find $MODULE_UPDATES -type f -name ${MODULE_UPDATE} -or -name ${MODULE_UPDATE}.gz | wc -l) +
Quoted 8 lines
backport/scripts/blacklist.sh line 33
Quoted 5 lines
backport/scripts/blacklist.sh new file +5
-0+ if [ $COUNT -ne 0 ]; then + if [ $COUNT_REPLACE -ne 0 ]; then + echo "Blacklisting $MODULE ..." + echo blacklist $i >> $BLACKLIST_CONF + fiSo you do mean "# new-driver old-driver", but then shouldn't the iwlwifi lines be reversed?
You would know better, sorry I thought iwlagn replaces those, I'll swap.
Luis
Re: [PATCH 13/18] backports: add blacklist module support
Quoted 4 lines · Luis R. Rodriguez
Quoted 2 lines
So you do mean "# new-driver old-driver", but then shouldn't the iwlwifi lines be reversed?
You would know better, sorry I thought iwlagn replaces those, I'll swap.
Well it's a bit complicated and it changed a few times, but now there's only iwlegacy and iwlwifi (with iwldvm/iwlmvm), so iwlagn no longer exists. It did inbetween at some point, and I think iwlwifi even existed before already, but that doesn't really matter since a new iwlwifi would override an existing iwlwifi. So yeah I think they should be switched.
johannes
PATCH 14/18 backports: add support for module compression
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
Some Linux distributions like to compress their modules. Add support to detect this in a modutils / modprobe agnostic way.
--- backport/Makefile.real | 6 +++++- backport/scripts/are_mods_compressed | 8 ++++++++ backport/scripts/mod_path | 8 ++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100755 backport/scripts/are_mods_compressed create mode 100755 backport/scripts/mod_path
backport/Makefile.real +5 -1
@@ -88,13 +88,17 @@ install: modules INSTALL_MOD_DIR=$(KMODDIR) $(KMODPATH_ARG) \ modules_install @./scripts/blacklist.sh $(KLIB)/ $(KLIB)/$(KMODDIR) + @./scripts/are_mods_compressed || ( \ + for driver in $$(find $(KLIB)/$(KMODDIR) \ + -type f -name *.ko); do \ + gzip -9 $$driver ;\ + done ) @/sbin/depmod -ae @echo @echo Your backported driver modules should be installed now. @echo Try loading them with modprobe. @echo # FIXME: -# compress modules # check depmod # install/load/unload/... scripts? # compat firmware class udev stuff
backport/scripts/are_mods_compressed new file +8 -0
@@ -0,0 +1,8 @@ +#!/bin/bash +MODULE=$(./scripts/mod_path mac80211) +MODULE=${MODULE##*/} +if [ "$MODULE" = "mac80211.ko.gz" ]; then + COMPRESSION_FOUND="y" + exit 1 +fi +exit 0
backport/scripts/mod_path new file +8 -0
@@ -0,0 +1,8 @@ +#!/bin/bash +which modinfo > /dev/null 2>&1 +if [[ $? -eq 0 ]]; then + MOD_QUERY="modinfo -F filename" +else + MOD_QUERY="modprobe -l" +fi +$MOD_QUERY $1 | tail -1
Signature · 1 line
1.7.10.4
Re: [PATCH 14/18] backports: add support for module compression
backport/scripts/are_mods_compressed line 5
Quoted 7 lines · Luis R. Rodriguez
+++ b/backport/scripts/are_mods_compressed
backport/scripts/are_mods_compressed new file +5
-0@@ -0,0 +1,8 @@ +#!/bin/bash +MODULE=$(./scripts/mod_path mac80211) +MODULE=${MODULE##*/} +if [ "$MODULE" = "mac80211.ko.gz" ]; then + COMPRESSION_FOUND="y"
That variable seems useless?
Also is there much value in splitting this across two scripts? Seems a bit small to do that?
johannes
PATCH 15/18 backports: add check_depmod to look for module search path
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
This backports project relies on you being able to update your Linux distribution modules by looking at an updates search path, if one is not found we update depmod to look for the new path for you.
--- backport/Makefile.real | 2 +- backport/scripts/check_depmod | 78 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 1 deletion(-) create mode 100755 backport/scripts/check_depmod
backport/Makefile.real +1 -1
@@ -93,12 +93,12 @@ install: modules -type f -name *.ko); do \ gzip -9 $$driver ;\ done ) + @./scripts/check_depmod @/sbin/depmod -ae @echo @echo Your backported driver modules should be installed now. @echo Try loading them with modprobe. @echo # FIXME: -# check depmod # install/load/unload/... scripts? # compat firmware class udev stuff
backport/scripts/check_depmod new file +78 -0
78 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [PATCH 15/18] backports: add check_depmod to look for module search path
Quoted 6 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
This backports project relies on you being able to update your Linux distribution modules by looking at an updates search path, if one is not found we update depmod to look for the new path for you.
Looks good, but I guess it's not going to apply by itself without the previosu patches.
johannes
PATCH 16/18 backports: add udev rules if required for backported firmware_class
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
--- backport/Makefile.real | 2 +- backport/scripts/backport_firmware_install | 21 +++++++++++++++++ backport/udev/50-compat_firmware.rules | 4 ++++ backport/udev/compat_firmware.sh | 35 ++++++++++++++++++++++++++++ backport/udev/ubuntu/compat_firmware.sh | 29 +++++++++++++++++++++++ gentree.py | 2 +- 6 files changed, 91 insertions(+), 2 deletions(-) create mode 100755 backport/scripts/backport_firmware_install create mode 100644 backport/udev/50-compat_firmware.rules create mode 100755 backport/udev/compat_firmware.sh create mode 100755 backport/udev/ubuntu/compat_firmware.sh
backport/Makefile.real +1 -1
@@ -94,6 +94,7 @@ install: modules gzip -9 $$driver ;\ done ) @./scripts/check_depmod + @./scripts/backport_firmware_install @/sbin/depmod -ae @echo @echo Your backported driver modules should be installed now.
@@ -101,4 +102,3 @@ install: modules @echo # FIXME: # install/load/unload/... scripts? -# compat firmware class udev stuff
backport/scripts/backport_firmware_install new file +21 -0
@@ -0,0 +1,21 @@ +#!/bin/sh + +if [ -f /usr/bin/lsb_release ]; then + LSB_RED_ID=$(/usr/bin/lsb_release -i -s) +else + LSB_RED_ID="Unknown" +fi + +case $LSB_RED_ID in +"Ubuntu") + mkdir -p /lib/udev/ /lib/udev/rules.d/ + cp udev/ubuntu/compat_firmware.sh /lib/udev/ + cp udev/50-compat_firmware.rules /lib/udev/rules.d/ + ;; +*) + mkdir -p /lib/udev/ /lib/udev/rules.d/ + cp udev/compat_firmware.sh /lib/udev/ + cp udev/50-compat_firmware.rules /lib/udev/rules.d/ + ;; +esac +
backport/udev/50-compat_firmware.rules new file +4 -0
@@ -0,0 +1,4 @@ +# do not edit this file, it will be overwritten on update + +# compat_firmware-class requests, copies files into the kernel +SUBSYSTEM=="compat_firmware", ACTION=="add", RUN+="compat_firmware.sh"
backport/udev/compat_firmware.sh new file +35 -0
@@ -0,0 +1,35 @@ +#!/bin/sh -e + +# This is ported from Ubuntu but ubuntu uses these directories which +# other distributions don't care about: +# FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \ +# /lib/firmware/$(uname -r) /lib/firmware" +# If your distribution looks for firmware in other directories +# feel free to extend this and add your own directory here. +# +FIRMWARE_DIRS="/lib/firmware" + +err() { + echo "$@" >&2 + logger -t "${0##*/}[$$]" "$@" 2>/dev/null || true +} + +if [ ! -e /sys$DEVPATH/loading ]; then + err "udev firmware loader misses sysfs directory" + exit 1 +fi + +for DIR in $FIRMWARE_DIRS; do + [ -e "$DIR/$FIRMWARE" ] || continue + echo 1 > /sys$DEVPATH/loading + cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data + echo 0 > /sys$DEVPATH/loading + exit 0 +done + +echo -1 > /sys$DEVPATH/loading +err "Cannot find firmware file '$FIRMWARE'" +mkdir -p /dev/.udev/firmware-missing +file=$(echo "$FIRMWARE" | sed 's:/:\\x2f:g') +ln -s -f "$DEVPATH" /dev/.udev/firmware-missing/$file +exit 1
backport/udev/ubuntu/compat_firmware.sh new file +29 -0
@@ -0,0 +1,29 @@ +#!/bin/sh -e + +FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \ + /lib/firmware/$(uname -r) /lib/firmware" + +err() { + echo "$@" >&2 + logger -t "${0##*/}[$$]" "$@" 2>/dev/null || true +} + +if [ ! -e /sys$DEVPATH/loading ]; then + err "udev firmware loader misses sysfs directory" + exit 1 +fi + +for DIR in $FIRMWARE_DIRS; do + [ -e "$DIR/$FIRMWARE" ] || continue + echo 1 > /sys$DEVPATH/loading + cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data + echo 0 > /sys$DEVPATH/loading + exit 0 +done + +echo -1 > /sys$DEVPATH/loading +err "Cannot find firmware file '$FIRMWARE'" +mkdir -p /dev/.udev/firmware-missing +file=$(echo "$FIRMWARE" | sed 's:/:\\x2f:g') +ln -s -f "$DEVPATH" /dev/.udev/firmware-missing/$file +exit 1
gentree.py +1 -1
@@ -324,7 +324,7 @@ def process(kerneldir, outdir, copy_list_file, git_revision=None, backport_files = [(x, x) for x in [ 'Kconfig', 'Makefile', 'Makefile.build', 'Makefile.kernel', '.gitignore', 'Makefile.real', 'compat/', 'include/', 'kconfig/', 'defconfigs/', - 'scripts/', '.blacklist.map', + 'scripts/', '.blacklist.map', 'udev/', ]] if not args.git_revision: logwrite('Copy original source files ...')
Signature · 1 line
1.7.10.4
Re: [PATCH 16/18] backports: add udev rules if required for backported firmware_class
Quoted 1 line · Luis R. Rodriguez
+err "Cannot find firmware file '$FIRMWARE'"
nitpick: need only one space :)
Other than that this looks like voodoo to me, so I guess it's good :)
johannes
Re: [PATCH 16/18] backports: add udev rules if required for backported firmware_class
In reply to Luis R. RodriguezOh, I wonder if there's a way to know this isn't needed on newer kernels? But I guess it doesn't really hurt anyway.
johannes
Re: [PATCH 16/18] backports: add udev rules if required for backported firmware_class
Quoted 2 lines · Johannes Berg
Oh, I wonder if there's a way to know this isn't needed on newer kernels? But I guess it doesn't really hurt anyway.
Its where we left off on compat-drivers so I welcome evolutions :)
Luis
PATCH 17/18 backports: use depmod -a
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
Use only depmod -a and at the same time tell the
user to reboot, we no longer support unloading /
loading for them given that we backport too many
modules.
--- backport/Makefile.real | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
backport/Makefile.real +2 -4
@@ -95,10 +95,8 @@ install: modules done ) @./scripts/check_depmod @./scripts/backport_firmware_install - @/sbin/depmod -ae + @/sbin/depmod -a @echo @echo Your backported driver modules should be installed now. - @echo Try loading them with modprobe. + @echo Reboot. @echo -# FIXME: -# install/load/unload/... scripts?
Signature · 1 line
1.7.10.4
Re: [PATCH 17/18] backports: use depmod -a
Quoted 6 lines · Luis R. Rodriguez
From: "Luis R. Rodriguez" <[email protected]>
Use only depmod -a and at the same time tell the
user to reboot, we no longer support unloading /
loading for them given that we backport too many
modules.
Heh, fine with me.
johannes
PATCH 18/18 backports: add update-initramfs support
In reply to Luis R. RodriguezFrom: "Luis R. Rodriguez" <[email protected]>
You'll need to update your initramfs for for a few modules. This is very distribution specific.
--- backport/Makefile.real | 1 + backport/scripts/update-initramfs | 62 +++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100755 backport/scripts/update-initramfs
backport/Makefile.real +1 -0
@@ -96,6 +96,7 @@ install: modules @./scripts/check_depmod @./scripts/backport_firmware_install @/sbin/depmod -a + @./scripts/update-initramfs $(KLIB) @echo @echo Your backported driver modules should be installed now. @echo Reboot.
backport/scripts/update-initramfs new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
1.7.10.4
Re: [PATCH 18/18] backports: add update-initramfs support
Quoted 1 line · Luis R. Rodriguez
+KLIB=1
pretty sure that should be "$1" or at least just $1 ?
johannes
Re: [PATCH 18/18] backports: add update-initramfs support
Quoted 5 lines · Johannes Berg
Quoted 1 line · Luis R. Rodriguez
+KLIB=1
pretty sure that should be "$1" or at least just $1 ?
Fuck sorry yes.
Luis