aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/osd
diff options
context:
space:
mode:
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>2013-02-01 14:40:17 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-02-06 15:18:56 -0500
commit9f3b795a626ee79574595e06d1437fe0c7d51d29 (patch)
tree1952cb2ac880c0e66f291916815c2a36b4ceb300 /drivers/scsi/osd
parent807be03cae191cb88e2f267adcd49aba785c658b (diff)
driver-core: constify data for class_find_device()
All in-kernel users of class_find_device() don't really need mutable data for match callback. In two places (kernel/power/suspend_test.c, drivers/scsi/osd/osd_uld.c) this patch changes match callbacks to use const search data. The const is propagated to rtc_class_open() and power_supply_get_by_name() parameters. Note that there's a dev reference leak in suspend_test.c that's not touched in this patch. Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl> Acked-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/scsi/osd')
-rw-r--r--drivers/scsi/osd/osd_uld.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
index 43754176a7b7..0fab6b5c7b82 100644
--- a/drivers/scsi/osd/osd_uld.c
+++ b/drivers/scsi/osd/osd_uld.c
@@ -268,18 +268,11 @@ static inline bool _the_same_or_null(const u8 *a1, unsigned a1_len,
268 return 0 == memcmp(a1, a2, a1_len); 268 return 0 == memcmp(a1, a2, a1_len);
269} 269}
270 270
271struct find_oud_t { 271static int _match_odi(struct device *dev, const void *find_data)
272 const struct osd_dev_info *odi;
273 struct device *dev;
274 struct osd_uld_device *oud;
275} ;
276
277int _mach_odi(struct device *dev, void *find_data)
278{ 272{
279 struct osd_uld_device *oud = container_of(dev, struct osd_uld_device, 273 struct osd_uld_device *oud = container_of(dev, struct osd_uld_device,
280 class_dev); 274 class_dev);
281 struct find_oud_t *fot = find_data; 275 const struct osd_dev_info *odi = find_data;
282 const struct osd_dev_info *odi = fot->odi;
283 276
284 if (_the_same_or_null(oud->odi.systemid, oud->odi.systemid_len, 277 if (_the_same_or_null(oud->odi.systemid, oud->odi.systemid_len,
285 odi->systemid, odi->systemid_len) && 278 odi->systemid, odi->systemid_len) &&
@@ -287,7 +280,6 @@ int _mach_odi(struct device *dev, void *find_data)
287 odi->osdname, odi->osdname_len)) { 280 odi->osdname, odi->osdname_len)) {
288 OSD_DEBUG("found device sysid_len=%d osdname=%d\n", 281 OSD_DEBUG("found device sysid_len=%d osdname=%d\n",
289 odi->systemid_len, odi->osdname_len); 282 odi->systemid_len, odi->osdname_len);
290 fot->oud = oud;
291 return 1; 283 return 1;
292 } else { 284 } else {
293 return 0; 285 return 0;
@@ -301,19 +293,19 @@ int _mach_odi(struct device *dev, void *find_data)
301 */ 293 */
302struct osd_dev *osduld_info_lookup(const struct osd_dev_info *odi) 294struct osd_dev *osduld_info_lookup(const struct osd_dev_info *odi)
303{ 295{
304 struct find_oud_t find = {.odi = odi}; 296 struct device *dev = class_find_device(&osd_uld_class, NULL, odi, _match_odi);
305 297 if (likely(dev)) {
306 find.dev = class_find_device(&osd_uld_class, NULL, &find, _mach_odi);
307 if (likely(find.dev)) {
308 struct osd_dev_handle *odh = kzalloc(sizeof(*odh), GFP_KERNEL); 298 struct osd_dev_handle *odh = kzalloc(sizeof(*odh), GFP_KERNEL);
299 struct osd_uld_device *oud = container_of(dev,
300 struct osd_uld_device, class_dev);
309 301
310 if (unlikely(!odh)) { 302 if (unlikely(!odh)) {
311 put_device(find.dev); 303 put_device(dev);
312 return ERR_PTR(-ENOMEM); 304 return ERR_PTR(-ENOMEM);
313 } 305 }
314 306
315 odh->od = find.oud->od; 307 odh->od = oud->od;
316 odh->oud = find.oud; 308 odh->oud = oud;
317 309
318 return &odh->od; 310 return &odh->od;
319 } 311 }