Sunday, May 9, 2021

Skeleton of a platform driver with fops

 
struct dummy_drvdata {
struct cdev dummy_cdev;
struct device *dev;
};

static size_t dummy_read(struct file *file, char _user *data, size_t len, lofft *ppos)
{
struct dummy_drvdata = file->private_data;
        .......
}

static int dummy_open(struct inode *inode, struct file *file)
{
struct dummy_drvdata *drvdata = container_of(inode->i_cdev, 
                                                                struct dummy_drvdata, dummy_cdev);
file->private_data = drvdata;
return 0;
}

struct file_operations dummy_fops = {
.open = dummy_open,
.read = dummy_read,
};

static int dummy_devices_register(struct dummy_drvdata *drvdata)
{
dev_id dev;

alloc_chrdev_region(&dev, 0, 1, "dummy-devices");
cdev_init(&drv_data->dummy_cdev, dummy_fops);
cdev_add(&drvdata->dummy_cdev, dev, 1);
}

static int dummy_probe(struct platform_device *pdev)
{
struct dummy_drvdata *drvdata = kmalloc();
drvdata->dev = &pdev->dev;

platform_set_drvdata(pdev, drvdata); //needed in dummy_remove function
dummy_devices_register(drvdata);
}

const struct of_device_id dummy_device_id = {
{.compactible = "qcom,dummy-driver"},
{}
}

static struct platform_driver dummy_platform_driver = {
.probe = dummy_probe,
.remove = dummy_remove,
.device_driver = {
.name = "dummy-driver",
.of_match_table = dummy_match_table,
},
};
static int my_module_init(void)
{
platform_driver_register(
}
module_init(dummy_module_init);
module_exit(dummy_module_exit);

Wednesday, April 14, 2021

DS & Algos


Cheat Sheet for cpp and more: https://hackingcpp.com/cpp/cheat_sheets.html

https://github.com/orrsella/soft-eng-interview-prep

DP:

https://leetcode.com/discuss/general-discussion/475924/my-experience-and-notes-for-learning-dp

Quick Recap:

https://leetcode.com/discuss/career/217868/My-notes-for-the-night-before-interview.

Comprehensive Guide:

Comprehensive-data-structure-and-algorithm-study-guide

  Grouping similar questions - but algorithm or data structure used by the solution might vary.


Group 1

https://www.techiedelight.com/find-elements-array-greater-than-elements-right/

https://www.techiedelight.com/replace-every-element-array-least-greater-element-right/

https://www.geeksforgeeks.org/count-of-larger-elements-on-right-side-of-each-element-in-an-array/

https://www.geeksforgeeks.org/count-smaller-elements-on-right-side/

https://www.techiedelight.com/previous-smaller-element/

https://www.techiedelight.com/next-greater-element-circular-array/

https://www.techiedelight.com/inversion-count-array/


Sorting Logic application

https://www.techiedelight.com/problems-solved-using-partitioning-logic-quicksort/

https://www.techiedelight.com/segregate-positive-negative-integers-using-mergesort/


Dynamic Programing

https://www.techiedelight.com/4-sum-problem/


Trees

https://leetcode.com/problems/binary-tree-maximum-path-sum

https://leetcode.com/problems/path-sum-iv/solution/

Kth Frequent elements.

Kth frequent elements in a stream.

LRU cache Implementation

All of the above can be done in O(1) time


String

https://www.techiedelight.com/check-given-string-rotated-palindrome-not/

https://www.techiedelight.com/longest-palindromic-substring-non-dp-space-optimized-solution/


Custom Sort:

https://www.programmersought.com/article/82237172611/