Re: [RFC 5/9] SQUASHME: prd: Last fixes for partitions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2014-08-13 at 15:16 +0300, Boaz Harrosh wrote:
> From: Boaz Harrosh <boaz@xxxxxxxxxxxxx>
> 
> This streamlines prd with the latest brd code.
> 
> In prd we do not allocate new devices dynamically on devnod
> access, because we need parameterization of each device. So
> the dynamic allocation in prd_init_one is removed.
> 
> Therefor prd_init_one only called from prd_prob is moved
> there, now that it is small.
> 
> And other small fixes regarding partitions
> 
> Signed-off-by: Boaz Harrosh <boaz@xxxxxxxxxxxxx>
> ---
>  drivers/block/prd.c | 47 ++++++++++++++++++++++++-----------------------
>  1 file changed, 24 insertions(+), 23 deletions(-)

<snip>

> @@ -308,24 +314,6 @@ static void prd_free(struct prd_device *prd)
>  	kfree(prd);
>  }
>  
> -static struct prd_device *prd_init_one(int i)
> -{
> -	struct prd_device *prd;
> -
> -	list_for_each_entry(prd, &prd_devices, prd_list) {
> -		if (prd->prd_number == i)
> -			goto out;
> -	}
> -
> -	prd = prd_alloc(i);
> -	if (prd) {
> -		add_disk(prd->prd_disk);
> -		list_add_tail(&prd->prd_list, &prd_devices);
> -	}
> -out:
> -	return prd;
> -}
> -
>  static void prd_del_one(struct prd_device *prd)
>  {
>  	list_del(&prd->prd_list);
> @@ -333,16 +321,27 @@ static void prd_del_one(struct prd_device *prd)
>  	prd_free(prd);
>  }
>  
> +/*FIXME: Actually in our driver prd_probe is never used. Can be removed */
>  static struct kobject *prd_probe(dev_t dev, int *part, void *data)
>  {
>  	struct prd_device *prd;
>  	struct kobject *kobj;
> +	int number = MINOR(dev);
>  
>  	mutex_lock(&prd_devices_mutex);
> -	prd = prd_init_one(MINOR(dev));
> -	kobj = prd ? get_disk(prd->prd_disk) : NULL;
> -	mutex_unlock(&prd_devices_mutex);
>  
> +	list_for_each_entry(prd, &prd_devices, prd_list) {
> +		if (prd->prd_number == number) {
> +			kobj = get_disk(prd->prd_disk);
> +			goto out;
> +		}
> +	}
> +
> +	pr_err("prd: prd_probe: Unexpected parameter=%d\n", number);
> +	kobj = NULL;
> +
> +out:
> +	mutex_unlock(&prd_devices_mutex);
>  	return kobj;
>  }

I really like where you're going with getting rid of prd_probe.  Clearly I
just copied this from brd, but I'd love to be rid of it entirely.  Is there a
valid way for our probe function to get called?  If not, can we just have a
little stub with a BUG() in it to make sure we hear about it if it does ever
get called, and delete a bunch of code?

I think this would let us get rid of pmem_probe(), pmem_init_one(), and the
pmem_devices_mutex.

If there *is* a valid way for this code to get called, let's figure it out so
we can at least test this function.  This will be especially necessary as we
add support for more pmem disks.

>  
> @@ -424,5 +423,7 @@ static void __exit prd_exit(void)
>  
>  MODULE_AUTHOR("Ross Zwisler <ross.zwisler@xxxxxxxxxxxxxxx>");
>  MODULE_LICENSE("GPL");
> +MODULE_ALIAS("pmem");

Let's just go with the full rename s/prd/pmem/.  That turned out to be really
clean & made everything consistent - thanks for the good suggestion.

- Ross


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]