{
struct tx_event *ev = NULL;
- ev = kzalloc(sizeof(struct tx_event), GFP_KERNEL);
+ ev = devm_kzalloc(tx_dev->dev,
+ sizeof(struct tx_event), GFP_KERNEL);
irblaster_dbg("event_get ev=0x%p\n", ev);
return ev;
}
static void event_put(struct tx_event *ev)
{
irblaster_dbg("event_put ev=0x%p\n", ev);
- kfree(ev);
+ devm_kfree(tx_dev->dev, ev);
+
}
static int send_bit(unsigned int hightime, unsigned int lowtime,
if (j >= PS_SIZE) {
pr_err("send timing value is out of range\n");
+ event_put(ev);
return -ENOMEM;
}
}
j++;
if (j >= PS_SIZE) {
pr_err("send timing value is out of range\n");
+ event_put(ev);
return -ENOMEM;
}
}
static int aml_irblaster_probe(struct platform_device *pdev)
{
- int r;
+ int r = 0;
struct irtx_dev *dev;
struct pinctrl *p;
pr_info("irblaster probe\n");
- dev = kzalloc(sizeof(struct irtx_dev), GFP_KERNEL);
+ dev = devm_kzalloc(&pdev->dev,
+ sizeof(struct irtx_dev), GFP_KERNEL);
if (!dev) {
- pr_info("");
+ pr_info("kzalloc failed\n");
return -ENOMEM;
}
- irblaster = kzalloc(sizeof(struct blaster_window), GFP_KERNEL);
+ irblaster = devm_kzalloc(&pdev->dev,
+ sizeof(struct blaster_window), GFP_KERNEL);
if (irblaster == NULL)
return -1;
}
cdev_init(&amirblaster_device, &aml_irblaster_fops);
amirblaster_device.owner = THIS_MODULE;
- cdev_add(&(amirblaster_device), amirblaster_id, DEIVE_COUNT);
+ r = cdev_add(&(amirblaster_device), amirblaster_id, DEIVE_COUNT);
+ if (r) {
+ pr_err("failed to add cdev\n");
+ return r;
+ }
irblaster_class = class_create(THIS_MODULE, DEVICE_NAME);
if (IS_ERR(irblaster_class)) {
unregister_chrdev_region(amirblaster_id, DEIVE_COUNT);
{
struct tx_event *ev = NULL;
- ev = kzalloc(sizeof(struct tx_event), GFP_KERNEL);
+ ev = devm_kzalloc(tx_dev->dev,
+ sizeof(struct tx_event), GFP_KERNEL);
irblaster_dbg("irblaster_event_get ev=0x%p\n", ev);
return ev;
}
static void irblaster_event_put(struct tx_event *ev)
{
- irblaster_dbg("irblaster_event_put ev=0x%p\n", ev);
- kfree(ev);
+ irblaster_dbg("event_put ev=0x%p\n", ev);
+ devm_kfree(tx_dev->dev, ev);
}
static int irblaster_send_bit(unsigned int hightime, unsigned int lowtime,
j++;
if (j >= PS_SIZE) {
+ irblaster_event_put(ev);
pr_err("send timing value is out of range\n");
return -ENOMEM;
}
void __iomem *reset_base = NULL;
pr_info("irblaster probe\n");
- dev = kzalloc(sizeof(struct irtx_dev), GFP_KERNEL);
+ dev = devm_kzalloc(&pdev->dev,
+ sizeof(struct irtx_dev), GFP_KERNEL);
if (!dev) {
pr_info("faid to kzalloc irtx_dev");
return -ENOMEM;
}
- irblaster_win = kzalloc(sizeof(struct blaster_window), GFP_KERNEL);
+ irblaster_win = devm_kzalloc(&pdev->dev,
+ sizeof(struct blaster_window), GFP_KERNEL);
if (irblaster_win == NULL)
return -1;