Skip to content

Commit 07ec389

Browse files
Christoph Hellwigjgunthorpe
authored andcommitted
mm: remove the struct hmm_device infrastructure
This code is a trivial wrapper around device model helpers, which should have been integrated into the driver device model usage from the start. Assuming it actually had users, which it never had since the code was added more than 1 1/2 years ago. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: John Hubbard <[email protected]> Reviewed-by: Dan Williams <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent c2561e6 commit 07ec389

File tree

2 files changed

+0
-100
lines changed

2 files changed

+0
-100
lines changed

include/linux/hmm.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -751,26 +751,6 @@ static inline unsigned long hmm_devmem_page_get_drvdata(const struct page *page)
751751
{
752752
return page->hmm_data;
753753
}
754-
755-
756-
/*
757-
* struct hmm_device - fake device to hang device memory onto
758-
*
759-
* @device: device struct
760-
* @minor: device minor number
761-
*/
762-
struct hmm_device {
763-
struct device device;
764-
unsigned int minor;
765-
};
766-
767-
/*
768-
* A device driver that wants to handle multiple devices memory through a
769-
* single fake device can use hmm_device to do so. This is purely a helper and
770-
* it is not strictly needed, in order to make use of any HMM functionality.
771-
*/
772-
struct hmm_device *hmm_device_new(void *drvdata);
773-
void hmm_device_put(struct hmm_device *hmm_device);
774754
#endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */
775755
#else /* IS_ENABLED(CONFIG_HMM) */
776756
static inline void hmm_mm_destroy(struct mm_struct *mm) {}

mm/hmm.c

Lines changed: 0 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,84 +1528,4 @@ struct hmm_devmem *hmm_devmem_add_resource(const struct hmm_devmem_ops *ops,
15281528
return devmem;
15291529
}
15301530
EXPORT_SYMBOL_GPL(hmm_devmem_add_resource);
1531-
1532-
/*
1533-
* A device driver that wants to handle multiple devices memory through a
1534-
* single fake device can use hmm_device to do so. This is purely a helper
1535-
* and it is not needed to make use of any HMM functionality.
1536-
*/
1537-
#define HMM_DEVICE_MAX 256
1538-
1539-
static DECLARE_BITMAP(hmm_device_mask, HMM_DEVICE_MAX);
1540-
static DEFINE_SPINLOCK(hmm_device_lock);
1541-
static struct class *hmm_device_class;
1542-
static dev_t hmm_device_devt;
1543-
1544-
static void hmm_device_release(struct device *device)
1545-
{
1546-
struct hmm_device *hmm_device;
1547-
1548-
hmm_device = container_of(device, struct hmm_device, device);
1549-
spin_lock(&hmm_device_lock);
1550-
clear_bit(hmm_device->minor, hmm_device_mask);
1551-
spin_unlock(&hmm_device_lock);
1552-
1553-
kfree(hmm_device);
1554-
}
1555-
1556-
struct hmm_device *hmm_device_new(void *drvdata)
1557-
{
1558-
struct hmm_device *hmm_device;
1559-
1560-
hmm_device = kzalloc(sizeof(*hmm_device), GFP_KERNEL);
1561-
if (!hmm_device)
1562-
return ERR_PTR(-ENOMEM);
1563-
1564-
spin_lock(&hmm_device_lock);
1565-
hmm_device->minor = find_first_zero_bit(hmm_device_mask, HMM_DEVICE_MAX);
1566-
if (hmm_device->minor >= HMM_DEVICE_MAX) {
1567-
spin_unlock(&hmm_device_lock);
1568-
kfree(hmm_device);
1569-
return ERR_PTR(-EBUSY);
1570-
}
1571-
set_bit(hmm_device->minor, hmm_device_mask);
1572-
spin_unlock(&hmm_device_lock);
1573-
1574-
dev_set_name(&hmm_device->device, "hmm_device%d", hmm_device->minor);
1575-
hmm_device->device.devt = MKDEV(MAJOR(hmm_device_devt),
1576-
hmm_device->minor);
1577-
hmm_device->device.release = hmm_device_release;
1578-
dev_set_drvdata(&hmm_device->device, drvdata);
1579-
hmm_device->device.class = hmm_device_class;
1580-
device_initialize(&hmm_device->device);
1581-
1582-
return hmm_device;
1583-
}
1584-
EXPORT_SYMBOL(hmm_device_new);
1585-
1586-
void hmm_device_put(struct hmm_device *hmm_device)
1587-
{
1588-
put_device(&hmm_device->device);
1589-
}
1590-
EXPORT_SYMBOL(hmm_device_put);
1591-
1592-
static int __init hmm_init(void)
1593-
{
1594-
int ret;
1595-
1596-
ret = alloc_chrdev_region(&hmm_device_devt, 0,
1597-
HMM_DEVICE_MAX,
1598-
"hmm_device");
1599-
if (ret)
1600-
return ret;
1601-
1602-
hmm_device_class = class_create(THIS_MODULE, "hmm_device");
1603-
if (IS_ERR(hmm_device_class)) {
1604-
unregister_chrdev_region(hmm_device_devt, HMM_DEVICE_MAX);
1605-
return PTR_ERR(hmm_device_class);
1606-
}
1607-
return 0;
1608-
}
1609-
1610-
device_initcall(hmm_init);
16111531
#endif /* CONFIG_DEVICE_PRIVATE || CONFIG_DEVICE_PUBLIC */

0 commit comments

Comments
 (0)