* [PATCH]: complete cleanup of check_region
@ 2007-06-07 9:39 Surya
2007-06-07 10:08 ` Jesper Juhl
2007-06-07 11:33 ` [PATCH]: complete cleanup of check_region Eberhard Moenkeberg
0 siblings, 2 replies; 9+ messages in thread
From: Surya @ 2007-06-07 9:39 UTC (permalink / raw)
To: emoenke, linux-kernel; +Cc: alan, kernel-janitors, trivial, hannu
Hi all,
This patch cleans up all the instances of check_region and
__check_region and replaces them with request_region and
__request_region. Applies and compiles clean on latest Linus tree.
Files affected:
drivers/cdrom/sbpcd.c
drivers/pnp/resource.c
include/linux/ioport.h
kernel/resource.c
sound/oss/pss.c
thanks.
Signed-off-by: Surya Prabhakar <surya.prabhakar@wipro.com>
---
diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
index a1283b1..2c1355e 100644
--- a/drivers/cdrom/sbpcd.c
+++ b/drivers/cdrom/sbpcd.c
@@ -358,6 +358,11 @@
* Add bio/kdev_t changes for 2.5.x required to make it work again.
* Still room for improvement in the request handling here if anyone
* actually cares. Bring your own chainsaw. Paul G. 02/2002
+ *
+ *
+ * Cleaned up the reference for deprecated check_region to
+ * request_region.
+ * Thu Jun 7 12:14:00 IST 2007 Surya <surya.prabhakar@wipro.com>
*/
@@ -5670,7 +5675,7 @@ int __init sbpcd_init(void)
{
addr[1]=sbpcd[port_index];
if (addr[1]==0) break;
- if (check_region(addr[1],4))
+ if (request_region(addr[1],4, "sbpcd driver"))
{
msg(DBG_INF,"check_region: %03X is not free.\n",addr[1]);
continue;
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index a685fbe..2be8001 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -251,7 +251,7 @@ int pnp_check_port(struct pnp_dev * dev, int idx)
/* check if the resource is already in use, skip if the
* device is active because it itself may be in use */
if(!dev->active) {
- if (__check_region(&ioport_resource, *port, length(port,end)))
+ if (__request_region(&ioport_resource, *port, length(port,end), "isapnp request-region"))
return 0;
}
diff --git a/include/linux/ioport.h b/include/linux/ioport.h
index 71ea923..ebe6c22 100644
--- a/include/linux/ioport.h
+++ b/include/linux/ioport.h
@@ -124,19 +124,12 @@ extern struct resource * __request_region(struct resource *,
/* Compatibility cruft */
#define release_region(start,n) __release_region(&ioport_resource, (start), (n))
-#define check_mem_region(start,n) __check_region(&iomem_resource, (start), (n))
+#define check_mem_region(start,n) __request_region(&iomem_resource, (start), (n), "request-region")
#define release_mem_region(start,n) __release_region(&iomem_resource, (start), (n))
-extern int __check_region(struct resource *, resource_size_t, resource_size_t);
extern void __release_region(struct resource *, resource_size_t,
resource_size_t);
-static inline int __deprecated check_region(resource_size_t s,
- resource_size_t n)
-{
- return __check_region(&ioport_resource, s, n);
-}
-
/* Wrappers for managed devices */
struct device;
#define devm_request_region(dev,start,n,name) \
diff --git a/kernel/resource.c b/kernel/resource.c
index 9bd14fd..99a97ca 100644
--- a/kernel/resource.c
+++ b/kernel/resource.c
@@ -520,36 +520,6 @@ struct resource * __request_region(struct resource *parent,
EXPORT_SYMBOL(__request_region);
/**
- * __check_region - check if a resource region is busy or free
- * @parent: parent resource descriptor
- * @start: resource start address
- * @n: resource region size
- *
- * Returns 0 if the region is free at the moment it is checked,
- * returns %-EBUSY if the region is busy.
- *
- * NOTE:
- * This function is deprecated because its use is racy.
- * Even if it returns 0, a subsequent call to request_region()
- * may fail because another driver etc. just allocated the region.
- * Do NOT use it. It will be removed from the kernel.
- */
-int __check_region(struct resource *parent, resource_size_t start,
- resource_size_t n)
-{
- struct resource * res;
-
- res = __request_region(parent, start, n, "check-region");
- if (!res)
- return -EBUSY;
-
- release_resource(res);
- kfree(res);
- return 0;
-}
-EXPORT_SYMBOL(__check_region);
-
-/**
* __release_region - release a previously reserved resource region
* @parent: parent resource descriptor
* @start: resource start address
diff --git a/sound/oss/pss.c b/sound/oss/pss.c
index ece428b..c61a1a3 100644
--- a/sound/oss/pss.c
+++ b/sound/oss/pss.c
@@ -54,6 +54,9 @@
* Added __init to probe_pss(), attach_pss() and probe_pss_mpu()
* 02-Jan-2001: Chris Rankin
* Specify that this module owns the coprocessor
+ * 07-Jun-2007: Surya Prabhakar <surya.prabhakar@wipro.com>
+ * Cleaned up the reference for deprecated check_region to
+ * request_region.
*/
@@ -677,7 +680,7 @@ static void configure_nonsound_components(void)
{
printk(KERN_INFO "PSS: CDROM port not enabled.\n");
}
- else if(check_region(pss_cdrom_port, 2))
+ else if(request_region(pss_cdrom_port, 2, "CDROM config"))
{
printk(KERN_ERR "PSS: CDROM I/O port conflict.\n");
}
--
surya .
07/06/2007
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH]: complete cleanup of check_region
2007-06-07 9:39 [PATCH]: complete cleanup of check_region Surya
@ 2007-06-07 10:08 ` Jesper Juhl
[not found] ` <1181215018.3275.2.camel@bluegenie>
2007-06-07 11:33 ` [PATCH]: complete cleanup of check_region Eberhard Moenkeberg
1 sibling, 1 reply; 9+ messages in thread
From: Jesper Juhl @ 2007-06-07 10:08 UTC (permalink / raw)
To: Surya; +Cc: emoenke, linux-kernel, alan, kernel-janitors, trivial, hannu
On 07/06/07, Surya <surya.prabhakar@wipro.com> wrote:
> Hi all,
> This patch cleans up all the instances of check_region and
> __check_region and replaces them with request_region and
> __request_region. Applies and compiles clean on latest Linus tree.
>
> Files affected:
> drivers/cdrom/sbpcd.c
> drivers/pnp/resource.c
> include/linux/ioport.h
> kernel/resource.c
> sound/oss/pss.c
>
>
> thanks.
>
>
> Signed-off-by: Surya Prabhakar <surya.prabhakar@wipro.com>
> ---
>
> diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
> index a1283b1..2c1355e 100644
> --- a/drivers/cdrom/sbpcd.c
> +++ b/drivers/cdrom/sbpcd.c
> @@ -358,6 +358,11 @@
> * Add bio/kdev_t changes for 2.5.x required to make it work again.
> * Still room for improvement in the request handling here if anyone
> * actually cares. Bring your own chainsaw. Paul G. 02/2002
> + *
> + *
> + * Cleaned up the reference for deprecated check_region to
> + * request_region.
> + * Thu Jun 7 12:14:00 IST 2007 Surya <surya.prabhakar@wipro.com>
> */
>
>
> @@ -5670,7 +5675,7 @@ int __init sbpcd_init(void)
> {
> addr[1]=sbpcd[port_index];
> if (addr[1]==0) break;
> - if (check_region(addr[1],4))
> + if (request_region(addr[1],4, "sbpcd driver"))
No! You can't just swap one for the other.
check_region() simply checks if the region is available, it doesn't
reserve it (well, it does, briefly, but it lets it go again).
request_region() reserves the region. That's different behaviour that
you need to take into account.
Then there's the matter of return values. check_region() returns 0 on
success while request_region returns != 0 on success. I don't see your
patch dealing with that.
And finally, now that you request (and thus reserve) these regions,
where is the code to release them again when they are no longer
needed. just as memory allocated with kmalloc() needs to be freed with
kfree() after use, so regions reserved with request_region() need to
be released again with release_region() when they are no longer
needed. I don't see anything in your patch that releases the requested
regions.
Same comments for the rest of the patch.
--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH]: complete cleanup of check_region
2007-06-07 9:39 [PATCH]: complete cleanup of check_region Surya
2007-06-07 10:08 ` Jesper Juhl
@ 2007-06-07 11:33 ` Eberhard Moenkeberg
2007-06-07 13:07 ` Jesper Juhl
1 sibling, 1 reply; 9+ messages in thread
From: Eberhard Moenkeberg @ 2007-06-07 11:33 UTC (permalink / raw)
To: Surya; +Cc: linux-kernel, alan, kernel-janitors, trivial, hannu
[-- Attachment #1: Type: TEXT/PLAIN, Size: 5485 bytes --]
Hi,
On Thu, 7 Jun 2007, Surya wrote:
>
> Hi all,
> This patch cleans up all the instances of check_region and
> __check_region and replaces them with request_region and
> __request_region. Applies and compiles clean on latest Linus tree.
>
> Files affected:
> drivers/cdrom/sbpcd.c
> drivers/pnp/resource.c
> include/linux/ioport.h
> kernel/resource.c
> sound/oss/pss.c
>
>
> thanks.
>
>
> Signed-off-by: Surya Prabhakar <surya.prabhakar@wipro.com>
in drivers/cdrom/sbpcd.c the message string should be changed too.
Acked-by: Eberhard Moenkeberg <emoenke@gwdg.de>
> ---
>
> diff --git a/drivers/cdrom/sbpcd.c b/drivers/cdrom/sbpcd.c
> index a1283b1..2c1355e 100644
> --- a/drivers/cdrom/sbpcd.c
> +++ b/drivers/cdrom/sbpcd.c
> @@ -358,6 +358,11 @@
> * Add bio/kdev_t changes for 2.5.x required to make it work again.
> * Still room for improvement in the request handling here if anyone
> * actually cares. Bring your own chainsaw. Paul G. 02/2002
> + *
> + *
> + * Cleaned up the reference for deprecated check_region to
> + * request_region.
> + * Thu Jun 7 12:14:00 IST 2007 Surya <surya.prabhakar@wipro.com>
> */
>
>
> @@ -5670,7 +5675,7 @@ int __init sbpcd_init(void)
> {
> addr[1]=sbpcd[port_index];
> if (addr[1]==0) break;
> - if (check_region(addr[1],4))
> + if (request_region(addr[1],4, "sbpcd driver"))
> {
> msg(DBG_INF,"check_region: %03X is not free.\n",addr[1]);
> continue;
> diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
> index a685fbe..2be8001 100644
> --- a/drivers/pnp/resource.c
> +++ b/drivers/pnp/resource.c
> @@ -251,7 +251,7 @@ int pnp_check_port(struct pnp_dev * dev, int idx)
> /* check if the resource is already in use, skip if the
> * device is active because it itself may be in use */
> if(!dev->active) {
> - if (__check_region(&ioport_resource, *port, length(port,end)))
> + if (__request_region(&ioport_resource, *port, length(port,end), "isapnp request-region"))
> return 0;
> }
>
> diff --git a/include/linux/ioport.h b/include/linux/ioport.h
> index 71ea923..ebe6c22 100644
> --- a/include/linux/ioport.h
> +++ b/include/linux/ioport.h
> @@ -124,19 +124,12 @@ extern struct resource * __request_region(struct resource *,
>
> /* Compatibility cruft */
> #define release_region(start,n) __release_region(&ioport_resource, (start), (n))
> -#define check_mem_region(start,n) __check_region(&iomem_resource, (start), (n))
> +#define check_mem_region(start,n) __request_region(&iomem_resource, (start), (n), "request-region")
> #define release_mem_region(start,n) __release_region(&iomem_resource, (start), (n))
>
> -extern int __check_region(struct resource *, resource_size_t, resource_size_t);
> extern void __release_region(struct resource *, resource_size_t,
> resource_size_t);
>
> -static inline int __deprecated check_region(resource_size_t s,
> - resource_size_t n)
> -{
> - return __check_region(&ioport_resource, s, n);
> -}
> -
> /* Wrappers for managed devices */
> struct device;
> #define devm_request_region(dev,start,n,name) \
> diff --git a/kernel/resource.c b/kernel/resource.c
> index 9bd14fd..99a97ca 100644
> --- a/kernel/resource.c
> +++ b/kernel/resource.c
> @@ -520,36 +520,6 @@ struct resource * __request_region(struct resource *parent,
> EXPORT_SYMBOL(__request_region);
>
> /**
> - * __check_region - check if a resource region is busy or free
> - * @parent: parent resource descriptor
> - * @start: resource start address
> - * @n: resource region size
> - *
> - * Returns 0 if the region is free at the moment it is checked,
> - * returns %-EBUSY if the region is busy.
> - *
> - * NOTE:
> - * This function is deprecated because its use is racy.
> - * Even if it returns 0, a subsequent call to request_region()
> - * may fail because another driver etc. just allocated the region.
> - * Do NOT use it. It will be removed from the kernel.
> - */
> -int __check_region(struct resource *parent, resource_size_t start,
> - resource_size_t n)
> -{
> - struct resource * res;
> -
> - res = __request_region(parent, start, n, "check-region");
> - if (!res)
> - return -EBUSY;
> -
> - release_resource(res);
> - kfree(res);
> - return 0;
> -}
> -EXPORT_SYMBOL(__check_region);
> -
> -/**
> * __release_region - release a previously reserved resource region
> * @parent: parent resource descriptor
> * @start: resource start address
> diff --git a/sound/oss/pss.c b/sound/oss/pss.c
> index ece428b..c61a1a3 100644
> --- a/sound/oss/pss.c
> +++ b/sound/oss/pss.c
> @@ -54,6 +54,9 @@
> * Added __init to probe_pss(), attach_pss() and probe_pss_mpu()
> * 02-Jan-2001: Chris Rankin
> * Specify that this module owns the coprocessor
> + * 07-Jun-2007: Surya Prabhakar <surya.prabhakar@wipro.com>
> + * Cleaned up the reference for deprecated check_region to
> + * request_region.
> */
>
>
> @@ -677,7 +680,7 @@ static void configure_nonsound_components(void)
> {
> printk(KERN_INFO "PSS: CDROM port not enabled.\n");
> }
> - else if(check_region(pss_cdrom_port, 2))
> + else if(request_region(pss_cdrom_port, 2, "CDROM config"))
> {
> printk(KERN_ERR "PSS: CDROM I/O port conflict.\n");
> }
>
>
> --
> surya .
> 07/06/2007
Viele Grüße
Eberhard Mönkeberg (emoenke@gwdg.de, em@kki.org)
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH]: complete cleanup of check_region
2007-06-07 11:33 ` [PATCH]: complete cleanup of check_region Eberhard Moenkeberg
@ 2007-06-07 13:07 ` Jesper Juhl
2007-06-07 14:11 ` Eberhard Moenkeberg
0 siblings, 1 reply; 9+ messages in thread
From: Jesper Juhl @ 2007-06-07 13:07 UTC (permalink / raw)
To: Eberhard Moenkeberg
Cc: Surya, linux-kernel, alan, kernel-janitors, trivial, hannu
On 07/06/07, Eberhard Moenkeberg <emoenke@gwdg.de> wrote:
> Hi,
>
> On Thu, 7 Jun 2007, Surya wrote:
>
> >
> > Hi all,
> > This patch cleans up all the instances of check_region and
> > __check_region and replaces them with request_region and
> > __request_region. Applies and compiles clean on latest Linus tree.
> >
> > Files affected:
> > drivers/cdrom/sbpcd.c
> > drivers/pnp/resource.c
> > include/linux/ioport.h
> > kernel/resource.c
> > sound/oss/pss.c
> >
> >
> > thanks.
> >
> >
> > Signed-off-by: Surya Prabhakar <surya.prabhakar@wipro.com>
>
>
> in drivers/cdrom/sbpcd.c the message string should be changed too.
>
> Acked-by: Eberhard Moenkeberg <emoenke@gwdg.de>
>
Huh? I don't understand how you can ACK that patch.
Are my comments here: http://lkml.org/lkml/2007/6/7/102 completely
out in left field?
--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH]: complete cleanup of check_region
2007-06-07 13:07 ` Jesper Juhl
@ 2007-06-07 14:11 ` Eberhard Moenkeberg
0 siblings, 0 replies; 9+ messages in thread
From: Eberhard Moenkeberg @ 2007-06-07 14:11 UTC (permalink / raw)
To: Jesper Juhl; +Cc: Surya, linux-kernel, alan, kernel-janitors, trivial, hannu
[-- Attachment #1: Type: TEXT/PLAIN, Size: 1125 bytes --]
Hi,
On Thu, 7 Jun 2007, Jesper Juhl wrote:
> On 07/06/07, Eberhard Moenkeberg <emoenke@gwdg.de> wrote:
> > On Thu, 7 Jun 2007, Surya wrote:
> > > Hi all,
> > > This patch cleans up all the instances of check_region and
> > > __check_region and replaces them with request_region and
> > > __request_region. Applies and compiles clean on latest Linus tree.
> > >
> > > Files affected:
> > > drivers/cdrom/sbpcd.c
> > > drivers/pnp/resource.c
> > > include/linux/ioport.h
> > > kernel/resource.c
> > > sound/oss/pss.c
> > >
> > >
> > > thanks.
> > >
> > >
> > > Signed-off-by: Surya Prabhakar <surya.prabhakar@wipro.com>
> >
> >
> > in drivers/cdrom/sbpcd.c the message string should be changed too.
> >
> > Acked-by: Eberhard Moenkeberg <emoenke@gwdg.de>
> >
>
> Huh? I don't understand how you can ACK that patch.
> Are my comments here: http://lkml.org/lkml/2007/6/7/102 completely
> out in left field?
Yes, my ACK is invalid. It has an earlier time stamp than your clearing
mail.
Viele Grüße
Eberhard Mönkeberg (emoenke@gwdg.de, em@kki.org)
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2007-06-25 23:07 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-07 9:39 [PATCH]: complete cleanup of check_region Surya
2007-06-07 10:08 ` Jesper Juhl
[not found] ` <1181215018.3275.2.camel@bluegenie>
[not found] ` <9a8748490706070902i218e01bdq1c418c770e99ca4@mail.gmail.com>
2007-06-08 2:46 ` Surya
2007-06-11 11:18 ` Jesper Juhl
2007-06-12 4:15 ` [PATCH]: check_region cleanup in sbpcd.c Surya
2007-06-25 23:07 ` Jesper Juhl
2007-06-07 11:33 ` [PATCH]: complete cleanup of check_region Eberhard Moenkeberg
2007-06-07 13:07 ` Jesper Juhl
2007-06-07 14:11 ` Eberhard Moenkeberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®