diff options
Diffstat (limited to 'drivers')
22 files changed, 76 insertions, 143 deletions
diff --git a/drivers/ata/pata_hpt366.c b/drivers/ata/pata_hpt366.c index 0038dc4c06c7..e5fb7525a5df 100644 --- a/drivers/ata/pata_hpt366.c +++ b/drivers/ata/pata_hpt366.c | |||
@@ -176,17 +176,14 @@ static int hpt_dma_blacklisted(const struct ata_device *dev, char *modestr, | |||
176 | const char * const list[]) | 176 | const char * const list[]) |
177 | { | 177 | { |
178 | unsigned char model_num[ATA_ID_PROD_LEN + 1]; | 178 | unsigned char model_num[ATA_ID_PROD_LEN + 1]; |
179 | int i = 0; | 179 | int i; |
180 | 180 | ||
181 | ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num)); | 181 | ata_id_c_string(dev->id, model_num, ATA_ID_PROD, sizeof(model_num)); |
182 | 182 | ||
183 | while (list[i] != NULL) { | 183 | i = match_string(list, -1, model_num); |
184 | if (!strcmp(list[i], model_num)) { | 184 | if (i >= 0) { |
185 | pr_warn("%s is not supported for %s\n", | 185 | pr_warn("%s is not supported for %s\n", modestr, list[i]); |
186 | modestr, list[i]); | 186 | return 1; |
187 | return 1; | ||
188 | } | ||
189 | i++; | ||
190 | } | 187 | } |
191 | return 0; | 188 | return 0; |
192 | } | 189 | } |
diff --git a/drivers/base/property.c b/drivers/base/property.c index 76628a7b45f1..9b1a65debd49 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c | |||
@@ -651,7 +651,7 @@ int fwnode_property_match_string(struct fwnode_handle *fwnode, | |||
651 | const char *propname, const char *string) | 651 | const char *propname, const char *string) |
652 | { | 652 | { |
653 | const char **values; | 653 | const char **values; |
654 | int nval, ret, i; | 654 | int nval, ret; |
655 | 655 | ||
656 | nval = fwnode_property_read_string_array(fwnode, propname, NULL, 0); | 656 | nval = fwnode_property_read_string_array(fwnode, propname, NULL, 0); |
657 | if (nval < 0) | 657 | if (nval < 0) |
@@ -668,13 +668,9 @@ int fwnode_property_match_string(struct fwnode_handle *fwnode, | |||
668 | if (ret < 0) | 668 | if (ret < 0) |
669 | goto out; | 669 | goto out; |
670 | 670 | ||
671 | ret = -ENODATA; | 671 | ret = match_string(values, nval, string); |
672 | for (i = 0; i < nval; i++) { | 672 | if (ret < 0) |
673 | if (!strcmp(values[i], string)) { | 673 | ret = -ENODATA; |
674 | ret = i; | ||
675 | break; | ||
676 | } | ||
677 | } | ||
678 | out: | 674 | out: |
679 | kfree(values); | 675 | kfree(values); |
680 | return ret; | 676 | return ret; |
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c index d048d2009e89..437b3a822f44 100644 --- a/drivers/block/aoe/aoecmd.c +++ b/drivers/block/aoe/aoecmd.c | |||
@@ -875,7 +875,7 @@ bio_pageinc(struct bio *bio) | |||
875 | * compound pages is no longer allowed by the kernel. | 875 | * compound pages is no longer allowed by the kernel. |
876 | */ | 876 | */ |
877 | page = compound_head(bv.bv_page); | 877 | page = compound_head(bv.bv_page); |
878 | atomic_inc(&page->_count); | 878 | page_ref_inc(page); |
879 | } | 879 | } |
880 | } | 880 | } |
881 | 881 | ||
@@ -888,7 +888,7 @@ bio_pagedec(struct bio *bio) | |||
888 | 888 | ||
889 | bio_for_each_segment(bv, bio, iter) { | 889 | bio_for_each_segment(bv, bio, iter) { |
890 | page = compound_head(bv.bv_page); | 890 | page = compound_head(bv.bv_page); |
891 | atomic_dec(&page->_count); | 891 | page_ref_dec(page); |
892 | } | 892 | } |
893 | } | 893 | } |
894 | 894 | ||
diff --git a/drivers/firmware/broadcom/bcm47xx_nvram.c b/drivers/firmware/broadcom/bcm47xx_nvram.c index 0c2f0a61b0ea..0b631e5b5b84 100644 --- a/drivers/firmware/broadcom/bcm47xx_nvram.c +++ b/drivers/firmware/broadcom/bcm47xx_nvram.c | |||
@@ -94,15 +94,14 @@ static int nvram_find_and_copy(void __iomem *iobase, u32 lim) | |||
94 | 94 | ||
95 | found: | 95 | found: |
96 | __ioread32_copy(nvram_buf, header, sizeof(*header) / 4); | 96 | __ioread32_copy(nvram_buf, header, sizeof(*header) / 4); |
97 | header = (struct nvram_header *)nvram_buf; | 97 | nvram_len = ((struct nvram_header *)(nvram_buf))->len; |
98 | nvram_len = header->len; | ||
99 | if (nvram_len > size) { | 98 | if (nvram_len > size) { |
100 | pr_err("The nvram size according to the header seems to be bigger than the partition on flash\n"); | 99 | pr_err("The nvram size according to the header seems to be bigger than the partition on flash\n"); |
101 | nvram_len = size; | 100 | nvram_len = size; |
102 | } | 101 | } |
103 | if (nvram_len >= NVRAM_SPACE) { | 102 | if (nvram_len >= NVRAM_SPACE) { |
104 | pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n", | 103 | pr_err("nvram on flash (%i bytes) is bigger than the reserved space in memory, will just copy the first %i bytes\n", |
105 | header->len, NVRAM_SPACE - 1); | 104 | nvram_len, NVRAM_SPACE - 1); |
106 | nvram_len = NVRAM_SPACE - 1; | 105 | nvram_len = NVRAM_SPACE - 1; |
107 | } | 106 | } |
108 | /* proceed reading data after header */ | 107 | /* proceed reading data after header */ |
diff --git a/drivers/gpu/drm/drm_edid_load.c b/drivers/gpu/drm/drm_edid_load.c index 698b8c3b09d9..9a401aed98e0 100644 --- a/drivers/gpu/drm/drm_edid_load.c +++ b/drivers/gpu/drm/drm_edid_load.c | |||
@@ -170,16 +170,11 @@ static void *edid_load(struct drm_connector *connector, const char *name, | |||
170 | int i, valid_extensions = 0; | 170 | int i, valid_extensions = 0; |
171 | bool print_bad_edid = !connector->bad_edid_counter || (drm_debug & DRM_UT_KMS); | 171 | bool print_bad_edid = !connector->bad_edid_counter || (drm_debug & DRM_UT_KMS); |
172 | 172 | ||
173 | builtin = 0; | 173 | builtin = match_string(generic_edid_name, GENERIC_EDIDS, name); |
174 | for (i = 0; i < GENERIC_EDIDS; i++) { | 174 | if (builtin >= 0) { |
175 | if (strcmp(name, generic_edid_name[i]) == 0) { | 175 | fwdata = generic_edid[builtin]; |
176 | fwdata = generic_edid[i]; | 176 | fwsize = sizeof(generic_edid[builtin]); |
177 | fwsize = sizeof(generic_edid[i]); | 177 | } else { |
178 | builtin = 1; | ||
179 | break; | ||
180 | } | ||
181 | } | ||
182 | if (!builtin) { | ||
183 | struct platform_device *pdev; | 178 | struct platform_device *pdev; |
184 | int err; | 179 | int err; |
185 | 180 | ||
@@ -252,7 +247,7 @@ static void *edid_load(struct drm_connector *connector, const char *name, | |||
252 | } | 247 | } |
253 | 248 | ||
254 | DRM_INFO("Got %s EDID base block and %d extension%s from " | 249 | DRM_INFO("Got %s EDID base block and %d extension%s from " |
255 | "\"%s\" for connector \"%s\"\n", builtin ? "built-in" : | 250 | "\"%s\" for connector \"%s\"\n", (builtin >= 0) ? "built-in" : |
256 | "external", valid_extensions, valid_extensions == 1 ? "" : "s", | 251 | "external", valid_extensions, valid_extensions == 1 ? "" : "s", |
257 | name, connector_name); | 252 | name, connector_name); |
258 | 253 | ||
diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c index 696b6c1ec940..f94baadbf424 100644 --- a/drivers/ide/hpt366.c +++ b/drivers/ide/hpt366.c | |||
@@ -531,14 +531,9 @@ static const struct hpt_info hpt371n = { | |||
531 | .timings = &hpt37x_timings | 531 | .timings = &hpt37x_timings |
532 | }; | 532 | }; |
533 | 533 | ||
534 | static int check_in_drive_list(ide_drive_t *drive, const char **list) | 534 | static bool check_in_drive_list(ide_drive_t *drive, const char **list) |
535 | { | 535 | { |
536 | char *m = (char *)&drive->id[ATA_ID_PROD]; | 536 | return match_string(list, -1, (char *)&drive->id[ATA_ID_PROD]) >= 0; |
537 | |||
538 | while (*list) | ||
539 | if (!strcmp(*list++, m)) | ||
540 | return 1; | ||
541 | return 0; | ||
542 | } | 537 | } |
543 | 538 | ||
544 | static struct hpt_info *hpt3xx_get_info(struct device *dev) | 539 | static struct hpt_info *hpt3xx_get_info(struct device *dev) |
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index b9ecf197ad11..f21b2c479780 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c | |||
@@ -2944,7 +2944,7 @@ static bool gfar_add_rx_frag(struct gfar_rx_buff *rxb, u32 lstatus, | |||
2944 | /* change offset to the other half */ | 2944 | /* change offset to the other half */ |
2945 | rxb->page_offset ^= GFAR_RXB_TRUESIZE; | 2945 | rxb->page_offset ^= GFAR_RXB_TRUESIZE; |
2946 | 2946 | ||
2947 | atomic_inc(&page->_count); | 2947 | page_ref_inc(page); |
2948 | 2948 | ||
2949 | return true; | 2949 | return true; |
2950 | } | 2950 | } |
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_main.c b/drivers/net/ethernet/intel/fm10k/fm10k_main.c index b243c3cbe68f..b4547ebed774 100644 --- a/drivers/net/ethernet/intel/fm10k/fm10k_main.c +++ b/drivers/net/ethernet/intel/fm10k/fm10k_main.c | |||
@@ -243,7 +243,7 @@ static bool fm10k_can_reuse_rx_page(struct fm10k_rx_buffer *rx_buffer, | |||
243 | /* Even if we own the page, we are not allowed to use atomic_set() | 243 | /* Even if we own the page, we are not allowed to use atomic_set() |
244 | * This would break get_page_unless_zero() users. | 244 | * This would break get_page_unless_zero() users. |
245 | */ | 245 | */ |
246 | atomic_inc(&page->_count); | 246 | page_ref_inc(page); |
247 | 247 | ||
248 | return true; | 248 | return true; |
249 | } | 249 | } |
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 31e5f3942839..5b4ad1ad4d5f 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c | |||
@@ -6630,7 +6630,7 @@ static bool igb_can_reuse_rx_page(struct igb_rx_buffer *rx_buffer, | |||
6630 | /* Even if we own the page, we are not allowed to use atomic_set() | 6630 | /* Even if we own the page, we are not allowed to use atomic_set() |
6631 | * This would break get_page_unless_zero() users. | 6631 | * This would break get_page_unless_zero() users. |
6632 | */ | 6632 | */ |
6633 | atomic_inc(&page->_count); | 6633 | page_ref_inc(page); |
6634 | 6634 | ||
6635 | return true; | 6635 | return true; |
6636 | } | 6636 | } |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index c4003a88bbf6..e6035ff6b861 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | |||
@@ -1942,7 +1942,7 @@ static bool ixgbe_add_rx_frag(struct ixgbe_ring *rx_ring, | |||
1942 | /* Even if we own the page, we are not allowed to use atomic_set() | 1942 | /* Even if we own the page, we are not allowed to use atomic_set() |
1943 | * This would break get_page_unless_zero() users. | 1943 | * This would break get_page_unless_zero() users. |
1944 | */ | 1944 | */ |
1945 | atomic_inc(&page->_count); | 1945 | page_ref_inc(page); |
1946 | 1946 | ||
1947 | return true; | 1947 | return true; |
1948 | } | 1948 | } |
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c index 3558f019b631..0ea14c0a2e74 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | |||
@@ -837,7 +837,7 @@ add_tail_frag: | |||
837 | /* Even if we own the page, we are not allowed to use atomic_set() | 837 | /* Even if we own the page, we are not allowed to use atomic_set() |
838 | * This would break get_page_unless_zero() users. | 838 | * This would break get_page_unless_zero() users. |
839 | */ | 839 | */ |
840 | atomic_inc(&page->_count); | 840 | page_ref_inc(page); |
841 | 841 | ||
842 | return true; | 842 | return true; |
843 | } | 843 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index 41440b2b20a3..86bcfe510e4e 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c | |||
@@ -82,8 +82,7 @@ static int mlx4_alloc_pages(struct mlx4_en_priv *priv, | |||
82 | /* Not doing get_page() for each frag is a big win | 82 | /* Not doing get_page() for each frag is a big win |
83 | * on asymetric workloads. Note we can not use atomic_set(). | 83 | * on asymetric workloads. Note we can not use atomic_set(). |
84 | */ | 84 | */ |
85 | atomic_add(page_alloc->page_size / frag_info->frag_stride - 1, | 85 | page_ref_add(page, page_alloc->page_size / frag_info->frag_stride - 1); |
86 | &page->_count); | ||
87 | return 0; | 86 | return 0; |
88 | } | 87 | } |
89 | 88 | ||
@@ -127,7 +126,7 @@ out: | |||
127 | dma_unmap_page(priv->ddev, page_alloc[i].dma, | 126 | dma_unmap_page(priv->ddev, page_alloc[i].dma, |
128 | page_alloc[i].page_size, PCI_DMA_FROMDEVICE); | 127 | page_alloc[i].page_size, PCI_DMA_FROMDEVICE); |
129 | page = page_alloc[i].page; | 128 | page = page_alloc[i].page; |
130 | atomic_set(&page->_count, 1); | 129 | set_page_count(page, 1); |
131 | put_page(page); | 130 | put_page(page); |
132 | } | 131 | } |
133 | } | 132 | } |
@@ -165,7 +164,7 @@ static int mlx4_en_init_allocator(struct mlx4_en_priv *priv, | |||
165 | 164 | ||
166 | en_dbg(DRV, priv, " frag %d allocator: - size:%d frags:%d\n", | 165 | en_dbg(DRV, priv, " frag %d allocator: - size:%d frags:%d\n", |
167 | i, ring->page_alloc[i].page_size, | 166 | i, ring->page_alloc[i].page_size, |
168 | atomic_read(&ring->page_alloc[i].page->_count)); | 167 | page_ref_count(ring->page_alloc[i].page)); |
169 | } | 168 | } |
170 | return 0; | 169 | return 0; |
171 | 170 | ||
@@ -177,7 +176,7 @@ out: | |||
177 | dma_unmap_page(priv->ddev, page_alloc->dma, | 176 | dma_unmap_page(priv->ddev, page_alloc->dma, |
178 | page_alloc->page_size, PCI_DMA_FROMDEVICE); | 177 | page_alloc->page_size, PCI_DMA_FROMDEVICE); |
179 | page = page_alloc->page; | 178 | page = page_alloc->page; |
180 | atomic_set(&page->_count, 1); | 179 | set_page_count(page, 1); |
181 | put_page(page); | 180 | put_page(page); |
182 | page_alloc->page = NULL; | 181 | page_alloc->page = NULL; |
183 | } | 182 | } |
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c index ab6051a43134..9cc45649f477 100644 --- a/drivers/net/ethernet/sun/niu.c +++ b/drivers/net/ethernet/sun/niu.c | |||
@@ -3341,7 +3341,7 @@ static int niu_rbr_add_page(struct niu *np, struct rx_ring_info *rp, | |||
3341 | 3341 | ||
3342 | niu_hash_page(rp, page, addr); | 3342 | niu_hash_page(rp, page, addr); |
3343 | if (rp->rbr_blocks_per_page > 1) | 3343 | if (rp->rbr_blocks_per_page > 1) |
3344 | atomic_add(rp->rbr_blocks_per_page - 1, &page->_count); | 3344 | page_ref_add(page, rp->rbr_blocks_per_page - 1); |
3345 | 3345 | ||
3346 | for (i = 0; i < rp->rbr_blocks_per_page; i++) { | 3346 | for (i = 0; i < rp->rbr_blocks_per_page; i++) { |
3347 | __le32 *rbr = &rp->rbr[start_index + i]; | 3347 | __le32 *rbr = &rp->rbr[start_index + i]; |
diff --git a/drivers/net/wireless/marvell/mwifiex/debugfs.c b/drivers/net/wireless/marvell/mwifiex/debugfs.c index 0b9c580af988..2eff989c6d9f 100644 --- a/drivers/net/wireless/marvell/mwifiex/debugfs.c +++ b/drivers/net/wireless/marvell/mwifiex/debugfs.c | |||
@@ -880,14 +880,12 @@ mwifiex_reset_write(struct file *file, | |||
880 | { | 880 | { |
881 | struct mwifiex_private *priv = file->private_data; | 881 | struct mwifiex_private *priv = file->private_data; |
882 | struct mwifiex_adapter *adapter = priv->adapter; | 882 | struct mwifiex_adapter *adapter = priv->adapter; |
883 | char cmd; | ||
884 | bool result; | 883 | bool result; |
884 | int rc; | ||
885 | 885 | ||
886 | if (copy_from_user(&cmd, ubuf, sizeof(cmd))) | 886 | rc = kstrtobool_from_user(ubuf, count, &result); |
887 | return -EFAULT; | 887 | if (rc) |
888 | 888 | return rc; | |
889 | if (strtobool(&cmd, &result)) | ||
890 | return -EINVAL; | ||
891 | 889 | ||
892 | if (!result) | 890 | if (!result) |
893 | return -EINVAL; | 891 | return -EINVAL; |
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index 29984b36926a..c223a9ef1fe1 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c | |||
@@ -334,7 +334,6 @@ int pinmux_map_to_setting(struct pinctrl_map const *map, | |||
334 | unsigned num_groups; | 334 | unsigned num_groups; |
335 | int ret; | 335 | int ret; |
336 | const char *group; | 336 | const char *group; |
337 | int i; | ||
338 | 337 | ||
339 | if (!pmxops) { | 338 | if (!pmxops) { |
340 | dev_err(pctldev->dev, "does not support mux function\n"); | 339 | dev_err(pctldev->dev, "does not support mux function\n"); |
@@ -363,19 +362,13 @@ int pinmux_map_to_setting(struct pinctrl_map const *map, | |||
363 | return -EINVAL; | 362 | return -EINVAL; |
364 | } | 363 | } |
365 | if (map->data.mux.group) { | 364 | if (map->data.mux.group) { |
366 | bool found = false; | ||
367 | group = map->data.mux.group; | 365 | group = map->data.mux.group; |
368 | for (i = 0; i < num_groups; i++) { | 366 | ret = match_string(groups, num_groups, group); |
369 | if (!strcmp(group, groups[i])) { | 367 | if (ret < 0) { |
370 | found = true; | ||
371 | break; | ||
372 | } | ||
373 | } | ||
374 | if (!found) { | ||
375 | dev_err(pctldev->dev, | 368 | dev_err(pctldev->dev, |
376 | "invalid group \"%s\" for function \"%s\"\n", | 369 | "invalid group \"%s\" for function \"%s\"\n", |
377 | group, map->data.mux.function); | 370 | group, map->data.mux.function); |
378 | return -EINVAL; | 371 | return ret; |
379 | } | 372 | } |
380 | } else { | 373 | } else { |
381 | group = groups[0]; | 374 | group = groups[0]; |
diff --git a/drivers/power/ab8500_btemp.c b/drivers/power/ab8500_btemp.c index 8f8044e1acf3..bf2e5dd301e7 100644 --- a/drivers/power/ab8500_btemp.c +++ b/drivers/power/ab8500_btemp.c | |||
@@ -906,26 +906,21 @@ static int ab8500_btemp_get_property(struct power_supply *psy, | |||
906 | static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data) | 906 | static int ab8500_btemp_get_ext_psy_data(struct device *dev, void *data) |
907 | { | 907 | { |
908 | struct power_supply *psy; | 908 | struct power_supply *psy; |
909 | struct power_supply *ext; | 909 | struct power_supply *ext = dev_get_drvdata(dev); |
910 | const char **supplicants = (const char **)ext->supplied_to; | ||
910 | struct ab8500_btemp *di; | 911 | struct ab8500_btemp *di; |
911 | union power_supply_propval ret; | 912 | union power_supply_propval ret; |
912 | int i, j; | 913 | int j; |
913 | bool psy_found = false; | ||
914 | 914 | ||
915 | psy = (struct power_supply *)data; | 915 | psy = (struct power_supply *)data; |
916 | ext = dev_get_drvdata(dev); | ||
917 | di = power_supply_get_drvdata(psy); | 916 | di = power_supply_get_drvdata(psy); |
918 | 917 | ||
919 | /* | 918 | /* |
920 | * For all psy where the name of your driver | 919 | * For all psy where the name of your driver |
921 | * appears in any supplied_to | 920 | * appears in any supplied_to |
922 | */ | 921 | */ |
923 | for (i = 0; i < ext->num_supplicants; i++) { | 922 | j = match_string(supplicants, ext->num_supplicants, psy->desc->name); |
924 | if (!strcmp(ext->supplied_to[i], psy->desc->name)) | 923 | if (j < 0) |
925 | psy_found = true; | ||
926 | } | ||
927 | |||
928 | if (!psy_found) | ||
929 | return 0; | 924 | return 0; |
930 | 925 | ||
931 | /* Go through all properties for the psy */ | 926 | /* Go through all properties for the psy */ |
diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index e388171f4e58..30de5d42b26a 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c | |||
@@ -1929,11 +1929,11 @@ static int ab8540_charger_usb_pre_chg_enable(struct ux500_charger *charger, | |||
1929 | static int ab8500_charger_get_ext_psy_data(struct device *dev, void *data) | 1929 | static int ab8500_charger_get_ext_psy_data(struct device *dev, void *data) |
1930 | { | 1930 | { |
1931 | struct power_supply *psy; | 1931 | struct power_supply *psy; |
1932 | struct power_supply *ext; | 1932 | struct power_supply *ext = dev_get_drvdata(dev); |
1933 | const char **supplicants = (const char **)ext->supplied_to; | ||
1933 | struct ab8500_charger *di; | 1934 | struct ab8500_charger *di; |
1934 | union power_supply_propval ret; | 1935 | union power_supply_propval ret; |
1935 | int i, j; | 1936 | int j; |
1936 | bool psy_found = false; | ||
1937 | struct ux500_charger *usb_chg; | 1937 | struct ux500_charger *usb_chg; |
1938 | 1938 | ||
1939 | usb_chg = (struct ux500_charger *)data; | 1939 | usb_chg = (struct ux500_charger *)data; |
@@ -1941,15 +1941,9 @@ static int ab8500_charger_get_ext_psy_data(struct device *dev, void *data) | |||
1941 | 1941 | ||
1942 | di = to_ab8500_charger_usb_device_info(usb_chg); | 1942 | di = to_ab8500_charger_usb_device_info(usb_chg); |
1943 | 1943 | ||
1944 | ext = dev_get_drvdata(dev); | ||
1945 | |||
1946 | /* For all psy where the driver name appears in any supplied_to */ | 1944 | /* For all psy where the driver name appears in any supplied_to */ |
1947 | for (i = 0; i < ext->num_supplicants; i++) { | 1945 | j = match_string(supplicants, ext->num_supplicants, psy->desc->name); |
1948 | if (!strcmp(ext->supplied_to[i], psy->desc->name)) | 1946 | if (j < 0) |
1949 | psy_found = true; | ||
1950 | } | ||
1951 | |||
1952 | if (!psy_found) | ||
1953 | return 0; | 1947 | return 0; |
1954 | 1948 | ||
1955 | /* Go through all properties for the psy */ | 1949 | /* Go through all properties for the psy */ |
diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c index 3830dade5d69..5a36cf88578a 100644 --- a/drivers/power/ab8500_fg.c +++ b/drivers/power/ab8500_fg.c | |||
@@ -2168,26 +2168,21 @@ static int ab8500_fg_get_property(struct power_supply *psy, | |||
2168 | static int ab8500_fg_get_ext_psy_data(struct device *dev, void *data) | 2168 | static int ab8500_fg_get_ext_psy_data(struct device *dev, void *data) |
2169 | { | 2169 | { |
2170 | struct power_supply *psy; | 2170 | struct power_supply *psy; |
2171 | struct power_supply *ext; | 2171 | struct power_supply *ext = dev_get_drvdata(dev); |
2172 | const char **supplicants = (const char **)ext->supplied_to; | ||
2172 | struct ab8500_fg *di; | 2173 | struct ab8500_fg *di; |
2173 | union power_supply_propval ret; | 2174 | union power_supply_propval ret; |
2174 | int i, j; | 2175 | int j; |
2175 | bool psy_found = false; | ||
2176 | 2176 | ||
2177 | psy = (struct power_supply *)data; | 2177 | psy = (struct power_supply *)data; |
2178 | ext = dev_get_drvdata(dev); | ||
2179 | di = power_supply_get_drvdata(psy); | 2178 | di = power_supply_get_drvdata(psy); |
2180 | 2179 | ||
2181 | /* | 2180 | /* |
2182 | * For all psy where the name of your driver | 2181 | * For all psy where the name of your driver |
2183 | * appears in any supplied_to | 2182 | * appears in any supplied_to |
2184 | */ | 2183 | */ |
2185 | for (i = 0; i < ext->num_supplicants; i++) { | 2184 | j = match_string(supplicants, ext->num_supplicants, psy->desc->name); |
2186 | if (!strcmp(ext->supplied_to[i], psy->desc->name)) | 2185 | if (j < 0) |
2187 | psy_found = true; | ||
2188 | } | ||
2189 | |||
2190 | if (!psy_found) | ||
2191 | return 0; | 2186 | return 0; |
2192 | 2187 | ||
2193 | /* Go through all properties for the psy */ | 2188 | /* Go through all properties for the psy */ |
diff --git a/drivers/power/abx500_chargalg.c b/drivers/power/abx500_chargalg.c index 541f702e0451..d9104b1ab7cf 100644 --- a/drivers/power/abx500_chargalg.c +++ b/drivers/power/abx500_chargalg.c | |||
@@ -975,22 +975,18 @@ static void handle_maxim_chg_curr(struct abx500_chargalg *di) | |||
975 | static int abx500_chargalg_get_ext_psy_data(struct device *dev, void *data) | 975 | static int abx500_chargalg_get_ext_psy_data(struct device *dev, void *data) |
976 | { | 976 | { |
977 | struct power_supply *psy; | 977 | struct power_supply *psy; |
978 | struct power_supply *ext; | 978 | struct power_supply *ext = dev_get_drvdata(dev); |
979 | const char **supplicants = (const char **)ext->supplied_to; | ||
979 | struct abx500_chargalg *di; | 980 | struct abx500_chargalg *di; |
980 | union power_supply_propval ret; | 981 | union power_supply_propval ret; |
981 | int i, j; | 982 | int j; |
982 | bool psy_found = false; | ||
983 | bool capacity_updated = false; | 983 | bool capacity_updated = false; |
984 | 984 | ||
985 | psy = (struct power_supply *)data; | 985 | psy = (struct power_supply *)data; |
986 | ext = dev_get_drvdata(dev); | ||
987 | di = power_supply_get_drvdata(psy); | 986 | di = power_supply_get_drvdata(psy); |
988 | /* For all psy where the driver name appears in any supplied_to */ | 987 | /* For all psy where the driver name appears in any supplied_to */ |
989 | for (i = 0; i < ext->num_supplicants; i++) { | 988 | j = match_string(supplicants, ext->num_supplicants, psy->desc->name); |
990 | if (!strcmp(ext->supplied_to[i], psy->desc->name)) | 989 | if (j < 0) |
991 | psy_found = true; | ||
992 | } | ||
993 | if (!psy_found) | ||
994 | return 0; | 990 | return 0; |
995 | 991 | ||
996 | /* | 992 | /* |
diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c index 1ea5d1aa268b..e664ca7c0afd 100644 --- a/drivers/power/charger-manager.c +++ b/drivers/power/charger-manager.c | |||
@@ -2020,27 +2020,6 @@ static void __exit charger_manager_cleanup(void) | |||
2020 | module_exit(charger_manager_cleanup); | 2020 | module_exit(charger_manager_cleanup); |
2021 | 2021 | ||
2022 | /** | 2022 | /** |
2023 | * find_power_supply - find the associated power_supply of charger | ||
2024 | * @cm: the Charger Manager representing the battery | ||
2025 | * @psy: pointer to instance of charger's power_supply | ||
2026 | */ | ||
2027 | static bool find_power_supply(struct charger_manager *cm, | ||
2028 | struct power_supply *psy) | ||
2029 | { | ||
2030 | int i; | ||
2031 | bool found = false; | ||
2032 | |||
2033 | for (i = 0; cm->desc->psy_charger_stat[i]; i++) { | ||
2034 | if (!strcmp(psy->desc->name, cm->desc->psy_charger_stat[i])) { | ||
2035 | found = true; | ||
2036 | break; | ||
2037 | } | ||
2038 | } | ||
2039 | |||
2040 | return found; | ||
2041 | } | ||
2042 | |||
2043 | /** | ||
2044 | * cm_notify_event - charger driver notify Charger Manager of charger event | 2023 | * cm_notify_event - charger driver notify Charger Manager of charger event |
2045 | * @psy: pointer to instance of charger's power_supply | 2024 | * @psy: pointer to instance of charger's power_supply |
2046 | * @type: type of charger event | 2025 | * @type: type of charger event |
@@ -2057,9 +2036,11 @@ void cm_notify_event(struct power_supply *psy, enum cm_event_types type, | |||
2057 | 2036 | ||
2058 | mutex_lock(&cm_list_mtx); | 2037 | mutex_lock(&cm_list_mtx); |
2059 | list_for_each_entry(cm, &cm_list, entry) { | 2038 | list_for_each_entry(cm, &cm_list, entry) { |
2060 | found_power_supply = find_power_supply(cm, psy); | 2039 | if (match_string(cm->desc->psy_charger_stat, -1, |
2061 | if (found_power_supply) | 2040 | psy->desc->name) >= 0) { |
2041 | found_power_supply = true; | ||
2062 | break; | 2042 | break; |
2043 | } | ||
2063 | } | 2044 | } |
2064 | mutex_unlock(&cm_list_mtx); | 2045 | mutex_unlock(&cm_list_mtx); |
2065 | 2046 | ||
diff --git a/drivers/usb/common/common.c b/drivers/usb/common/common.c index 49fbfe8b0f24..e3d01619d6b3 100644 --- a/drivers/usb/common/common.c +++ b/drivers/usb/common/common.c | |||
@@ -65,18 +65,15 @@ EXPORT_SYMBOL_GPL(usb_speed_string); | |||
65 | enum usb_device_speed usb_get_maximum_speed(struct device *dev) | 65 | enum usb_device_speed usb_get_maximum_speed(struct device *dev) |
66 | { | 66 | { |
67 | const char *maximum_speed; | 67 | const char *maximum_speed; |
68 | int err; | 68 | int ret; |
69 | int i; | ||
70 | 69 | ||
71 | err = device_property_read_string(dev, "maximum-speed", &maximum_speed); | 70 | ret = device_property_read_string(dev, "maximum-speed", &maximum_speed); |
72 | if (err < 0) | 71 | if (ret < 0) |
73 | return USB_SPEED_UNKNOWN; | 72 | return USB_SPEED_UNKNOWN; |
74 | 73 | ||
75 | for (i = 0; i < ARRAY_SIZE(speed_names); i++) | 74 | ret = match_string(speed_names, ARRAY_SIZE(speed_names), maximum_speed); |
76 | if (strcmp(maximum_speed, speed_names[i]) == 0) | ||
77 | return i; | ||
78 | 75 | ||
79 | return USB_SPEED_UNKNOWN; | 76 | return (ret < 0) ? USB_SPEED_UNKNOWN : ret; |
80 | } | 77 | } |
81 | EXPORT_SYMBOL_GPL(usb_get_maximum_speed); | 78 | EXPORT_SYMBOL_GPL(usb_get_maximum_speed); |
82 | 79 | ||
@@ -110,13 +107,10 @@ static const char *const usb_dr_modes[] = { | |||
110 | 107 | ||
111 | static enum usb_dr_mode usb_get_dr_mode_from_string(const char *str) | 108 | static enum usb_dr_mode usb_get_dr_mode_from_string(const char *str) |
112 | { | 109 | { |
113 | int i; | 110 | int ret; |
114 | |||
115 | for (i = 0; i < ARRAY_SIZE(usb_dr_modes); i++) | ||
116 | if (!strcmp(usb_dr_modes[i], str)) | ||
117 | return i; | ||
118 | 111 | ||
119 | return USB_DR_MODE_UNKNOWN; | 112 | ret = match_string(usb_dr_modes, ARRAY_SIZE(usb_dr_modes), str); |
113 | return (ret < 0) ? USB_DR_MODE_UNKNOWN : ret; | ||
120 | } | 114 | } |
121 | 115 | ||
122 | enum usb_dr_mode usb_get_dr_mode(struct device *dev) | 116 | enum usb_dr_mode usb_get_dr_mode(struct device *dev) |
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 0c3691f46575..f2b77dea8d3c 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/balloon_compaction.h> | 30 | #include <linux/balloon_compaction.h> |
31 | #include <linux/oom.h> | 31 | #include <linux/oom.h> |
32 | #include <linux/wait.h> | 32 | #include <linux/wait.h> |
33 | #include <linux/mm.h> | ||
33 | 34 | ||
34 | /* | 35 | /* |
35 | * Balloon device works in 4K page units. So each page is pointed to by | 36 | * Balloon device works in 4K page units. So each page is pointed to by |
@@ -229,10 +230,13 @@ static void update_balloon_stats(struct virtio_balloon *vb) | |||
229 | unsigned long events[NR_VM_EVENT_ITEMS]; | 230 | unsigned long events[NR_VM_EVENT_ITEMS]; |
230 | struct sysinfo i; | 231 | struct sysinfo i; |
231 | int idx = 0; | 232 | int idx = 0; |
233 | long available; | ||
232 | 234 | ||
233 | all_vm_events(events); | 235 | all_vm_events(events); |
234 | si_meminfo(&i); | 236 | si_meminfo(&i); |
235 | 237 | ||
238 | available = si_mem_available(); | ||
239 | |||
236 | update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN, | 240 | update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN, |
237 | pages_to_bytes(events[PSWPIN])); | 241 | pages_to_bytes(events[PSWPIN])); |
238 | update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_OUT, | 242 | update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_OUT, |
@@ -243,6 +247,8 @@ static void update_balloon_stats(struct virtio_balloon *vb) | |||
243 | pages_to_bytes(i.freeram)); | 247 | pages_to_bytes(i.freeram)); |
244 | update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMTOT, | 248 | update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMTOT, |
245 | pages_to_bytes(i.totalram)); | 249 | pages_to_bytes(i.totalram)); |
250 | update_stat(vb, idx++, VIRTIO_BALLOON_S_AVAIL, | ||
251 | pages_to_bytes(available)); | ||
246 | } | 252 | } |
247 | 253 | ||
248 | /* | 254 | /* |