Skip to contentSkip to conversation

My updates

MTD Superseded Maxim Levitsky 2 participants 9 messages Sep 18, 2010 – Sep 20, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

The first patch should finally fix both hotplug and the case of non removeable modules. In fact all modules can be removed always.
Testing is welcome.

The 2nd and 3rd patches are cosmetic additions to my code. (First patch avoids double powerdown/up, but it seemed to work both ways)

Best regards,
Maxim Levitsky

#1 lore raw

PATCH 1/3 MTD: blktrans: Final version of hotplug support

Or at least this patch claims it to be so...

Now it once again possible to remove mtdtrans and mtd drivers even if underlying mtd device is mounted.
This time in addition to code review, I also made the code pass some torture tests like module reload in a loop + read in a loop + card insert/removal all at same time.

The blktrans_open/blktrans_release don't take the mtd table lock because:

While device is added (that includes execution of add_mtd_blktrans_dev) the lock is already taken

Now suppose the device will never be removed. In this case even if we have changes in mtd table, the entry that we need will stay exactly the same. (Note that we don't look at table at all, just following private pointer of block device).

Now suppose that someone tries to remove the mtd device.
This will be propagated to trans driver which _ought_ to call del_mtd_blktrans_dev which will take the per device lock, release the mtd device and set trans->mtd = NULL.

Quoted 1 line

From this point on, following opens won't even be able to know anything about that mtd device

(which at that point is likely not to exist)
Also the same care is taken not to trip over NULL mtd pointer in blktrans_dev_release.

In addition to that I moved the blk_cleanup_queue back to del_mtd_blktrans_dev because I now know that is ok, and I removed the BUG from deregister_mtd_blktrans because the current mtd trans driver can still have 'dead' users upon removal. These won't touch it again, so its safe to remove the module.

---
 drivers/mtd/mtd_blkdevs.c |   67 +++++++++++++++++++-------------------------
 1 files changed, 29 insertions(+), 38 deletions(-)
drivers/mtd/mtd_blkdevs.c +29 -38
index 62e6870..d773a40 100644
@@ -47,7 +47,6 @@ void blktrans_dev_release(struct kref *kref)
 		container_of(kref, struct mtd_blktrans_dev, ref);
 
 	dev->disk->private_data = NULL;
-	blk_cleanup_queue(dev->rq);
 	put_disk(dev->disk);
 	list_del(&dev->list);
 	kfree(dev);
@@ -133,6 +132,10 @@ static int mtd_blktrans_thread(void *arg)
 
 		if (!req && !(req = blk_fetch_request(rq))) {
 			set_current_state(TASK_INTERRUPTIBLE);
+
+			if (kthread_should_stop())
+				break;
+
 			spin_unlock_irq(rq->queue_lock);
 			schedule();
 			spin_lock_irq(rq->queue_lock);
@@ -176,54 +179,51 @@ static void mtd_blktrans_request(struct request_queue *rq)
 static int blktrans_open(struct block_device *bdev, fmode_t mode)
 {
 	struct mtd_blktrans_dev *dev = blktrans_dev_get(bdev->bd_disk);
-	int ret;
+	int ret = 0;
 
 	if (!dev)
-		return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/
+		return -EIO;
 
-	lock_kernel();
 	mutex_lock(&dev->lock);
 
-	if (!dev->mtd) {
-		ret = -ENXIO;
+	if (dev->open++)
 		goto unlock;
-	}
 
-	ret = !dev->open++ && dev->tr->open ? dev->tr->open(dev) : 0;
+	kref_get(&dev->ref);
+
+	if (dev->mtd) {
+		ret = dev->tr->open ? dev->tr->open(dev) : 0;
+		__get_mtd_device(dev->mtd);
+	}
 
-	/* Take another reference on the device so it won't go away till
-		last release */
-	if (!ret)
-		kref_get(&dev->ref);
 unlock:
 	mutex_unlock(&dev->lock);
 	blktrans_dev_put(dev);
-	unlock_kernel();
 	return ret;
 }
 
 static int blktrans_release(struct gendisk *disk, fmode_t mode)
 {
 	struct mtd_blktrans_dev *dev = blktrans_dev_get(disk);
-	int ret = -ENXIO;
+	int ret = 0;
 
 	if (!dev)
 		return ret;
 
-	lock_kernel();
 	mutex_lock(&dev->lock);
 
-	/* Release one reference, we sure its not the last one here*/
-	kref_put(&dev->ref, blktrans_dev_release);
-
-	if (!dev->mtd)
+	if (--dev->open)
 		goto unlock;
 
-	ret = !--dev->open && dev->tr->release ? dev->tr->release(dev) : 0;
+	kref_put(&dev->ref, blktrans_dev_release);
+
+	if (dev->mtd) {
+		ret = dev->tr->release ? dev->tr->release(dev) : 0;
+		__put_mtd_device(dev->mtd);
+	}
 unlock:
 	mutex_unlock(&dev->lock);
 	blktrans_dev_put(dev);
-	unlock_kernel();
 	return ret;
 }
 
@@ -256,7 +256,6 @@ static int blktrans_ioctl(struct block_device *bdev, fmode_t mode,
 	if (!dev)
 		return ret;
 
-	lock_kernel();
 	mutex_lock(&dev->lock);
 
 	if (!dev->mtd)
@@ -271,7 +270,6 @@ static int blktrans_ioctl(struct block_device *bdev, fmode_t mode,
 	}
 unlock:
 	mutex_unlock(&dev->lock);
-	unlock_kernel();
 	blktrans_dev_put(dev);
 	return ret;
 }
@@ -385,9 +383,6 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 
 	gd->queue = new->rq;
 
-	__get_mtd_device(new->mtd);
-	__module_get(tr->owner);
-
 	/* Create processing thread */
 	/* TODO: workqueue ? */
 	new->thread = kthread_run(mtd_blktrans_thread, new,
@@ -410,8 +405,6 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 	}
 	return 0;
 error4:
-	module_put(tr->owner);
-	__put_mtd_device(new->mtd);
 	blk_cleanup_queue(new->rq);
 error3:
 	put_disk(new->disk);
@@ -448,17 +441,17 @@ int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
 	blk_start_queue(old->rq);
 	spin_unlock_irqrestore(&old->queue_lock, flags);
 
-	/* Ask trans driver for release to the mtd device */
+	blk_cleanup_queue(old->rq);
+
+	/* If the device is currently open, tell trans driver to close it,
+		then put mtd device, and don't touch it again */
 	mutex_lock(&old->lock);
-	if (old->open && old->tr->release) {
-		old->tr->release(old);
-		old->open = 0;
+	if (old->open) {
+		if (old->tr->release)
+			old->tr->release(old);
+		__put_mtd_device(old->mtd);
 	}
 
-	__put_mtd_device(old->mtd);
-	module_put(old->tr->owner);
-
-	/* At that point, we don't touch the mtd anymore */
 	old->mtd = NULL;
 
 	mutex_unlock(&old->lock);
@@ -542,8 +535,6 @@ int deregister_mtd_blktrans(struct mtd_blktrans_ops *tr)
 
 	unregister_blkdev(tr->major, tr->name);
 	mutex_unlock(&mtd_table_mutex);
-
-	BUG_ON(!list_empty(&tr->devs));
 	return 0;
 }
 
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH v2 1/1 MTD: blktrans: Final version of hotplug support

From: Maxim Levitsky <[email protected]>

Or at least this patch claims it to be so...

Now it once again possible to remove mtdtrans and mtd drivers even if underlying mtd device is mounted.
This time in addition to code review, I also made the code pass some torture tests like module reload in a loop + read in a loop + card insert/removal all at same time.

The blktrans_open/blktrans_release don't take the mtd table lock because:

While device is added (that includes execution of add_mtd_blktrans_dev) the lock is already taken

Now suppose the device will never be removed. In this case even if we have changes in mtd table, the entry that we need will stay exactly the same. (Note that we don't look at table at all, just following private pointer of block device).

Now suppose that someone tries to remove the mtd device.
This will be propagated to trans driver which _ought_ to call del_mtd_blktrans_dev which will take the per device lock, release the mtd device and set trans->mtd = NULL.

Quoted 1 line

From this point on, following opens won't even be able to know anything about that mtd device

(which at that point is likely not to exist)
Also the same care is taken not to trip over NULL mtd pointer in blktrans_dev_release.

In addition to that I moved the blk_cleanup_queue back to del_mtd_blktrans_dev because I now know that is ok.

---
 drivers/mtd/mtd_blkdevs.c |   67 +++++++++++++++++++++------------------------
 1 files changed, 31 insertions(+), 36 deletions(-)
drivers/mtd/mtd_blkdevs.c +31 -36
index 62e6870..c124cbe 100644
@@ -47,7 +47,6 @@ void blktrans_dev_release(struct kref *kref)
 		container_of(kref, struct mtd_blktrans_dev, ref);
 
 	dev->disk->private_data = NULL;
-	blk_cleanup_queue(dev->rq);
 	put_disk(dev->disk);
 	list_del(&dev->list);
 	kfree(dev);
@@ -133,6 +132,10 @@ static int mtd_blktrans_thread(void *arg)
 
 		if (!req && !(req = blk_fetch_request(rq))) {
 			set_current_state(TASK_INTERRUPTIBLE);
+
+			if (kthread_should_stop())
+				break;
+
 			spin_unlock_irq(rq->queue_lock);
 			schedule();
 			spin_lock_irq(rq->queue_lock);
@@ -176,54 +179,53 @@ static void mtd_blktrans_request(struct request_queue *rq)
 static int blktrans_open(struct block_device *bdev, fmode_t mode)
 {
 	struct mtd_blktrans_dev *dev = blktrans_dev_get(bdev->bd_disk);
-	int ret;
+	int ret = 0;
 
 	if (!dev)
-		return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/
+		return -EIO;
 
-	lock_kernel();
 	mutex_lock(&dev->lock);
 
-	if (!dev->mtd) {
-		ret = -ENXIO;
+	if (dev->open++)
 		goto unlock;
-	}
 
-	ret = !dev->open++ && dev->tr->open ? dev->tr->open(dev) : 0;
+	kref_get(&dev->ref);
+	__module_get(dev->tr->owner);
+
+	if (dev->mtd) {
+		ret = dev->tr->open ? dev->tr->open(dev) : 0;
+		__get_mtd_device(dev->mtd);
+	}
 
-	/* Take another reference on the device so it won't go away till
-		last release */
-	if (!ret)
-		kref_get(&dev->ref);
 unlock:
 	mutex_unlock(&dev->lock);
 	blktrans_dev_put(dev);
-	unlock_kernel();
 	return ret;
 }
 
 static int blktrans_release(struct gendisk *disk, fmode_t mode)
 {
 	struct mtd_blktrans_dev *dev = blktrans_dev_get(disk);
-	int ret = -ENXIO;
+	int ret = 0;
 
 	if (!dev)
 		return ret;
 
-	lock_kernel();
 	mutex_lock(&dev->lock);
 
-	/* Release one reference, we sure its not the last one here*/
-	kref_put(&dev->ref, blktrans_dev_release);
-
-	if (!dev->mtd)
+	if (--dev->open)
 		goto unlock;
 
-	ret = !--dev->open && dev->tr->release ? dev->tr->release(dev) : 0;
+	kref_put(&dev->ref, blktrans_dev_release);
+	module_put(dev->tr->owner);
+
+	if (dev->mtd) {
+		ret = dev->tr->release ? dev->tr->release(dev) : 0;
+		__put_mtd_device(dev->mtd);
+	}
 unlock:
 	mutex_unlock(&dev->lock);
 	blktrans_dev_put(dev);
-	unlock_kernel();
 	return ret;
 }
 
@@ -256,7 +258,6 @@ static int blktrans_ioctl(struct block_device *bdev, fmode_t mode,
 	if (!dev)
 		return ret;
 
-	lock_kernel();
 	mutex_lock(&dev->lock);
 
 	if (!dev->mtd)
@@ -271,7 +272,6 @@ static int blktrans_ioctl(struct block_device *bdev, fmode_t mode,
 	}
 unlock:
 	mutex_unlock(&dev->lock);
-	unlock_kernel();
 	blktrans_dev_put(dev);
 	return ret;
 }
@@ -385,9 +385,6 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 
 	gd->queue = new->rq;
 
-	__get_mtd_device(new->mtd);
-	__module_get(tr->owner);
-
 	/* Create processing thread */
 	/* TODO: workqueue ? */
 	new->thread = kthread_run(mtd_blktrans_thread, new,
@@ -410,8 +407,6 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 	}
 	return 0;
 error4:
-	module_put(tr->owner);
-	__put_mtd_device(new->mtd);
 	blk_cleanup_queue(new->rq);
 error3:
 	put_disk(new->disk);
@@ -448,17 +443,17 @@ int del_mtd_blktrans_dev(struct mtd_blktrans_dev *old)
 	blk_start_queue(old->rq);
 	spin_unlock_irqrestore(&old->queue_lock, flags);
 
-	/* Ask trans driver for release to the mtd device */
+	blk_cleanup_queue(old->rq);
+
+	/* If the device is currently open, tell trans driver to close it,
+		then put mtd device, and don't touch it again */
 	mutex_lock(&old->lock);
-	if (old->open && old->tr->release) {
-		old->tr->release(old);
-		old->open = 0;
+	if (old->open) {
+		if (old->tr->release)
+			old->tr->release(old);
+		__put_mtd_device(old->mtd);
 	}
 
-	__put_mtd_device(old->mtd);
-	module_put(old->tr->owner);
-
-	/* At that point, we don't touch the mtd anymore */
 	old->mtd = NULL;
 
 	mutex_unlock(&old->lock);
Signature · 1 line
1.7.0.4
#3 lore raw

Re: [PATCH 1/3] MTD: blktrans: Final version of hotplug support

In reply to Maxim Levitsky
Quoted 24 lines · Maxim Levitsky

Or at least this patch claims it to be so...

Now it once again possible to remove mtdtrans and mtd drivers even if underlying mtd device is mounted.
This time in addition to code review, I also made the code pass some torture tests like module reload in a loop + read in a loop + card insert/removal all at same time.

The blktrans_open/blktrans_release don't take the mtd table lock because:

While device is added (that includes execution of add_mtd_blktrans_dev) the lock is already taken

Now suppose the device will never be removed. In this case even if we have changes in mtd table, the entry that we need will stay exactly the same. (Note that we don't look at table at all, just following private pointer of block device).

Now suppose that someone tries to remove the mtd device.
This will be propagated to trans driver which _ought_ to call del_mtd_blktrans_dev which will take the per device lock, release the mtd device and set trans->mtd = NULL. From this point on, following opens won't even be able to know anything about that mtd device (which at that point is likely not to exist)
Also the same care is taken not to trip over NULL mtd pointer in blktrans_dev_release.

Quoted 6 lines

In addition to that I moved the blk_cleanup_queue back to del_mtd_blktrans_dev because I now know that is ok, and I removed the BUG from deregister_mtd_blktrans because the current mtd trans driver can still have 'dead' users upon removal. These won't touch it again, so its safe to remove the module.

Too many changes in one patch - please, split it on smaller patches. Do one change per patch not many changes in one. This patch is not really reviewable. And since you are fixing regression, make sure you have first N _minimal_ patches which just fix the regression and nothing else, and to the rest in the following M patches.

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Битюцкий Артём)
#4 lore raw

Re: [PATCH 1/3] MTD: blktrans: Final version of hotplug support

Quoted 30 lines · Artem Bityutskiy
Quoted 29 lines · Maxim Levitsky

Or at least this patch claims it to be so...

Now it once again possible to remove mtdtrans and mtd drivers even if underlying mtd device is mounted.
This time in addition to code review, I also made the code pass some torture tests like module reload in a loop + read in a loop + card insert/removal all at same time.

The blktrans_open/blktrans_release don't take the mtd table lock because:

While device is added (that includes execution of add_mtd_blktrans_dev) the lock is already taken

Now suppose the device will never be removed. In this case even if we have changes in mtd table, the entry that we need will stay exactly the same. (Note that we don't look at table at all, just following private pointer of block device).

Now suppose that someone tries to remove the mtd device.
This will be propagated to trans driver which _ought_ to call del_mtd_blktrans_dev which will take the per device lock, release the mtd device and set trans->mtd = NULL. From this point on, following opens won't even be able to know anything about that mtd device (which at that point is likely not to exist)
Also the same care is taken not to trip over NULL mtd pointer in blktrans_dev_release.

In addition to that I moved the blk_cleanup_queue back to del_mtd_blktrans_dev because I now know that is ok, and I removed the BUG from deregister_mtd_blktrans because the current mtd trans driver can still have 'dead' users upon removal. These won't touch it again, so its safe to remove the module.

Quoted 7 lines
Quoted 1 line

Too many changes in one patch - please, split it on smaller patches. Do one change per patch not many changes in one. This patch is not really reviewable. And since you are fixing regression, make sure you have first N _minimal_ patches which just fix the regression and nothing else, and to the rest in the following M patches.

Artem, this patch, really fixes just one regression (especially V2). The move of blk_cleanup_queue back if you insist, I can skip, its just one line.

I really can't split this.

Note that in V2 I restricted again the unloading of the trans module if its block device is in use.
If I were to allow that, it turns out that removal will work just fine, but if module is loaded again, it could register a block device with same major/minor as the block device that still exists, and that causes havoc.

Best regards,
Maxim Levitsky

#5 lore raw

Re: [PATCH 1/3] MTD: blktrans: Final version of hotplug support

Quoted 33 lines · Maxim Levitsky
Quoted 32 lines · Artem Bityutskiy
Quoted 30 lines · Maxim Levitsky

Or at least this patch claims it to be so...

Now it once again possible to remove mtdtrans and mtd drivers even if underlying mtd device is mounted.
This time in addition to code review, I also made the code pass some torture tests like module reload in a loop + read in a loop + card insert/removal all at same time.

The blktrans_open/blktrans_release don't take the mtd table lock because:

While device is added (that includes execution of add_mtd_blktrans_dev) the lock is already taken

Now suppose the device will never be removed. In this case even if we have changes in mtd table, the entry that we need will stay exactly the same. (Note that we don't look at table at all, just following private pointer of block device).

Now suppose that someone tries to remove the mtd device.
This will be propagated to trans driver which _ought_ to call del_mtd_blktrans_dev which will take the per device lock, release the mtd device and set trans->mtd = NULL. From this point on, following opens won't even be able to know anything about that mtd device (which at that point is likely not to exist)
Also the same care is taken not to trip over NULL mtd pointer in blktrans_dev_release.

In addition to that I moved the blk_cleanup_queue back to del_mtd_blktrans_dev because I now know that is ok, and I removed the BUG from deregister_mtd_blktrans because the current mtd trans driver can still have 'dead' users upon removal. These won't touch it again, so its safe to remove the module.

Quoted 8 lines
Quoted 5 lines

Too many changes in one patch - please, split it on smaller patches. Do one change per patch not many changes in one. This patch is not really reviewable. And since you are fixing regression, make sure you have first N _minimal_ patches which just fix the regression and nothing else, and to the rest in the following M patches.

Artem, this patch, really fixes just one regression (especially V2). The move of blk_cleanup_queue back if you insist, I can skip, its just one line.

On the second thought, you are right,
I dudn't notice few more changes I added because I was busy stabilizing it.
Btw, no crashes yet despite many attempts.

Best regards,
Maxim Levitsky

#6 lore raw

Re: [PATCH 1/3] MTD: blktrans: Final version of hotplug support

In reply to Maxim Levitsky

In one of your e-mails you said this patch is minimalistic. Here are some suggestions.

Quoted 10 lines · Maxim Levitsky
---
 drivers/mtd/mtd_blkdevs.c |   67 +++++++++++++++++++-------------------------
 1 files changed, 29 insertions(+), 38 deletions(-)
drivers/mtd/mtd_blkdevs.c +0 -0
index 62e6870..d773a40 100644

drivers/mtd/mtd_blkdevs.c void blktrans_dev_release(struct kref *kref) · line 50

Quoted 4 lines
drivers/mtd/mtd_blkdevs.c +0 -1
@@ -47,7 +47,6 @@ void blktrans_dev_release(struct kref *kref)
 		container_of(kref, struct mtd_blktrans_dev, ref);
 
 	dev->disk->private_data = NULL;
-	blk_cleanup_queue(dev->rq);

Them can be a separate patch.

drivers/mtd/mtd_blkdevs.c static int mtd_blktrans_thread(void *arg) · line 137

Quoted 10 lines
drivers/mtd/mtd_blkdevs.c +3 -0
 	put_disk(dev->disk);
 	list_del(&dev->list);
 	kfree(dev);
@@ -133,6 +132,10 @@ static int mtd_blktrans_thread(void *arg)
 
 		if (!req && !(req = blk_fetch_request(rq))) {
 			set_current_state(TASK_INTERRUPTIBLE);
+
+			if (kthread_should_stop())
+				break;

This could be a separate patch.

Quoted 5 lines
drivers/mtd/mtd_blkdevs.c +1 -0
+
 			spin_unlock_irq(rq->queue_lock);
 			schedule();
 			spin_lock_irq(rq->queue_lock);

drivers/mtd/mtd_blkdevs.c static void mtd_blktrans_request(struct request_queue *rq) · line 185

Quoted 9 lines
drivers/mtd/mtd_blkdevs.c +2 -2
@@ -176,54 +179,51 @@ static void mtd_blktrans_request(struct request_queue *rq)
 static int blktrans_open(struct block_device *bdev, fmode_t mode)
 {
 	struct mtd_blktrans_dev *dev = blktrans_dev_get(bdev->bd_disk);
-	int ret;
+	int ret = 0;
 
 	if (!dev)
-		return -ERESTARTSYS; /* FIXME: busy loop! -arnd*/
+		return -EIO;

Hmm, why EIO? ENODEV is better. And this can be a separate patch, may be?

Quoted 15 lines
drivers/mtd/mtd_blkdevs.c +6 -5
-	lock_kernel();
 	mutex_lock(&dev->lock);
 
-	if (!dev->mtd) {
-		ret = -ENXIO;
+	if (dev->open++)
 		goto unlock;
-	}
 
-	ret = !dev->open++ && dev->tr->open ? dev->tr->open(dev) : 0;
+	kref_get(&dev->ref);
+
+	if (dev->mtd) {
+		ret = dev->tr->open ? dev->tr->open(dev) : 0;
+		__get_mtd_device(dev->mtd);

drivers/mtd/mtd_blkdevs.c static void mtd_blktrans_request(struct request_queue *rq) · line 201

Quoted 10 lines
drivers/mtd/mtd_blkdevs.c +1 -5
+	}
 
-	/* Take another reference on the device so it won't go away till
-		last release */
-	if (!ret)
-		kref_get(&dev->ref);
 unlock:
 	mutex_unlock(&dev->lock);
 	blktrans_dev_put(dev);
-	unlock_kernel();

So you kill BKL in the same patch? No, make it separately, please.

Did not look further.

Please, make a nice set of independent minimalistic patches. This is very important for patches which will go to 2.6.36 to be minimal and just fix the problem. Then the rest of the patches can do more things and they will go to 2.6.37.

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
#7 lore raw

PATCH 2/3 MTD: r852: remove useless pci powerup/down from suspend/resume routines.

In reply to Maxim Levitsky

It turns out that pci core now handles these, so this code is redundand and can even cause bugs

---
 drivers/mtd/nand/r852.c |   30 +-----------------------------
 drivers/mtd/nand/r852.h |    2 --
 2 files changed, 1 insertions(+), 31 deletions(-)
drivers/mtd/nand/r852.c +1 -29
index 5169ca6..d9d7efb 100644
@@ -757,11 +757,6 @@ static irqreturn_t r852_irq(int irq, void *data)
 
 	spin_lock_irqsave(&dev->irqlock, flags);
 
-	/* We can recieve shared interrupt while pci is suspended
-		in that case reads will return 0xFFFFFFFF.... */
-	if (dev->insuspend)
-		goto out;
-
 	/* handle card detection interrupts first */
 	card_status = r852_read_reg(dev, R852_CARD_IRQ_STA);
 	r852_write_reg(dev, R852_CARD_IRQ_STA, card_status);
@@ -1035,7 +1030,6 @@ void r852_shutdown(struct pci_dev *pci_dev)
 int r852_suspend(struct device *device)
 {
 	struct r852_device *dev = pci_get_drvdata(to_pci_dev(device));
-	unsigned long flags;
 
 	if (dev->ctlreg & R852_CTL_CARDENABLE)
 		return -EBUSY;
@@ -1047,43 +1041,22 @@ int r852_suspend(struct device *device)
 	r852_disable_irqs(dev);
 	r852_engine_disable(dev);
 
-	spin_lock_irqsave(&dev->irqlock, flags);
-	dev->insuspend = 1;
-	spin_unlock_irqrestore(&dev->irqlock, flags);
-
-	/* At that point, even if interrupt handler is running, it will quit */
-	/* So wait for this to happen explictly */
-	synchronize_irq(dev->irq);
-
 	/* If card was pulled off just during the suspend, which is very
 		unlikely, we will remove it on resume, it too late now
 		anyway... */
 	dev->card_unstable = 0;
-
-	pci_save_state(to_pci_dev(device));
-	return pci_prepare_to_sleep(to_pci_dev(device));
+	return 0;
 }
 
 int r852_resume(struct device *device)
 {
 	struct r852_device *dev = pci_get_drvdata(to_pci_dev(device));
-	unsigned long flags;
-
-	/* Turn on the hardware */
-	pci_back_from_sleep(to_pci_dev(device));
-	pci_restore_state(to_pci_dev(device));
 
 	r852_disable_irqs(dev);
 	r852_card_update_present(dev);
 	r852_engine_disable(dev);
 
 
-	/* Now its safe for IRQ to run */
-	spin_lock_irqsave(&dev->irqlock, flags);
-	dev->insuspend = 0;
-	spin_unlock_irqrestore(&dev->irqlock, flags);
-
-
 	/* If card status changed, just do the work */
 	if (dev->card_detected != dev->card_registred) {
 		dbg("card was %s during low power state",
@@ -1121,7 +1094,6 @@ MODULE_DEVICE_TABLE(pci, r852_pci_id_tbl);
 
 SIMPLE_DEV_PM_OPS(r852_pm_ops, r852_suspend, r852_resume);
 
-
 static struct pci_driver r852_pci_driver = {
 	.name		= DRV_NAME,
 	.id_table	= r852_pci_id_tbl,
drivers/mtd/nand/r852.h +0 -2
index 8096cc2..e6a21d9 100644
@@ -140,8 +140,6 @@ struct r852_device {
 	/* interrupt handling */
 	spinlock_t irqlock;		/* IRQ protecting lock */
 	int irq;			/* irq num */
-	int insuspend;			/* device is suspended */
-
 	/* misc */
 	void *tmp_buffer;		/* temporary buffer */
 	uint8_t ctlreg;			/* cached contents of control reg */
Signature · 1 line
1.7.0.4
#8 lore raw

PATCH 3/3 mtd: sm_ftl: cosmetic, use bool when possible

In reply to Maxim Levitsky

I didn't know that kernel allows use of that typedef.

---
 drivers/mtd/sm_ftl.h |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/mtd/sm_ftl.h +4 -4
index e30e48e..43bb730 100644
@@ -20,7 +20,7 @@
 
 
 struct ftl_zone {
-	int initialized;
+	bool initialized;
 	int16_t *lba_to_phys_table;		/* LBA to physical table */
 	struct kfifo free_sectors;	/* queue of free sectors */
 };
@@ -37,8 +37,8 @@ struct sm_ftl {
 	int zone_count;			/* number of zones */
 	int max_lba;			/* maximum lba in a zone */
 	int smallpagenand;		/* 256 bytes/page nand */
-	int readonly;			/* is FS readonly */
-	int unstable;
+	bool readonly;			/* is FS readonly */
+	bool unstable;
 	int cis_block;			/* CIS block location */
 	int cis_boffset;		/* CIS offset in the block */
 	int cis_page_offset;		/* CIS offset in the page */
@@ -49,7 +49,7 @@ struct sm_ftl {
 	int cache_zone;			/* zone of cached block */
 	unsigned char *cache_data;	/* cached block data */
 	long unsigned int cache_data_invalid_bitmap;
-	int cache_clean;
+	bool cache_clean;
 	struct work_struct flush_work;
 	struct timer_list timer;
 
Signature · 1 line
1.7.0.4